Cleaned up ELF64 address handling.

* platform_allocate_elf_region() is removed, it is implemented in platform-
  independent code now (ELF*Class::AllocateRegion). For ELF64 it is now
  assumed that 64-bit addresses are mapped in the loader's 32-bit address space
  as (address - KERNEL_BASE_64BIT + KERNEL_BASE).
* mapped_delta field from preloaded_*_image removed, now handled compile-time
  using the ELF*Class::Map method.
* Also link the kernel with -z max-page-size=0x1000, removes the need for
  2MB alignment on the data segment (not going to map the kernel with large
  pages for the time being).
This commit is contained in:
Alex Smith
2012-06-25 13:00:50 +01:00
parent 8846189866
commit 6f6d78e877
16 changed files with 124 additions and 239 deletions
@@ -17,6 +17,10 @@
#define KERNEL_SIZE 0x80000000
#define KERNEL_TOP (KERNEL_BASE + (KERNEL_SIZE - 1))
#ifdef _BOOT_MODE
# define KERNEL_BASE_64BIT 0xffffffff80000000
#endif
/* User space layout is a little special:
* The user space does not completely cover the space not covered by the
* kernel. There is a gap of 64kb between the user and kernel space. The 64kb
@@ -13,29 +13,30 @@
// Base of the kernel address space.
// When compiling the bootloader, KERNEL_BASE is set to the x86 base address,
// the correct 64-bit addresses are calculated differently.
// For the kernel, this is the base of the kernel address space. This is NOT
// the address where the kernel is loaded to: the kernel is loaded in the top
// 2GB of the virtual address space as required by GCC's kernel code model.
// KERNEL_BASE_64BIT is set to where the kernel loaded to.
// For the kernel, KERNEL_BASE is the base of the kernel address space. This is
// NOT the address where the kernel is loaded to: the kernel is loaded in the
// top 2GB of the virtual address space as required by GCC's kernel code model.
// The whole kernel address space is the top 512GB of the address space.
#ifdef _BOOT_MODE
# define KERNEL_BASE 0x80000000
# define KERNEL_BASE 0x80000000
# define KERNEL_BASE_64BIT 0xffffffff80000000
#else
# define KERNEL_BASE 0xFFFFFF8000000000
# define KERNEL_BASE 0xffffff8000000000
#endif
#define KERNEL_SIZE 0x8000000000
#define KERNEL_TOP (KERNEL_BASE + (KERNEL_SIZE - 1))
#define KERNEL_SIZE 0x8000000000
#define KERNEL_TOP (KERNEL_BASE + (KERNEL_SIZE - 1))
// Userspace address space layout.
#define USER_BASE 0x0
#define USER_BASE_ANY 0x100000
#define USER_SIZE 0x800000000000
#define USER_TOP (USER_BASE + USER_SIZE)
#define USER_BASE 0x0
#define USER_BASE_ANY 0x100000
#define USER_SIZE 0x800000000000
#define USER_TOP (USER_BASE + USER_SIZE)
#define KERNEL_USER_DATA_BASE 0x7FFFEFFF0000
#define USER_STACK_REGION 0x7FFFF0000000
#define KERNEL_USER_DATA_BASE 0x7fffefff0000
#define USER_STACK_REGION 0x7ffff0000000
#define USER_STACK_REGION_SIZE (USER_TOP - USER_STACK_REGION)
+2 -14
View File
@@ -47,7 +47,6 @@ struct preloaded_elf32_image : public preloaded_image {
Elf32_Ehdr elf_header;
elf32_region text_region;
elf32_region data_region;
uint32 mapped_delta;
FixedWidthPointer<Elf32_Sym> syms;
FixedWidthPointer<Elf32_Rel> rel;
@@ -65,7 +64,6 @@ struct preloaded_elf64_image : public preloaded_image {
Elf64_Ehdr elf_header;
elf64_region text_region;
elf64_region data_region;
uint64 mapped_delta;
FixedWidthPointer<Elf64_Sym> syms;
FixedWidthPointer<Elf64_Rel> rel;
@@ -84,18 +82,8 @@ extern status_t boot_elf_resolve_symbol(preloaded_elf32_image* image,
struct Elf32_Sym* symbol, Elf32_Addr* symbolAddress);
extern status_t boot_elf_resolve_symbol(preloaded_elf64_image* image,
struct Elf64_Sym* symbol, Elf64_Addr* symbolAddress);
// Helper method to set a relocation at the mapped address in the loader's
// address space.
template<typename ImageType, typename AddrType>
inline void
boot_elf_set_relocation(ImageType* image, AddrType resolveAddress,
AddrType finalAddress)
{
AddrType* dest = (AddrType*)(addr_t)(resolveAddress + image->mapped_delta);
*dest = finalAddress;
}
extern void boot_elf64_set_relocation(Elf64_Addr resolveAddress,
Elf64_Addr finalAddress);
#endif
#endif /* KERNEL_BOOT_ELF_H */
-7
View File
@@ -72,13 +72,6 @@ extern size_t platform_get_user_input_text(Menu *menu, MenuItem *item,
char *buffer, size_t bufferSize);
extern char* platform_debug_get_log_buffer(size_t* _size);
/* ELF functions */
extern status_t platform_allocate_elf_region(uint32 *_address, uint32 size,
uint8 protection, void **_mappedAddress);
extern status_t platform_allocate_elf_region(uint64 *_address, uint64 size,
uint8 protection, void **_mappedAddress);
#endif
#endif /* KERNEL_BOOT_PLATFORM_H */