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.
This commit is contained in:
@@ -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
|
||||
;
|
||||
|
||||
@@ -0,0 +1,84 @@
|
||||
/*
|
||||
* Copyright 2004-2005, Axel Dörfler, [email protected]. 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;
|
||||
}
|
||||
|
||||
@@ -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
|
||||
;
|
||||
|
||||
@@ -0,0 +1,97 @@
|
||||
/*
|
||||
* Copyright 2004-2005, Axel Dörfler, [email protected]. 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;
|
||||
}
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user