NetBurner 3.5.6
PDF Version
effs_pt.h
1/*NB_REVISION*/
2
3/*NB_COPYRIGHT*/
4
13#ifndef __EFFSPT_H
14#define __EFFSPT_H
15
16#include <basictypes.h>
17
19enum ePartType {
20 PARTITION_TYPE_EMPTY = 0x00,
21 PARTITION_TYPE_FAT12 = 0x01,
22 PARTITION_TYPE_FAT16 = 0x04,
23 PARTITION_TYPE_NTFS = 0x07,
24 PARTITION_TYPE_EXFAT = 0x07,
25 PARTITION_TYPE_LINUX = 0x93,
26
27 PARTITION_TYPE_EFFS = 0x25,
28};
29
31enum ePartFlags {
32 PARTITION_FLAG_FREE = 0x00,
33 PARTITION_FLAG_INUSE = 0x01,
34 PARTITION_FLAG_EXTENDED = 0x02,
35 PARTITION_FLAG_BOOT = 0x80,
36};
37
39enum ePartError {
40 PARTITION_ERROR_NOERR = 0,
41
42 PARTITION_ERROR_OVERLAP = -1,
43 PARTITION_ERROR_TOOBIG = -2,
44 PARTITION_ERROR_IDX = -3,
45 PARTITION_ERROR_TYPE = -4,
46 PARTITION_ERROR_TABLE_FULL= -5,
47 PARTITION_ERROR_BOUNDS = -6,
48 PARTITION_ERROR_UNKNOWN = -255,
49};
50
60 uint32_t flags : 8;
61 uint32_t sectorCount : 24;
62 uint32_t partitionType : 8;
63 uint32_t firstSector : 24;
64
65 uint64_t start();
66 uint64_t end();
67 uint64_t startAddr(uint32_t sectorSize);
68 uint64_t endAddr(uint32_t sectorSize);
69 uint64_t sectors();
70 uint64_t setStart(uint64_t startSector);
71 uint64_t setSectors(uint64_t sCount);
72};
73
82 union {
83 struct {
84 uint8_t bootExe[422];
85 uint8_t tableLenExp;
86 uint8_t sectorLenExp;
87 uint32_t totalSectors;
89 uint8_t csums[16];
90 };
91 uint8_t pAsBytePtr[1];
92 };
93 uint64_t sectors();
94 uint64_t setSectors(uint64_t sCount);
95
96 inline uint64_t sectorLen() { return 1ull << sectorLenExp; }
97};
98
100struct Effs_Cfg {
101 union {
102 struct {
103 uint16_t maxblock;
104 uint8_t sSizeExp;
105 uint8_t blSizeExp;
106 uint8_t dSizeExp;
107 uint8_t cacheSizeExp;
108 uint8_t separatedir;
109 uint8_t csum;
110 };
111 uint8_t pAsBytePtr[1];
112 };
113};
114
115uint32_t hamming_checksum(const uint8_t *dat, uint32_t datBits, uint8_t codeLen);
116int hamming_validate(const uint8_t *dat, uint32_t datBits, uint32_t checksum, uint8_t codeLen);
117int hamming_validateOrFix(uint8_t *dat, uint32_t datBits, uint32_t checksum, uint8_t codeLen);
118int hamming_anneal(uint8_t *dat, uint32_t datBits, uint32_t checksum, uint8_t codeLen, uint8_t errBit);
119
120
121int getPartitionTable(PartitionTable *pt);
122int validatePartitionTable(PartitionTable *pt);
123int createPartitionTable(PartitionTable *pt, uint8_t sectorLenExp, uint64_t totalSectors);
124int movePartitionEntriesUp(PartitionTable *pt, int startIdx);
125int movePartitionEntriesDown(PartitionTable *pt, int startIdx);
126int createPartitionEntry(PartitionTable *pt, PartitionEntry *pte,
127 uint64_t startSector, uint64_t sectorCount,
128 uint8_t type, bool makeBootable);
129int createPartition(PartitionTable *pt, PartitionEntry *pte);
130int deletePartition(PartitionTable *pt, int partIdx);
131int writePartitionTable(PartitionTable *pt);
132
133int createDefaultFilesystem(PartitionTable *pt, int partIdx);
134
135void showPartitionTable(PartitionTable *pt);
136void showPartition(PartitionEntry *pte);
137
138extern PartitionTable AppFlash_pt;
139
140#define HAL_FS_MOUNT_SYS "A:/sys"
141#define HAL_FS_MOUNT_APP "A:/app"
142#define HAL_FS_MOUNT_USR "A:/usr"
143
144#define HAL_FS_SYS_FILE_DIR "files"
145#define HAL_FS_PATH_SYS HAL_FS_MOUNT_SYS "/" HAL_FS_SYS_FILE_DIR "/"
146#define HAL_FS_PATH_APP HAL_FS_MOUNT_APP "/"
147#define HAL_FS_PATH_USR HAL_FS_MOUNT_USR "/"
148
149#define HAL_FS_NAME_CONFIG "config"
150#define HAL_FS_NAME_CERTSTORE "certs"
151#define HAL_FS_NAME_USERPARAM "usrparam"
152#define HAL_FS_NAME_APP "app"
153
154#define HAL_FS_VER_SUFFIX ".x"
155
156#define HAL_FS_FILE_CONFIG HAL_FS_PATH_SYS HAL_FS_NAME_CONFIG
157#define HAL_FS_FILE_CERTSTORE HAL_FS_PATH_SYS HAL_FS_NAME_CERTSTORE
158#define HAL_FS_FILE_USERPARAM HAL_FS_PATH_SYS HAL_FS_NAME_USERPARAM
159#define HAL_FS_FILE_APP HAL_FS_PATH_SYS HAL_FS_NAME_APP
160
161#endif /* ----- #ifndef __EFFSPT_H ----- */
Filesystem Configuration.
Definition effs_pt.h:100
uint8_t dSizeExp
Max size of fat+directory+block index.
Definition effs_pt.h:106
uint8_t sSizeExp
Sector size wanted to use (less than block size.
Definition effs_pt.h:104
uint8_t pAsBytePtr[1]
Definition effs_pt.h:111
uint8_t csum
Hamming code csum of struct.
Definition effs_pt.h:109
uint8_t cacheSizeExp
Write cache size.
Definition effs_pt.h:107
uint8_t separatedir
If directory used separatelly from FAT (NAND)
Definition effs_pt.h:108
uint16_t maxblock
Maximum number of block can be used.
Definition effs_pt.h:103
uint8_t blSizeExp
Block size in bytes.
Definition effs_pt.h:105
Definition effs_pt.h:59
uint64_t endAddr(uint32_t sectorSize)
uint32_t firstSector
Index of first sector for this partition.
Definition effs_pt.h:63
uint32_t flags
Any special flags for the partition.
Definition effs_pt.h:60
uint64_t startAddr(uint32_t sectorSize)
uint64_t setStart(uint64_t startSector)
uint64_t sectors()
uint64_t start()
uint64_t setSectors(uint64_t sCount)
uint64_t end()
uint32_t partitionType
What type of filesystem is this partition.
Definition effs_pt.h:62
uint32_t sectorCount
How many sectors are in this partition.
Definition effs_pt.h:61
Definition effs_pt.h:81
PartitionEntry part[8]
Partition entries.
Definition effs_pt.h:88
uint8_t pAsBytePtr[1]
Definition effs_pt.h:91
uint64_t sectorLen()
Definition effs_pt.h:96
uint32_t totalSectors
Total sectors available, see.
Definition effs_pt.h:87
uint64_t sectors()
uint8_t sectorLenExp
Sector Length, see Table Length.
Definition effs_pt.h:86
uint64_t setSectors(uint64_t sCount)
uint8_t bootExe[422]
If direct execution is ever supported...
Definition effs_pt.h:84
uint8_t tableLenExp
Table Length => 2**tableLenExp: 2**8 => 256 bytes.
Definition effs_pt.h:85
uint8_t csums[16]
Hamming code csum of 31 byte blocks comprising the Table.
Definition effs_pt.h:89