Compare commits

..

2 Commits

Author SHA1 Message Date
86d966811b prototypes for displaying some memory maps
but now I need to write an arena allocator...so brb
2025-09-04 17:51:52 -04:00
c10394a0cd early allocator prototypes 2025-09-04 17:49:57 -04:00
2 changed files with 98 additions and 0 deletions

View File

@@ -84,6 +84,38 @@ GetMemoryMap:
pop es
__CDECL16_EXIT
ret
PrintMemoryMap:
__CDECL16_ENTRY
.func:
mov eax, dword [SteviaInfo + SteviaInfoStruct_t.MemoryMapEntries]
cmp eax, 0
je PrintMemoryMap.endp ; if entries == 0, exit
mov ecx, eax ; store # of entries in counter
mov eax, BIOSMemoryMap ; address to start of e820 mmap
push dword ecx
push dword eax
call FormatMemoryMapEntry
add sp, 0x8
; ax contains segment offset to string after call
; TODO: going to need an allocator for strings and stuff...
; print_string strformat_buffer
.endp:
__CDECL16_EXIT
ret
FormatMemoryMapEntry:
__CDECL16_ENTRY
.func:
; create a string buffer somewhere and return address to result string in ax
.endp:
__CDECL16_EXIT
ret
%endif
%define __INC_E820MEMORY_MAP

View File

@@ -0,0 +1,66 @@
%ifndef __INC_ARENA_ALLOC_FUNC
%define __ARENA_HEAP_START 0x8000
%define __ARENA_HEAP_SIZE 0x6000 ; 0x8000 -> 0xE000 = 24KiB of Heap
struc ArenaStateStruc_t
.start resw 1
.end resw 1
.mark resw 1
endstruc
; void arena_init(void *mem, size_t bytes)
;
arena_init:
__CDECL16_ENTRY
.func:
.endp:
__CDECL16_EXIT
ret
; size_t align_up(size_t x, size_t a)
arena_align_up:
__CDECL16_ENTRY
.func:
; align the mark to the nearest specified alignment
.endp:
__CDECL16_EXIT
ret
; void* arena_alloc(void* a, size_t bytes, size_t align)
arena_alloc:
__CDECL16_ENTRY
.func:
; remove bytes from pool and increment mark to the new cursor location
; return a pointer to the begining of allocated segment
.endp:
__CDECL16_EXIT
ret
arena_mark:
__CDECL16_ENTRY
.func:
; return the current location of the 'cursor' in the allocator
.endp:
__CDECL16_EXIT
ret
arena_reset_to:
__CDECL16_ENTRY
.func:
; rewind the arena to a previously marked point
.endp:
__CDECL16_EXIT
ret
arena_reset:
__CDECL16_ENTRY
.func:
; reset the entire heap to a fresh state
.endp:
__CDECL16_EXIT
ret
%endif
%define __INC_ARENA_ALLOC_FUNC