moved VMA initialization of APIC and MultiProcessing related stuff to apic.c
This commit is contained in:
parent
8180734e19
commit
ff130c4538
4 changed files with 14 additions and 39 deletions
|
@ -62,7 +62,7 @@ typedef struct {
|
|||
static const apic_processor_entry_t* apic_processors[MAX_CORES] = {[0 ... MAX_CORES-1] = NULL};
|
||||
static uint32_t boot_processor = MAX_CORES;
|
||||
apic_mp_t* apic_mp __attribute__ ((section (".data"))) = NULL;
|
||||
apic_config_table_t* apic_config = NULL;
|
||||
static apic_config_table_t* apic_config = NULL;
|
||||
static size_t lapic = 0;
|
||||
static volatile ioapic_t* ioapic = NULL;
|
||||
static uint32_t icr = 0;
|
||||
|
@ -557,18 +557,22 @@ int map_apic(void)
|
|||
lapic = map_region(0 /*lapic*/, lapic, 1, MAP_KERNEL_SPACE|MAP_NO_CACHE);
|
||||
if (BUILTIN_EXPECT(!lapic, 0))
|
||||
return -ENXIO;
|
||||
#elif defined(CONFIG_X86_64)
|
||||
if (lapic != LAPIC_ADDR) {
|
||||
kprintf("Upps! Kernel has to remap LAPIC!\n");
|
||||
lapic = map_region(0 /*lapic*/, lapic, 1, MAP_KERNEL_SPACE|MAP_NO_CACHE);
|
||||
if (BUILTIN_EXPECT(!lapic, 0))
|
||||
return -ENXIO;
|
||||
}
|
||||
#endif
|
||||
|
||||
vma_add(LAPIC_ADDR, LAPIC_ADDR + PAGE_SIZE, VMA_READ|VMA_WRITE);
|
||||
vma_add(PAGE_CEIL((size_t) apic_config),
|
||||
PAGE_FLOOR((size_t) apic_config + sizeof(apic_config_table_t)),
|
||||
VMA_READ|VMA_WRITE|VMA_EXECUTE|VMA_CACHEABLE);
|
||||
|
||||
vma_add(PAGE_CEIL((size_t) apic_mp),
|
||||
PAGE_FLOOR((size_t) apic_mp + sizeof(apic_mp_t)),
|
||||
VMA_READ|VMA_WRITE|VMA_EXECUTE|VMA_CACHEABLE);
|
||||
|
||||
kprintf("Mapped LAPIC at 0x%x\n", lapic);
|
||||
|
||||
if (ioapic) {
|
||||
ioapic = (ioapic_t*) map_region(IOAPIC_ADDR, (size_t) ioapic, 1, MAP_KERNEL_SPACE|MAP_NO_CACHE);
|
||||
vma_add(IOAPIC_ADDR, IOAPIC_ADDR + PAGE_SIZE, VMA_READ|VMA_WRITE);
|
||||
kprintf("Mapped IOAPIC at %p\n", ioapic);
|
||||
kprintf("IOAPIC version: 0x%x\n", ioapic_version());
|
||||
kprintf("Max Redirection Entry: %u\n", ioapic_max_redirection_entry());
|
||||
|
@ -832,7 +836,7 @@ check_lapic:
|
|||
|
||||
kprintf("Found APIC at 0x%x\n", lapic);
|
||||
#ifdef CONFIG_X86_64
|
||||
// On a x64 system, we already map the lapic below the kernel
|
||||
// On a x64 system, we already mapped the LAPIC at LAPIC_ADDR
|
||||
lapic = LAPIC_ADDR;
|
||||
#endif
|
||||
kprintf("Maximum LVT Entry: 0x%x\n", apic_lvt_entries());
|
||||
|
|
|
@ -201,7 +201,7 @@ check_lapic:
|
|||
and edx, 0x200
|
||||
cmp edx, 0
|
||||
je .unsupported
|
||||
; Map lapic at 0xFEE00000 below the kernel
|
||||
; Map lapic at 0xFEE00000
|
||||
mov edi, LAPIC_ADDR
|
||||
shr edi, 9 ; (edi >> 12) * 8
|
||||
add edi, boot_pgt
|
||||
|
|
|
@ -86,9 +86,6 @@ typedef struct vma {
|
|||
* Reserves several system-relevant virtual memory regions:
|
||||
* - SMP boot page (SMP_SETUP_ADDR)
|
||||
* - VGA video memory (VIDEO_MEM_ADDR)
|
||||
* - MP Table (apic_mp)
|
||||
* - IOAPIC mapped registers (IOAPIC_ADDR)
|
||||
* - LAPIC mapped registers (LAPIC_ADDR)
|
||||
* - The kernel (kernel_start - kernel_end)
|
||||
* - Multiboot structure (mb_info)
|
||||
* - Multiboot mmap (mb_info->mmap_*)
|
||||
|
|
26
mm/vma.c
26
mm/vma.c
|
@ -27,10 +27,6 @@
|
|||
#ifdef CONFIG_MULTIBOOT
|
||||
#include <asm/multiboot.h>
|
||||
#endif
|
||||
#include <asm/apic.h>
|
||||
|
||||
extern apic_mp_t* apic_mp;
|
||||
extern apic_config_table_t* apic_config;
|
||||
|
||||
/*
|
||||
* Note that linker symbols are not variables, they have no memory allocated for
|
||||
|
@ -62,28 +58,6 @@ int vma_init()
|
|||
if (BUILTIN_EXPECT(ret, 0))
|
||||
goto out;
|
||||
|
||||
// add MP Table
|
||||
ret = vma_add(PAGE_CEIL((size_t) apic_mp),
|
||||
PAGE_FLOOR((size_t) apic_mp + sizeof(apic_mp_t)),
|
||||
VMA_READ|VMA_WRITE|VMA_EXECUTE|VMA_CACHEABLE);
|
||||
if (BUILTIN_EXPECT(ret, 0))
|
||||
goto out;
|
||||
|
||||
ret = vma_add(PAGE_CEIL((size_t) apic_config),
|
||||
PAGE_FLOOR((size_t) apic_config + sizeof(apic_config_table_t)),
|
||||
VMA_READ|VMA_WRITE|VMA_EXECUTE|VMA_CACHEABLE);
|
||||
if (BUILTIN_EXPECT(ret, 0))
|
||||
goto out;
|
||||
|
||||
// add IOAPIC and LAPIC memory mapped registers
|
||||
ret = vma_add(LAPIC_ADDR, LAPIC_ADDR + PAGE_SIZE, VMA_READ|VMA_WRITE);
|
||||
if (BUILTIN_EXPECT(ret, 0))
|
||||
goto out;
|
||||
|
||||
ret = vma_add(IOAPIC_ADDR, IOAPIC_ADDR + PAGE_SIZE, VMA_READ|VMA_WRITE);
|
||||
if (BUILTIN_EXPECT(ret, 0))
|
||||
goto out;
|
||||
|
||||
#ifdef CONFIG_VGA
|
||||
// add VGA video memory
|
||||
ret = vma_add(VIDEO_MEM_ADDR, VIDEO_MEM_ADDR + PAGE_SIZE, VMA_READ|VMA_WRITE);
|
||||
|
|
Loading…
Add table
Reference in a new issue