mirror of
https://github.com/Mathewnd/Astral.git
synced 2026-10-27 12:48:22 +00:00
mm: rename vmm api to mm
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
#include <logging.h>
|
||||
#include <kernel/vmm.h>
|
||||
#include <kernel/mm.h>
|
||||
#include <arch/mmu.h>
|
||||
#include <kernel/alloc.h>
|
||||
#include <kernel/interrupt.h>
|
||||
@@ -274,7 +274,7 @@ void arch_apic_init() {
|
||||
|
||||
void *paddr = (void *) rdmsr(MSR_IA32APICBASE);
|
||||
|
||||
lapic_address = vmm_map(NULL, PAGE_SIZE, VMM_FLAGS_PHYSICAL, ARCH_MMU_FLAGS_READ | ARCH_MMU_FLAGS_WRITE | ARCH_MMU_FLAGS_NOEXEC, paddr);
|
||||
lapic_address = mm_map(NULL, PAGE_SIZE, MM_RANGE_FLAGS_PHYSICAL, ARCH_MMU_FLAGS_READ | ARCH_MMU_FLAGS_WRITE | ARCH_MMU_FLAGS_NOEXEC, paddr);
|
||||
__assert(lapic_address);
|
||||
|
||||
// map I/O apics to memory
|
||||
@@ -286,7 +286,7 @@ void arch_apic_init() {
|
||||
struct acpi_madt_ioapic *entry = getentry(ACPI_MADT_ENTRY_TYPE_IOAPIC, i);
|
||||
|
||||
__assert((entry->address % PAGE_SIZE) == 0);
|
||||
ioapics[i].addr = vmm_map(NULL, PAGE_SIZE, VMM_FLAGS_PHYSICAL, ARCH_MMU_FLAGS_READ | ARCH_MMU_FLAGS_WRITE | ARCH_MMU_FLAGS_NOEXEC, (void *)(uint64_t)entry->address);
|
||||
ioapics[i].addr = mm_map(NULL, PAGE_SIZE, MM_RANGE_FLAGS_PHYSICAL, ARCH_MMU_FLAGS_READ | ARCH_MMU_FLAGS_WRITE | ARCH_MMU_FLAGS_NOEXEC, (void *)(uint64_t)entry->address);
|
||||
__assert(ioapics[i].addr);
|
||||
ioapics[i].base = entry->gsi_base;
|
||||
ioapics[i].top = ioapics[i].base + ((readioapic(ioapics[i].addr, IOAPIC_REG_ENTRY_COUNT) >> 16) & 0xff) + 1;
|
||||
|
||||
@@ -349,7 +349,7 @@ void arch_cpu_init() {
|
||||
current_cpu()->topology_node = topology_nodes[topology_depth - 1];
|
||||
|
||||
// allocate ists
|
||||
uint64_t *ist1 = vmm_map(NULL, PAGE_SIZE * 4, VMM_FLAGS_ALLOCATE, ARCH_MMU_FLAGS_READ | ARCH_MMU_FLAGS_WRITE | ARCH_MMU_FLAGS_NOEXEC, NULL);
|
||||
uint64_t *ist1 = mm_map(NULL, PAGE_SIZE * 4, MM_RANGE_FLAGS_ALLOCATE, ARCH_MMU_FLAGS_READ | ARCH_MMU_FLAGS_WRITE | ARCH_MMU_FLAGS_NOEXEC, NULL);
|
||||
__assert(ist1);
|
||||
|
||||
// the cpu automatically aligns to 16 bytes when pushing the interrupt frame, so save ourselves the trouble:
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include <time.h>
|
||||
#include <logging.h>
|
||||
#include <arch/hpet.h>
|
||||
#include <kernel/vmm.h>
|
||||
#include <kernel/mm.h>
|
||||
#include <kernel/interrupt.h>
|
||||
#include <arch/tsc.h>
|
||||
#include <kernel/kernel_args.h>
|
||||
@@ -103,7 +103,7 @@ static timekeeper_source_info_t *hpet_init(void) {
|
||||
__assert(table->address.address_space_id == ACPI_AS_ID_SYS_MEM);
|
||||
|
||||
uint64_t page_offset = table->address.address % PAGE_SIZE;
|
||||
hpet_private.hpet = vmm_map(NULL, (PAGE_SIZE + page_offset), VMM_FLAGS_PHYSICAL, ARCH_MMU_FLAGS_READ | ARCH_MMU_FLAGS_WRITE | ARCH_MMU_FLAGS_NOEXEC, (void *)(table->address.address - page_offset));
|
||||
hpet_private.hpet = mm_map(NULL, (PAGE_SIZE + page_offset), MM_RANGE_FLAGS_PHYSICAL, ARCH_MMU_FLAGS_READ | ARCH_MMU_FLAGS_WRITE | ARCH_MMU_FLAGS_NOEXEC, (void *)(table->address.address - page_offset));
|
||||
__assert(hpet_private.hpet);
|
||||
hpet_private.hpet = (void *)((uintptr_t)hpet_private.hpet + page_offset);
|
||||
|
||||
|
||||
@@ -56,7 +56,7 @@ static timekeeper_source_info_t *kvm_timer_init(void) {
|
||||
|
||||
int page_offset = (uintptr_t)virtual_address % PAGE_SIZE;
|
||||
void *virtual_page = (void *)((uintptr_t)virtual_address - page_offset);
|
||||
void *physical_page = vmm_getphysical(virtual_page, 0);
|
||||
void *physical_page = mm_get_physical_address(virtual_page, 0);
|
||||
__assert(physical_page);
|
||||
|
||||
timekeeper_source_info->private = (void *)((uintptr_t)physical_page + page_offset);
|
||||
|
||||
@@ -75,10 +75,10 @@ int arch_ldt_set_entry(unsigned int which, ldt_entry_t entry) {
|
||||
done = 0;
|
||||
|
||||
for (int i = 0; i < arch_smp_cpusawake; ++i) {
|
||||
// reading the vmm context like this is racey but there are no ill side effects other than spurious shootdowns
|
||||
// if a cpu changes to this vmmctx, they will already have done a ldt invalidation.
|
||||
// reading the mm context like this is racey but there are no ill side effects other than spurious shootdowns
|
||||
// if a cpu changes to this mmctx, they will already have done a ldt invalidation.
|
||||
// if it changes out of it, same thing
|
||||
if (smp_cpus[i] == current_cpu() || (smp_cpus[i]->vmmctx != current_thread()->vmmctx))
|
||||
if (smp_cpus[i] == current_cpu() || (smp_cpus[i]->mmctx != current_thread()->mmctx))
|
||||
continue;
|
||||
|
||||
++shootdown_total;
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#include <string.h>
|
||||
#include <logging.h>
|
||||
#include <kernel/interrupt.h>
|
||||
#include <kernel/vmm.h>
|
||||
#include <kernel/mm.h>
|
||||
#include <arch/cpu.h>
|
||||
#include <arch/smp.h>
|
||||
#include <kernel/init.h>
|
||||
@@ -264,10 +264,10 @@ void arch_mmu_invalidate_range(void *page, size_t size) {
|
||||
old_ipl = interrupt_raiseipl(IPL_DPC);
|
||||
|
||||
for (int i = 0; i < arch_smp_cpusawake; ++i) {
|
||||
// reading the vmm context like this is racey but there are no ill side effects other than spurious shootdowns
|
||||
// if a cpu changes to this vmmctx, they will already have done a tlb invalidation.
|
||||
// reading the mm context like this is racey but there are no ill side effects other than spurious shootdowns
|
||||
// if a cpu changes to this mmctx, they will already have done a tlb invalidation.
|
||||
// if it changes out of it, same thing
|
||||
if (smp_cpus[i] == current_cpu() || (user_shootdown && smp_cpus[i]->vmmctx != current_thread()->vmmctx))
|
||||
if (smp_cpus[i] == current_cpu() || (user_shootdown && smp_cpus[i]->mmctx != current_thread()->mmctx))
|
||||
continue;
|
||||
|
||||
spinlock_acquire(&smp_cpus[i]->shootdown_lock);
|
||||
@@ -339,16 +339,16 @@ static void pfisr(isr_t *self, context_t *ctx) {
|
||||
arch_cpu_user_access_end();
|
||||
|
||||
interrupt_set(true);
|
||||
int vmmerror = 0;
|
||||
int mm_error = 0;
|
||||
|
||||
vmmerror |= VMM_ACTION_READ; // valid x86 PTEs will always have read permission (present) and actions will always have a read because of that.
|
||||
mm_error |= MM_FAULT_ACTION_READ; // valid x86 PTEs will always have read permission (present) and actions will always have a read because of that.
|
||||
if (ctx->error & ERROR_WRITE)
|
||||
vmmerror |= VMM_ACTION_WRITE;
|
||||
mm_error |= MM_FAULT_ACTION_WRITE;
|
||||
|
||||
if (ctx->error & ERROR_FETCH)
|
||||
vmmerror |= VMM_ACTION_EXEC;
|
||||
mm_error |= MM_FAULT_ACTION_EXEC;
|
||||
|
||||
if (vmm_pagefault((void *)ctx->cr2, ctx->cs != 8, vmmerror) == false) {
|
||||
if (mm_handle_page_fault((void *)ctx->cr2, ctx->cs != 8, mm_error) == false) {
|
||||
if (thread && thread->usercopyctx) {
|
||||
memcpy(ctx, thread->usercopyctx, sizeof(context_t));
|
||||
ctx->rflags &= ~ARCH_CONTEXT_RFLAGS_AC;
|
||||
|
||||
@@ -39,7 +39,7 @@ static void cpuwakeup(struct limine_mp_info *info) {
|
||||
dpc_init();
|
||||
arch_extracontext_detect();
|
||||
arch_mmu_apswitch();
|
||||
vmm_apinit();
|
||||
mm_apinit();
|
||||
|
||||
arch_apic_initap();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user