Move kernel libs into subdir, create NBP-specific entrypoint
This commit is contained in:
parent
c2e68a217e
commit
260db9f8d7
8
Makefile
8
Makefile
@ -1,5 +1,7 @@
|
|||||||
kernel.com: *.asm
|
default: nbp.com
|
||||||
nasm -s -o kernel.com main.asm
|
|
||||||
|
%.com: %.asm
|
||||||
|
nasm -s -o $@ $<
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f kernel.com
|
rm -f *.com
|
||||||
|
28
kernel/heap.asm
Normal file
28
kernel/heap.asm
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
heap_size:
|
||||||
|
dw 0x0100
|
||||||
|
|
||||||
|
heap_init:
|
||||||
|
push ax ; byte value (0)
|
||||||
|
push cx ; loop counter
|
||||||
|
push di ; target ptr
|
||||||
|
xor ax, ax
|
||||||
|
mov cx, [heap_size]
|
||||||
|
mov di, heap
|
||||||
|
rep stosb ; rep makes this loop cx times, incrementing di, writing al
|
||||||
|
pop di
|
||||||
|
pop cx
|
||||||
|
pop ax
|
||||||
|
ret
|
||||||
|
|
||||||
|
; in ax number of bytes to alloc
|
||||||
|
; out ds:di
|
||||||
|
malloc:
|
||||||
|
push dx ; length of block index
|
||||||
|
or ax,0x0F
|
||||||
|
inc ax
|
||||||
|
mov dx, 0x100
|
||||||
|
mov bp, heap
|
||||||
|
|
||||||
|
int 0x2E
|
||||||
|
pop dx
|
||||||
|
ret
|
@ -1,6 +1,6 @@
|
|||||||
; assumptions about the starting envionment
|
; assumptions about the starting envionment
|
||||||
cpu 8086
|
cpu 8086
|
||||||
org 0x0000 ; if we are not at CS:0000, CS adjustment will fix it for us
|
org 0x0000
|
||||||
; dl probable drive number
|
; dl probable drive number
|
||||||
; ds:si probable pointer to partition structure
|
; ds:si probable pointer to partition structure
|
||||||
; es:bx probable pxeenv+ structure
|
; es:bx probable pxeenv+ structure
|
||||||
@ -42,28 +42,24 @@ _exit:
|
|||||||
main:
|
main:
|
||||||
mov ax, cs
|
mov ax, cs
|
||||||
mov ds, ax
|
mov ds, ax
|
||||||
|
mov es, ax
|
||||||
|
|
||||||
mov bx, 0x002E
|
mov bx, 0x002E
|
||||||
mov dx, debug_reg_ir
|
mov dx, debug_reg_ir
|
||||||
|
|
||||||
call ivt_set
|
call ivt_set
|
||||||
|
|
||||||
mov ax, 0
|
call heap_init
|
||||||
mov bx, 0
|
mov ax, 18
|
||||||
call cons
|
call malloc
|
||||||
mov si, di
|
|
||||||
call print
|
|
||||||
|
|
||||||
ret
|
ret
|
||||||
|
|
||||||
%include "intr.asm"
|
%include "kernel/heap.asm"
|
||||||
%include "debug.asm"
|
%include "kernel/intr.asm"
|
||||||
%include "kprintf.asm"
|
%include "kernel/debug.asm"
|
||||||
%include "heap.asm"
|
%include "kernel/kprintf.asm"
|
||||||
|
|
||||||
%include "cons.asm"
|
|
||||||
%include "int.asm"
|
|
||||||
%include "print.asm"
|
|
||||||
|
|
||||||
|
align 16
|
||||||
heap:
|
heap:
|
||||||
dw 0
|
dw 0
|
4
run.sh
4
run.sh
@ -1,5 +1,5 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
exec qemu-system-x86_64 -boot n \
|
exec qemu-system-x86_64 -boot n -fda fd0.img \
|
||||||
-option-rom /usr/share/qemu/pxe-rtl8139.rom \
|
-option-rom /usr/share/qemu/pxe-rtl8139.rom \
|
||||||
-device e1000,netdev=mynet0,mac=52:54:00:12:34:56 \
|
-device e1000,netdev=mynet0,mac=52:54:00:12:34:56 \
|
||||||
-netdev user,id=mynet0,net=192.168.76.0/24,dhcpstart=192.168.76.9,tftp=$PWD,bootfile=kernel.com
|
-netdev user,id=mynet0,net=192.168.76.0/24,dhcpstart=192.168.76.9,tftp=$PWD,bootfile=nbp.com
|
||||||
|
Loading…
Reference in New Issue
Block a user