#include <string.h>#include "minfs.h"Defines | |
| #define | BE_SWAP_16(val) |
| #define | BE_SWAP_32(val) |
| #define | LE_GET(dst, p_src, len) |
| #define | LE_SET(p_dst, src, len) |
| #define | TC_SET(p_dst, src, len) |
| #define | TC_GET(dst, p_src, len) |
| #define | CALC_PEC(p_buf, data_len, pec_val_inttype, pec_val) |
| #define | MINFS_RW_MODE_READ 0 |
| #define | MINFS_RW_MODE_WRITE 1 |
Functions | |
| int32_t | MINFS_Read (MINFS_fs_t *p_fs, MINFS_block_buf_t *p_block_buf, uint16_t data_offset, uint16_t data_len) |
| int32_t | MINFS_Write (MINFS_fs_t *p_fs, MINFS_block_buf_t *p_block_buf, uint16_t data_offset, uint16_t data_len) |
| int32_t | MINFS_GetBlockBuffer (MINFS_fs_t *p_fs, MINFS_block_buf_t **pp_block_buf, uint32_t block_n, uint32_t file_id) |
| int32_t | MINFS_InitBlockBuffer (MINFS_block_buf_t *p_block_buf) |
| int32_t | MINFS_FlushBlockBuffer (MINFS_fs_t *p_fs, MINFS_block_buf_t *p_block_buf) |
| int32_t | MINFS_Format (MINFS_fs_t *p_fs, MINFS_block_buf_t *p_block_buf) |
| int32_t | MINFS_FSOpen (MINFS_fs_t *p_fs, MINFS_block_buf_t *p_block_buf) |
| int32_t | MINFS_FileOpen (MINFS_fs_t *p_fs, uint32_t file_id, MINFS_file_t *p_file, MINFS_block_buf_t *p_block_buf) |
| int32_t | MINFS_FileRead (MINFS_file_t *p_file, void *p_buf, uint32_t *p_len, MINFS_block_buf_t *p_block_buf) |
| int32_t | MINFS_FileWrite (MINFS_file_t *p_file, void *p_buf, uint32_t len, MINFS_block_buf_t *p_block_buf) |
| int32_t | MINFS_FileSeek (MINFS_file_t *p_file, uint32_t pos, MINFS_block_buf_t *p_block_buf) |
| int32_t | MINFS_FileSetSize (MINFS_file_t *p_file, uint32_t new_size, MINFS_block_buf_t *p_block_buf) |
| int32_t | MINFS_FileTouch (MINFS_fs_t *p_fs, uint32_t file_id, MINFS_block_buf_t *p_block_buf) |
| int32_t | MINFS_FileUnlink (MINFS_fs_t *p_fs, uint32_t file_id, uint8_t check_last_truncate, MINFS_block_buf_t *p_block_buf) |
| int32_t | MINFS_FileMove (MINFS_fs_t *p_fs, uint32_t src_file_id, uint32_t dst_file_id, uint8_t check_last_truncate, MINFS_block_buf_t *p_block_buf) |
| int32_t | MINFS_FileExists (MINFS_fs_t *p_fs, uint32_t file_id, MINFS_block_buf_t *p_block_buf) |
| int32_t | MINFS_FileGetFreeID (MINFS_fs_t *p_fs, uint8_t mode, MINFS_block_buf_t *p_block_buf) |
| int32_t | MINFS_FileIndexTruncate (MINFS_fs_t *p_fs, MINFS_block_buf_t *p_block_buf) |
| #define BE_SWAP_16 | ( | val | ) |
if( *( (uint8_t*)(&BECV) ) == 0 ){ \
*(uint8_t*)(&val) ^= *(uint8_t*)(&val + 1); \
*(uint8_t*)(&val + 1) ^= *(uint8_t*)(&val); \
*(uint8_t*)(&val) ^= *(uint8_t*)(&val + 1); \
}
| #define BE_SWAP_32 | ( | val | ) |
if( *( (uint8_t*)(&BECV) ) == 0 ){ \
*(uint8_t*)(&val) ^= *(uint8_t*)(&val + 3); \
*(uint8_t*)(&val + 3) ^= *(uint8_t*)(&val); \
*(uint8_t*)(&val) ^= *(uint8_t*)(&val + 3); \
*(uint8_t*)(&val + 1) ^= *(uint8_t*)(&val + 2); \
*(uint8_t*)(&val + 2) ^= *(uint8_t*)(&val + 1); \
*(uint8_t*)(&val + 1) ^= *(uint8_t*)(&val + 2); \
}
| #define CALC_PEC | ( | p_buf, | |||
| data_len, | |||||
| pec_val_inttype, | |||||
| pec_val | ) |
{\
pec_val_inttype * p_val;\
for( p_val = (pec_val_inttype*) p_buf ; (uint8_t*)p_val < ( (uint8_t*)p_buf + data_len); p_val++ )\
pec_val ^= *p_val;\
}
| #define LE_GET | ( | dst, | |||
| p_src, | |||||
| len | ) |
{ \
dst = *( (uint8_t*) (p_src) ); \
if( len > 1 ) \
dst |= (uint16_t)( *( (uint8_t*) (p_src + 1) ) ) << 8; \
if( len > 2 ) \
dst |= (uint32_t)( *( (uint8_t*) (p_src + 2) ) ) << 16; \
if( len > 3 ) \
dst |= (uint32_t)( *( (uint8_t*) (p_src + 3) ) ) << 24; \
}
| #define LE_SET | ( | p_dst, | |||
| src, | |||||
| len | ) |
{ \
*( (uint8_t*)p_dst ) = (uint8_t)src; \
if( len > 1 ) \
*( (uint8_t*)(p_dst + 1) ) |= (uint8_t)( src >> 8 ); \
if( len > 2 ) \
*( (uint8_t*)(p_dst + 2) ) |= (uint8_t)( src >> 16 ); \
if( len > 3 ) \
*( (uint8_t*)(p_dst + 3) ) |= (uint8_t)( src >> 24 ); \
}
| #define MINFS_RW_MODE_READ 0 |
| #define MINFS_RW_MODE_WRITE 1 |
| #define TC_GET | ( | dst, | |||
| p_src, | |||||
| len | ) |
{ \
if( len > 2 ) \
(uint32_t)dst = *((uint32_t*)p_src); \
else if( len > 1 ) \
(uint16_t)dst = *((uint16_t*)p_src); \
else \
(uint8_t)dst = *((uint8_t*)p_src); \
}
| #define TC_SET | ( | p_dst, | |||
| src, | |||||
| len | ) |
{ \
if( len > 2 ) \
*((uint32_t*)p_dst) = (uint32_t)src; \
else if( len > 1 ) \
*((uint16_t*)p_dst) = (uint16_t)src; \
else \
*((uint8_t*)p_dst) = (uint8_t)src; \
}
| int32_t MINFS_FileExists | ( | MINFS_fs_t * | p_fs, | |
| uint32_t | file_id, | |||
| MINFS_block_buf_t * | p_block_buf | |||
| ) |
| int32_t MINFS_FileGetFreeID | ( | MINFS_fs_t * | p_fs, | |
| uint8_t | mode, | |||
| MINFS_block_buf_t * | p_block_buf | |||
| ) |
| int32_t MINFS_FileIndexTruncate | ( | MINFS_fs_t * | p_fs, | |
| MINFS_block_buf_t * | p_block_buf | |||
| ) |
| int32_t MINFS_FileMove | ( | MINFS_fs_t * | p_fs, | |
| uint32_t | src_file_id, | |||
| uint32_t | dst_file_id, | |||
| uint8_t | check_last_truncate, | |||
| MINFS_block_buf_t * | p_block_buf | |||
| ) |
| int32_t MINFS_FileOpen | ( | MINFS_fs_t * | p_fs, | |
| uint32_t | file_id, | |||
| MINFS_file_t * | p_file, | |||
| MINFS_block_buf_t * | p_block_buf | |||
| ) |
| int32_t MINFS_FileRead | ( | MINFS_file_t * | p_file, | |
| void * | p_buf, | |||
| uint32_t * | p_len, | |||
| MINFS_block_buf_t * | p_block_buf | |||
| ) |
| int32_t MINFS_FileSeek | ( | MINFS_file_t * | p_file, | |
| uint32_t | pos, | |||
| MINFS_block_buf_t * | p_block_buf | |||
| ) |
| int32_t MINFS_FileSetSize | ( | MINFS_file_t * | p_file, | |
| uint32_t | new_size, | |||
| MINFS_block_buf_t * | p_block_buf | |||
| ) |
| int32_t MINFS_FileTouch | ( | MINFS_fs_t * | p_fs, | |
| uint32_t | file_id, | |||
| MINFS_block_buf_t * | p_block_buf | |||
| ) |
| int32_t MINFS_FileUnlink | ( | MINFS_fs_t * | p_fs, | |
| uint32_t | file_id, | |||
| uint8_t | check_last_truncate, | |||
| MINFS_block_buf_t * | p_block_buf | |||
| ) |
| int32_t MINFS_FileWrite | ( | MINFS_file_t * | p_file, | |
| void * | p_buf, | |||
| uint32_t | len, | |||
| MINFS_block_buf_t * | p_block_buf | |||
| ) |
| int32_t MINFS_FlushBlockBuffer | ( | MINFS_fs_t * | p_fs, | |
| MINFS_block_buf_t * | p_block_buf | |||
| ) |
| int32_t MINFS_Format | ( | MINFS_fs_t * | p_fs, | |
| MINFS_block_buf_t * | p_block_buf | |||
| ) |
| int32_t MINFS_FSOpen | ( | MINFS_fs_t * | p_fs, | |
| MINFS_block_buf_t * | p_block_buf | |||
| ) |
| int32_t MINFS_GetBlockBuffer | ( | MINFS_fs_t * | p_fs, | |
| MINFS_block_buf_t ** | pp_block_buf, | |||
| uint32_t | block_n, | |||
| uint32_t | file_id | |||
| ) |
| int32_t MINFS_InitBlockBuffer | ( | MINFS_block_buf_t * | p_block_buf | ) |
| int32_t MINFS_Read | ( | MINFS_fs_t * | p_fs, | |
| MINFS_block_buf_t * | p_block_buf, | |||
| uint16_t | data_offset, | |||
| uint16_t | data_len | |||
| ) |
| int32_t MINFS_Write | ( | MINFS_fs_t * | p_fs, | |
| MINFS_block_buf_t * | p_block_buf, | |||
| uint16_t | data_offset, | |||
| uint16_t | data_len | |||
| ) |
1.6.1