re-naming
This commit is contained in:
@@ -11,9 +11,9 @@ endstruc
|
|||||||
|
|
||||||
; void arena_init(ArenaState *a)
|
; void arena_init(ArenaState *a)
|
||||||
;
|
;
|
||||||
arena_init:
|
ArenaInit:
|
||||||
__CDECL16_PROC_ENTRY
|
__CDECL16_PROC_ENTRY
|
||||||
.func:
|
.proc:
|
||||||
mov ax, word [bp + 4] ; ptr to state structure
|
mov ax, word [bp + 4] ; ptr to state structure
|
||||||
mov di, ax
|
mov di, ax
|
||||||
|
|
||||||
@@ -25,15 +25,11 @@ arena_init:
|
|||||||
; zero out heap area on init
|
; zero out heap area on init
|
||||||
; void* kmemset_byte(void* dst, uint8_t val, uint16_t len);
|
; void* kmemset_byte(void* dst, uint8_t val, uint16_t len);
|
||||||
; TODO: use word or qword spacing at least to speed this up
|
; TODO: use word or qword spacing at least to speed this up
|
||||||
mov ax, __ARENA_HEAP_SIZE
|
push __ARENA_HEAP_SIZE ; len
|
||||||
push ax ; len
|
push 0x0 ; val = 0
|
||||||
xor ax, ax
|
push __ARENA_HEAP_START ; dst
|
||||||
push ax ; val = 0
|
|
||||||
mov ax, __ARENA_HEAP_START
|
|
||||||
push ax ; dst
|
|
||||||
call kmemset
|
call kmemset
|
||||||
add sp, 0x6
|
add sp, 0x6
|
||||||
|
|
||||||
.endp:
|
.endp:
|
||||||
__CDECL16_PROC_EXIT
|
__CDECL16_PROC_EXIT
|
||||||
ret
|
ret
|
||||||
@@ -43,7 +39,7 @@ arena_init:
|
|||||||
; align x up to the nearest specified alignment (a), a should be a power of 2
|
; align x up to the nearest specified alignment (a), a should be a power of 2
|
||||||
; (x + (a-1)) & ~(a-1)
|
; (x + (a-1)) & ~(a-1)
|
||||||
; return value in ax
|
; return value in ax
|
||||||
arena_align_up:
|
ArenaAlignUp:
|
||||||
__CDECL16_PROC_ENTRY
|
__CDECL16_PROC_ENTRY
|
||||||
.func:
|
.func:
|
||||||
; if a == 0 return x
|
; if a == 0 return x
|
||||||
@@ -51,7 +47,7 @@ arena_align_up:
|
|||||||
mov bx, [bp + 6] ; a
|
mov bx, [bp + 6] ; a
|
||||||
|
|
||||||
test bx, bx
|
test bx, bx
|
||||||
jz .endp
|
jz .endf
|
||||||
|
|
||||||
; enforce power-of-two for alignment, return x
|
; enforce power-of-two for alignment, return x
|
||||||
; for example...
|
; for example...
|
||||||
@@ -69,7 +65,7 @@ arena_align_up:
|
|||||||
mov cx, bx
|
mov cx, bx
|
||||||
dec cx
|
dec cx
|
||||||
test bx, cx
|
test bx, cx
|
||||||
jnz .endp
|
jnz .endf
|
||||||
|
|
||||||
dec bx ; a - 1
|
dec bx ; a - 1
|
||||||
|
|
||||||
@@ -80,7 +76,7 @@ arena_align_up:
|
|||||||
and cx, bx ; and with the inverse
|
and cx, bx ; and with the inverse
|
||||||
|
|
||||||
mov ax, cx ; move to ax and return
|
mov ax, cx ; move to ax and return
|
||||||
.endp:
|
.endf:
|
||||||
__CDECL16_PROC_EXIT
|
__CDECL16_PROC_EXIT
|
||||||
ret
|
ret
|
||||||
|
|
||||||
@@ -88,9 +84,9 @@ arena_align_up:
|
|||||||
; bp-2 - current used arena (i.e 'highmark')
|
; bp-2 - current used arena (i.e 'highmark')
|
||||||
; bp-4 - aligned_ptr
|
; bp-4 - aligned_ptr
|
||||||
; bp-6 - new_end
|
; bp-6 - new_end
|
||||||
arena_alloc:
|
ArenaAlloc:
|
||||||
__CDECL16_PROC_ENTRY 0x10
|
__CDECL16_PROC_ENTRY 0x10
|
||||||
.func:
|
.proc:
|
||||||
; remove bytes from pool and increment mark to the new cursor location
|
; remove bytes from pool and increment mark to the new cursor location
|
||||||
; return a pointer to the begining of allocated segment
|
; return a pointer to the begining of allocated segment
|
||||||
mov bx, early_heap_state
|
mov bx, early_heap_state
|
||||||
@@ -102,11 +98,10 @@ arena_alloc:
|
|||||||
|
|
||||||
push bx ; save heap_state pointer
|
push bx ; save heap_state pointer
|
||||||
|
|
||||||
mov ax, word [bp + 6] ; requested next allocation alignment
|
|
||||||
push ax
|
push word [bp + 6] ; requested next allocation alignment
|
||||||
mov ax, word [bp - 2] ; current arena 'highmark'
|
push word [bp - 2] ; current arena 'highmark'
|
||||||
push ax
|
call ArenaAlignUp
|
||||||
call arena_align_up
|
|
||||||
add sp, 0x4
|
add sp, 0x4
|
||||||
mov word [bp - 4], ax ; save return value
|
mov word [bp - 4], ax ; save return value
|
||||||
|
|
||||||
@@ -118,7 +113,7 @@ arena_alloc:
|
|||||||
|
|
||||||
mov dx, word [bx + ArenaStateStruc_t.end]
|
mov dx, word [bx + ArenaStateStruc_t.end]
|
||||||
cmp ax, dx
|
cmp ax, dx
|
||||||
ja arena_alloc.error ; if our heap end is < the requested throw an error, heap is full
|
ja .error ; if our heap end is < the requested throw an error, heap is full
|
||||||
; else update the mark to the new value & return the aligned pointer
|
; else update the mark to the new value & return the aligned pointer
|
||||||
|
|
||||||
; mark_delta = new_end - curr_used
|
; mark_delta = new_end - curr_used
|
||||||
@@ -140,7 +135,7 @@ arena_alloc:
|
|||||||
|
|
||||||
arena_mark:
|
arena_mark:
|
||||||
__CDECL16_PROC_ENTRY
|
__CDECL16_PROC_ENTRY
|
||||||
.func:
|
.proc:
|
||||||
; return the current location of the 'cursor' in the allocator
|
; return the current location of the 'cursor' in the allocator
|
||||||
ERROR STEVIA_DEBUG_UNIMPLEMENTED
|
ERROR STEVIA_DEBUG_UNIMPLEMENTED
|
||||||
.endp:
|
.endp:
|
||||||
@@ -149,7 +144,7 @@ arena_mark:
|
|||||||
|
|
||||||
arena_reset_to:
|
arena_reset_to:
|
||||||
__CDECL16_PROC_ENTRY
|
__CDECL16_PROC_ENTRY
|
||||||
.func:
|
.proc:
|
||||||
; rewind the arena to a previously marked point
|
; rewind the arena to a previously marked point
|
||||||
ERROR STEVIA_DEBUG_UNIMPLEMENTED
|
ERROR STEVIA_DEBUG_UNIMPLEMENTED
|
||||||
.endp:
|
.endp:
|
||||||
@@ -158,7 +153,7 @@ arena_reset_to:
|
|||||||
|
|
||||||
arena_reset:
|
arena_reset:
|
||||||
__CDECL16_PROC_ENTRY
|
__CDECL16_PROC_ENTRY
|
||||||
.func:
|
.proc:
|
||||||
; reset the entire heap to a fresh state
|
; reset the entire heap to a fresh state
|
||||||
ERROR STEVIA_DEBUG_UNIMPLEMENTED
|
ERROR STEVIA_DEBUG_UNIMPLEMENTED
|
||||||
.endp:
|
.endp:
|
||||||
|
|||||||
@@ -126,14 +126,14 @@ main:
|
|||||||
|
|
||||||
; setup the early heap
|
; setup the early heap
|
||||||
__CDECL16_CALL_ARGS early_heap_state
|
__CDECL16_CALL_ARGS early_heap_state
|
||||||
__CDECL16_CALL arena_init, 1
|
__CDECL16_CALL ArenaInit, 1
|
||||||
|
|
||||||
__CDECL16_CALL_ARGS pszHelloPrompt
|
__CDECL16_CALL_ARGS pszHelloPrompt
|
||||||
__CDECL16_CALL PrintString, 1
|
__CDECL16_CALL PrintString, 1
|
||||||
|
|
||||||
; setup and store our vbr/mbr (e)bpb
|
; setup and store our vbr/mbr (e)bpb
|
||||||
__CDECL16_CALL_ARGS 0x200, 0x10
|
__CDECL16_CALL_ARGS 0x200, 0x10
|
||||||
__CDECL16_CALL arena_alloc, 2
|
__CDECL16_CALL ArenaAlloc, 2
|
||||||
mov word [mbr_ptr], ax
|
mov word [mbr_ptr], ax
|
||||||
|
|
||||||
push ax ; dst
|
push ax ; dst
|
||||||
@@ -142,13 +142,13 @@ main:
|
|||||||
__CDECL16_CALL ReadMbrData, 2 ; fill mbr buffer
|
__CDECL16_CALL ReadMbrData, 2 ; fill mbr buffer
|
||||||
|
|
||||||
__CDECL16_CALL_ARGS 0x200, 0x10
|
__CDECL16_CALL_ARGS 0x200, 0x10
|
||||||
__CDECL16_CALL arena_alloc, 2
|
__CDECL16_CALL ArenaAlloc, 2
|
||||||
mov word [vbr_ptr], ax
|
mov word [vbr_ptr], ax
|
||||||
|
|
||||||
push ax ; dst
|
push ax ; dst
|
||||||
movzx ax, byte [u8_BootDrive]
|
movzx ax, byte [u8_BootDrive]
|
||||||
push ax ; boot_drive
|
push ax ; boot_drive
|
||||||
__CDECL16_CALL ReadVbrData, 2 ; fill vbr buffer
|
__CDECL16_CALL ReadVbrData, 2 ; fill vbr buffer
|
||||||
|
|
||||||
; enable A20 gate
|
; enable A20 gate
|
||||||
call EnableA20
|
call EnableA20
|
||||||
|
|||||||
Reference in New Issue
Block a user