Trond Enger / d7a_1x

Fork of d7a_1x by WizziLab

Revision:
26:9f0b9833cac6
Parent:
25:aac250164497
Child:
27:934ab7455115
--- a/include/d7a_fs.h	Fri Mar 25 16:48:02 2016 +0000
+++ b/include/d7a_fs.h	Thu Mar 31 14:48:50 2016 +0000
@@ -6,6 +6,8 @@
 #include "d7a_common.h"
 #include "d7a_com.h"
 
+#define TO_FS       (200)
+
 typedef uint32_t (*WriteFileFunction)(  const uint8_t file_id,
                                         const uint16_t offset,
                                         const uint16_t file_size,
@@ -16,6 +18,56 @@
                                         const uint16_t file_size,
                                         uint8_t* buf);
 
+// PROP Byte
+#define FS_BFO_STORAGE_CLASS    0
+#define FS_BFO_ACT_COND         4
+#define FS_BFO_ACT_EN           7
+#define FS_BFS_STORAGE_CLASS    2
+#define FS_BFS_ACT_COND         3
+#define FS_BFS_ACT_EN           1
+
+//======================================================================
+// Attributes and macros
+//======================================================================
+// "Piped" File: rd/wr are not stored but just sent on IF
+#define FS_TRANSIENT         (TRANSIENT  << FS_BFO_STORAGE_CLASS)
+// "RAM" File: rd/wr to a volatile buffer.
+#define FS_VOLATILE          (VOLATILE   << FS_BFO_STORAGE_CLASS)
+// "Mirrored" File: loaded from NVM, cached/used in RAM. Flushable to NVM.
+#define FS_RESTORABLE        (RESTORABLE << FS_BFO_STORAGE_CLASS)
+// "Normal" File: rd/wr from/to NVM
+#define FS_PERMANENT         (PERMANENT  << FS_BFO_STORAGE_CLASS)
+#define FS_ACT_COND(c)       ((c & 0x7) << FS_BFO_ACT_COND)
+#define FS_ACT_EN            (1  << FS_BFO_ACT_EN)
+
+#define FS_RUNNABLE          (1  << FS_BFO_RUNNABLE)
+#define FS_ENCRYPTED         (1  << FS_BFO_ENCRYPTED)
+
+// XXX Old ALP Hack
+#define NACK                 FS_RUNNABLE
+#define NOTIF                FS_ENCRYPTED
+
+// D7AactP Enabled File properties
+#if 0 // Condition is not used (nor usable)
+    #define FS_TRANSIENT_NOTIF(c) (FS_TRANSIENT  | FS_ACT_EN | FS_ACT_COND(c))
+    #define FS_VOLATILE_NOTIF(c)  (FS_VOLATILE   | FS_ACT_EN | FS_ACT_COND(c))
+    #define FS_RESTORABLE_NOTIF(c)(FS_RESTORABLE | FS_ACT_EN | FS_ACT_COND(c))
+    #define FS_PERMANENT_NOTIF(c) (FS_PERMANENT  | FS_ACT_EN | FS_ACT_COND(c))
+#else
+    #define FS_TRANSIENT_NOTIF    (FS_TRANSIENT  | FS_ACT_EN)
+    #define FS_VOLATILE_NOTIF     (FS_VOLATILE   | FS_ACT_EN)
+    #define FS_RESTORABLE_NOTIF   (FS_RESTORABLE | FS_ACT_EN)
+    #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
@@ -159,10 +211,11 @@
 } d7a_fs_properties_t;
 
 void d7a_fs_open(WriteFileFunction write_file, ReadFileFunction read_file);
-void d7a_fs_wait_done(uint32_t millisec = osWaitForever);
+void* d7a_fs_wait_done(uint32_t millisec = osWaitForever);
 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);
+void d7a_fs_distant_stat(uint8_t fid, int* length);
 int d7a_fs_distant_create(uint8_t fid, d7a_fs_properties_t* props);