Improve ordering of binary data in kernel
This commit is contained in:
parent
f9b180ea57
commit
5382edc2ae
125
boot/kernel.asm
125
boot/kernel.asm
@ -1,31 +1,69 @@
|
||||
cpu 8086
|
||||
org 0x500
|
||||
jmp 0:(init+0x7C00-$$)
|
||||
|
||||
%include "kernel/fd.asm"
|
||||
%include "kernel/con.asm"
|
||||
%include "inc/bpb.asm"
|
||||
%include "inc/mbr.asm"
|
||||
|
||||
; Far call via interrupt vector
|
||||
%macro intcall 1
|
||||
call far [cs:%1*4]
|
||||
%endmacro
|
||||
; kernel stack size in words
|
||||
%define stacksize 512
|
||||
|
||||
; Far jump via interrupt vector
|
||||
%macro intjmp 1
|
||||
jmp far [cs:%1*4]
|
||||
%endmacro
|
||||
init: cli
|
||||
xor ax, ax
|
||||
mov ds, ax
|
||||
mov es, ax
|
||||
mov ss, ax
|
||||
mov sp, ( stack+stacksize )
|
||||
|
||||
; stack size
|
||||
%define stacks 512
|
||||
; relocate
|
||||
mov si, 0x7C00
|
||||
mov di, $$
|
||||
mov cx, (_end-$$)
|
||||
rep movsb
|
||||
|
||||
jmp 0:main
|
||||
|
||||
main: ; zero out first 64kb except our code
|
||||
; bss and boot sector area gets cleared by this
|
||||
mov cx, di
|
||||
neg cx
|
||||
xor ax, ax
|
||||
rep stosb
|
||||
|
||||
; install interrupt vectors
|
||||
mov si, vects
|
||||
mov di, (0x20*4)
|
||||
mov cx, 0x0A
|
||||
intlp: movsw
|
||||
mov ax, cs
|
||||
stosw
|
||||
loop intlp
|
||||
|
||||
; file descriptor 0 = CON
|
||||
mov word [fd_table], con_ftab
|
||||
|
||||
; print banner
|
||||
mov dx, banner
|
||||
mov cx, 13
|
||||
mov bx, 0
|
||||
call fd_write
|
||||
|
||||
call dnconv
|
||||
mov al, dl
|
||||
call select
|
||||
call load_bpb
|
||||
|
||||
loop: int 0x28
|
||||
jmp loop
|
||||
|
||||
section .data
|
||||
|
||||
banner: db "rdos loaded", 0xA, 0xD, '$'
|
||||
|
||||
section .text
|
||||
|
||||
; Alias for Int 21h,AH=0h
|
||||
int20h: xor ah, ah
|
||||
; allow extenders to get away with only hooking 21h
|
||||
intjmp 0x21
|
||||
jmp far [cs:0x21*4]
|
||||
|
||||
int21h: ; inside of kernel, direction always goes up
|
||||
; the iret will restore it to the user value later
|
||||
@ -53,6 +91,8 @@ iretfl: push ax
|
||||
iret: iret
|
||||
retf: retf
|
||||
|
||||
section .data
|
||||
|
||||
; Subfunction ptr
|
||||
; this is used as extra register in int21h
|
||||
sfptr: dw 0
|
||||
@ -78,6 +118,8 @@ sftab: dw sferr, getc, putc, sferr
|
||||
dw sferr, sferr, sferr, sferr
|
||||
dw sferr, sferr, sferr, sferr
|
||||
|
||||
section .text
|
||||
|
||||
; OUT al character read
|
||||
getc: xor ax, ax
|
||||
int 0x16
|
||||
@ -195,59 +237,20 @@ fputc: push ax
|
||||
pop ax
|
||||
iret
|
||||
|
||||
%include "kernel/fd.asm"
|
||||
%include "kernel/con.asm"
|
||||
|
||||
%include "kernel/diskio.asm"
|
||||
%include "kernel/fat.asm"
|
||||
|
||||
section .data
|
||||
|
||||
vects: dw int20h, int21h, retf, retf
|
||||
dw retf, retf, retf, int20h
|
||||
dw idle, fputc
|
||||
|
||||
main: ; zero out first 64kb except our code
|
||||
; bss and boot sector area gets cleared by this
|
||||
mov di, init
|
||||
mov cx, di
|
||||
neg cx
|
||||
xor ax, ax
|
||||
rep movsb
|
||||
|
||||
; install interrupt vectors
|
||||
mov si, vects
|
||||
mov di, (0x20*4)
|
||||
mov cx, 0x0A
|
||||
intlp: movsw
|
||||
mov ax, cs
|
||||
stosw
|
||||
loop intlp
|
||||
|
||||
; print banner
|
||||
mov dx, banner
|
||||
mov cx, 13
|
||||
mov bx, 0
|
||||
call con_write
|
||||
|
||||
call dnconv
|
||||
mov al, dl
|
||||
call select
|
||||
call load_bpb
|
||||
|
||||
loop: int 0x28
|
||||
jmp loop
|
||||
|
||||
init: cli
|
||||
xor ax, ax
|
||||
mov ds, ax
|
||||
mov es, ax
|
||||
mov ss, ax
|
||||
mov sp, ( stack+stacks )
|
||||
|
||||
; relocate
|
||||
mov si, 0x7C00
|
||||
mov di, $$
|
||||
mov cx, (init-$$)
|
||||
rep movsb
|
||||
|
||||
jmp 0:main
|
||||
_end: dw 0x55AA, 0x55AA
|
||||
|
||||
section .bss
|
||||
; stack to be used during init and disk i/o
|
||||
stack: resw stacks
|
||||
stack: resw stacksize
|
||||
|
Loading…
Reference in New Issue
Block a user