feat(boot/loader): move kernel to 0x100000
This commit is contained in:
parent
41676291fe
commit
a0c99799e8
|
@ -10,7 +10,7 @@ struc BootInfoRange {
|
|||
;;
|
||||
;; StupidOS boot protocol structure
|
||||
struc BootInfo {
|
||||
.mmap dd 4*2*40 dup(0)
|
||||
.mmap dd 4*2*20 dup(0)
|
||||
.kernel_start dd ?
|
||||
.kernel_size dd ?
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@ FALSE = 0
|
|||
MBR_BASE = 0x0600
|
||||
BOOTSECT_BASE = 0x7C00
|
||||
LOADER_BASE = 0x1000
|
||||
KERNEL_BASE = 0x100000
|
||||
MULTIBOOT_BASE = 0x100000
|
||||
DISK_BUFFER = 0x8000
|
||||
KERNEL_PRELOAD = 0xF000
|
||||
|
|
|
@ -179,6 +179,12 @@ multiboot:
|
|||
common32:
|
||||
mov [0xB8000], dword 0x07690748
|
||||
|
||||
; move kernel to 0x100000
|
||||
mov ecx, [uKernelSize]
|
||||
mov esi, KERNEL_PRELOAD
|
||||
mov edi, KERNEL_BASE
|
||||
rep movsb
|
||||
|
||||
; identity map first 1MB
|
||||
xor esi, esi
|
||||
xor ecx, ecx
|
||||
|
@ -196,7 +202,7 @@ common32:
|
|||
mov dword [boot_page_directory], boot_0_page_table + 0x3 ; preset and writable
|
||||
|
||||
; map kernel at 0xC0000000
|
||||
mov esi, KERNEL_PRELOAD
|
||||
mov esi, KERNEL_BASE
|
||||
mov edi, boot_768_page_table
|
||||
xor ecx, ecx
|
||||
@@:
|
||||
|
@ -225,6 +231,8 @@ common32:
|
|||
mov eax, STPDBOOT_MAGIC
|
||||
mov ebx, boot_structure
|
||||
|
||||
xchg bx, bx
|
||||
|
||||
mov ecx, 0xC0000000
|
||||
jmp ecx
|
||||
|
||||
|
|
|
@ -56,10 +56,10 @@ memory_e820_get_map:
|
|||
mov di, pE280AddrRange
|
||||
mov ecx, 20
|
||||
mov eax, 0xE820
|
||||
mov edx, 0x534D4150
|
||||
mov edx, 'PAMS'
|
||||
int 0x15
|
||||
jc .error
|
||||
cmp eax, 0x534D4150
|
||||
cmp eax, 'PAMS'
|
||||
jne .error
|
||||
or ebx, ebx
|
||||
jz .end
|
||||
|
|
|
@ -7,7 +7,8 @@ SRCS = kernel.asm \
|
|||
const.inc \
|
||||
klog.inc \
|
||||
dev/vga_console.inc \
|
||||
mm/mm.inc
|
||||
mm/mm.inc \
|
||||
mm/pmm.inc
|
||||
|
||||
.PHONY: all
|
||||
all: $(KERNEL)
|
||||
|
|
16
kernel/bootinfo.inc
Normal file
16
kernel/bootinfo.inc
Normal file
|
@ -0,0 +1,16 @@
|
|||
;; File: bootinfo.inc
|
||||
|
||||
;; Struct: BootInfoRange
|
||||
struc BootInfoRange {
|
||||
.base dd ?
|
||||
.length dd ?
|
||||
}
|
||||
|
||||
;; Struct: BootInfo
|
||||
;;
|
||||
;; StupidOS boot protocol structure
|
||||
struc BootInfo {
|
||||
.mmap dd 4*2*20 dup(0)
|
||||
.kernel_start dd ?
|
||||
.kernel_size dd ?
|
||||
}
|
0
kernel/idt.inc
Normal file
0
kernel/idt.inc
Normal file
|
@ -3,7 +3,7 @@ File: Introduction
|
|||
About: kernel memory map
|
||||
|
||||
>
|
||||
> Physical map
|
||||
> Physical map virtual map
|
||||
> +---------------+
|
||||
> | |
|
||||
> +---------------+
|
||||
|
|
|
@ -19,16 +19,17 @@ db 32 dup(0)
|
|||
;; EBX - Boot structure address
|
||||
;;
|
||||
kmain:
|
||||
xchg bx, bx
|
||||
|
||||
mov esp, stack_top
|
||||
|
||||
cmp eax, STPDBOOT_MAGIC
|
||||
jne .halt
|
||||
jne .error_magic
|
||||
|
||||
; init memory manager
|
||||
; init idt, gdt
|
||||
; copy boot structure
|
||||
xchg bx, bx
|
||||
call vga_console_clear
|
||||
;call vga_console_clear
|
||||
|
||||
mov [0xC03B0000], dword 0x08740953
|
||||
mov [0xC03B0004], dword 0x05700675
|
||||
|
@ -44,12 +45,18 @@ kmain:
|
|||
.halt:
|
||||
hlt
|
||||
jmp $
|
||||
.error_magic:
|
||||
mov esi, szErrorBootProtocol
|
||||
.error:
|
||||
call klog
|
||||
jmp .halt
|
||||
|
||||
include 'klog.inc'
|
||||
include 'dev/vga_console.inc'
|
||||
include 'mm/mm.inc'
|
||||
|
||||
szMsgKernelAlive db "Kernel is alive", 0
|
||||
szErrorBootProtocol db "Error: wrong magic number", 0
|
||||
|
||||
align 4
|
||||
stack_bottom:
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
free_block_head dd 0x0
|
||||
|
||||
include "pmm.inc"
|
||||
|
||||
mm_init:
|
||||
ret
|
||||
|
|
|
@ -1,3 +1,16 @@
|
|||
struc
|
||||
{
|
||||
}
|
||||
|
||||
align 4
|
||||
;aPhysPageBitmap:
|
||||
; dd 32769 dup(0)
|
||||
|
||||
pmm_init:
|
||||
ret
|
||||
|
||||
pmm_alloc_page:
|
||||
ret
|
||||
|
||||
pmm_free_range:
|
||||
ret
|
||||
|
||||
pmm_free_page:
|
||||
ret
|
||||
|
|
Loading…
Reference in a new issue