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
include/d7a_fs.h
- Committer:
- Jeej
- Date:
- 2016-03-25
- Revision:
- 25:aac250164497
- Child:
- 26:9f0b9833cac6
File content as of revision 25:aac250164497:
#ifndef _D7A_FS_H_ #define _D7A_FS_H_ #include "mbed.h" #include "rtos.h" #include "d7a_common.h" #include "d7a_com.h" typedef uint32_t (*WriteFileFunction)( const uint8_t file_id, const uint16_t offset, const uint16_t file_size, const uint8_t * const content); typedef uint32_t (*ReadFileFunction)( const uint8_t file_id, const uint16_t offset, const uint16_t file_size, uint8_t* buf); // COM-FS Operation-codes. Mimics ALP ones. #define FS_OP_NULL 0 #define FS_OP_RD 1 #define FS_OP_WR 4 #define FS_OP_STAT 16 #define FS_OP_DSTAT 30 // Variant of STAT for distant files #define FS_OP_CREATE 17 #define FS_OP_FLUSH 20 #define FS_OP_RETSTAT 32 #define FS_OP_RETDATA 34 // FS/COM-FS Status-codes. Mimics ALP ones. enum { FS_STAT_PENDING = 1, FS_STAT_OK = 0, FS_STAT_ERR_FID_NOEXIST = -1, // FF FS_STAT_ERR_FID_ALREADYEXIST = -2, // FE FS_STAT_ERR_NOTRESTORABLE = -3, // FD FS_STAT_ERR_PERMISSION = -4, // FC FS_STAT_ERR_LENGTH_OVFL = -5, // FB FS_STAT_ERR_ALLOC_OVFL = -6, // FA FS_STAT_ERR_START_OFFSET_OVFL = -7, // F9 FS_STAT_ERR_WRITE_OVFL = -8, // F8 FS_STAT_ERR_WRITE_PROTECTED = -9, // F7 FS_STAT_ERR_UNKNOWN_OPERATION = -10, // F6 FS_STAT_ERR_INCOMPLETE_OPERAND = -11, // F5 FS_STAT_ERR_WRONG_OPERAND = -12, // F4 FS_STAT_ERR_UNKNOWN = -127, // 80 }; // Memory "TYPE" #define FS_TYPE_DISTANT 0x80 enum { NOFILE = 0, PFLASH, EEPROM, RAM, HOST = 0x80 + 0x10, // Distant HST_COM Files ERASED = 0xff }; // 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; void d7a_fs_open(WriteFileFunction write_file, ReadFileFunction read_file); 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); int d7a_fs_distant_create(uint8_t fid, d7a_fs_properties_t* props); #endif