NetBurner 3.5.8
PDF Version
EffsPT.h
1#ifndef __EFFSPT_H
2#define __EFFSPT_H
3/*NB_REVISION*/
4
5/*NB_COPYRIGHT*/
6
7#include <basictypes.h>
8/*******************************************************************************
9 * This header defines the Partition Table structures used by both applications*
10 * and the boot monitor to mount the application File System in order to *
11 * access the bootable image, configuration data, and user data. *
12 *******************************************************************************/
13
14enum ePartType {
15 PARTITION_TYPE_EMPTY = 0x00,
16 PARTITION_TYPE_FAT12 = 0x01,
17 PARTITION_TYPE_FAT16 = 0x04,
18 PARTITION_TYPE_NTFS = 0x07,
19 PARTITION_TYPE_EXFAT = 0x07,
20 PARTITION_TYPE_LINUX = 0x93,
21
22 PARTITION_TYPE_EFFS = 0x25,
23};
24
25enum ePartFlags {
26 PARTITION_FLAG_FREE = 0x00,
27 PARTITION_FLAG_INUSE = 0x01,
28 PARTITION_FLAG_EXTENDED = 0x02,
29 PARTITION_FLAG_BOOT = 0x80,
30};
31
32enum ePartError {
33 PARTITION_ERROR_NOERR = 0,
34
35 PARTITION_ERROR_OVERLAP = -1,
36 PARTITION_ERROR_TOOBIG = -2,
37 PARTITION_ERROR_IDX = -3,
38 PARTITION_ERROR_TYPE = -4,
39 PARTITION_ERROR_TABLE_FULL= -5,
40 PARTITION_ERROR_BOUNDS = -6,
41 PARTITION_ERROR_UNKNOWN = -255,
42};
43
44// Note: sectorCount and firstSector have special meaning if the MSB is set.
45// If MSB is set, the format is as follows:
46// realSectorCount = (2**(sectorCount[22:18]+4)*(sectorCount[17:0])
47// realFirstSector = (2**(firstSector[22:18]+4)*(firstSector[17:0])
48struct PartitionEntry {
49 uint32_t flags : 8; // Any special flags for the partition
50 uint32_t sectorCount : 24; // How many sectors are in this partition
51 uint32_t partitionType : 8; // What type of filesystem is this partition
52 uint32_t firstSector : 24; // Index of first sector for this partition
53
54 uint64_t start();
55 uint64_t end();
56 uint64_t startAddr(uint32_t sectorSize);
57 uint64_t endAddr(uint32_t sectorSize);
58 uint64_t sectors();
59 uint64_t setStart(uint64_t startSector);
60 uint64_t setSectors(uint64_t sCount);
61};
62
63// Note: totalSectors has special meaning if the MSB is set.
64// If MSB is set, the format is as follows:
65// realSectorCount = (2**(sectorCount[30:27]+4))*(sectorCount[26:0])
66struct PartitionTable {
67 union {
68 struct {
69 uint8_t bootExe[422]; // If direct execution is ever supported...
70 uint8_t tableLenExp; // Table Length => 2**tableLenExp: 2**8 => 256 bytes
71 uint8_t sectorLenExp; // Sector Length, see Table Length
72 uint32_t totalSectors; // Total sectors available, see
73 PartitionEntry part[8]; // Partition entries
74 uint8_t csums[16]; // Hamming code csum of 31 byte blocks comprising the Table
75 };
76 uint8_t pAsBytePtr[];
77 };
78 uint64_t sectors();
79 uint64_t setSectors(uint64_t sCount);
80
81 inline uint64_t sectorLen() { return 2ull << sectorLenExp; }
82};
83
84struct Effs_Cfg {
85 union {
86 struct {
87 uint16_t maxblock; /* maximum number of block can be used */
88 uint8_t sSizeExp; /* sector size wanted to use (less than block size */
89 uint8_t blSizeExp; /* block size in bytes */
90 uint8_t dSizeExp; /* max size of fat+directory+block index */
91 uint8_t cacheSizeExp; /* write cache size */
92 uint8_t separatedir; /* if directory used separatelly from FAT (NAND) */
93 uint8_t csum; // hamming code csum of struct
94 };
95 uint8_t pAsBytePtr[];
96 };
97};
98
99uint32_t hamming_checksum(const uint8_t *dat, uint32_t datBits, uint8_t codeLen);
100int hamming_validate(const uint8_t *dat, uint32_t datBits, uint32_t checksum, uint8_t codeLen);
101int hamming_validateOrFix(const uint8_t *dat, uint32_t datBits, uint32_t checksum, uint8_t codeLen);
102int hamming_anneal(uint8_t *dat, uint32_t datBits, uint32_t checksum, uint8_t codeLen, uint8_t errBit);
103
104
105#endif /* ----- #ifndef __EFFSPT_H ----- */
Filesystem Configuration.
Definition MIMXRT10xx/include/effs_pt.h:100
Definition MIMXRT10xx/include/effs_pt.h:59
uint64_t endAddr(uint32_t sectorSize)
Definition nbpart.cpp:36
uint32_t firstSector
Index of first sector for this partition.
Definition MIMXRT10xx/include/effs_pt.h:63
uint32_t flags
Any special flags for the partition.
Definition MIMXRT10xx/include/effs_pt.h:60
uint64_t startAddr(uint32_t sectorSize)
Definition nbpart.cpp:30
uint64_t setStart(uint64_t startSector)
Definition nbpart.cpp:42
uint64_t sectors()
Definition nbpart.cpp:101
uint64_t start()
Definition nbpart.cpp:15
uint64_t setSectors(uint64_t sCount)
Definition nbpart.cpp:71
uint64_t end()
Definition nbpart.cpp:24
uint32_t partitionType
What type of filesystem is this partition.
Definition MIMXRT10xx/include/effs_pt.h:62
uint32_t sectorCount
How many sectors are in this partition.
Definition MIMXRT10xx/include/effs_pt.h:61
Definition MIMXRT10xx/include/effs_pt.h:81
uint64_t sectorLen()
Definition MIMXRT10xx/include/effs_pt.h:96
uint64_t sectors()
Definition nbpart.cpp:110
uint64_t setSectors(uint64_t sCount)
Definition nbpart.cpp:119