From 037f252fd0dd3e85ebf9eaceee58b1a5ce73ca0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Revol?= Date: Thu, 24 May 2012 21:27:37 +0200 Subject: [PATCH] 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. --- .../boot/platform/u-boot/arch/arm/Jamfile | 2 +- .../platform/u-boot/arch/arm/arch_cpu.cpp | 84 ++++++++++++++++ .../boot/platform/u-boot/arch/ppc/Jamfile | 2 +- .../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 + 6 files changed, 194 insertions(+), 29 deletions(-) create mode 100644 src/system/boot/platform/u-boot/arch/arm/arch_cpu.cpp create mode 100644 src/system/boot/platform/u-boot/arch/ppc/arch_cpu.cpp diff --git a/src/system/boot/platform/u-boot/arch/arm/Jamfile b/src/system/boot/platform/u-boot/arch/arm/Jamfile index a81e46bc90..f8b00e7826 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 0000000000..676191803d --- /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@pinc-software.de. 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 +#include +#include +#include +#include +#include +#include +#include + +#include + + +//#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 +#include +#include +#include +#include +#include +#include +#include +#include + +#include + + +//#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