Now only required number of kernel pages assigned.
This commit is contained in:
parent
cea54a8b77
commit
6e481f72aa
@ -9,6 +9,13 @@ type
|
||||
const
|
||||
blankPageDirectory: PageDirectoryEntry = 0x00000002
|
||||
|
||||
var
|
||||
kernelMemoryStart{.importc: "_kernel_start"}: uint32
|
||||
kernelMemoryEnd{.importc: "_kernel_end"}: uint32
|
||||
|
||||
proc kernelMemoryStartAddress(): uint32 = cast[uint32](kernelMemoryStart.addr)
|
||||
proc kernelMemoryEndAddress(): uint32 = cast[uint32](kernelMemoryEnd.addr)
|
||||
|
||||
var
|
||||
pageDirectory: ptr PageDirectory
|
||||
pageTable0{.exportc, codegenDecl: "$# $# __attribute__((aligned(0x1000)))".}: PageTable
|
||||
@ -54,7 +61,13 @@ proc init*() =
|
||||
pageDirectory = cast[ptr PageDirectory](toVirtual(pagingAddress))
|
||||
for i in 0..767:
|
||||
pageDirectory[][i] = blankPageDirectory
|
||||
for i in 0..1023:
|
||||
var pages: uint = uint(int(kernelMemoryEndAddress() - 0xC0000000'u32) / 0x1000)
|
||||
serial.write("Pages:")
|
||||
serial.writeLine(pages)
|
||||
# Assign VGA memory area to 0xC0000000
|
||||
pageTable0[0] = createEntry(address = 0xB8000, readWrite = true, present = true)
|
||||
# Assign kernel memory pages to 0xC0100000+
|
||||
for i in 256..pages:
|
||||
pageTable0[i] = createEntry(address = uint32(i) * 0x1000, readWrite = true, present = true)
|
||||
pageDirectory[][768] = createDirectory(address = toPhysical(cast[uint32](pageTable0.addr)), readWrite = true, present = true)
|
||||
for i in 769..1023:
|
||||
|
@ -8,7 +8,7 @@ type
|
||||
VGAMemory = ptr array[0..(vgaWidth * vgaHeight - 1), VGADoubleByte]
|
||||
|
||||
const
|
||||
terminalBufferBaseAddress = 0xC00B8000
|
||||
terminalBufferBaseAddress = 0xC0000000
|
||||
vgaMem = cast[VGAMemory](terminalBufferBaseAddress)
|
||||
|
||||
var
|
||||
|
Loading…
Reference in New Issue
Block a user