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