[haiku-commits] haiku: hrev53604 - src/system/boot/platform/efi src/system/boot/platform/efi/arch/arm src/system/boot/platform/efi/arch/x86_64 headers/private/kernel/boot/platform/efi

  • From: Alex von Gluck IV <kallisti5@xxxxxxxxxxx>
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Tue, 26 Nov 2019 16:34:46 -0500 (EST)

hrev53604 adds 1 changeset to branch 'master'
old head: 9e15c9f153c5ffff9ad51b95b581326eb579b0fd
new head: b482adb1bc21e66bc071a281876ed473d06db050
overview: 
https://git.haiku-os.org/haiku/log/?qt=range&q=b482adb1bc21+%5E9e15c9f153c5

----------------------------------------------------------------------------

b482adb1bc21: kernel/boot/efi: Continue breaking apart arch-specific code; hpet
  
    * Move x86 hpet behind timer interface.
    * Add a few if x86,x86_64 macros to start.cpp.
  
  Change-Id: I583ec1b064785182e6d48dfbcd91b1bb2ead4b44
  Reviewed-on: https://review.haiku-os.org/c/haiku/+/1929
  Reviewed-by: Alex von Gluck IV <kallisti5@xxxxxxxxxxx>

                          [ Alexander von Gluck IV <kallisti5@xxxxxxxxxxx> ]

----------------------------------------------------------------------------

Revision:    hrev53604
Commit:      b482adb1bc21e66bc071a281876ed473d06db050
URL:         https://git.haiku-os.org/haiku/commit/?id=b482adb1bc21
Author:      Alexander von Gluck IV <kallisti5@xxxxxxxxxxx>
Date:        Sat Nov  2 01:15:56 2019 UTC
Committer:   Alex von Gluck IV <kallisti5@xxxxxxxxxxx>
Commit-Date: Tue Nov 26 21:34:43 2019 UTC

----------------------------------------------------------------------------

11 files changed, 153 insertions(+), 8 deletions(-)
.../kernel/boot/platform/efi/arch_timer.h        | 10 ++++++
src/system/boot/platform/efi/Jamfile             |  2 +-
src/system/boot/platform/efi/arch/arm/Jamfile    | 30 ++++++++++++++++++
.../boot/platform/efi/arch/arm/arch_timer.cpp    | 33 ++++++++++++++++++++
.../efi/{hpet.h => arch/arm/arch_timer.h}        |  2 +-
src/system/boot/platform/efi/arch/x86_64/Jamfile |  1 +
.../efi/{hpet.cpp => arch/x86_64/arch_timer.cpp} | 17 +++++++---
src/system/boot/platform/efi/mmu.cpp             |  4 +++
src/system/boot/platform/efi/start.cpp           |  8 +++--
src/system/boot/platform/efi/timer.cpp           | 31 ++++++++++++++++++
src/system/boot/platform/efi/timer.h             | 23 ++++++++++++++

----------------------------------------------------------------------------

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@xxxxxxxxx. 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 <kallisti5@xxxxxxxxxxx>
+*/
+
+
+#include "arch_timer.h"
+
+#include <KernelExport.h>
+
+#include <kernel.h>
+#include <safemode.h>
+#include <boot/stage2.h>
+#include <boot/menu.h>
+
+#include <string.h>
+
+//#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 <KernelExport.h>
+#include <SupportDefs.h>
 
 #include <kernel.h>
 #include <safemode.h>
@@ -23,15 +25,15 @@
 
 #include <string.h>
 
-//#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<preloaded_elf64_image*>(
                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@xxxxxxxxx. All rights reserved.
+ * Copyright 2004-2010, Axel Dörfler, axeld@xxxxxxxxxxxxxxxx.
+ * 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 <string.h>
+#include <KernelExport.h>
+
+#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@xxxxxxxxxxxxxxxx. All rights reserved.
+ * Distributed under the terms of the MIT License.
+ */
+#ifndef EFI_TIMER_H
+#define EFI_TIMER_H
+
+
+#include <SupportDefs.h>
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+extern void timer_init(void);
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif /* EFI_TIMER_H */


Other related posts:

  • » [haiku-commits] haiku: hrev53604 - src/system/boot/platform/efi src/system/boot/platform/efi/arch/arm src/system/boot/platform/efi/arch/x86_64 headers/private/kernel/boot/platform/efi - Alex von Gluck IV