FreeCalypso > hg > ffs-editor
comparison src/cs/drivers/drv_app/ffs/board/ffspcm.c @ 0:92470e5d0b9e
src: partial import from FC Selenite
| author | Mychaela Falconia <falcon@freecalypso.org> |
|---|---|
| date | Fri, 15 May 2020 01:28:16 +0000 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| -1:000000000000 | 0:92470e5d0b9e |
|---|---|
| 1 /* | |
| 2 * Flash File System (ffs) | |
| 3 * | |
| 4 * WCP PCM Compatibility Support | |
| 5 */ | |
| 6 | |
| 7 #include <string.h> | |
| 8 #include "main/sys_types.h" | |
| 9 #include "memif/mem.h" | |
| 10 #include "ffs/ffs.h" | |
| 11 #include "ffs/board/ffspcm.h" | |
| 12 #include "nucleus.h" | |
| 13 #include "csmi/csmi.h" | |
| 14 #include "csmi/csmi_gsmctrl.h" | |
| 15 #include "ffs/pcm.h" | |
| 16 | |
| 17 | |
| 18 // Factory FFS area description | |
| 19 #pragma DATA_SECTION(FlashImage, ".ffs_img") | |
| 20 const unsigned char FlashImage[0x4000]; | |
| 21 | |
| 22 | |
| 23 /* | |
| 24 * | |
| 25 * ffs_InitRFCap | |
| 26 * | |
| 27 * Purpose : Set rfcap for tri-band config | |
| 28 * | |
| 29 * Arguments: In : none | |
| 30 * | |
| 31 * Out: none | |
| 32 * | |
| 33 * Returns : none | |
| 34 * | |
| 35 */ | |
| 36 | |
| 37 #define SIZE_EF_RFCAP 16 | |
| 38 | |
| 39 static const UBYTE rfcap_TriBand[SIZE_EF_RFCAP] = {0x00, 0x0F, 0x41, 0x10, 0x00, 0x00, 0x00, 0x00, \ | |
| 40 0x40, 0x00, 0x00, 0xA5, 0x05, 0x00, 0xC0, 0x00}; | |
| 41 | |
| 42 static const UBYTE rfcap_DualExt[SIZE_EF_RFCAP] = {0x00, 0x0B, 0x41, 0x00, 0x00, 0x00, 0x00, 0x00, \ | |
| 43 0x40, 0x00, 0x00, 0xA5, 0x05, 0x00, 0xC0, 0x00}; | |
| 44 | |
| 45 effs_t ffs_InitRFCap () | |
| 46 { | |
| 47 ffs_mkdir_nb("/gsm" ,0); | |
| 48 ffs_mkdir_nb("/gsm/com" ,0); | |
| 49 | |
| 50 ffs_fwrite_nb("/gsm/com/rfcap", (void*)rfcap_TriBand, SIZE_EF_RFCAP, 0); | |
| 51 } | |
| 52 | |
| 53 /* | |
| 54 * | |
| 55 * ffs_SetBand | |
| 56 * | |
| 57 * Purpose : Set std config according to the selected Band | |
| 58 * | |
| 59 * Arguments: In : Band number | |
| 60 * | |
| 61 * Out: none | |
| 62 * | |
| 63 * Returns : none | |
| 64 * | |
| 65 */ | |
| 66 | |
| 67 effs_t ffs_SetBand (unsigned char* band) | |
| 68 { | |
| 69 // Check validity of std band (1, 3 and 6 are supported) | |
| 70 switch(*band) | |
| 71 { | |
| 72 case 1: | |
| 73 case 3: | |
| 74 case 6: | |
| 75 // fall through | |
| 76 break; | |
| 77 | |
| 78 default: | |
| 79 return EFFS_BADNAME; | |
| 80 } | |
| 81 | |
| 82 // Write STD file and set global variable | |
| 83 ffs_fwrite_nb("/pcm/STD", band, 1, 0); | |
| 84 } | |
| 85 | |
| 86 /* | |
| 87 * | |
| 88 * ffs_GetBand | |
| 89 * | |
| 90 * Purpose : Get STD config as recorded in FFS | |
| 91 * | |
| 92 * Arguments: In : none | |
| 93 * | |
| 94 * Out: none | |
| 95 * | |
| 96 * Returns : STD | |
| 97 * | |
| 98 */ | |
| 99 | |
| 100 unsigned char ffs_GetBand () | |
| 101 { | |
| 102 UBYTE ubStd = 0; | |
| 103 effs_t result; | |
| 104 | |
| 105 // get FFS value | |
| 106 result = ffs_fread("/pcm/STD", &ubStd, 1); | |
| 107 | |
| 108 // default if an error occured : 900-1800 | |
| 109 if (result < EFFS_OK) | |
| 110 { | |
| 111 ubStd = 6; | |
| 112 } | |
| 113 | |
| 114 return ubStd; | |
| 115 } | |
| 116 | |
| 117 /* | |
| 118 * ffs_restore | |
| 119 * | |
| 120 * Restores flash file system from MPU Persistent Storage | |
| 121 * Restore Factory FFS in cae of file corruption | |
| 122 * | |
| 123 * Procedure described in PE023 document | |
| 124 * | |
| 125 */ | |
| 126 | |
| 127 void ffs_restore(void) | |
| 128 { | |
| 129 effs_t res; | |
| 130 | |
| 131 // FFS restore procedure started | |
| 132 // send a message through CSMI | |
| 133 if( GC_RestoreFFSReq(FFS_BASE_ADDRESS, IMAGE_SIZE) == CSMI_ERROR ) | |
| 134 { | |
| 135 // In case of MPU File corruption, | |
| 136 // restore working FFS from factory FFS | |
| 137 memcpy((char *) FFS_BASE_ADDRESS, FlashImage, IMAGE_SIZE); | |
| 138 | |
| 139 // backup FFS on MPU side | |
| 140 // if we are running with the OS | |
| 141 if(GC_RunningWithOs()) | |
| 142 ffs_backup(); | |
| 143 } | |
| 144 } | |
| 145 | |
| 146 /* | |
| 147 * ffs_backup | |
| 148 * | |
| 149 * Backup flash file system | |
| 150 * | |
| 151 * Procedure described in PE023 document | |
| 152 * | |
| 153 */ | |
| 154 | |
| 155 void ffs_backup(void) | |
| 156 { | |
| 157 // FFS backup procedure started | |
| 158 // send a message through CSMI | |
| 159 GC_BackupFFSReq(FFS_BASE_ADDRESS, IMAGE_SIZE); | |
| 160 } |
