diff --git a/headers/private/kernel/boot/platform/efi/arch_timer.h b/headers/private/kernel/boot/platform/efi/arch_timer.h new file mode 100644 index 0000000000..695aace29c --- /dev/null +++ b/headers/private/kernel/boot/platform/efi/arch_timer.h @@ -0,0 +1,10 @@ +/* + * Copyright 2008, Dustin Howett, dustin.howett@gmail.com. All rights reserved. + * Distributed under the terms of the MIT License. + */ +#ifndef ARCH_TIMER_H +#define ARCH_TIMER_H + +void arch_timer_init(void); + +#endif /* ARCH_TIMER_H */ diff --git a/src/system/boot/platform/efi/Jamfile b/src/system/boot/platform/efi/Jamfile index 7e9fb76208..08d510d65e 100644 --- a/src/system/boot/platform/efi/Jamfile +++ b/src/system/boot/platform/efi/Jamfile @@ -27,9 +27,9 @@ local platform_src = mmu.cpp heap.cpp acpi.cpp + timer.cpp menu.cpp devices.cpp - hpet.cpp cpu.cpp smp.cpp serial.cpp diff --git a/src/system/boot/platform/efi/arch/arm/Jamfile b/src/system/boot/platform/efi/arch/arm/Jamfile new file mode 100644 index 0000000000..9b25f3fe40 --- /dev/null +++ b/src/system/boot/platform/efi/arch/arm/Jamfile @@ -0,0 +1,30 @@ +SubDir HAIKU_TOP src system boot platform efi arch arm ; + +SubDirHdrs $(HAIKU_TOP) src system boot platform efi ; + +UsePrivateHeaders [ FDirName kernel boot platform efi ] ; +UseBuildFeatureHeaders gnuefi ; +UseBuildFeatureHeaders gnuefi : headersProtocol ; +UseBuildFeatureHeaders gnuefi : headersArch ; + +local arch_src = + #entry.S + relocation_func.cpp + #arch_smp.cpp + #arch_mmu.cpp + arch_timer.cpp + ; + +BootMergeObject boot_platform_efi_arm.o : + $(arch_src) + ; + +Includes [ FGristFiles $(arch_src) ] + : + [ BuildFeatureAttribute gnuefi : headers ] + [ BuildFeatureAttribute gnuefi : headersProtocol ] + [ BuildFeatureAttribute gnuefi : headersArch ] + ; + +Depends [ FGristFiles $(arch_src) ] + : [ BuildFeatureAttribute gnuefi : libdir ] ; diff --git a/src/system/boot/platform/efi/arch/arm/arch_timer.cpp b/src/system/boot/platform/efi/arch/arm/arch_timer.cpp new file mode 100644 index 0000000000..0f9f76a535 --- /dev/null +++ b/src/system/boot/platform/efi/arch/arm/arch_timer.cpp @@ -0,0 +1,33 @@ +/* + * Copyright, 2019, Haiku, Inc. All rights reserved. + * Distributed under the terms of the MIT License. + * + * Authors: + * Alexander von Gluck IV +*/ + + +#include "arch_timer.h" + +#include + +#include +#include +#include +#include + +#include + +//#define TRACE_TIMER +#ifdef TRACE_TIMER +# define TRACE(x) dprintf x +#else +# define TRACE(x) ; +#endif + + +void +arch_timer_init(void) +{ + // Stub +} diff --git a/src/system/boot/platform/efi/hpet.h b/src/system/boot/platform/efi/arch/arm/arch_timer.h similarity index 91% rename from src/system/boot/platform/efi/hpet.h rename to src/system/boot/platform/efi/arch/arm/arch_timer.h index 124eef7fc8..bfe3e9b4dd 100644 --- a/src/system/boot/platform/efi/hpet.h +++ b/src/system/boot/platform/efi/arch/arm/arch_timer.h @@ -12,7 +12,7 @@ extern "C" { #endif -void hpet_init(void); +void arch_timer_init(void); #ifdef __cplusplus } diff --git a/src/system/boot/platform/efi/arch/x86_64/Jamfile b/src/system/boot/platform/efi/arch/x86_64/Jamfile index 1497069661..e870ca6bfe 100644 --- a/src/system/boot/platform/efi/arch/x86_64/Jamfile +++ b/src/system/boot/platform/efi/arch/x86_64/Jamfile @@ -12,6 +12,7 @@ local arch_src = relocation_func.cpp arch_smp.cpp arch_mmu.cpp + arch_timer.cpp ; BootMergeObject boot_platform_efi_x86_64.o : diff --git a/src/system/boot/platform/efi/hpet.cpp b/src/system/boot/platform/efi/arch/x86_64/arch_timer.cpp similarity index 90% rename from src/system/boot/platform/efi/hpet.cpp rename to src/system/boot/platform/efi/arch/x86_64/arch_timer.cpp index 7371ae460e..a5485fcfbc 100644 --- a/src/system/boot/platform/efi/hpet.cpp +++ b/src/system/boot/platform/efi/arch/x86_64/arch_timer.cpp @@ -7,11 +7,13 @@ */ +#include "arch_timer.h" + #include "mmu.h" #include "acpi.h" -#include "hpet.h" #include +#include #include #include @@ -23,15 +25,15 @@ #include -//#define TRACE_HPET -#ifdef TRACE_HPET +//#define TRACE_TIMER +#ifdef TRACE_TIMER # define TRACE(x) dprintf x #else # define TRACE(x) ; #endif -void +static void hpet_init(void) { // Try to find the HPET ACPI table. @@ -53,3 +55,10 @@ hpet_init(void) gKernelArgs.arch_args.hpet = (void *)mmu_map_physical_memory( gKernelArgs.arch_args.hpet_phys, B_PAGE_SIZE, EfiACPIReclaimMemory); } + + +void +arch_timer_init(void) +{ + hpet_init(); +} diff --git a/src/system/boot/platform/efi/mmu.cpp b/src/system/boot/platform/efi/mmu.cpp index 9cb7b64cae..42bd278f6c 100644 --- a/src/system/boot/platform/efi/mmu.cpp +++ b/src/system/boot/platform/efi/mmu.cpp @@ -203,7 +203,11 @@ mmu_post_efi_setup(UINTN memory_map_size, EFI_MEMORY_DESCRIPTOR *memory_map, UIN kRuntimeServices->SetVirtualAddressMap(memory_map_size, descriptor_size, descriptor_version, memory_map); // Important. Make sure supervisor threads can fault on read only pages... + #if defined(__x86_64__) || defined(__x86__) asm("mov %%rax, %%cr0" : : "a" ((1 << 31) | (1 << 16) | (1 << 5) | 1)); + #else + #error Ensure supervisor threads can fault on read-only pages on this architecture! + #endif } diff --git a/src/system/boot/platform/efi/start.cpp b/src/system/boot/platform/efi/start.cpp index 076626b010..0c1f7ed7c7 100644 --- a/src/system/boot/platform/efi/start.cpp +++ b/src/system/boot/platform/efi/start.cpp @@ -22,11 +22,11 @@ #include "acpi.h" #include "console.h" #include "efi_platform.h" -#include "hpet.h" #include "cpu.h" #include "mmu.h" #include "serial.h" #include "smp.h" +#include "timer.h" extern void (*__ctor_list)(void); @@ -88,8 +88,10 @@ convert_kernel_args() fix_address(gKernelArgs.edid_info); fix_address(gKernelArgs.debug_output); fix_address(gKernelArgs.boot_splash); + #if defined(__x86_64__) || defined(__x86__) fix_address(gKernelArgs.arch_args.apic); fix_address(gKernelArgs.arch_args.hpet); + #endif convert_preloaded_image(static_cast( gKernelArgs.kernel_image.Pointer())); @@ -261,12 +263,14 @@ efi_main(EFI_HANDLE image, EFI_SYSTEM_TABLE *systemTable) gKernelArgs.platform_args.apm.version = 0; gKernelArgs.num_cpus = 1; + #if defined(__x86_64__) || defined(__x86__) gKernelArgs.arch_args.hpet_phys = 0; gKernelArgs.arch_args.hpet = NULL; + #endif cpu_init(); acpi_init(); - hpet_init(); + timer_init(); smp_init(); main(&args); diff --git a/src/system/boot/platform/efi/timer.cpp b/src/system/boot/platform/efi/timer.cpp new file mode 100644 index 0000000000..25f89b3a7b --- /dev/null +++ b/src/system/boot/platform/efi/timer.cpp @@ -0,0 +1,31 @@ +/* + * Copyright 2008, Dustin Howett, dustin.howett@gmail.com. All rights reserved. + * Copyright 2004-2010, Axel Dörfler, axeld@pinc-software.de. + * Distributed under the terms of the MIT License. + * + * Copyright 2001, Travis Geiselbrecht. All rights reserved. + * Distributed under the terms of the NewOS License. +*/ + + +#include "timer.h" + +#include +#include + +#include "arch_timer.h" + + +//#define TRACE_TIMER +#ifdef TRACE_TIMER +# define TRACE(x) dprintf x +#else +# define TRACE(x) ; +#endif + + +void +timer_init(void) +{ + arch_timer_init(); +} diff --git a/src/system/boot/platform/efi/timer.h b/src/system/boot/platform/efi/timer.h new file mode 100644 index 0000000000..0bcd7c1528 --- /dev/null +++ b/src/system/boot/platform/efi/timer.h @@ -0,0 +1,23 @@ +/* + * Copyright 2005, Axel Dörfler, axeld@pinc-software.de. All rights reserved. + * Distributed under the terms of the MIT License. + */ +#ifndef EFI_TIMER_H +#define EFI_TIMER_H + + +#include + + +#ifdef __cplusplus +extern "C" { +#endif + +extern void timer_init(void); + +#ifdef __cplusplus +} +#endif + + +#endif /* EFI_TIMER_H */