[haiku-commits] haiku: hrev44199 - in src/system/boot/platform/u-boot/arch: ppc arm src/system/boot/platform/u-boot

  • From: revol@xxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Thu, 24 May 2012 21:44:06 +0200 (CEST)

hrev44199 adds 1 changeset to branch 'master'
old head: 3bd0ac4aa39e077d335e787dbe7a8dc0c04f247d
new head: 037f252fd0dd3e85ebf9eaceee58b1a5ce73ca0d

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

037f252: U-Boot: split cpu.cpp into arch-specific and common parts
  
  * the common part should try to use the U-Boot API when found.
  * the arch part can make use of cpu features (like timer register)
  * the ppc code enables the FPU in the MSR, since it's used by vsnprintf(),
  which at least saves one FP register in its prologue.

                                          [ François Revol <revol@xxxxxxx> ]

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

Revision:    hrev44199
Commit:      037f252fd0dd3e85ebf9eaceee58b1a5ce73ca0d
URL:         http://cgit.haiku-os.org/haiku/commit/?id=037f252
Author:      François Revol <revol@xxxxxxx>
Date:        Thu May 24 19:27:37 2012 UTC

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

6 files changed, 194 insertions(+), 29 deletions(-)
src/system/boot/platform/u-boot/arch/arm/Jamfile   |    2 +-
.../boot/platform/u-boot/arch/arm/arch_cpu.cpp     |   84 +++++++++++++
src/system/boot/platform/u-boot/arch/ppc/Jamfile   |    2 +-
.../boot/platform/u-boot/arch/ppc/arch_cpu.cpp     |   97 ++++++++++++++++
src/system/boot/platform/u-boot/cpu.cpp            |   36 ++----
src/system/boot/platform/u-boot/cpu.h              |    2 +

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

diff --git a/src/system/boot/platform/u-boot/arch/arm/Jamfile 
b/src/system/boot/platform/u-boot/arch/arm/Jamfile
index a81e46b..f8b00e7 100644
--- a/src/system/boot/platform/u-boot/arch/arm/Jamfile
+++ b/src/system/boot/platform/u-boot/arch/arm/Jamfile
@@ -15,7 +15,7 @@ KernelMergeObject boot_platform_u-boot_arm.o :
        #arch_mmu.cpp
        #arch_cpu_asm.S
        arch_start_kernel.S
-       #cpu.cpp
+       arch_cpu.cpp
        #mmu.cpp
        : -fno-pic
 ;
diff --git a/src/system/boot/platform/u-boot/arch/arm/arch_cpu.cpp 
b/src/system/boot/platform/u-boot/arch/arm/arch_cpu.cpp
new file mode 100644
index 0000000..6761918
--- /dev/null
+++ b/src/system/boot/platform/u-boot/arch/arm/arch_cpu.cpp
@@ -0,0 +1,84 @@
+/*
+ * Copyright 2004-2005, Axel Dörfler, axeld@xxxxxxxxxxxxxxxxx All rights 
reserved.
+ * Distributed under the terms of the MIT License.
+ *
+ * calculate_cpu_conversion_factor() was written by Travis Geiselbrecht and
+ * licensed under the NewOS license.
+ */
+
+
+#include "cpu.h"
+
+#include <OS.h>
+#include <boot/platform.h>
+#include <boot/stdio.h>
+#include <boot/kernel_args.h>
+#include <boot/stage2.h>
+#include <arch/cpu.h>
+#include <arch_kernel.h>
+#include <arch_system_info.h>
+
+#include <string.h>
+
+
+//#define TRACE_CPU
+#ifdef TRACE_CPU
+#      define TRACE(x) dprintf x
+#else
+#      define TRACE(x) ;
+#endif
+
+//uint32 gTimeConversionFactor;
+
+
+static void
+calculate_cpu_conversion_factor()
+{
+         #warning U-Boot:TODO!
+}
+
+
+static status_t
+check_cpu_features()
+{
+
+        #warning U-Boot:TODO!
+       return B_OK;
+}
+
+
+//     #pragma mark -
+
+
+extern "C" void
+arch_spin(bigtime_t microseconds)
+{
+       for(bigtime_t i=0;i<microseconds;i=i+1)
+       {
+               /*
+               asm volatile ("mov r0,r0");
+               asm volatile ("mov r0,r0");
+               */
+       }
+       #warning U-Boot:ARM:TODO!!
+}
+
+
+extern "C" status_t
+boot_arch_cpu_init(void)
+{
+       status_t err = check_cpu_features();
+
+       if (err != B_OK) {
+               panic("You need a Pentium or higher in order to boot!\n");
+               return err;
+       }
+
+       calculate_cpu_conversion_factor();
+
+       gKernelArgs.num_cpus = 1;
+               // this will eventually be corrected later on
+
+       return B_OK;
+}
+
diff --git a/src/system/boot/platform/u-boot/arch/ppc/Jamfile 
b/src/system/boot/platform/u-boot/arch/ppc/Jamfile
index ad93d59..793ca77 100644
--- a/src/system/boot/platform/u-boot/arch/ppc/Jamfile
+++ b/src/system/boot/platform/u-boot/arch/ppc/Jamfile
@@ -15,7 +15,7 @@ KernelMergeObject boot_platform_u-boot_ppc.o :
        #arch_mmu.cpp
        #arch_cpu_asm.S
        arch_start_kernel.S
-       #cpu.cpp
+       arch_cpu.cpp
        #mmu.cpp
        : -fno-pic
 ;
diff --git a/src/system/boot/platform/u-boot/arch/ppc/arch_cpu.cpp 
b/src/system/boot/platform/u-boot/arch/ppc/arch_cpu.cpp
new file mode 100644
index 0000000..09e1e2f
--- /dev/null
+++ b/src/system/boot/platform/u-boot/arch/ppc/arch_cpu.cpp
@@ -0,0 +1,97 @@
+/*
+ * Copyright 2004-2005, Axel Dörfler, axeld@xxxxxxxxxxxxxxxxx All rights 
reserved.
+ * Distributed under the terms of the MIT License.
+ *
+ * calculate_cpu_conversion_factor() was written by Travis Geiselbrecht and
+ * licensed under the NewOS license.
+ */
+
+
+#include "cpu.h"
+
+#include <OS.h>
+#include <boot/platform.h>
+#include <boot/stdio.h>
+#include <boot/kernel_args.h>
+#include <boot/stage2.h>
+#include <arch/cpu.h>
+#include <arch/ppc/arch_cpu.h>
+#include <arch_kernel.h>
+#include <arch_system_info.h>
+
+#include <string.h>
+
+
+//#define TRACE_CPU
+#ifdef TRACE_CPU
+#      define TRACE(x) dprintf x
+#else
+#      define TRACE(x) ;
+#endif
+
+//uint32 gTimeConversionFactor;
+
+
+static void
+calculate_cpu_conversion_factor()
+{
+       #warning U-Boot:TODO!
+}
+
+
+static status_t
+check_cpu_features()
+{
+       uint32 msr;
+
+       // we do need an FPU
+       // on Sam460ex at least U-Boot doesn't enable the FPU for us
+       msr = get_msr();
+       msr |= MSR_FP_AVAILABLE;
+       msr = set_msr(msr);
+
+       if ((msr & MSR_FP_AVAILABLE) == 0) {
+               // sadly panic uses vsnprintf which fails without FPU anyway
+               panic("no FPU!");
+               return B_ERROR;
+       }
+
+       return B_OK;
+}
+
+
+//     #pragma mark -
+
+
+extern "C" void
+arch_spin(bigtime_t microseconds)
+{
+       for(bigtime_t i=0;i<microseconds;i=i+1)
+       {
+               /*
+               asm volatile ("mov r0,r0");
+               asm volatile ("mov r0,r0");
+               */
+       }
+       #warning U-Boot:PPC:TODO!!
+}
+
+
+extern "C" status_t
+boot_arch_cpu_init(void)
+{
+       status_t err = check_cpu_features();
+
+       if (err != B_OK) {
+               panic("You need a Pentium or higher in order to boot!\n");
+               return err;
+       }
+
+       calculate_cpu_conversion_factor();
+
+       gKernelArgs.num_cpus = 1;
+               // this will eventually be corrected later on
+
+       return B_OK;
+}
+
diff --git a/src/system/boot/platform/u-boot/cpu.cpp 
b/src/system/boot/platform/u-boot/cpu.cpp
index 9868f01..672d027 100644
--- a/src/system/boot/platform/u-boot/cpu.cpp
+++ b/src/system/boot/platform/u-boot/cpu.cpp
@@ -28,31 +28,13 @@
 #      define TRACE(x) ;
 #endif
 
-//uint32 gTimeConversionFactor;
-
-
-static void
-calculate_cpu_conversion_factor()
-{
-         #warning U-Boot:TODO!
-}
-
-
-static status_t
-check_cpu_features()
-{
-
-        #warning U-Boot:TODO!
-       return B_OK;
-}
-
-
-//     #pragma mark -
-
 
 extern "C" void
 spin(bigtime_t microseconds)
 {
+       #warning U-Boot:TODO!!
+       // TODO: use API if available
+
        for(bigtime_t i=0;i<microseconds;i=i+1)
        {
                /*
@@ -60,19 +42,19 @@ spin(bigtime_t microseconds)
                asm volatile ("mov r0,r0");
                */
        }
-       #warning U-Boot:TODO!!
+
+       // fallback to arch-specific code
+       //arch_spin(microseconds);
 }
 
 
 extern "C" void
 cpu_init()
 {
-       if (check_cpu_features() != B_OK)
-               panic("You need a Pentium or higher in order to boot!\n");
-
-       calculate_cpu_conversion_factor();
-
        gKernelArgs.num_cpus = 1;
                // this will eventually be corrected later on
+
+       if (boot_arch_cpu_init() != B_OK)
+               panic("You need a 6502 or higher in order to boot!\n");
 }
 
diff --git a/src/system/boot/platform/u-boot/cpu.h 
b/src/system/boot/platform/u-boot/cpu.h
index f8eff4f..dd9de74 100644
--- a/src/system/boot/platform/u-boot/cpu.h
+++ b/src/system/boot/platform/u-boot/cpu.h
@@ -13,6 +13,8 @@
 extern "C" {
 #endif
 
+extern void arch_spin(bigtime_t microseconds);
+extern status_t boot_arch_cpu_init(void);
 extern void cpu_init(void);
 
 #ifdef __cplusplus


Other related posts:

  • » [haiku-commits] haiku: hrev44199 - in src/system/boot/platform/u-boot/arch: ppc arm src/system/boot/platform/u-boot - revol