Compare commits

...

3 Commits

Author SHA1 Message Date
f5e4927d70 add basic arena area init code
Some checks failed
Daily Build and trunk tester / debian_update (push) Failing after 1m14s
2025-09-04 20:04:25 -04:00
b106eae066 fix alignment macros 2025-09-04 20:04:03 -04:00
f2657fdc01 seems I found a /little/ oopsie in the fat32 system 2025-09-04 19:59:36 -04:00
3 changed files with 57 additions and 31 deletions

View File

@@ -32,7 +32,7 @@ InitFATDriver:
mov ax, fat32_state
push ax ; address of structure
call kmemset
sub sp, 0x6
add sp, 0x6
.calc_active_part:
mov ax, word [partition_offset]
@@ -221,7 +221,7 @@ NextCluster:
mov ax, fat32_nc_data
push ax ; address of structure
call kmemset
sub sp, 0x6
add sp, 0x6
mov edx, dword [bp + 4]
mov si, fat32_nc_data ; instead of push/pop and moving the data back

View File

@@ -9,11 +9,29 @@ struc ArenaStateStruc_t
.mark resw 1
endstruc
; void arena_init(void *mem, size_t bytes)
; void arena_init(ArenaState *a)
;
arena_init:
__CDECL16_ENTRY
.func:
movzx eax, word [bp + 4] ; ptr to state structure
mov di, ax
xor eax, eax
mov word [di + ArenaStateStruc_t.mark], eax
mov word [di + ArenaStateStruc_t.end], word (__ARENA_HEAP_START + __ARENA_HEAP_SIZE)
mov word [di + ArenaStateStruc_t.start], __ARENA_HEAP_START
; zero out heap area on init
; void* kmemset_byte(void* dst, uint8_t val, uint16_t len);
mov ax, __ARENA_HEAP_SIZE
push ax ; len
xor ax, ax
push ax ; val = 0
mov ax, __ARENA_HEAP_START
push ax ; dst
call kmemset
add sp, 0x6
.endp:
__CDECL16_EXIT

View File

@@ -361,13 +361,13 @@ begin_data:
%define CRLF 0Dh, 0Ah
%macro define_cstr 2
ALIGN 16
align 16
%1_cstr:
db %2, 00h
%endmacro
%macro define_info 2
ALIGN 16
align 16
%1_info:
db %2, CRLF, 00h
%endmacro
@@ -386,7 +386,7 @@ define_info MaybeFound_Boot, "Maybe found a file...checking..."
define_cstr BootTarget, "BOOT BIN"
ALIGN 16, db 0
align 16, db 0
BootTarget:
db 'BOOT BIN'
@@ -394,28 +394,28 @@ BootTarget:
; pre-bss init globals (generally const...but there are exceptions)
;
align 8, db 0x00
align 8, db 0
boot_drive:
db 0x00
align 8, db 0x00
align 8, db 0
partition_offset:
dw 0x0000
align 8, db 0x00
align 8, db 0
vbr_fat32_bpb_ptr:
dw 0x0000
align 8, db 0x00
align 8, db 0
vbr_part_table_ptr:
dw 0x0000
ALIGN 16
align 16, db 0
IntToHex_table:
db '0123456789ABCDEF'
; see docs/gdt.txt for a quick refresher on GDT
ALIGN 16, db 0
align 16, db 0
unreal_gdt_info:
unreal_gdt_size: dw (unreal_gdt_end - unreal_gdt_start) - 1
unreal_gdt_ptr: dd ((__STAGE2_SEGMENT << 4) + unreal_gdt_start)
@@ -438,7 +438,7 @@ unreal_gdt_start:
db 0x00 ; Base Address(31:24)
unreal_gdt_end:
ALIGN 16, db 0
align 16, db 0
gdt32_info:
gdt32_size: dw (gdt32_end - gdt32_start) - 1
gdt32_ptr: dd ((__STAGE2_SEGMENT << 4) + gdt32_start)
@@ -474,19 +474,19 @@ gdt32_start:
db 0x00
gdt32_end:
ALIGN 8,db 0x00
align 16,db 0
BUILD_NASM_VER:
db "Stevia Stage2 built with NASM - ", __NASM_VER__, 00h
ALIGN 8,db 0x00
align 16,db 0
BUILD_DATETIME:
db 'Assembled - ', __DATE__, ' ', __TIME__, 00h
ALIGN 8,db 0x00
align 16,db 0
BUILD_GIT_VER:
db __GIT_VER__, 00h
ALIGN 8,db 0x00
align 16,db 0
BUILD_GIT_HASH:
db __GIT_HASH__, 00h
end_data:
@@ -504,24 +504,29 @@ section .bss follows=.sign
begin_bss:
; structures
alignb 16
partition_table resb PartTable_t_size
align 16, resb 1
partition_table:
resb PartTable_t_size
alignb 16
fat32_bpb resb FAT32_bpb_t_size
fat32_ebpb resb FAT32_ebpb_t_size
align 16, resb 1
fat32_bpb:
resb FAT32_bpb_t_size
fat32_ebpb:
resb FAT32_ebpb_t_size
alignb 16
fat32_nc_data resb 16
align 16, resb 1
fat32_nc_data:
resb 16
alignb 16
lba_packet resb LBAPkt_t_size
align 16, resb 1
lba_packet:
resb LBAPkt_t_size
alignb 16
align 16, resb 1
fat32_state:
resb FAT32_State_t_size
alignb 16
align 16, resb 1
SteviaInfo:
resd 4
;
@@ -531,7 +536,7 @@ SteviaInfo:
;
; large continuous allocations
;
alignb 16
align 16, resb 1
disk_buffer:
resb 512
fat_buffer:
@@ -541,12 +546,15 @@ dir_buffer:
fat_fsinfo:
resb 512
alignb 16
; TODO: this will hold 42 entries from the map function
; the e820 function needs to check that it doesn't overflow
; but realisticly 42 entries is enough for dev work
align 16, resb 1
%define BIOSMemoryMap_SIZE 1024
BIOSMemoryMap:
resb BIOSMemoryMap_SIZE
alignb 512
align 16, resb 1
stack_bottom:
resb 1024
stack_top: