added 2 changesets to branch 'refs/remotes/xyzzy-github/x86_64' old head: 1651dd72d9dbd14fa8e97a204b166c0f32d97e90 new head: 6b87898af5966561770a79a17f13415c47c38aa0 ---------------------------------------------------------------------------- 17e407e: Proper implementation of arch_kernel.h for x86_64. 6b87898: Code style fixes. [ Alex Smith <alex@xxxxxxxxxxxxxxxx> ] ---------------------------------------------------------------------------- 5 files changed, 58 insertions(+), 18 deletions(-) headers/private/kernel/arch/x86_64/arch_kernel.h | 38 +++++++++++++++- headers/private/kernel/util/FixedWidthPointer.h | 18 ++++---- src/system/boot/platform/cfe/arch/ppc/mmu.cpp | 9 ++-- .../boot/platform/openfirmware/arch/ppc/mmu.cpp | 9 ++-- src/system/kernel/fs/vfs_boot.cpp | 2 +- ############################################################################ Commit: 17e407e945f313ed8c2878ad7699ef9384f8a1a0 Author: Alex Smith <alex@xxxxxxxxxxxxxxxx> Date: Fri Jun 22 09:53:08 2012 UTC Proper implementation of arch_kernel.h for x86_64. ---------------------------------------------------------------------------- diff --git a/headers/private/kernel/arch/x86_64/arch_kernel.h b/headers/private/kernel/arch/x86_64/arch_kernel.h index a7e45b3..056efaf 100644 --- a/headers/private/kernel/arch/x86_64/arch_kernel.h +++ b/headers/private/kernel/arch/x86_64/arch_kernel.h @@ -1,6 +1,42 @@ +/* + * Copyright 2012, Alex Smith, alex@xxxxxxxxxxxxxxxxx + * Distributed under the terms of the MIT License. + */ #ifndef _KERNEL_ARCH_X86_64_KERNEL_H #define _KERNEL_ARCH_X86_64_KERNEL_H -#include "../x86/arch_kernel.h" + +#ifndef _ASSEMBLER +# include <arch/cpu.h> +#endif + + +// 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. +// The whole kernel address space is the top 512GB of the address space. +#ifdef _BOOT_MODE +# define KERNEL_BASE 0x80000000 +#else +# define KERNEL_BASE 0xFFFFFF8000000000 +#endif + +#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 KERNEL_USER_DATA_BASE 0x7FFFEFFF0000 +#define USER_STACK_REGION 0x7FFFF0000000 +#define USER_STACK_REGION_SIZE (USER_TOP - USER_STACK_REGION) + #endif /* _KERNEL_ARCH_X86_64_KERNEL_H */ ############################################################################ Commit: 6b87898af5966561770a79a17f13415c47c38aa0 Author: Alex Smith <alex@xxxxxxxxxxxxxxxx> Date: Fri Jun 22 10:56:55 2012 UTC Code style fixes. ---------------------------------------------------------------------------- diff --git a/headers/private/kernel/util/FixedWidthPointer.h b/headers/private/kernel/util/FixedWidthPointer.h index b8ceaaf..b6e9662 100644 --- a/headers/private/kernel/util/FixedWidthPointer.h +++ b/headers/private/kernel/util/FixedWidthPointer.h @@ -30,23 +30,23 @@ public: return (addr_t)fValue; } - Type &operator*() const + Type& operator*() const { return *(Type *)*this; } - Type *operator->() const + Type* operator->() const { return *this; } - FixedWidthPointer &operator=(const FixedWidthPointer &p) + FixedWidthPointer& operator=(const FixedWidthPointer& p) { fValue = p.fValue; return *this; } - FixedWidthPointer &operator=(Type *p) + FixedWidthPointer& operator=(Type* p) { fValue = (addr_t)p; return *this; @@ -69,6 +69,7 @@ public: { fValue = addr; } + private: uint64 fValue; } _PACKED; @@ -80,13 +81,13 @@ class FixedWidthPointer<void> { public: operator void*() const { - return (void *)(addr_t)fValue; + return (void*)(addr_t)fValue; } template<typename OtherType> operator OtherType*() const { - return (OtherType *)(addr_t)fValue; + return (OtherType*)(addr_t)fValue; } operator addr_t() const @@ -94,13 +95,13 @@ public: return (addr_t)fValue; } - FixedWidthPointer &operator=(const FixedWidthPointer &p) + FixedWidthPointer& operator=(const FixedWidthPointer& p) { fValue = p.fValue; return *this; } - FixedWidthPointer &operator=(void *p) + FixedWidthPointer& operator=(void* p) { fValue = (addr_t)p; return *this; @@ -115,6 +116,7 @@ public: { fValue = addr; } + private: uint64 fValue; } _PACKED; diff --git a/src/system/boot/platform/cfe/arch/ppc/mmu.cpp b/src/system/boot/platform/cfe/arch/ppc/mmu.cpp index b20495e..68c709e 100644 --- a/src/system/boot/platform/cfe/arch/ppc/mmu.cpp +++ b/src/system/boot/platform/cfe/arch/ppc/mmu.cpp @@ -261,8 +261,8 @@ find_free_physical_range(size_t size) } for (uint32 i = 0; i < gKernelArgs.num_physical_allocated_ranges; i++) { - void *address = - (void *)(addr_t)(gKernelArgs.physical_allocated_range[i].start + void *address + = (void *)(addr_t)(gKernelArgs.physical_allocated_range[i].start + gKernelArgs.physical_allocated_range[i].size); if (!is_physical_allocated(address, size) && is_physical_memory(address, size)) @@ -281,8 +281,9 @@ find_free_virtual_range(void *base, size_t size) void *firstFound = NULL; void *firstBaseFound = NULL; for (uint32 i = 0; i < gKernelArgs.num_virtual_allocated_ranges; i++) { - void *address = (void *)(addr_t)(gKernelArgs.virtual_allocated_range[i].start - + gKernelArgs.virtual_allocated_range[i].size); + void *address + = (void *)(addr_t)(gKernelArgs.virtual_allocated_range[i].start + + gKernelArgs.virtual_allocated_range[i].size); if (!is_virtual_allocated(address, size)) { if (!base) return address; diff --git a/src/system/boot/platform/openfirmware/arch/ppc/mmu.cpp b/src/system/boot/platform/openfirmware/arch/ppc/mmu.cpp index 7f46272..a89fec7 100644 --- a/src/system/boot/platform/openfirmware/arch/ppc/mmu.cpp +++ b/src/system/boot/platform/openfirmware/arch/ppc/mmu.cpp @@ -442,8 +442,8 @@ find_free_physical_range(size_t size) } for (uint32 i = 0; i < gKernelArgs.num_physical_allocated_ranges; i++) { - void *address = - (void *)(addr_t)(gKernelArgs.physical_allocated_range[i].start + void *address + = (void *)(addr_t)(gKernelArgs.physical_allocated_range[i].start + gKernelArgs.physical_allocated_range[i].size); if (!is_physical_allocated(address, size) && is_physical_memory(address, size)) @@ -462,8 +462,9 @@ find_free_virtual_range(void *base, size_t size) void *firstFound = NULL; void *firstBaseFound = NULL; for (uint32 i = 0; i < gKernelArgs.num_virtual_allocated_ranges; i++) { - void *address = (void *)(addr_t)(gKernelArgs.virtual_allocated_range[i].start - + gKernelArgs.virtual_allocated_range[i].size); + void *address + = (void *)(addr_t)(gKernelArgs.virtual_allocated_range[i].start + + gKernelArgs.virtual_allocated_range[i].size); if (!is_virtual_allocated(address, size)) { if (!base) return address; diff --git a/src/system/kernel/fs/vfs_boot.cpp b/src/system/kernel/fs/vfs_boot.cpp index c01a132..21b1b9e 100644 --- a/src/system/kernel/fs/vfs_boot.cpp +++ b/src/system/kernel/fs/vfs_boot.cpp @@ -320,7 +320,7 @@ DiskBootMethod::SortPartitions(KPartition** partitions, int32 count) The boot code should then just try them one by one. */ static status_t -get_boot_partitions(KMessage &bootVolume, PartitionStack& partitions) +get_boot_partitions(KMessage& bootVolume, PartitionStack& partitions) { dprintf("get_boot_partitions(): boot volume message:\n"); bootVolume.Dump(&dprintf);