Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of d7a_1x by
d7a_fs.h
00001 #ifndef _D7A_FS_H_ 00002 #define _D7A_FS_H_ 00003 00004 #include "mbed.h" 00005 #include "rtos.h" 00006 #include "dbg.h" 00007 #include "d7a_common.h" 00008 #include "d7a_com.h" 00009 #include "d7a.h" 00010 00011 #define TO_FS (8000) // Long time to give the modem time to reboot in case of assert 00012 #define FS_MAX_CONCURRENCY 16 // Maximum number of concurrent access 00013 00014 // PROP Byte 00015 #define FS_BFO_STORAGE_CLASS 0 00016 #define FS_BFO_ACT_COND 4 00017 #define FS_BFO_ACT_EN 7 00018 #define FS_BFS_STORAGE_CLASS 2 00019 #define FS_BFS_ACT_COND 3 00020 #define FS_BFS_ACT_EN 1 00021 00022 //====================================================================== 00023 // Attributes and macros 00024 //====================================================================== 00025 // "Piped" File: rd/wr are not stored but just sent on IF 00026 #define FS_TRANSIENT (TRANSIENT << FS_BFO_STORAGE_CLASS) 00027 // "RAM" File: rd/wr to a volatile buffer. 00028 #define FS_VOLATILE (VOLATILE << FS_BFO_STORAGE_CLASS) 00029 // "Mirrored" File: loaded from NVM, cached/used in RAM. Flushable to NVM. 00030 #define FS_RESTORABLE (RESTORABLE << FS_BFO_STORAGE_CLASS) 00031 // "Normal" File: rd/wr from/to NVM 00032 #define FS_PERMANENT (PERMANENT << FS_BFO_STORAGE_CLASS) 00033 #define FS_ACT_COND(c) ((c & 0x7) << FS_BFO_ACT_COND) 00034 #define FS_ACT_EN (1 << FS_BFO_ACT_EN) 00035 00036 #define FS_RUNNABLE (1 << FS_BFO_RUNNABLE) 00037 #define FS_ENCRYPTED (1 << FS_BFO_ENCRYPTED) 00038 00039 // XXX Old ALP Hack 00040 #define NACK FS_RUNNABLE 00041 #define NOTIF FS_ENCRYPTED 00042 00043 // D7AactP Enabled File properties 00044 #if 0 // Condition is not used (nor usable) 00045 #define FS_TRANSIENT_NOTIF(c) (FS_TRANSIENT | FS_ACT_EN | FS_ACT_COND(c)) 00046 #define FS_VOLATILE_NOTIF(c) (FS_VOLATILE | FS_ACT_EN | FS_ACT_COND(c)) 00047 #define FS_RESTORABLE_NOTIF(c)(FS_RESTORABLE | FS_ACT_EN | FS_ACT_COND(c)) 00048 #define FS_PERMANENT_NOTIF(c) (FS_PERMANENT | FS_ACT_EN | FS_ACT_COND(c)) 00049 #else 00050 #define FS_TRANSIENT_NOTIF (FS_TRANSIENT | FS_ACT_EN) 00051 #define FS_VOLATILE_NOTIF (FS_VOLATILE | FS_ACT_EN) 00052 #define FS_RESTORABLE_NOTIF (FS_RESTORABLE | FS_ACT_EN) 00053 #define FS_PERMANENT_NOTIF (FS_PERMANENT | FS_ACT_EN) 00054 #endif 00055 00056 // COM-FS Operation-codes. Mimics ALP ones. 00057 #define FS_OP_NULL 0 00058 #define FS_OP_RD 1 00059 #define FS_OP_WR 4 00060 #define FS_OP_SYNC 6 // Write File Properties 00061 #define FS_OP_TOUCH 7 // Not in ALP but '7' is still in 'write' actions area 00062 #define FS_OP_STAT 16 00063 #define FS_OP_DSTAT 30 // Not in ALP: Variant of STAT for distant files 00064 #define FS_OP_CREATE 17 00065 #define FS_OP_FLUSH 20 00066 #define FS_OP_EXECUTE 31 00067 #define FS_OP_RETSTAT 32 00068 #define FS_OP_RETDATA 34 00069 00070 00071 // FS/COM-FS Status-codes. Mimics ALP ones. 00072 enum { 00073 FS_STAT_PENDING = 1, 00074 FS_STAT_OK = 0, 00075 FS_STAT_ERR_FID_NOEXIST = -1, // FF 00076 FS_STAT_ERR_FID_ALREADYEXIST = -2, // FE 00077 FS_STAT_ERR_NOTRESTORABLE = -3, // FD 00078 FS_STAT_ERR_PERMISSION = -4, // FC 00079 FS_STAT_ERR_LENGTH_OVFL = -5, // FB 00080 FS_STAT_ERR_ALLOC_OVFL = -6, // FA 00081 FS_STAT_ERR_START_OFFSET_OVFL = -7, // F9 00082 FS_STAT_ERR_WRITE_OVFL = -8, // F8 00083 FS_STAT_ERR_WRITE_PROTECTED = -9, // F7 00084 FS_STAT_ERR_UNKNOWN_OPERATION = -10, // F6 00085 FS_STAT_ERR_INCOMPLETE_OPERAND = -11, // F5 00086 FS_STAT_ERR_WRONG_OPERAND = -12, // F4 00087 FS_STAT_ERR_UNKNOWN = -127, // 80 00088 }; 00089 00090 00091 // Memory "TYPE" 00092 // ------------------------------------------------------ 00093 // | Sync | Distant | Com | MemType | 00094 // ------------------------------------------------------ 00095 // | b7 | b6 | b5-b4 | b3-b0 | 00096 // ------------------------------------------------------ 00097 #define FS_TYPE_SYNC 0x80 00098 #define FS_TYPE_DISTANT 0x40 00099 #define FS_MEM_TYPE(t) ((t)&0x0F) 00100 #define FS_COM_TYPE(t) ((t)&0x30) 00101 #define FS_DISTANT_TYPE(t) ((t)&0x70) 00102 00103 enum { 00104 // Markers 00105 NOFILE = 0, 00106 ERASED = 0xff, 00107 // Physical Type 00108 PFLASH = 1, 00109 EEPROM = 2, 00110 RAM = 3, 00111 OTP = 4, 00112 UNKNOWN = 0x0F, 00113 // PSRAM 00114 // DDR 00115 // ...etc 00116 00117 FS_COM_UART = (0<<4), 00118 FS_COM_SPI = (1<<4), 00119 FS_COM_I2C = (2<<4), 00120 // DISTANT Full Types 00121 // Symetric HST-COM Files: 00122 // - Header on Host side (i.e. need syncro on STAT) 00123 // - Data on Host side 00124 // - Same/Similar memory physical types 00125 HOSTNS = FS_TYPE_SYNC + FS_TYPE_DISTANT + FS_COM_UART, 00126 // Synchronised Symetric HST / COM Files 00127 // - Idem Symetric HST-COM Files excepted: 00128 // - Local header is assumed to be syncronised (through FS:SYNC) 00129 HOSTS = FS_TYPE_DISTANT + FS_COM_UART, 00130 HOST = FS_TYPE_DISTANT + FS_COM_UART, // Common Alias for FS_DISTANT_TYPE(t) usage 00131 }; 00132 00133 00134 // D7AactP "trigger" TODO: is it really applicable ? 00135 enum { LIST=0, READ, WRITE, WRITE_FLUSH}; 00136 00137 00138 // Utils 00139 #define D7A_READ(fid,offset,len,data) do {\ 00140 d7a_errors_t status = d7a_alp_read_file((fid), (offset), (len), (uint8_t*)(data));\ 00141 ASSERT(status >= 0, "Read file error %d (FID:%d OFF:%d LEN:%d)\r\n", status, (fid), (offset), (len));\ 00142 } while(0); 00143 00144 d7a_errors_t d7a_fs_open(WriteFileFunction wf, ReadFileFunction rf); 00145 d7a_errors_t d7a_fs_close(void); 00146 void d7a_fs_new_pkt(d7a_com_rx_msg_t* pkt); 00147 d7a_com_rx_msg_t* d7a_fs_wait_pkt( uint32_t millisec = osWaitForever ); 00148 void d7a_fs_notif_done(const uint8_t file_id, const uint8_t error); 00149 00150 #endif
Generated on Sun Jul 17 2022 09:41:51 by
1.7.2
