forked from AbleOS/ableos
fat32 cleanup patch
This commit is contained in:
parent
dc3b7f71d5
commit
68840571c0
|
@ -6,11 +6,11 @@ VALID_JUMP_BYTES := [u8].(0xEB, 0x3C, 0x90)
|
||||||
OemIdent := struct {
|
OemIdent := struct {
|
||||||
dos_version: [u8; 8],
|
dos_version: [u8; 8],
|
||||||
dos_version_name: [u8; 8],
|
dos_version_name: [u8; 8],
|
||||||
}
|
|
||||||
|
|
||||||
new_oem_ident := fn(major: int, minor: int): OemIdent {
|
new := fn(major: int, minor: int): OemIdent {
|
||||||
return .(.(0, 0, 0, 0, 0, 0, 0, 0), .(0, 0, 0, 0, 0, 0, 0, 0))
|
return .(.(0, 0, 0, 0, 0, 0, 0, 0), .(0, 0, 0, 0, 0, 0, 0, 0))
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
BiosParameterBlock := struct {
|
BiosParameterBlock := struct {
|
||||||
jump_bytes: [u8; 3],
|
jump_bytes: [u8; 3],
|
||||||
|
@ -30,14 +30,13 @@ BiosParameterBlock := struct {
|
||||||
head_count: u16,
|
head_count: u16,
|
||||||
hidden_sectors: u32,
|
hidden_sectors: u32,
|
||||||
large_sector_count: u32,
|
large_sector_count: u32,
|
||||||
}
|
|
||||||
|
|
||||||
bpb_sanity_check := fn(bpb: BiosParameterBlock): int {
|
sanity_check := fn(bpb: BiosParameterBlock): int {
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
new_bpb := fn(): BiosParameterBlock {
|
new := fn(): BiosParameterBlock {
|
||||||
return .(VALID_JUMP_BYTES, new_oem_ident(0, 0), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
|
return .(VALID_JUMP_BYTES, OemIdent.new(0, 0), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
sector_count := fn(bpb: BiosParameterBlock): u32 {
|
sector_count := fn(bpb: BiosParameterBlock): u32 {
|
||||||
|
@ -47,6 +46,7 @@ sector_count := fn(bpb: BiosParameterBlock): u32 {
|
||||||
return bpb.total_sectors
|
return bpb.total_sectors
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
FatVersionNumber := struct {
|
FatVersionNumber := struct {
|
||||||
major_version: u8,
|
major_version: u8,
|
||||||
|
@ -85,9 +85,8 @@ ExtendedBootRecord := struct {
|
||||||
system_identifier_string: SystemIdentifierString,
|
system_identifier_string: SystemIdentifierString,
|
||||||
boot_code: BootCode,
|
boot_code: BootCode,
|
||||||
partition_signature: u16,
|
partition_signature: u16,
|
||||||
}
|
|
||||||
|
|
||||||
ebr_sanity_check := fn(ebr: ExtendedBootRecord): int {
|
sanity_check := fn(ebr: ExtendedBootRecord): int {
|
||||||
ret := 0
|
ret := 0
|
||||||
if ebr.drive_number != 0x0 | ebr.drive_number != 0x80 {
|
if ebr.drive_number != 0x0 | ebr.drive_number != 0x80 {
|
||||||
log.warn("EBR-Drive-Number sanity check failed\0")
|
log.warn("EBR-Drive-Number sanity check failed\0")
|
||||||
|
@ -104,7 +103,7 @@ ebr_sanity_check := fn(ebr: ExtendedBootRecord): int {
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
new_ebr := fn(): ExtendedBootRecord {
|
new := fn(): ExtendedBootRecord {
|
||||||
version := FatVersionNumber.(0, 0)
|
version := FatVersionNumber.(0, 0)
|
||||||
fmt_res := FormatReservation.(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
|
fmt_res := FormatReservation.(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
|
||||||
vol_name := @as([u8; 11], idk)
|
vol_name := @as([u8; 11], idk)
|
||||||
|
@ -128,6 +127,7 @@ new_ebr := fn(): ExtendedBootRecord {
|
||||||
0,
|
0,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
VALID_LEAD_FS_INFO := @as(u32, 0x41615252)
|
VALID_LEAD_FS_INFO := @as(u32, 0x41615252)
|
||||||
VALID_TRAIL_FS_INFO := @as(u32, 0xAA550000)
|
VALID_TRAIL_FS_INFO := @as(u32, 0xAA550000)
|
||||||
|
@ -141,9 +141,8 @@ FSInfo := struct {
|
||||||
last_known_avalible_cluster: u32,
|
last_known_avalible_cluster: u32,
|
||||||
trail_reserved: [u8; 12],
|
trail_reserved: [u8; 12],
|
||||||
trail_signature: u32,
|
trail_signature: u32,
|
||||||
}
|
|
||||||
|
|
||||||
fs_info_sanity_check := fn(fs_info: FSInfo): uint {
|
sanity_check := fn(fs_info: FSInfo): uint {
|
||||||
ret := 0
|
ret := 0
|
||||||
if fs_info.lead_signature != VALID_LEAD_FS_INFO {
|
if fs_info.lead_signature != VALID_LEAD_FS_INFO {
|
||||||
ret &= 1
|
ret &= 1
|
||||||
|
@ -165,7 +164,7 @@ fs_info_sanity_check := fn(fs_info: FSInfo): uint {
|
||||||
return ret
|
return ret
|
||||||
}
|
}
|
||||||
|
|
||||||
new_fs_info := fn(): FSInfo {
|
new := fn(): FSInfo {
|
||||||
lead_reserved := @as([u8; 480], idk)
|
lead_reserved := @as([u8; 480], idk)
|
||||||
trail_reserved := @as([u8; 12], idk)
|
trail_reserved := @as([u8; 12], idk)
|
||||||
return FSInfo.(
|
return FSInfo.(
|
||||||
|
@ -177,3 +176,4 @@ new_fs_info := fn(): FSInfo {
|
||||||
VALID_TRAIL_FS_INFO,
|
VALID_TRAIL_FS_INFO,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
}
|
|
@ -2,12 +2,6 @@ Date := struct {
|
||||||
year: u16,
|
year: u16,
|
||||||
month: u16,
|
month: u16,
|
||||||
day: u16,
|
day: u16,
|
||||||
}
|
|
||||||
Time := struct {
|
|
||||||
hour: u16,
|
|
||||||
minutes: u16,
|
|
||||||
seconds: u16,
|
|
||||||
}
|
|
||||||
|
|
||||||
compress_date := fn(year: u16, month: u16, day: u16): u16 {
|
compress_date := fn(year: u16, month: u16, day: u16): u16 {
|
||||||
return 0
|
return 0
|
||||||
|
@ -15,6 +9,12 @@ compress_date := fn(year: u16, month: u16, day: u16): u16 {
|
||||||
decompress_date := fn(date: u16): Date {
|
decompress_date := fn(date: u16): Date {
|
||||||
return Date.(0, 0, 0)
|
return Date.(0, 0, 0)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Time := struct {
|
||||||
|
hour: u16,
|
||||||
|
minutes: u16,
|
||||||
|
seconds: u16,
|
||||||
|
|
||||||
compress_time := fn(hour: u16, minutes: u16, seconds: u16): u16 {
|
compress_time := fn(hour: u16, minutes: u16, seconds: u16): u16 {
|
||||||
return 0
|
return 0
|
||||||
|
@ -23,3 +23,4 @@ compress_time := fn(hour: u16, minutes: u16, seconds: u16): u16 {
|
||||||
decompress_time := fn(time: u16): Time {
|
decompress_time := fn(time: u16): Time {
|
||||||
return Time.(0, 0, 0)
|
return Time.(0, 0, 0)
|
||||||
}
|
}
|
||||||
|
}
|
|
@ -6,7 +6,7 @@ datetime := @use("datetime.hb")
|
||||||
directory := @use("file.hb")
|
directory := @use("file.hb")
|
||||||
bios_parameter_block := @use("bios_parameter_block.hb");
|
bios_parameter_block := @use("bios_parameter_block.hb");
|
||||||
.{bpb_sanity_check, ebr_sanity_check, fs_info_sanity_check} := bios_parameter_block;
|
.{bpb_sanity_check, ebr_sanity_check, fs_info_sanity_check} := bios_parameter_block;
|
||||||
.{new_bpb, new_ebr, new_fs_info} := bios_parameter_block
|
.{BiosParameterBlock, ExtendedBootRecord, FSInfo} := bios_parameter_block
|
||||||
|
|
||||||
FAT12_THRESHOLD := 4085
|
FAT12_THRESHOLD := 4085
|
||||||
FAT16_THRESHOLD := 65525
|
FAT16_THRESHOLD := 65525
|
||||||
|
@ -29,9 +29,9 @@ calculate_fat_type := fn(sector_size: uint, total_clusters: uint): uint {
|
||||||
}
|
}
|
||||||
|
|
||||||
main := fn(): int {
|
main := fn(): int {
|
||||||
bpb := new_bpb()
|
bpb := BiosParameterBlock.new()
|
||||||
ebr := new_ebr()
|
ebr := ExtendedBootRecord.new()
|
||||||
fsi := new_fs_info()
|
fsi := FSInfo.new()
|
||||||
|
|
||||||
fat_type := calculate_fat_type(1, 100)
|
fat_type := calculate_fat_type(1, 100)
|
||||||
|
|
||||||
|
@ -39,9 +39,9 @@ main := fn(): int {
|
||||||
log.warn("filesystem_fat32 driver only supports Fat32.\0")
|
log.warn("filesystem_fat32 driver only supports Fat32.\0")
|
||||||
}
|
}
|
||||||
|
|
||||||
bsc := bpb_sanity_check(bpb)
|
bsc := bpb.sanity_check()
|
||||||
esc := ebr_sanity_check(ebr)
|
esc := ebr.sanity_check()
|
||||||
fssc := fs_info_sanity_check(fsi)
|
fssc := fsi.sanity_check()
|
||||||
|
|
||||||
msg_type := 0
|
msg_type := 0
|
||||||
|
|
||||||
|
|
|
@ -34,11 +34,14 @@ resolution = "1024x768x24"
|
||||||
# [boot.limine.ableos.modules.ps2_keyboard_driver]
|
# [boot.limine.ableos.modules.ps2_keyboard_driver]
|
||||||
# path = "boot:///ps2_keyboard_driver.hbf"
|
# path = "boot:///ps2_keyboard_driver.hbf"
|
||||||
|
|
||||||
[boot.limine.ableos.modules.ps2_driver]
|
# [boot.limine.ableos.modules.ps2_driver]
|
||||||
path = "boot:///ps2_driver.hbf"
|
# path = "boot:///ps2_driver.hbf"
|
||||||
|
|
||||||
# [boot.limine.ableos.modules.sunset_client]
|
# [boot.limine.ableos.modules.sunset_client]
|
||||||
# path = "boot:///sunset_client.hbf"
|
# path = "boot:///sunset_client.hbf"
|
||||||
|
|
||||||
# [boot.limine.ableos.modules.sunset_server]
|
# [boot.limine.ableos.modules.sunset_server]
|
||||||
# path = "boot:///sunset_server.hbf"
|
# path = "boot:///sunset_server.hbf"
|
||||||
|
|
||||||
|
[boot.limine.ableos.modules.filesystem_fat32]
|
||||||
|
path = "boot:///filesystem_fat32.hbf"
|
||||||
|
|
Loading…
Reference in a new issue