diff --git a/sysdata/programs/filesystem_fat32/src/bios_parameter_block.hb b/sysdata/programs/filesystem_fat32/src/bios_parameter_block.hb index d6774c1a..bc688da3 100644 --- a/sysdata/programs/filesystem_fat32/src/bios_parameter_block.hb +++ b/sysdata/programs/filesystem_fat32/src/bios_parameter_block.hb @@ -6,10 +6,10 @@ VALID_JUMP_BYTES := [u8].(0xEB, 0x3C, 0x90) OemIdent := struct { dos_version: [u8; 8], dos_version_name: [u8; 8], -} -new_oem_ident := fn(major: int, minor: int): OemIdent { - return .(.(0, 0, 0, 0, 0, 0, 0, 0), .(0, 0, 0, 0, 0, 0, 0, 0)) + new := fn(major: int, minor: int): OemIdent { + return .(.(0, 0, 0, 0, 0, 0, 0, 0), .(0, 0, 0, 0, 0, 0, 0, 0)) + } } BiosParameterBlock := struct { @@ -30,21 +30,21 @@ BiosParameterBlock := struct { head_count: u16, hidden_sectors: u32, large_sector_count: u32, -} -bpb_sanity_check := fn(bpb: BiosParameterBlock): int { - return 0 -} + sanity_check := fn(bpb: BiosParameterBlock): int { + return 0 + } -new_bpb := fn(): BiosParameterBlock { - return .(VALID_JUMP_BYTES, new_oem_ident(0, 0), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) -} + new := fn(): BiosParameterBlock { + 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 { - if bpb.total_sectors == 0 { - return bpb.large_sector_count - } else { - return bpb.total_sectors + sector_count := fn(bpb: BiosParameterBlock): u32 { + if bpb.total_sectors == 0 { + return bpb.large_sector_count + } else { + return bpb.total_sectors + } } } @@ -85,48 +85,48 @@ ExtendedBootRecord := struct { system_identifier_string: SystemIdentifierString, boot_code: BootCode, partition_signature: u16, -} -ebr_sanity_check := fn(ebr: ExtendedBootRecord): int { - ret := 0 - if ebr.drive_number != 0x0 | ebr.drive_number != 0x80 { - log.warn("EBR-Drive-Number sanity check failed\0") + sanity_check := fn(ebr: ExtendedBootRecord): int { + ret := 0 + if ebr.drive_number != 0x0 | ebr.drive_number != 0x80 { + log.warn("EBR-Drive-Number sanity check failed\0") + } + + if ebr.signature != 0x28 | ebr.signature != 0x29 { + log.warn("EBR-Signature sanity check failed\0") + } + + // ! comparison between [u8] is not supported in hblang + // if ebr.system_identifier_string != VALID_SYSTEM_IDENTIFIER_STRING { + // log.warn("EBR-Signature-Identifier-String sanity check failed\0") + // } + return 0 } - if ebr.signature != 0x28 | ebr.signature != 0x29 { - log.warn("EBR-Signature sanity check failed\0") + new := fn(): ExtendedBootRecord { + version := FatVersionNumber.(0, 0) + fmt_res := FormatReservation.(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) + vol_name := @as([u8; 11], idk) + boot_code := @as([u8; 420], idk) + + return ExtendedBootRecord.( + 0, + 0, + version, + 0, + 0, + 0, + fmt_res, + 0, + 0, + 0, + 0, + vol_name, + VALID_SYSTEM_IDENTIFIER_STRING, + boot_code, + 0, + ) } - - // ! comparison between [u8] is not supported in hblang - // if ebr.system_identifier_string != VALID_SYSTEM_IDENTIFIER_STRING { - // log.warn("EBR-Signature-Identifier-String sanity check failed\0") - // } - return 0 -} - -new_ebr := fn(): ExtendedBootRecord { - version := FatVersionNumber.(0, 0) - fmt_res := FormatReservation.(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) - vol_name := @as([u8; 11], idk) - boot_code := @as([u8; 420], idk) - - return ExtendedBootRecord.( - 0, - 0, - version, - 0, - 0, - 0, - fmt_res, - 0, - 0, - 0, - 0, - vol_name, - VALID_SYSTEM_IDENTIFIER_STRING, - boot_code, - 0, - ) } VALID_LEAD_FS_INFO := @as(u32, 0x41615252) @@ -141,39 +141,39 @@ FSInfo := struct { last_known_avalible_cluster: u32, trail_reserved: [u8; 12], trail_signature: u32, -} -fs_info_sanity_check := fn(fs_info: FSInfo): uint { - ret := 0 - if fs_info.lead_signature != VALID_LEAD_FS_INFO { - ret &= 1 - log.warn("Invalid leading signature in FSInfo.\0") - } - if fs_info.last_known_free_cluster_count == 0xFFFFFFFF { - ret &= 2 - log.warn("Last known free cluster count unknown.\0") - } - if fs_info.last_known_avalible_cluster == 0xFFFFFFFF { - ret &= 4 - log.warn("Last known avalible cluster count unknown.\0") - } - if fs_info.trail_signature != VALID_TRAIL_FS_INFO { - ret &= 8 - log.warn("Invalid trailing signature in FSInfo.\0") + sanity_check := fn(fs_info: FSInfo): uint { + ret := 0 + if fs_info.lead_signature != VALID_LEAD_FS_INFO { + ret &= 1 + log.warn("Invalid leading signature in FSInfo.\0") + } + if fs_info.last_known_free_cluster_count == 0xFFFFFFFF { + ret &= 2 + log.warn("Last known free cluster count unknown.\0") + } + if fs_info.last_known_avalible_cluster == 0xFFFFFFFF { + ret &= 4 + log.warn("Last known avalible cluster count unknown.\0") + } + if fs_info.trail_signature != VALID_TRAIL_FS_INFO { + ret &= 8 + log.warn("Invalid trailing signature in FSInfo.\0") + } + + return ret } - return ret -} - -new_fs_info := fn(): FSInfo { - lead_reserved := @as([u8; 480], idk) - trail_reserved := @as([u8; 12], idk) - return FSInfo.( - VALID_LEAD_FS_INFO, - lead_reserved, - 0, - 0, - trail_reserved, - VALID_TRAIL_FS_INFO, - ) + new := fn(): FSInfo { + lead_reserved := @as([u8; 480], idk) + trail_reserved := @as([u8; 12], idk) + return FSInfo.( + VALID_LEAD_FS_INFO, + lead_reserved, + 0, + 0, + trail_reserved, + VALID_TRAIL_FS_INFO, + ) + } } \ No newline at end of file diff --git a/sysdata/programs/filesystem_fat32/src/datetime.hb b/sysdata/programs/filesystem_fat32/src/datetime.hb index fa6b589a..4df0dc87 100644 --- a/sysdata/programs/filesystem_fat32/src/datetime.hb +++ b/sysdata/programs/filesystem_fat32/src/datetime.hb @@ -2,24 +2,25 @@ Date := struct { year: u16, month: u16, day: u16, + + compress_date := fn(year: u16, month: u16, day: u16): u16 { + return 0 + } + decompress_date := fn(date: u16): Date { + return Date.(0, 0, 0) + } } + Time := struct { hour: u16, minutes: u16, seconds: u16, -} -compress_date := fn(year: u16, month: u16, day: u16): u16 { - return 0 -} -decompress_date := fn(date: u16): Date { - return Date.(0, 0, 0) -} + compress_time := fn(hour: u16, minutes: u16, seconds: u16): u16 { + return 0 + } -compress_time := fn(hour: u16, minutes: u16, seconds: u16): u16 { - return 0 -} - -decompress_time := fn(time: u16): Time { - return Time.(0, 0, 0) + decompress_time := fn(time: u16): Time { + return Time.(0, 0, 0) + } } \ No newline at end of file diff --git a/sysdata/programs/filesystem_fat32/src/main.hb b/sysdata/programs/filesystem_fat32/src/main.hb index e15a16cf..71172008 100644 --- a/sysdata/programs/filesystem_fat32/src/main.hb +++ b/sysdata/programs/filesystem_fat32/src/main.hb @@ -6,7 +6,7 @@ datetime := @use("datetime.hb") directory := @use("file.hb") bios_parameter_block := @use("bios_parameter_block.hb"); .{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 FAT16_THRESHOLD := 65525 @@ -29,9 +29,9 @@ calculate_fat_type := fn(sector_size: uint, total_clusters: uint): uint { } main := fn(): int { - bpb := new_bpb() - ebr := new_ebr() - fsi := new_fs_info() + bpb := BiosParameterBlock.new() + ebr := ExtendedBootRecord.new() + fsi := FSInfo.new() fat_type := calculate_fat_type(1, 100) @@ -39,9 +39,9 @@ main := fn(): int { log.warn("filesystem_fat32 driver only supports Fat32.\0") } - bsc := bpb_sanity_check(bpb) - esc := ebr_sanity_check(ebr) - fssc := fs_info_sanity_check(fsi) + bsc := bpb.sanity_check() + esc := ebr.sanity_check() + fssc := fsi.sanity_check() msg_type := 0 diff --git a/sysdata/system_config.toml b/sysdata/system_config.toml index 89830c95..d50fab87 100644 --- a/sysdata/system_config.toml +++ b/sysdata/system_config.toml @@ -34,11 +34,14 @@ resolution = "1024x768x24" # [boot.limine.ableos.modules.ps2_keyboard_driver] # path = "boot:///ps2_keyboard_driver.hbf" -[boot.limine.ableos.modules.ps2_driver] -path = "boot:///ps2_driver.hbf" +# [boot.limine.ableos.modules.ps2_driver] +# path = "boot:///ps2_driver.hbf" # [boot.limine.ableos.modules.sunset_client] # path = "boot:///sunset_client.hbf" # [boot.limine.ableos.modules.sunset_server] # path = "boot:///sunset_server.hbf" + +[boot.limine.ableos.modules.filesystem_fat32] +path = "boot:///filesystem_fat32.hbf"