boot/x86: unify KERNEL_LOAD_ADDRESS for BIOS and EFI
Change-Id: Ia3157c7c0908698da94c1aa85cb6366fb00fb7f1 Reviewed-on: https://review.haiku-os.org/c/haiku/+/5670 Tested-by: Commit checker robot <[email protected]> Reviewed-by: Jérôme Duval <[email protected]> Reviewed-by: Fredrik Holmqvist <[email protected]>
This commit is contained in:
@@ -18,14 +18,12 @@
|
|||||||
|
|
||||||
#ifdef _BOOT_MODE
|
#ifdef _BOOT_MODE
|
||||||
|
|
||||||
#ifdef _BOOT_PLATFORM_BIOS
|
#if defined(__x86_64__)
|
||||||
#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__)
|
|
||||||
#define KERNEL_LOAD_BASE 0xffffffff80000000ll
|
#define KERNEL_LOAD_BASE 0xffffffff80000000ll
|
||||||
#else
|
#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
|
#endif
|
||||||
|
|
||||||
#elif defined(__x86_64__)
|
#elif defined(__x86_64__)
|
||||||
|
|||||||
@@ -132,7 +132,7 @@ struct ELF64Class {
|
|||||||
{
|
{
|
||||||
#if defined(_BOOT_PLATFORM_BIOS)
|
#if defined(_BOOT_PLATFORM_BIOS)
|
||||||
// Assume the real 64-bit base address is KERNEL_LOAD_BASE_64_BIT and
|
// 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);
|
void* address = (void*)(addr_t)(*_address & 0xffffffff);
|
||||||
#else
|
#else
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ extern uint64 gLongKernelEntry;
|
|||||||
static inline uint64
|
static inline uint64
|
||||||
fix_address(uint64 address)
|
fix_address(uint64 address)
|
||||||
{
|
{
|
||||||
if(address >= KERNEL_LOAD_BASE_32_BIT)
|
if (address >= KERNEL_LOAD_BASE)
|
||||||
return address + KERNEL_FIXUP_FOR_LONG_MODE;
|
return address + KERNEL_FIXUP_FOR_LONG_MODE;
|
||||||
else
|
else
|
||||||
return address;
|
return address;
|
||||||
@@ -194,7 +194,7 @@ long_mmu_init()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Get the physical address to map.
|
// 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))
|
&physicalAddress))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ static uint32 *sPageDirectory = 0;
|
|||||||
#ifdef _PXE_ENV
|
#ifdef _PXE_ENV
|
||||||
|
|
||||||
static addr_t sNextPhysicalAddress = 0x112000;
|
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 addr_t sNextPageTableAddress = 0x7d000;
|
||||||
static const uint32 kPageTableRegionEnd = 0x8b000;
|
static const uint32 kPageTableRegionEnd = 0x8b000;
|
||||||
@@ -89,7 +89,7 @@ static const uint32 kPageTableRegionEnd = 0x8b000;
|
|||||||
#else
|
#else
|
||||||
|
|
||||||
static addr_t sNextPhysicalAddress = 0x100000;
|
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 addr_t sNextPageTableAddress = 0x90000;
|
||||||
static const uint32 kPageTableRegionEnd = 0x9e000;
|
static const uint32 kPageTableRegionEnd = 0x9e000;
|
||||||
@@ -202,7 +202,7 @@ unmap_page(addr_t virtualAddress)
|
|||||||
{
|
{
|
||||||
TRACE("unmap_page(virtualAddress = %p)\n", (void *)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",
|
panic("unmap_page: asked to unmap invalid page %p!\n",
|
||||||
(void *)virtualAddress);
|
(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,
|
TRACE("map_page: vaddr 0x%lx, paddr 0x%lx\n", virtualAddress,
|
||||||
physicalAddress);
|
physicalAddress);
|
||||||
|
|
||||||
if (virtualAddress < KERNEL_LOAD_BASE_32_BIT) {
|
if (virtualAddress < KERNEL_LOAD_BASE) {
|
||||||
panic("map_page: asked to map invalid page %p!\n",
|
panic("map_page: asked to map invalid page %p!\n",
|
||||||
(void *)virtualAddress);
|
(void *)virtualAddress);
|
||||||
}
|
}
|
||||||
@@ -404,8 +404,8 @@ mmu_allocate(void *virtualAddress, size_t size)
|
|||||||
addr_t address = (addr_t)virtualAddress;
|
addr_t address = (addr_t)virtualAddress;
|
||||||
|
|
||||||
// is the address within the valid range?
|
// is the address within the valid range?
|
||||||
if (address < KERNEL_LOAD_BASE_32_BIT || address + size * B_PAGE_SIZE
|
if (address < KERNEL_LOAD_BASE || address + size * B_PAGE_SIZE
|
||||||
>= KERNEL_LOAD_BASE_32_BIT + kMaxKernelSize)
|
>= KERNEL_LOAD_BASE + kMaxKernelSize)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
for (uint32 i = 0; i < size; i++) {
|
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;
|
size = (size + pageOffset + B_PAGE_SIZE - 1) / B_PAGE_SIZE * B_PAGE_SIZE;
|
||||||
|
|
||||||
// is the address within the valid range?
|
// 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",
|
panic("mmu_free: asked to unmap out of range region (%p, size %lx)\n",
|
||||||
(void *)address, size);
|
(void *)address, size);
|
||||||
}
|
}
|
||||||
@@ -507,14 +507,14 @@ mmu_free(void *virtualAddress, size_t size)
|
|||||||
size_t
|
size_t
|
||||||
mmu_get_virtual_usage()
|
mmu_get_virtual_usage()
|
||||||
{
|
{
|
||||||
return sNextVirtualAddress - KERNEL_LOAD_BASE_32_BIT;
|
return sNextVirtualAddress - KERNEL_LOAD_BASE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
mmu_get_virtual_mapping(addr_t virtualAddress, addr_t *_physicalAddress)
|
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",
|
panic("mmu_get_virtual_mapping: asked to lookup invalid page %p!\n",
|
||||||
(void *)virtualAddress);
|
(void *)virtualAddress);
|
||||||
}
|
}
|
||||||
@@ -580,9 +580,9 @@ mmu_init_for_kernel(void)
|
|||||||
|
|
||||||
// Save the memory we've virtually allocated (for the kernel and other
|
// Save the memory we've virtually allocated (for the kernel and other
|
||||||
// stuff)
|
// 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
|
gKernelArgs.virtual_allocated_range[0].size
|
||||||
= sNextVirtualAddress - KERNEL_LOAD_BASE_32_BIT;
|
= sNextVirtualAddress - KERNEL_LOAD_BASE;
|
||||||
gKernelArgs.num_virtual_allocated_ranges = 1;
|
gKernelArgs.num_virtual_allocated_ranges = 1;
|
||||||
|
|
||||||
// sort the address ranges
|
// sort the address ranges
|
||||||
@@ -627,7 +627,7 @@ mmu_init(void)
|
|||||||
{
|
{
|
||||||
TRACE("mmu_init\n");
|
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].start = sNextPhysicalAddress;
|
||||||
gKernelArgs.physical_allocated_range[0].size = 0;
|
gKernelArgs.physical_allocated_range[0].size = 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user