Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement memory range mapping/unmapping; Cleanup and standardize vmap API #308

Merged
merged 4 commits into from
Nov 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion arch/x86/apic.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include <cpu.h>
#include <ktf.h>
#include <lib.h>
#include <pagetable.h>
#include <percpu.h>
#include <processor.h>
#include <time.h>
Expand Down Expand Up @@ -160,7 +161,7 @@ void init_apic(unsigned int cpu_id, apic_mode_t mode) {
* X2APIC uses MSRs for accesses, so no mapping needed.
*/
if (apic_mode == APIC_MODE_XAPIC)
vmap_4k(apic_get_base(apic_base), apic_base.base, L1_PROT_NOCACHE);
vmap_kern_4k(apic_get_base(apic_base), apic_base.base, L1_PROT_NOCACHE);

spiv.reg = apic_read(APIC_SPIV);
spiv.vector = APIC_SPI_VECTOR;
Expand Down
8 changes: 2 additions & 6 deletions arch/x86/boot/multiboot.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include <errno.h>
#include <mm/pmm.h>
#include <multiboot2.h>
#include <pagetable.h>

#define TAG_ADDR(tag) \
((multiboot2_tag_t *) ((multiboot2_uint8_t *) (tag) + (((tag)->size + 7) & ~7)))
Expand Down Expand Up @@ -183,12 +184,7 @@ void init_multiboot(unsigned long *addr, const char **cmdline) {

void map_multiboot_areas(void) {
paddr_t mbi_start = _paddr(multiboot2_hdr);
paddr_t mbi_stop = mbi_start + multiboot2_hdr_size;

for (mfn_t mfn = paddr_to_mfn(mbi_start); mfn <= paddr_to_mfn(mbi_stop); mfn++) {
vmap_4k(mfn_to_virt(mfn), mfn, L1_PROT_RO);
kmap_4k(mfn, L1_PROT_RO);
}
vmap_range(mbi_start, multiboot2_hdr_size, L1_PROT_RO, VMAP_KERNEL | VMAP_IDENT);
}

unsigned mbi_get_avail_memory_ranges_num(void) {
Expand Down
6 changes: 4 additions & 2 deletions arch/x86/ioapic.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include <ktf.h>
#include <list.h>
#include <mm/slab.h>
#include <pagetable.h>
#include <string.h>

#define IOAPIC_SYSTEM_ISA_BUS_NAME "ISA"
Expand Down Expand Up @@ -217,8 +218,9 @@ ioapic_t *add_ioapic(uint8_t id, uint8_t version, bool enabled, uint64_t base_ad
ioapic->base_address = base_address;
ioapic->gsi_base = gsi_base;

ioapic->virt_address = vmap_4k(paddr_to_virt(ioapic->base_address),
paddr_to_mfn(ioapic->base_address), L1_PROT_NOCACHE);
ioapic->virt_address =
vmap_kern_4k(paddr_to_virt(ioapic->base_address),
paddr_to_mfn(ioapic->base_address), L1_PROT_NOCACHE);
BUG_ON(!ioapic->virt_address);

return ioapic;
Expand Down
Loading
Loading