Compare commits

..

No commits in common. "6aad8f0077be04c5cc137ea2a15afde10bd2883d" and "80aca5ee8a3c9c9a4c10bbb11140c0b11a345184" have entirely different histories.

7 changed files with 11 additions and 86 deletions

View file

@ -23,16 +23,6 @@ boot_info_add_memmap:
jbe @f jbe @f
ret ret
@@: @@:
; ----------------------------------------------------------------------
; dirty hack - TODO: clean this mess
cmp eax, 0x100000
jne @f
mov [boot_structure.high_mem], edx
@@:
; end hack
; ----------------------------------------------------------------------
push ebx push ebx
xor ecx, ecx xor ecx, ecx
.loop: .loop:

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

View file

@ -28,7 +28,6 @@ kmain:
mov ecx, sizeof.BootInfo mov ecx, sizeof.BootInfo
mov esi, ebx mov esi, ebx
mov edi, boot_structure mov edi, boot_structure
rep movsb
; print hello world ; print hello world
mov [0xC00B8000], dword 0x08740953 mov [0xC00B8000], dword 0x08740953
@ -47,11 +46,6 @@ kmain:
; init vmm ; init vmm
call mm_init call mm_init
mov eax, 0xC0400000
mov ebx, [boot_structure.high_mem]
add ebx, KERNEL_VIRT_BASE
call pmm_free_range
; map whole memory ; map whole memory
; idt, gdt ; idt, gdt

View file

@ -37,26 +37,28 @@ macro KV2P reg {
} }
;; Macro: KP2V ;; Macro: KP2V
;; Convert physical address to virtual
macro KP2V reg { macro KP2V reg {
add reg, KERNEL_VIRT_BASE add reg, KERNEL_VIRT_BASE
} }
;; Function: mm_kmap
mm_kmap: mm_kmap:
push esp ret
mov ebp, esp
sub esp, 0x10 ;; Function: mm_init
mm_init:
mov esi, szMsgMmInit
call klog
call pmm_alloc_page call pmm_alloc_page
mov [ebp-4], eax mov [pKernelPgDir], eax
; clear page dir ; clear page dir
mov edi, eax
mov ecx, 4096 mov ecx, 4096
xor al, al xor al, al
mov edi, [pKernelPgDir]
rep stosb rep stosb
;; Map kernel and kmemory
call pmm_alloc_page call pmm_alloc_page
xor esi, esi xor esi, esi
xor ecx, ecx xor ecx, ecx
@ -72,52 +74,13 @@ mm_kmap:
jb @b jb @b
or eax, (PDE_P or PDE_W) or eax, (PDE_P or PDE_W)
mov edx, [ebp-4] mov edx, [pKernelPgDir]
add edx, (768 * 4) add edx, (768 * 4)
KV2P eax KV2P eax
mov [edx], eax mov [edx], eax
mov eax, [ebp-4] ;; Map free memory
leave
ret
;; Function: mm_init
mm_init:
mov esi, szMsgMmInit
call klog
call mm_kmap
mov [pKernelPgDir], eax
; map whole memory
mov esi, 0x400000
mov ebx, (769 * 4)
.loop:
call pmm_alloc_page
xor ecx, ecx
mov edi, eax
@@:
mov edx, esi
or edx, (PTE_P or PTE_W)
mov [edi], edx
add edi, 4
add esi, 4096
inc ecx
cmp ecx, 1024
jb @b
or eax, (PDE_P or PDE_W)
mov edx, [pKernelPgDir]
add edx, ebx
add ebx, 4
KV2P eax
mov [edx], eax
cmp esi, [boot_structure.high_mem]
jb .loop
; reload cr3
mov eax, [pKernelPgDir] mov eax, [pKernelPgDir]
KV2P eax KV2P eax
mov cr3, eax mov cr3, eax
@ -128,12 +91,6 @@ mm_init:
ret ret
mm_alloc:
ret
mm_dealloc:
ret
mm_wallk_pagedir: mm_wallk_pagedir:
ret ret

View file

@ -1,18 +1,5 @@
;; File: pmm.inc ;; File: pmm.inc
macro ALIGN reg {
local end
push reg
and reg, 0xFFF
pop reg
jz end
and reg, 0xFFFFF000
add reg, 0x1000
end:
}
;; Function: pmm_init ;; Function: pmm_init
;; ;;
;; In: ;; In:
@ -68,8 +55,6 @@ pmm_free_range:
push ebp push ebp
mov ebp, esp mov ebp, esp
sub esp, 0x10 sub esp, 0x10
ALIGN eax
ALIGN ebx
mov [ebp-4], eax mov [ebp-4], eax
mov [ebp-8], ebx mov [ebp-8], ebx

View file

@ -13,7 +13,6 @@ struc BootInfo {
.mmap dd 4*2*20 dup(0) .mmap dd 4*2*20 dup(0)
.kernel_start dd ? .kernel_start dd ?
.kernel_size dd ? .kernel_size dd ?
.high_mem dd ?
} }
virtual at 0 virtual at 0
BootInfo BootInfo BootInfo BootInfo