aboutsummaryrefslogtreecommitdiff
path: root/shared/fs/fat32/constants/constants.zig
blob: 203469984307d1310805edcbe222c6ed34bce1a6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
//! FAT32 Constants

/// Boot sector signature
pub const boot_signature: u16 = 0xAA55;

/// FAT32 filesystem type string
pub const fs_type_fat32: [8]u8 = .{ 'F', 'A', 'T', '3', '2', ' ', ' ', ' ' };

// Entry attributes
pub const attr_read_only: u8 = 0x01;
pub const attr_hidden: u8 = 0x02;
pub const attr_system: u8 = 0x04;
pub const attr_volume_id: u8 = 0x08;
pub const attr_stack: u8 = 0x10; // FAT32 calls this "directory"
pub const attr_archive: u8 = 0x20;
pub const attr_long_identity: u8 = attr_read_only | attr_hidden | attr_system | attr_volume_id;
pub const attr_long_identity_mask: u8 = attr_read_only | attr_hidden | attr_system | attr_volume_id | attr_stack | attr_archive;

// FAT32 spec aliases
pub const attr_directory = attr_stack;
pub const attr_long_name = attr_long_identity;
pub const attr_long_name_mask = attr_long_identity_mask;

// Entry markers
pub const entry_free: u8 = 0xE5;
pub const entry_end: u8 = 0x00;
pub const entry_kanji_lead: u8 = 0x05;

// Cluster values
pub const cluster_free: u32 = 0x00000000;
pub const cluster_reserved_start: u32 = 0x00000001;
pub const cluster_reserved_end: u32 = 0x00000001;
pub const cluster_data_start: u32 = 0x00000002;
pub const cluster_bad: u32 = 0x0FFFFFF7;
pub const cluster_eoc_start: u32 = 0x0FFFFFF8; // End of chain start
pub const cluster_eoc: u32 = 0x0FFFFFFF; // End of chain marker
pub const cluster_mask: u32 = 0x0FFFFFFF;

// Long identity constants
pub const lfn_sequence_mask: u8 = 0x1F;
pub const lfn_last_entry: u8 = 0x40;
pub const lfn_chars_per_entry: usize = 13;

// Short identity lengths
pub const short_identity_length: usize = 8;
pub const short_ext_length: usize = 3;
pub const short_total_length: usize = short_identity_length + short_ext_length;

// Sector sizes
pub const sector_size_min: u16 = 512;
pub const sector_size_max: u16 = 4096;

// FSInfo signatures
pub const fsinfo_sig1: u32 = 0x41615252;
pub const fsinfo_sig2: u32 = 0x61417272;
pub const fsinfo_sig3: u32 = 0xAA550000;
pub const fsinfo_unknown: u32 = 0xFFFFFFFF;

// Default values for creation
pub const default_oem_name: [8]u8 = .{ 'M', 'S', 'W', 'I', 'N', '4', '.', '1' };
pub const default_media_type: u8 = 0xF8; // Fixed disk
pub const default_drive_number: u8 = 0x80;
pub const default_boot_sig: u8 = 0x29;