1
0
mirror of https://github.com/taigrr/gopher-os synced 2025-01-18 04:43:13 -08:00

Pass the virtual page offset for the kernel to kernel.Kmain

Ths page offset is defined in arch/XXX/constants.inc and needs to be
passed to the kernel so we can correctly calculate the physical frame
addresses that correspond to the ELF section virtual memory addresses.
This commit is contained in:
Achilleas Anagnostopoulos 2017-07-12 23:40:56 +01:00
parent a2d58f8949
commit cc4364f55c
3 changed files with 7 additions and 4 deletions

View File

@ -51,6 +51,8 @@ _rt0_64_entry:
extern _kernel_end
extern kernel.Kmain
mov rax, PAGE_OFFSET
push rax
mov rax, _kernel_end - PAGE_OFFSET
push rax
mov rax, _kernel_start - PAGE_OFFSET

View File

@ -20,18 +20,19 @@ var (
// allocated by the assembly code.
//
// The rt0 code passes the address of the multiboot info payload provided by the
// bootloader as well as the physical addresses for the kernel start/end.
// bootloader as well as the physical addresses for the kernel start/end. In
// addition, the start of the kernel virtual address space is passed to the
// kernelPageOffset argument.
//
// Kmain is not expected to return. If it does, the rt0 code will halt the CPU.
//
//go:noinline
func Kmain(multibootInfoPtr, kernelStart, kernelEnd uintptr) {
func Kmain(multibootInfoPtr, kernelStart, kernelEnd, kernelPageOffset uintptr) {
multiboot.SetInfoPtr(multibootInfoPtr)
var err *kernel.Error
if err = allocator.Init(kernelStart, kernelEnd); err != nil {
panic(err)
} else if err = vmm.Init(); err != nil {
panic(err)
} else if err = goruntime.Init(); err != nil {
panic(err)

View File

@ -11,5 +11,5 @@ var multibootInfoPtr uintptr
// A global variable is passed as an argument to Kmain to prevent the compiler
// from inlining the actual call and removing Kmain from the generated .o file.
func main() {
kmain.Kmain(multibootInfoPtr, 0, 0)
kmain.Kmain(multibootInfoPtr, 0, 0, 0)
}