UbixOS
2.0
fat_defs.h
Go to the documentation of this file.
1
#ifndef __FAT_DEFS_H__
2
#define __FAT_DEFS_H__
3
4
#include "
fat/fat.h
"
5
#include "
fat_opts.h
"
6
#include "
fat_types.h
"
7
8
//-----------------------------------------------------------------------------
9
// FAT32 Offsets
10
// Name Offset
11
//-----------------------------------------------------------------------------
12
13
// Boot Sector
14
#define BS_JMPBOOT 0 // Length = 3
15
#define BS_OEMNAME 3 // Length = 8
16
#define BPB_BYTSPERSEC 11 // Length = 2
17
#define BPB_SECPERCLUS 13 // Length = 1
18
#define BPB_RSVDSECCNT 14 // Length = 2
19
#define BPB_NUMFATS 16 // Length = 1
20
#define BPB_ROOTENTCNT 17 // Length = 2
21
#define BPB_TOTSEC16 19 // Length = 2
22
#define BPB_MEDIA 21 // Length = 1
23
#define BPB_FATSZ16 22 // Length = 2
24
#define BPB_SECPERTRK 24 // Length = 2
25
#define BPB_NUMHEADS 26 // Length = 2
26
#define BPB_HIDDSEC 28 // Length = 4
27
#define BPB_TOTSEC32 32 // Length = 4
28
29
// FAT 12/16
30
#define BS_FAT_DRVNUM 36 // Length = 1
31
#define BS_FAT_BOOTSIG 38 // Length = 1
32
#define BS_FAT_VOLID 39 // Length = 4
33
#define BS_FAT_VOLLAB 43 // Length = 11
34
#define BS_FAT_FILSYSTYPE 54 // Length = 8
35
36
// FAT 32
37
#define BPB_FAT32_FATSZ32 36 // Length = 4
38
#define BPB_FAT32_EXTFLAGS 40 // Length = 2
39
#define BPB_FAT32_FSVER 42 // Length = 2
40
#define BPB_FAT32_ROOTCLUS 44 // Length = 4
41
#define BPB_FAT32_FSINFO 48 // Length = 2
42
#define BPB_FAT32_BKBOOTSEC 50 // Length = 2
43
#define BS_FAT32_DRVNUM 64 // Length = 1
44
#define BS_FAT32_BOOTSIG 66 // Length = 1
45
#define BS_FAT32_VOLID 67 // Length = 4
46
#define BS_FAT32_VOLLAB 71 // Length = 11
47
#define BS_FAT32_FILSYSTYPE 82 // Length = 8
48
49
//-----------------------------------------------------------------------------
50
// FAT Types
51
//-----------------------------------------------------------------------------
52
#define FAT_TYPE_FAT12 1
53
#define FAT_TYPE_FAT16 2
54
#define FAT_TYPE_FAT32 3
55
56
//-----------------------------------------------------------------------------
57
// FAT32 Specific Statics
58
//-----------------------------------------------------------------------------
59
#define SIGNATURE_POSITION 510
60
#define SIGNATURE_VALUE 0xAA55
61
#define PARTITION1_TYPECODE_LOCATION 450
62
#define FAT32_TYPECODE1 0x0B
63
#define FAT32_TYPECODE2 0x0C
64
#define PARTITION1_LBA_BEGIN_LOCATION 454
65
#define PARTITION1_SIZE_LOCATION 458
66
67
#define FAT_DIR_ENTRY_SIZE 32
68
#define FAT_SFN_SIZE_FULL 11
69
#define FAT_SFN_SIZE_PARTIAL 8
70
71
//-----------------------------------------------------------------------------
72
// FAT32 File Attributes and Types
73
//-----------------------------------------------------------------------------
74
#define FILE_ATTR_READ_ONLY 0x01
75
#define FILE_ATTR_HIDDEN 0x02
76
#define FILE_ATTR_SYSTEM 0x04
77
#define FILE_ATTR_SYSHID 0x06
78
#define FILE_ATTR_VOLUME_ID 0x08
79
#define FILE_ATTR_DIRECTORY 0x10
80
#define FILE_ATTR_ARCHIVE 0x20
81
#define FILE_ATTR_LFN_TEXT 0x0F
82
#define FILE_HEADER_BLANK 0x00
83
#define FILE_HEADER_DELETED 0xE5
84
#define FILE_TYPE_DIR 0x10
85
#define FILE_TYPE_FILE 0x20
86
87
//-----------------------------------------------------------------------------
88
// Time / Date details
89
//-----------------------------------------------------------------------------
90
#define FAT_TIME_HOURS_SHIFT 11
91
#define FAT_TIME_HOURS_MASK 0x1F
92
#define FAT_TIME_MINUTES_SHIFT 5
93
#define FAT_TIME_MINUTES_MASK 0x3F
94
#define FAT_TIME_SECONDS_SHIFT 0
95
#define FAT_TIME_SECONDS_MASK 0x1F
96
#define FAT_TIME_SECONDS_SCALE 2
97
#define FAT_DATE_YEAR_SHIFT 9
98
#define FAT_DATE_YEAR_MASK 0x7F
99
#define FAT_DATE_MONTH_SHIFT 5
100
#define FAT_DATE_MONTH_MASK 0xF
101
#define FAT_DATE_DAY_SHIFT 0
102
#define FAT_DATE_DAY_MASK 0x1F
103
#define FAT_DATE_YEAR_OFFSET 1980
104
105
//-----------------------------------------------------------------------------
106
// Other Defines
107
//-----------------------------------------------------------------------------
108
#define FAT32_LAST_CLUSTER 0xFFFFFFFF
109
#define FAT32_INVALID_CLUSTER 0xFFFFFFFF
110
111
STRUCT_PACK_BEGIN
112
struct
fat_dir_entry
STRUCT_PACK
113
{
114
uint8
Name
[11];
115
uint8
Attr
;
116
uint8
NTRes
;
117
uint8
CrtTimeTenth
;
118
uint8
CrtTime
[2];
119
uint8
CrtDate
[2];
120
uint8
LstAccDate
[2];
121
uint16
FstClusHI
;
122
uint8
WrtTime
[2];
123
uint8
WrtDate
[2];
124
uint16
FstClusLO
;
125
uint32
FileSize
;
126
}
STRUCT_PACKED
;
127
STRUCT_PACK_END
128
129
#endif
fat_dir_entry::Name
uint8 Name[11]
Definition:
fat_defs.h:114
fat_types.h
uint8
unsigned char uint8
Definition:
fat_types.h:15
fat_dir_entry::WrtDate
uint8 WrtDate[2]
Definition:
fat_defs.h:123
fat_dir_entry::CrtTimeTenth
uint8 CrtTimeTenth
Definition:
fat_defs.h:117
fat_dir_entry::FstClusHI
uint16 FstClusHI
Definition:
fat_defs.h:121
STRUCT_PACK_END
#define STRUCT_PACK_END
Definition:
fat_types.h:65
fat_dir_entry::CrtTime
uint8 CrtTime[2]
Definition:
fat_defs.h:118
fat_dir_entry::LstAccDate
uint8 LstAccDate[2]
Definition:
fat_defs.h:120
fat_dir_entry
Definition:
fat_defs.h:112
fat_opts.h
fat_dir_entry::WrtTime
uint8 WrtTime[2]
Definition:
fat_defs.h:122
STRUCT_PACK_BEGIN
#define STRUCT_PACK_BEGIN
Definition:
fat_types.h:64
STRUCT_PACKED
#define STRUCT_PACKED
Definition:
fat_types.h:66
fat_dir_entry::NTRes
uint8 NTRes
Definition:
fat_defs.h:116
uint16
unsigned short uint16
Definition:
fat_types.h:16
fat_dir_entry::FstClusLO
uint16 FstClusLO
Definition:
fat_defs.h:124
fat_dir_entry::CrtDate
uint8 CrtDate[2]
Definition:
fat_defs.h:119
fat.h
uint32
unsigned long uint32
Definition:
fat_types.h:23
STRUCT_PACK
#define STRUCT_PACK
Definition:
fat_types.h:63
fat_dir_entry::Attr
uint8 Attr
Definition:
fat_defs.h:115
fat_dir_entry::FileSize
uint32 FileSize
Definition:
fat_defs.h:125
fs
fat
fat_defs.h
Generated by
1.8.16