diff --git a/headers/private/kernel/arch/x86/arch_kernel.h b/headers/private/kernel/arch/x86/arch_kernel.h index 3dee56cb22..f3ea30c4a2 100644 --- a/headers/private/kernel/arch/x86/arch_kernel.h +++ b/headers/private/kernel/arch/x86/arch_kernel.h @@ -18,14 +18,12 @@ #ifdef _BOOT_MODE -#ifdef _BOOT_PLATFORM_BIOS -#define KERNEL_LOAD_BASE_32_BIT 0x80000000 -#define KERNEL_LOAD_BASE_64_BIT 0xffffffff80000000ll -#define KERNEL_FIXUP_FOR_LONG_MODE (KERNEL_LOAD_BASE_64_BIT - KERNEL_LOAD_BASE_32_BIT) -#elif defined(__x86_64__) +#if defined(__x86_64__) #define KERNEL_LOAD_BASE 0xffffffff80000000ll #else -#define KERNEL_LOAD_BASE 0x80000000 +#define KERNEL_LOAD_BASE 0x80000000 +#define KERNEL_LOAD_BASE_64_BIT 0xffffffff80000000ll +#define KERNEL_FIXUP_FOR_LONG_MODE (KERNEL_LOAD_BASE_64_BIT - KERNEL_LOAD_BASE) #endif #elif defined(__x86_64__) diff --git a/src/system/boot/loader/elf.cpp b/src/system/boot/loader/elf.cpp index 3b5b8dac9a..0923e5d4b2 100644 --- a/src/system/boot/loader/elf.cpp +++ b/src/system/boot/loader/elf.cpp @@ -132,7 +132,7 @@ struct ELF64Class { { #if defined(_BOOT_PLATFORM_BIOS) // Assume the real 64-bit base address is KERNEL_LOAD_BASE_64_BIT and - // the mappings in the loader address space are at KERNEL_LOAD_BASE_32_BIT. + // the mappings in the loader address space are at KERNEL_LOAD_BASE. void* address = (void*)(addr_t)(*_address & 0xffffffff); #else diff --git a/src/system/boot/platform/bios_ia32/long.cpp b/src/system/boot/platform/bios_ia32/long.cpp index 0f5f4343e8..5683fd6c11 100644 --- a/src/system/boot/platform/bios_ia32/long.cpp +++ b/src/system/boot/platform/bios_ia32/long.cpp @@ -45,7 +45,7 @@ extern uint64 gLongKernelEntry; static inline uint64 fix_address(uint64 address) { - if(address >= KERNEL_LOAD_BASE_32_BIT) + if (address >= KERNEL_LOAD_BASE) return address + KERNEL_FIXUP_FOR_LONG_MODE; else return address; @@ -194,7 +194,7 @@ long_mmu_init() } // Get the physical address to map. - if (!mmu_get_virtual_mapping(KERNEL_LOAD_BASE_32_BIT + (i * B_PAGE_SIZE), + if (!mmu_get_virtual_mapping(KERNEL_LOAD_BASE + (i * B_PAGE_SIZE), &physicalAddress)) continue; diff --git a/src/system/boot/platform/bios_ia32/mmu.cpp b/src/system/boot/platform/bios_ia32/mmu.cpp index 68fad17137..d3d2361df0 100644 --- a/src/system/boot/platform/bios_ia32/mmu.cpp +++ b/src/system/boot/platform/bios_ia32/mmu.cpp @@ -80,7 +80,7 @@ static uint32 *sPageDirectory = 0; #ifdef _PXE_ENV static addr_t sNextPhysicalAddress = 0x112000; -static addr_t sNextVirtualAddress = KERNEL_LOAD_BASE_32_BIT + kMaxKernelSize; +static addr_t sNextVirtualAddress = KERNEL_LOAD_BASE + kMaxKernelSize; static addr_t sNextPageTableAddress = 0x7d000; static const uint32 kPageTableRegionEnd = 0x8b000; @@ -89,7 +89,7 @@ static const uint32 kPageTableRegionEnd = 0x8b000; #else static addr_t sNextPhysicalAddress = 0x100000; -static addr_t sNextVirtualAddress = KERNEL_LOAD_BASE_32_BIT + kMaxKernelSize; +static addr_t sNextVirtualAddress = KERNEL_LOAD_BASE + kMaxKernelSize; static addr_t sNextPageTableAddress = 0x90000; static const uint32 kPageTableRegionEnd = 0x9e000; @@ -202,7 +202,7 @@ unmap_page(addr_t virtualAddress) { TRACE("unmap_page(virtualAddress = %p)\n", (void *)virtualAddress); - if (virtualAddress < KERNEL_LOAD_BASE_32_BIT) { + if (virtualAddress < KERNEL_LOAD_BASE) { panic("unmap_page: asked to unmap invalid page %p!\n", (void *)virtualAddress); } @@ -227,7 +227,7 @@ map_page(addr_t virtualAddress, addr_t physicalAddress, uint32 flags) TRACE("map_page: vaddr 0x%lx, paddr 0x%lx\n", virtualAddress, physicalAddress); - if (virtualAddress < KERNEL_LOAD_BASE_32_BIT) { + if (virtualAddress < KERNEL_LOAD_BASE) { panic("map_page: asked to map invalid page %p!\n", (void *)virtualAddress); } @@ -404,8 +404,8 @@ mmu_allocate(void *virtualAddress, size_t size) addr_t address = (addr_t)virtualAddress; // is the address within the valid range? - if (address < KERNEL_LOAD_BASE_32_BIT || address + size * B_PAGE_SIZE - >= KERNEL_LOAD_BASE_32_BIT + kMaxKernelSize) + if (address < KERNEL_LOAD_BASE || address + size * B_PAGE_SIZE + >= KERNEL_LOAD_BASE + kMaxKernelSize) return NULL; for (uint32 i = 0; i < size; i++) { @@ -486,7 +486,7 @@ mmu_free(void *virtualAddress, size_t size) size = (size + pageOffset + B_PAGE_SIZE - 1) / B_PAGE_SIZE * B_PAGE_SIZE; // is the address within the valid range? - if (address < KERNEL_LOAD_BASE_32_BIT || address + size > sNextVirtualAddress) { + if (address < KERNEL_LOAD_BASE || address + size > sNextVirtualAddress) { panic("mmu_free: asked to unmap out of range region (%p, size %lx)\n", (void *)address, size); } @@ -507,14 +507,14 @@ mmu_free(void *virtualAddress, size_t size) size_t mmu_get_virtual_usage() { - return sNextVirtualAddress - KERNEL_LOAD_BASE_32_BIT; + return sNextVirtualAddress - KERNEL_LOAD_BASE; } bool mmu_get_virtual_mapping(addr_t virtualAddress, addr_t *_physicalAddress) { - if (virtualAddress < KERNEL_LOAD_BASE_32_BIT) { + if (virtualAddress < KERNEL_LOAD_BASE) { panic("mmu_get_virtual_mapping: asked to lookup invalid page %p!\n", (void *)virtualAddress); } @@ -580,9 +580,9 @@ mmu_init_for_kernel(void) // Save the memory we've virtually allocated (for the kernel and other // stuff) - gKernelArgs.virtual_allocated_range[0].start = KERNEL_LOAD_BASE_32_BIT; + gKernelArgs.virtual_allocated_range[0].start = KERNEL_LOAD_BASE; gKernelArgs.virtual_allocated_range[0].size - = sNextVirtualAddress - KERNEL_LOAD_BASE_32_BIT; + = sNextVirtualAddress - KERNEL_LOAD_BASE; gKernelArgs.num_virtual_allocated_ranges = 1; // sort the address ranges @@ -627,7 +627,7 @@ mmu_init(void) { TRACE("mmu_init\n"); - gKernelArgs.arch_args.virtual_end = KERNEL_LOAD_BASE_32_BIT; + gKernelArgs.arch_args.virtual_end = KERNEL_LOAD_BASE; gKernelArgs.physical_allocated_range[0].start = sNextPhysicalAddress; gKernelArgs.physical_allocated_range[0].size = 0;