kv2: add paging
this also fixes up a bunch of formatting, adding the type vaddr_t Signed-off-by: Michael Shaw <spencershawiscool@gmail.com>
This commit is contained in:
parent
27a7f3de75
commit
d6873d6c7a
18 changed files with 130 additions and 66 deletions
|
|
@ -2,3 +2,4 @@
|
|||
obj-y += msr.o
|
||||
obj-y += page.o
|
||||
obj-y += reg.o
|
||||
obj-y += stack.o
|
||||
|
|
|
|||
|
|
@ -8,13 +8,13 @@
|
|||
|
||||
void pgd_load(pgd_t *pgd)
|
||||
{
|
||||
uintptr_t i = (uintptr_t)pgd;
|
||||
vaddr_t i = (vaddr_t)pgd;
|
||||
|
||||
cr3_write(TO_PHYS(i));
|
||||
}
|
||||
|
||||
pgd_t *pgd_get()
|
||||
{
|
||||
uintptr_t ret = cr3_read() | hhdm_start;
|
||||
vaddr_t ret = cr3_read() | hhdm_start;
|
||||
return (void *)ret;
|
||||
}
|
||||
|
|
|
|||
12
amd64/arch/stack.S
Normal file
12
amd64/arch/stack.S
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
/* SPDX-License-Identifier: GPL-2.0-only */
|
||||
.intel_syntax noprefix
|
||||
|
||||
.global arch_stack_init
|
||||
arch_stack_init:
|
||||
pop rdx
|
||||
sub rsi, 8
|
||||
add rdi, rsi
|
||||
mov rsp, rdi
|
||||
mov rbp, rsp
|
||||
push rdx
|
||||
ret
|
||||
|
|
@ -5,8 +5,8 @@
|
|||
|
||||
#include <stdint.h>
|
||||
|
||||
static uintptr_t ioapic_addr = 0xFEC00000;
|
||||
static uintptr_t lapic_addr = 0xFEE00000;
|
||||
static vaddr_t ioapic_addr = 0xFEC00000;
|
||||
static vaddr_t lapic_addr = 0xFEE00000;
|
||||
static uint8_t lapic_id = 0;
|
||||
|
||||
static struct ioapic {
|
||||
|
|
@ -34,13 +34,13 @@ void ioapic_redirect_insert(size_t irq, size_t isr, size_t low_active, size_t le
|
|||
ioapic_write(0x10 + 2 * irq + 1, lapic_id << 24);
|
||||
}
|
||||
|
||||
uint32_t lapic_read(uintptr_t addr, unsigned int regoffset)
|
||||
uint32_t lapic_read(vaddr_t addr, unsigned int regoffset)
|
||||
{
|
||||
volatile uint32_t *lapic = (volatile uint32_t *)addr;
|
||||
return lapic[regoffset >> 2];
|
||||
}
|
||||
|
||||
uint32_t lapic_write(uintptr_t addr, unsigned int regoffset, uint32_t value)
|
||||
uint32_t lapic_write(vaddr_t addr, unsigned int regoffset, uint32_t value)
|
||||
{
|
||||
volatile uint32_t *lapic = (volatile uint32_t *)addr;
|
||||
lapic[regoffset >> 2] = value;
|
||||
|
|
|
|||
9
amd64/include/arch/init.h
Normal file
9
amd64/include/arch/init.h
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
/* SPDX-License-Identifier: GPL-2.0-only */
|
||||
#ifndef _INIT_H_
|
||||
#define _INIT_H_
|
||||
|
||||
#include <kernel/types.h>
|
||||
|
||||
void arch_stack_init(void *new_stack_addr, size_t stack_size);
|
||||
|
||||
#endif /* _INIT_H_ */
|
||||
|
|
@ -6,8 +6,7 @@
|
|||
|
||||
#define PAGE_SIZE 0x1000ull
|
||||
|
||||
#define PAGE_MASK_LOWER (~(PAGE_SIZE - 1))
|
||||
#define PAGE_MASK_UPPER ((PAGE_SIZE - 1))
|
||||
#define PAGE_MASK (~(PAGE_SIZE - 1))
|
||||
|
||||
#define PAGE_ALIGN (~(PAGE_SIZE - 1))
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue