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

207 kernel not building with 4k #208

Merged
merged 15 commits into from
May 8, 2024
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
2 changes: 1 addition & 1 deletion .github/FUNDING.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
github: dreamos82
patreon: inuyasha82
open_collective: # Replace with a single Open Collective username
ko_fi: # Replace with a single Ko-fi username
ko_fi: dreamos82
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
liberapay: # Replace with a single Liberapay username
Expand Down
1 change: 1 addition & 0 deletions build/Common.mk
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ TESTFLAGS := -std=gnu99 \
-I src/include/kernel/arch/x86_64 \
-I src/include/kernel/arch/common/mem \
-I src/include/sys \
-I src/include/utils \
-DSMALL_PAGES=$(SMALL_PAGES) \
-D_TEST_=1

Expand Down
5 changes: 2 additions & 3 deletions docs/kernel/Initialization.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,11 @@ The sequence of component that are intialized (refer to `src/main.c`):
* Load the PSF font from memory
* Basic System Initialization:
- Parse the multiboot information received from the bootloader.
- Parse the mmap and initialize the physical memory manager, marking the pmm areas as busy.
- Parse the mmap and initialize
- Initia physical memory manager, marking the pmm areas as busy and setup the hhdm.
- Initialize the physical memory manager, marking the area in the mmap as already taken.
- Validate and parse the SDT tables
- This section needs to be reviewed and check if all the steps are required
* Finish mapping the Framebuffer (there is a potential bug here, need to chek what i do while mapping it)
* Set the Higher Half direct map
* Initialize the kernel VMM
* Initialize the kernel heap
* Initialize the apic
Expand Down
54 changes: 54 additions & 0 deletions docs/kernel/MemoryManagement.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Memory Management

The memory management will be rewritten in the future.

Currently Dreamos64 avail of virtual memory, providing every process with its own address space.

The memory is divided in lower half for _users_ level and the higher half for the _supervisor_ level.

The kernel is loaded at -2G.

Current `PAGE_SIZE` is 2M.


## Initialization workflow

* `mmap_parse` -> Initialize global variable for reading mmap, and print its content.
* `pmm_setup` initialize the phyiscal memory manager layer
- It first calls `initialize_bitmap`
- Then

## Physical memory

The physical memory level, is manged using a simple bitmap algorithm. The memory allocated is returned in chunks of PAGE_SIZE.

There are two levels on the phyiscal memory manager:

* the bitmap level that contains the function to set/clear the bits in the bitmap and these functions should be used only by the pmm.
* the pmm level instead contains the function to allocate and free pages of physical memory.

### Memory map

The memory map is based on the one obtained from the multiboot, and during initialization.

## Paging

Paging is provided with fixed size paging (only one size of page is supported at time). The size can be configured between 4k and 2M pages, although lately only 2M pages have been tested.

It avails of `x86_64`paging mechanism.

### Higher Hald Direct Map (HHDM)

An hhdm is provided to the kernel as convenience.

## Virtual Memory Manager

It sucks, but for now it does its job (partially!)

Currently only the allocation of virtual memory is implemented. There is no `vmm_free` implemented yet.

## KHeap

This is the kernel heap, this is used by the kernel when it needs to allocate resources.


2 changes: 2 additions & 0 deletions src/include/kernel/arch/common/mem/vmm_mapping.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,6 @@ void *map_vaddress(void *address, size_t flags, uint64_t *pml4_root);
int unmap_vaddress(void *address);
int unmap_vaddress_hh(void *address, uint64_t *pml4_root);

uint8_t is_phyisical_address_mapped(uintptr_t physical_address, uintptr_t virtual_address);

#endif
19 changes: 12 additions & 7 deletions src/include/kernel/arch/x86_64/vm.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@

#define ALIGN_PHYSADDRESS(address)(address & (~(PAGE_ALIGNMENT_MASK)))

#define HIGHER_HALF_ADDRESS_OFFSET 0xFFFF800000000000
#define MMIO_HIGHER_HALF_ADDRESS_OFFSET 0xFFFF800000000000
#define MMIO_RESERVED_SPACE_SIZE 0x280000000
#define HIGHER_HALF_ADDRESS_OFFSET (MMIO_HIGHER_HALF_ADDRESS_OFFSET + MMIO_RESERVED_SPACE_SIZE)

#define PRESENT_BIT 1
#define WRITE_BIT 0b10
Expand All @@ -40,17 +42,20 @@
#define PAGE_ENTRY_FLAGS PRESENT_BIT | WRITE_BIT
#endif

void page_fault_handler(uint64_t);
#define VM_TYPE_MEMORY 0
#define VM_TYPE_MMIO 1

void page_fault_handler( uint64_t error_code );

void initialize_vm();

void clean_new_table(uint64_t *);
void clean_new_table( uint64_t *table_to_clean );

void invalidate_page_table(uint64_t *);
void invalidate_page_table( uint64_t *table_address );

void load_cr3(void*);
void load_cr3( void* cr3_value );

uint64_t ensure_address_in_higher_half( uint64_t );
uint64_t ensure_address_in_higher_half( uint64_t address, uint8_t type);

bool is_address_higher_half(uint64_t);
bool is_address_higher_half(uint64_t address);
#endif
10 changes: 5 additions & 5 deletions src/include/kernel/mem/bitmap.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ typedef enum {
extern size_t memory_size_in_bytes;
extern uint64_t memory_map_phys_addr;

void _initialize_bitmap(unsigned long);
void _initialize_bitmap(uint64_t end_of_reserved_area);
void _bitmap_get_region(uint64_t* base_address, size_t* length_in_bytes, address_type_t type);

int64_t _bitmap_request_frame();
int64_t _bitmap_request_frames(size_t number_of_frames);
void _bitmap_set_bit(uint64_t);
void _bitmap_free_bit(uint64_t);
bool _bitmap_test_bit(uint64_t);
void _bitmap_set_bit_from_address(uint64_t);
void _bitmap_set_bit(uint64_t location);
void _bitmap_free_bit(uint64_t location);
bool _bitmap_test_bit(uint64_t location);
void _bitmap_set_bit_from_address(uint64_t address);
uint32_t _compute_kernel_entries(uint64_t);

#endif
6 changes: 6 additions & 0 deletions src/include/kernel/mem/hh_direct_map.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@
#include <stddef.h>
#include <stdint.h>

// Same as kernel KERNEL_MEMORY_PADDING, that is in kheap.h, they will be merged once the memory initialization is fixed
#define HH_MEMORY_PADDING 0x1000

// This function is temporary
void early_map_physical_memory(uint64_t end_of_reserved_area);

void *hhdm_get_variable ( uintptr_t phys_address );
void hhdm_map_physical_memory();

Expand Down
1 change: 1 addition & 0 deletions src/include/kernel/mem/mmap.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ extern const char *mmap_types[];
void _mmap_parse(struct multiboot_tag_mmap*);
void _mmap_setup();
uintptr_t _mmap_determine_bitmap_region(uint64_t lower_limit, size_t size);
bool _mmap_is_address_in_available_space(uint64_t address, uint64_t upper_limit);
#endif
6 changes: 5 additions & 1 deletion src/include/kernel/mem/pmm.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,17 @@
#include <stdbool.h>
#include <stddef.h>

void pmm_setup(unsigned long addr, uint32_t size);
extern bool pmm_initialized;

void pmm_setup(uint64_t addr, uint32_t size);
void _map_pmm();
void *pmm_prepare_new_pagetable();
void *pmm_alloc_frame();
void *pmm_alloc_area(size_t size);
void pmm_free_frame(void *address);
bool pmm_check_frame_availability();

void pmm_reserve_area(uint64_t starting_address, size_t size);
void pmm_free_area(uint64_t starting_address, size_t size);

#endif
9 changes: 6 additions & 3 deletions src/include/kernel/mem/vmm.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
//#define WRITE_ENABLE 2
//#define USER_LEVEL 4

#define PAGE_DIR_SIZE 0x1000

#define PHYS_ADDRESS_NOT_MAPPED 0 // Address is not mapped
#define PHYS_ADDRESS_MAPPED 0b1
#define PHYS_ADDRESS_MISMATCH 0b10 // This is returned when given a phys and virt address, the virt address does not contain the phys one
Expand All @@ -18,7 +20,8 @@

#define VM_KERNEL_MEMORY_PADDING PAGE_SIZE_IN_BYTES

#define VMM_RESERVED_SPACE_SIZE 0x14480000000
#define VMM_RESERVED_SPACE_SIZE 0x14200000000
// #define VMM_RESERVED_SPACE_SIZE 0x14480000000

#define VPTR(x) (void*)((uint64_t)(x))

Expand All @@ -28,7 +31,7 @@ typedef enum {
VMM_FLAGS_WRITE_ENABLE = (1 << 1),
VMM_FLAGS_USER_LEVEL = (1 << 2),
VMM_FLAGS_ADDRESS_ONLY = (1 << 7),
VMM_FLAGS_STACK = (1 << 8)
VMM_FLAGS_STACK = (1 << 8),
} paging_flags_t;

typedef enum {
Expand Down Expand Up @@ -56,7 +59,7 @@ typedef struct VmmInfo {

size_t start_of_vmm_space; /**< The starting addres ofthe vmm space */

uintptr_t root_table_hhdm; /** the root page table loaded from the direct map */
uintptr_t root_table_hhdm; /**< the root page table loaded from the direct map */

struct VmmStatus {
size_t vmm_items_per_page; /**< Number of page items contained in one page */
Expand Down
3 changes: 3 additions & 0 deletions src/include/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
#define __MAIN_H_

#include <stdint.h>
#include <multiboot.h>

extern struct multiboot_tag *tag_start;

void _init_basic_system(unsigned long addr);
void kernel_start(unsigned long addr, unsigned long magic);
Expand Down
1 change: 1 addition & 0 deletions src/include/utils/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
#include <multiboot.h>

bool load_module_hh(struct multiboot_tag_module *loaded_module);
bool _is_address_in_multiboot(uint64_t address);

#endif
37 changes: 23 additions & 14 deletions src/kernel/arch/x86_64/cpu/acpi.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include <bitmap.h>
#include <cpu.h>
#include <framebuffer.h>
#include <hh_direct_map.h>
#include <kheap.h>
#include <logging.h>
#include <numbers.h>
Expand Down Expand Up @@ -30,39 +31,47 @@ void parse_SDT(uint64_t address, uint8_t type) {

void parse_RSDT(RSDPDescriptor *descriptor){
pretty_logf(Verbose, "- descriptor Address: 0x%x", descriptor->RsdtAddress);
map_phys_to_virt_addr((void *) ALIGN_PHYSADDRESS(descriptor->RsdtAddress), (void *) ensure_address_in_higher_half(descriptor->RsdtAddress), VMM_FLAGS_PRESENT | VMM_FLAGS_WRITE_ENABLE);
_bitmap_set_bit_from_address(ALIGN_PHYSADDRESS(descriptor->RsdtAddress));
rsdt_root = (RSDT *) ensure_address_in_higher_half((uint64_t) descriptor->RsdtAddress);
rsdt_root = (RSDT *) ensure_address_in_higher_half((uint64_t) descriptor->RsdtAddress, VM_TYPE_MMIO);

//rsdt_root = (RSDT_*) vmm_alloc(KERNEL_PAGE_SIZE, VMM_FLAGS_MMIO | VMM_FLAGS_PRESENT | VMM_FLAGS_WRITE_ENABLE);
//rsdt_root = (RSDT *) vmm_alloc(header.Length, VMM_FLAGS_PRESENT | VMM_FLAGS_WRITE_ENABLE | VMM_FLAGS_MMIO, NULL); //ensure_address_in_higher_half((uint64_t) descriptor->RsdtAddress);
map_phys_to_virt_addr((void *) ALIGN_PHYSADDRESS(descriptor->RsdtAddress), rsdt_root, VMM_FLAGS_PRESENT | VMM_FLAGS_WRITE_ENABLE);
//rsdt_root = (RSDT *) hhdm_get_variable((uintptr_t) descriptor->RsdtAddress);
ACPISDTHeader header = rsdt_root->header;
pretty_logf(Verbose, "- RSDT_Signature: %.4s - Length: %d", header.Signature, header.Length);
pretty_logf(Verbose, "- RSDT_Signature: %.4s - Length: %d - HH addr: 0x%x", header.Signature, header.Length, rsdt_root);
//while(1)
sdt_version = RSDT_V1;

// Ok here we are, and we have mapped the "head of rsdt", it will stay most likely in one page, but there is no way
// to know the length of the whole table before mapping its header. So now we are able to check if we need to map extra pages
size_t required_extra_pages = (header.Length / KERNEL_PAGE_SIZE) + 1;
if (required_extra_pages > 1) {
//uintptr_t rsdt_extra = (uintptr_t) vmm_alloc(header.Length, VMM_FLAGS_PRESENT | VMM_FLAGS_WRITE_ENABLE | VMM_FLAGS_MMIO);
//pretty_logf(Verbose, "- RSDT_PAGES_NEEDED: %d", required_extra_pages);
for (size_t j = 1; j < required_extra_pages; j++) {
uint64_t new_physical_address = descriptor->RsdtAddress + (j * KERNEL_PAGE_SIZE);
map_phys_to_virt_addr((void *) ALIGN_PHYSADDRESS(new_physical_address), (void *) ensure_address_in_higher_half(new_physical_address), VMM_FLAGS_PRESENT | VMM_FLAGS_WRITE_ENABLE);
map_phys_to_virt_addr((void *) ALIGN_PHYSADDRESS(new_physical_address), (void *) ensure_address_in_higher_half(new_physical_address, VM_TYPE_MMIO), VMM_FLAGS_PRESENT | VMM_FLAGS_WRITE_ENABLE);
// map_phys_to_virt_addr((void *) ALIGN_PHYSADDRESS(new_physical_address), (void *) rsdt_extra, VMM_FLAGS_PRESENT | VMM_FLAGS_WRITE_ENABLE);
_bitmap_set_bit_from_address(ALIGN_PHYSADDRESS(new_physical_address));
//rsdt_extra += KERNEL_PAGE_SIZE);
}
}
rsdtTablesTotal = (header.Length - sizeof(ACPISDTHeader)) / sizeof(uint32_t);
pretty_logf(Verbose, "- Total rsdt Tables: %d", rsdtTablesTotal);

for(uint32_t i=0; i < rsdtTablesTotal; i++) {
map_phys_to_virt_addr((void *) ALIGN_PHYSADDRESS(rsdt_root->tables[i]), (void *) ensure_address_in_higher_half(rsdt_root->tables[i]), VMM_FLAGS_PRESENT | VMM_FLAGS_WRITE_ENABLE);
ACPISDTHeader *tableHeader = (ACPISDTHeader *) ensure_address_in_higher_half(rsdt_root->tables[i]);
pretty_logf(Verbose, "\t%d): Signature: %.4s", i, tableHeader->Signature);
map_phys_to_virt_addr((void *) ALIGN_PHYSADDRESS(rsdt_root->tables[i]), (void *) ensure_address_in_higher_half(rsdt_root->tables[i], VM_TYPE_MMIO), VMM_FLAGS_PRESENT | VMM_FLAGS_WRITE_ENABLE);
ACPISDTHeader *tableHeader = (ACPISDTHeader *) ensure_address_in_higher_half(rsdt_root->tables[i], VM_TYPE_MMIO);
pretty_logf(Verbose, "\t%d): Signature: %.4s Length: %d phys_addr: 0x%x", i, tableHeader->Signature, tableHeader->Length, rsdt_root->tables[i]);
}
}

void parse_RSDTv2(RSDPDescriptor20 *descriptor){
pretty_logf(Verbose, "- Descriptor physical address: 0x%x", ALIGN_PHYSADDRESS(descriptor->XsdtAddress));
map_phys_to_virt_addr((void *) ALIGN_PHYSADDRESS(descriptor->XsdtAddress), (void *) ensure_address_in_higher_half(descriptor->XsdtAddress), VMM_FLAGS_PRESENT | VMM_FLAGS_WRITE_ENABLE);
map_phys_to_virt_addr((void *) ALIGN_PHYSADDRESS(descriptor->XsdtAddress), (void *) ensure_address_in_higher_half(descriptor->XsdtAddress, VM_TYPE_MMIO), VMM_FLAGS_PRESENT | VMM_FLAGS_WRITE_ENABLE);
_bitmap_set_bit_from_address(ALIGN_PHYSADDRESS(descriptor->XsdtAddress));
xsdt_root = (XSDT *) ensure_address_in_higher_half((uint64_t) descriptor->XsdtAddress);
xsdt_root = (XSDT *) ensure_address_in_higher_half((uint64_t) descriptor->XsdtAddress, VM_TYPE_MMIO);
pretty_logf(Verbose, "- XSDT_Length: 0x%x", descriptor->Length);
ACPISDTHeader header = xsdt_root->header;
pretty_logf(Verbose, "- XSDT_Signature: %.4s", header.Signature);
Expand All @@ -73,7 +82,7 @@ void parse_RSDTv2(RSDPDescriptor20 *descriptor){
if (required_extra_pages > 1) {
for (size_t j = 1; j < required_extra_pages; j++) {
uint64_t new_physical_address = descriptor->XsdtAddress + (j * KERNEL_PAGE_SIZE);
map_phys_to_virt_addr((uint64_t *) new_physical_address, (uint64_t *) ensure_address_in_higher_half(new_physical_address), VMM_FLAGS_PRESENT | VMM_FLAGS_WRITE_ENABLE);
map_phys_to_virt_addr((uint64_t *) new_physical_address, (uint64_t *) ensure_address_in_higher_half(new_physical_address, VM_TYPE_MMIO), VMM_FLAGS_PRESENT | VMM_FLAGS_WRITE_ENABLE);
_bitmap_set_bit_from_address(ALIGN_PHYSADDRESS(new_physical_address));
}
}
Expand All @@ -82,9 +91,9 @@ void parse_RSDTv2(RSDPDescriptor20 *descriptor){
pretty_logf(Verbose, "- Total xsdt Tables: %d", rsdtTablesTotal);

for(uint32_t i=0; i < rsdtTablesTotal; i++) {
map_phys_to_virt_addr((uint64_t *) ALIGN_PHYSADDRESS(xsdt_root->tables[i]), (uint64_t *) ensure_address_in_higher_half(xsdt_root->tables[i]), VMM_FLAGS_PRESENT | VMM_FLAGS_WRITE_ENABLE);
map_phys_to_virt_addr((uint64_t *) ALIGN_PHYSADDRESS(xsdt_root->tables[i]), (uint64_t *) ensure_address_in_higher_half(xsdt_root->tables[i], VM_TYPE_MMIO), VMM_FLAGS_PRESENT | VMM_FLAGS_WRITE_ENABLE);
_bitmap_set_bit_from_address(ALIGN_PHYSADDRESS(xsdt_root->tables[i]));
ACPISDTHeader *tableHeader = (ACPISDTHeader *) ensure_address_in_higher_half(xsdt_root->tables[i]);
ACPISDTHeader *tableHeader = (ACPISDTHeader *) ensure_address_in_higher_half(xsdt_root->tables[i], VM_TYPE_MMIO);
pretty_logf(Verbose, "\t%d): Signature: %.4s", i, tableHeader->Signature);
}

Expand All @@ -99,10 +108,10 @@ ACPISDTHeader* get_SDT_item(char* table_name) {
ACPISDTHeader *tableItem;
switch(sdt_version) {
case RSDT_V1:
tableItem = (ACPISDTHeader *) ensure_address_in_higher_half(rsdt_root->tables[i]);
tableItem = (ACPISDTHeader *) ensure_address_in_higher_half(rsdt_root->tables[i], VM_TYPE_MMIO);
break;
case RSDT_V2:
tableItem = (ACPISDTHeader *) ensure_address_in_higher_half(xsdt_root->tables[i]);
tableItem = (ACPISDTHeader *) ensure_address_in_higher_half(xsdt_root->tables[i], VM_TYPE_MMIO);
break;
default:
pretty_log(Fatal, "That should not happen, PANIC");
Expand Down
10 changes: 5 additions & 5 deletions src/kernel/arch/x86_64/cpu/ioapic.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ void init_ioapic(MADT *madt_table){
io_apic_source_override_array_size = 0;
if(item != NULL) {
pretty_logf(Verbose, "IOAPIC Item address: 0x%x Type: 0x%x - length: 0x%x", item, item->type, item->length);
IO_APIC_Item *ioapic_item = (IO_APIC_Item *) ( ensure_address_in_higher_half((uint64_t) item + sizeof(MADT_Item)));
if (is_phyisical_address_mapped(ALIGN_PHYSADDRESS((uint64_t) item), ensure_address_in_higher_half((uint64_t) item)) == PHYS_ADDRESS_NOT_MAPPED) {
map_phys_to_virt_addr((void *) ALIGN_PHYSADDRESS((uint64_t) item), (void *)ensure_address_in_higher_half((uint64_t) item),VMM_FLAGS_PRESENT | VMM_FLAGS_WRITE_ENABLE);
IO_APIC_Item *ioapic_item = (IO_APIC_Item *) ( ensure_address_in_higher_half((uint64_t) item + sizeof(MADT_Item), VM_TYPE_MMIO));
if (is_phyisical_address_mapped(ALIGN_PHYSADDRESS((uint64_t) item), ensure_address_in_higher_half((uint64_t) item, VM_TYPE_MMIO)) == PHYS_ADDRESS_NOT_MAPPED) {
map_phys_to_virt_addr((void *) ALIGN_PHYSADDRESS((uint64_t) item), (void *)ensure_address_in_higher_half((uint64_t) item, VM_TYPE_MMIO),VMM_FLAGS_PRESENT | VMM_FLAGS_WRITE_ENABLE);
}
pretty_logf(Verbose, "IOAPIC_ID: 0x%x, Address: 0x%x", ioapic_item->ioapic_id, ioapic_item->address );
pretty_logf(Verbose, "Global_System_Interrupt_Base: 0x%x", ioapic_item->global_system_interrupt_base);
pretty_logf(Verbose, "Higher Half Address: 0x%x", ensure_address_in_higher_half(ioapic_item->address));
pretty_logf(Verbose, "Higher Half Address: 0x%x", ensure_address_in_higher_half(ioapic_item->address, VM_TYPE_MMIO));
io_apic_base_address = ioapic_item->address;
io_apic_hh_base_address = ensure_address_in_higher_half(ioapic_item->address);
io_apic_hh_base_address = ensure_address_in_higher_half(ioapic_item->address, VM_TYPE_MMIO);
// This one should be mapped in the higher half ??
//map_phys_to_virt_addr(VPTR(io_apic_base_address), VPTR(io_apic_base_address), 0);
map_phys_to_virt_addr(VPTR(io_apic_base_address), (void *) io_apic_hh_base_address, VMM_FLAGS_PRESENT | VMM_FLAGS_WRITE_ENABLE);
Expand Down
2 changes: 1 addition & 1 deletion src/kernel/arch/x86_64/cpu/lapic.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ void init_apic() {
pretty_logf(Verbose, "APIC MSR Return value: 0x%X", msr_output);
pretty_logf(Verbose, "APIC MSR Base Address: 0x%X", (msr_output&APIC_BASE_ADDRESS_MASK));
apic_base_address = (msr_output&APIC_BASE_ADDRESS_MASK);
apic_hh_base_address = ensure_address_in_higher_half(apic_base_address);
apic_hh_base_address = ensure_address_in_higher_half(apic_base_address, VM_TYPE_MMIO);
pretty_logf(Verbose, "(%s): apic_hh_base_address: 0x%x", __FUNCTION__, apic_hh_base_address);
if(apic_base_address == 0) {
pretty_log(Error, "ERROR: cannot determine apic base address");
Expand Down
4 changes: 2 additions & 2 deletions src/kernel/arch/x86_64/cpu/madt.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ void map_madt(MADT* table){
}

uint64_t madt_address = ((uint64_t) table + sizeof(MADT));
map_phys_to_virt_addr((void *) ALIGN_PHYSADDRESS(madt_address), (void *) ensure_address_in_higher_half(madt_address), VMM_FLAGS_PRESENT | VMM_FLAGS_WRITE_ENABLE);
map_phys_to_virt_addr((void *) ALIGN_PHYSADDRESS(madt_address), (void *) ensure_address_in_higher_half(madt_address, VM_TYPE_MMIO), VMM_FLAGS_PRESENT | VMM_FLAGS_WRITE_ENABLE);
_bitmap_set_bit_from_address(ALIGN_PHYSADDRESS(madt_address));
pretty_logf(Verbose, "Sizeof MADT struct: 0x%x", sizeof(MADT));
madt_base = (MADT_Item *) ensure_address_in_higher_half((uint64_t)madt_address);
madt_base = (MADT_Item *) ensure_address_in_higher_half((uint64_t)madt_address, VM_TYPE_MMIO);
is_madt_mapped = true;
}

Expand Down
Loading
Loading