2 Commits

Author SHA1 Message Date
4a944bc493 minor changes in fat32 2025-09-20 08:29:43 -04:00
137735431a move stack after bss padding 2025-09-18 19:16:27 -04:00
3 changed files with 18 additions and 24 deletions

View File

@@ -126,11 +126,12 @@ FAT32_load_vbr:
; - fill fat32_bpb_t and compute derived fields
; - read FSInfo (free count/next free)
; - ???
; int fat32_mount(uint32_t partition_lba, fat32_bpb_t* out);
; int fat32_mount(FAT32_State_t* state, uint32_t partition_lba);
FAT32_mountfs:
__CDECL16_PROC_ENTRY
.proc:
; mount: parse BPB, derive fat0_lba, data_lba, cluster0_lba.
.endp:
__CDECL16_PROC_EXIT
ret
@@ -138,7 +139,7 @@ FAT32_mountfs:
ERROR STEVIA_DEBUG_ERR
; int fat32_read_fat(const fat32_bpb_t* v, uint32_t clus, uint32_t* out);
; int fat32_read_fat(FAT32_State_t* state, uint32_t clus, uint32_t* out);
FAT32_read_fat:
__CDECL16_PROC_ENTRY
.proc:
@@ -153,7 +154,7 @@ FAT32_read_fat:
; EOC if (val & 0x0FFFFFFF) >= 0x0FFFFFF8.
; bad if == 0x0FFFFFF7.
; free if == 0x00000000.
; int fat32_next_clus(const fat32_bpb_t* v, uint32_t clus, uint32_t* out_next);
; int fat32_next_clus(FAT32_State_t* state, uint32_t clus, uint32_t* out_next);
FAT32_next_cluster:
__CDECL16_PROC_ENTRY
.proc:
@@ -165,7 +166,7 @@ FAT32_next_cluster:
ERROR STEVIA_DEBUG_ERR
; e.g:
; uint64_t clus_to_lba(const fat32_bpb_t* v, uint32_t clus) {
; uint64_t clus_to_lba(FAT32_State_t* state, uint32_t clus) {
; return v->data_lba + (uint64_t)(clus - 2) * v->secs_per_clus;
; }
FAT32_clus_to_lba:

View File

@@ -195,20 +195,11 @@ endstruc
; 32 bytes
struc FAT32_State_t
.first_data_sector_32 resd 1
.first_fat_sector_32 resd 1
.fat_size_32 resd 1
.curr_FAT_cluster_32 resd 1
.curr_dir_cluster_32 resd 1
.curr_drive_lba_32 resd 1
endstruc
; 16 bytes
struc FAT32_NextClusterData_t
.fat_offset resd 1
.fat_sector resd 1
.entry_offset resd 1
.reserved_1 resd 1
.u32_TotalClusters resd 1
.u32_DataAreaStartSector resd 1
.u32_FATAreaStartSector resd 1
.p16_FATBuffer resw 1
.p16_ClustBuffer resw 1
endstruc
; FAT32 Attributes

View File

@@ -453,17 +453,19 @@ align 16, resb 1
%define BIOSMemoryMap_SIZE 1024
BIOSMemoryMap:
resb BIOSMemoryMap_SIZE
align 16, resb 1
stack_bottom:
resb 2048
stack_top:
end_bss:
; !!! End bss data !!!
%define STACK_SIZE 0x1000 ; 4 KiB
; Pad to the cap (emits nothing in the file; only increases .bss virtual size).
; If BSS_SIZE > BSS_MAX_BYTES, this becomes negative and NASM errors out.
%define BSS_MAX_BYTES 0x2000
%define BSS_MAX_BYTES (0x2000 - STACK_SIZE)
resb (BSS_MAX_BYTES - (end_bss - begin_bss))
align 16, resb 1
stack_bottom:
resb STACK_SIZE
stack_top:
; Optional: keep a label for later math:
bss_cap_end: