Trond Enger / d7a_1x

Fork of d7a_1x by WizziLab

Revision:
43:28202405094d
Parent:
38:c1e7f97ab396
Child:
44:8ebe6b70f932
--- a/include/d7a_fs.h	Thu Aug 25 09:38:40 2016 +0000
+++ b/include/d7a_fs.h	Tue Aug 30 16:59:12 2016 +0000
@@ -6,6 +6,7 @@
 #include "dbg.h"
 #include "d7a_common.h"
 #include "d7a_com.h"
+#include "d7a.h"
 
 #define TO_FS       (8000)     // Long time to give the modem time to reboot in case of assert
 #define FS_MAX_CONCURRENCY  16 // Maximum number of concurrent access
@@ -52,14 +53,6 @@
     #define FS_PERMANENT_NOTIF    (FS_PERMANENT  | FS_ACT_EN)
 #endif
 
-#define RWX_RWX             0b00111111
-#define RW_ALL              0b00110110
-#define RW_RW               0b00110110
-#define RW_STANDARD         0b00110100
-#define RW_R                0b00110100
-#define R_R                 0b00100100
-
-
 // COM-FS Operation-codes. Mimics ALP ones.
 #define FS_OP_NULL      0
 #define FS_OP_RD        1
@@ -74,7 +67,6 @@
 #define FS_OP_RETDATA   34
 
 
-
 // FS/COM-FS Status-codes. Mimics ALP ones.
 enum {
     FS_STAT_PENDING                =  1,
@@ -96,9 +88,18 @@
 
 
 // Memory "TYPE"
-#define FS_TYPE_DISTANT 0x80
-#define FS_PHY_TYPE(t)  ((t)&0x0F)
-#define FS_COM_TYPE(t)  ((t)&0xF0)
+// ------------------------------------------------------
+// |  Sync   | Distant |    Com       |   MemType       |
+// ------------------------------------------------------
+// |   b7    |   b6    |   b5-b4      |     b3-b0       |
+// ------------------------------------------------------
+#define FS_TYPE_SYNC        0x80
+#define FS_TYPE_DISTANT     0x40
+#define FS_MEM_TYPE(t)      ((t)&0x0F)
+#define FS_COM_TYPE(t)      ((t)&0x30)
+#define FS_DISTANT_TYPE(t)  ((t)&0x70)
+#define FS_DISTANT_INFO(t)  ((t)&0xf0)
+
 enum {
     // Markers
         NOFILE  = 0,
@@ -107,159 +108,41 @@
         PFLASH  = 1,
         EEPROM  = 2,
         RAM     = 3,
+        OTP     = 4,
         UNKNOWN = 0xF,
         // PSRAM
         // DDR
         // ...etc
     // COM Type for 'distant' files
-        HOST    = FS_TYPE_DISTANT + (1<<4), // Distant HST_COM Files
-        SPI     = FS_TYPE_DISTANT + (2<<4),
-        I2C     = FS_TYPE_DISTANT + (3<<4),
+        FS_COM_UART    = (0<<4),
+        FS_COM_SPI     = (1<<4),
+        FS_COM_I2C     = (2<<4),
+    // DISTANT Full Types
+        // Symetric HST-COM Files:
+        // - Header on Host side (i.e. need syncro on STAT)
+        // - Data on Host side
+        // - Same/Similar memory physical types
+        HOSTNS  = FS_TYPE_SYNC + FS_TYPE_DISTANT + FS_COM_UART,
+        // Synchronised Symetric HST / COM Files
+        // - Idem Symetric HST-COM Files excepted:
+        // - Local header is assumed to be syncronised (through FS:SYNC)
+        HOSTS   = FS_TYPE_DISTANT + FS_COM_UART,
+        HOST    = FS_TYPE_DISTANT + FS_COM_UART, // Common Alias for FS_DISTANT_TYPE(t) usage
+};
 
-};
-// File "Storage Class"
-enum { TRANSIENT=0, VOLATILE, RESTORABLE, PERMANENT};
 // D7AactP "trigger" TODO: is it really applicable ?
 enum { LIST=0, READ, WRITE, WRITE_FLUSH};
 
-// =======================================================================
-// d7a_fs_header_t
-// -----------------------------------------------------------------------
-/// Header Structure
-// =======================================================================
-TYPEDEF_STRUCT_PACKED{
-    uint32_t addr         : 32;
-
-    uint32_t type         : 8;
-
-    // RAM Mirroring
-    uint32_t mirror_idx   : 7;
-    uint32_t mirrored     : 1;
-
-    uint32_t fid          : 8;
-
-    uint32_t afid         : 8;
-
-    /// Storage Class
-    uint32_t storage_class : 2;
-    /// RFU
-    uint32_t rfu_2         : 1;
-    uint32_t rfu_3         : 1;
-    /// D7AactP condition
-    uint32_t act_cond      : 3;
-    /// D7AactP is enabled
-    uint32_t act_en        : 1;
-
-    /// Guest permissions
-    uint32_t guest_x       : 1;
-    uint32_t guest_w       : 1;
-    uint32_t guest_r       : 1;
-    /// User permissions
-    uint32_t user_x        : 1;
-    uint32_t user_w        : 1;
-    uint32_t user_r        : 1;
-    /// File is executable
-    uint32_t runable       : 1;
-    /// File is encrypted
-    uint32_t encrypted     : 1;
-
-
-    uint32_t length        : 24;
-    uint32_t alloc         : 24;
-
-    uint32_t ifid          : 8;
-} d7a_fs_header_bf_t;
-
-TYPEDEF_STRUCT_PACKED{
-    uint32_t addr;
-    uint8_t  type;
-    uint8_t  mirror;
-    uint8_t  fid;
-
-    uint8_t  afid;
-    uint8_t  prop;
-    uint8_t  perm;
-
-    uint8_t  length[3];
-    uint8_t  alloc[3];
-    uint8_t  ifid;
-} d7a_fs_header_byte_t;
-
-typedef union
-{
-    d7a_fs_header_bf_t bf;
-    d7a_fs_header_byte_t byte;
-
-} d7a_fs_header_t;
-
-
-typedef enum {
-    KAL_FS_PROP_SIZE,
-    KAL_FS_PROP_ALLOC,
-    KAL_FS_PROP_TYPE,
-    KAL_FS_PROP_ADDR,
-    KAL_FS_PROP_AFID,
-    KAL_FS_PROP_IFID,
-    KAL_FS_PROP_PROP,
-    KAL_FS_PROP_PERM,
-
-    KAL_FS_PROP_ALL,
-} d7a_fs_property_t;
-
-typedef struct{
-    uint32_t addr;
-    uint8_t  type;
-    uint8_t  afid;
-    uint8_t  ifid;
-    uint8_t  prop;
-    uint8_t  perm;
-    uint32_t length;
-    uint32_t alloc;
-} d7a_fs_properties_t;
-
-
-typedef d7a_fs_header_t* (*GetStatFileFunction)(const uint8_t file_id);
-
-typedef bool (*SetStatFileFunction)(const uint8_t file_id, const d7a_fs_header_t* hdr);
-
-typedef uint32_t (*WriteFileFunction)(  const uint8_t file_id,
-                                        const uint16_t offset,
-                                        const uint16_t size,
-                                        const uint8_t * const content);
-                                            
-typedef uint32_t (*ReadFileFunction)(   const uint8_t file_id,
-                                        const uint16_t offset,
-                                        const uint16_t size,
-                                        uint8_t* buf);
-
-typedef uint32_t (*TouchFileFunction)(  const uint8_t file_id,
-                                        const uint16_t offset,
-                                        const uint16_t size);
-                                        
-typedef struct {
-    GetStatFileFunction get_stat;
-    SetStatFileFunction set_stat;
-    WriteFileFunction   write_file;
-    ReadFileFunction    read_file;
-    TouchFileFunction   touch_file;
-} d7a_fs_callbacks_t;
-
 
 // Utils
-#define D7A_FS_READ(fid,data,offset,len)    do {\
-        int status = d7a_fs_read((fid), (data), (offset), (len));\
+#define D7A_READ(fid,data,offset,len)    do {\
+        int status = d7a_alp_read_file((fid), (data), (offset), (len));\
         ASSERT(status == FS_STAT_OK, "Read file error %d (FID:%d OFF:%d LEN:%d)\r\n", status, (fid), (offset), (len));\
     } while(0);
 
 
 void d7a_fs_open(const d7a_fs_callbacks_t* config);
-int8_t d7a_fs_wait_done(const uint8_t id, uint32_t millisec);
 void d7a_fs_new_pkt(d7a_com_rx_msg_t* pkt);
 d7a_com_rx_msg_t* d7a_fs_wait_pkt( uint32_t millisec = osWaitForever );
-uint32_t d7a_fs_get_properties(uint8_t fid, d7a_fs_property_t prop, d7a_fs_properties_t* props);
-int d7a_fs_distant_stat(uint8_t fid, int* length);
-int d7a_fs_distant_create(uint8_t fid, d7a_fs_properties_t* props);
-int d7a_fs_read(uint8_t fid, void *data, uint32_t offset, uint32_t length);
-
 
 #endif
\ No newline at end of file