feat(mm): bootstrap don't map extra memory after kernel end
This commit is contained in:
parent
6510df8068
commit
0c4a3e29f6
3 changed files with 68 additions and 4 deletions
|
@ -8,23 +8,22 @@ mm_bootstrap:
|
|||
mov esi, szMsgMmBootstrap
|
||||
call klog
|
||||
; 0x400000
|
||||
; PDE entry: 0x7ffc00 phys addr 0xC0 and curr virt addr: 0xc07ffc00
|
||||
; PDE entry: 0x7ffc00 phys addr and curr virt addr: 0xc07ffc00
|
||||
|
||||
; map first 4MB at KERNEL_VIRT_BASE
|
||||
xor esi, esi
|
||||
mov edi, KERNEL_VIRT_BASE + 0x400000 + (768 * PAGE_SIZE)
|
||||
xor ecx, ecx
|
||||
@@:
|
||||
mov edx, esi
|
||||
or edx, (PTE_P or PTE_W)
|
||||
mov [edi], edx
|
||||
add edi, 4
|
||||
add esi, PAGE_SIZE
|
||||
inc ecx
|
||||
cmp ecx, 1024
|
||||
cmp esi, kend - KERNEL_VIRT_BASE
|
||||
jb @b
|
||||
|
||||
; recusive page dir
|
||||
mov esi, 0x400000
|
||||
mov edi, KERNEL_VIRT_BASE + 0x400000 + (1023 * PAGE_SIZE)
|
||||
xor ecx, ecx
|
||||
@@:
|
||||
|
|
49
kernel/mm/mm.new.inc
Normal file
49
kernel/mm/mm.new.inc
Normal file
|
@ -0,0 +1,49 @@
|
|||
;; Based on <https://github.com/rdmsr/tinyvmem at tinyvm>
|
||||
VM_BESTFIT = (1 shl 0)
|
||||
VM_INSTANTFIT = (1 shl 1)
|
||||
VM_NEXTFIT = (1 shl 2)
|
||||
VM_SLEEP = (1 shl 3)
|
||||
VM_NOSLEEP = (1 shl 4)
|
||||
VM_BOOTSTRAP = (1 shl 5)
|
||||
|
||||
FREELISTS_N = 4 * 8
|
||||
HASHTABLE_N = 16
|
||||
|
||||
SEGMENT_ALLOCATED = 0
|
||||
SEGMENT_FREE = 1
|
||||
SEGMENT_SPAN = 2
|
||||
|
||||
struc VmSegment {
|
||||
.type db ?
|
||||
.imported db ?
|
||||
.base dd ?
|
||||
.size dd ?
|
||||
}
|
||||
|
||||
struc VmObject {
|
||||
.tmp dd ?
|
||||
}
|
||||
|
||||
struc VmPager {
|
||||
.tmp dd ?
|
||||
}
|
||||
|
||||
struc Vmem {
|
||||
.name db 32 dup(0)
|
||||
.base dd ?
|
||||
.size dd ?
|
||||
.quantum dd ?
|
||||
.alloc dd ?
|
||||
.free dd ?
|
||||
.source dd ?
|
||||
.qcache_max dd ?
|
||||
.vmflag dd ? ;; db ?
|
||||
|
||||
.segqueue dd ?
|
||||
.freelist dd FREELISTS_N dup(0)
|
||||
.hashtable dd HASHTABLE_N dup(0)
|
||||
.spanlist dd ?
|
||||
}
|
||||
|
||||
vmem_init:
|
||||
ret
|
|
@ -4,4 +4,20 @@ struc PMMFreeRange {
|
|||
.next dd ?
|
||||
}
|
||||
|
||||
;;
|
||||
pPMMFreeListHead dd 0
|
||||
|
||||
pmm_alloc:
|
||||
ret
|
||||
|
||||
pmm_alloc_page:
|
||||
ret
|
||||
|
||||
pmm_free_page:
|
||||
ret
|
||||
|
||||
;;
|
||||
;; kend - 4Mb
|
||||
;; 8Mb - max ram
|
||||
pmm_init:
|
||||
ret
|
||||
|
|
Loading…
Reference in a new issue