From 7ef3cafe20d0a662ce526fb30aab3d000ef52196 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Revol?= Date: Sat, 12 Jan 2008 22:12:20 +0000 Subject: [PATCH] CPU init stuff. TODO: check for LPSTOP (040), and cpu model (must be >= 020). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23449 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/system/boot/platform/atari_m68k/cpu.cpp | 73 +++++++++++++++++++++ src/system/boot/platform/atari_m68k/cpu.h | 22 +++++++ 2 files changed, 95 insertions(+) create mode 100644 src/system/boot/platform/atari_m68k/cpu.cpp create mode 100644 src/system/boot/platform/atari_m68k/cpu.h diff --git a/src/system/boot/platform/atari_m68k/cpu.cpp b/src/system/boot/platform/atari_m68k/cpu.cpp new file mode 100644 index 0000000000..b128f1d0dd --- /dev/null +++ b/src/system/boot/platform/atari_m68k/cpu.cpp @@ -0,0 +1,73 @@ +/* + * 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 + +bool gCpuHasLPSTOP = false; + +static status_t +check_cpu_features() +{ +#warning M68K: check for LPSTOP + if (false) + gCpuHasLPSTOP = true; + +#warning M68K: check for >= 020 + + return B_OK; +} + + +// #pragma mark - + + +extern "C" void +spin(bigtime_t microseconds) +{ + bigtime_t time = system_time(); + if (gCpuHasLPSTOP) { + while ((system_time() - time) < microseconds) + asm volatile ("lpstop;"); + } else { + while ((system_time() - time) < microseconds) + asm volatile ("nop;"); + } +} + + +extern "C" void +cpu_init() +{ + if (check_cpu_features() != B_OK) + panic("You need a 68020 or higher in order to boot!\n"); + + gKernelArgs.num_cpus = 1; + // this will eventually be corrected later on + // ...or not! +} + diff --git a/src/system/boot/platform/atari_m68k/cpu.h b/src/system/boot/platform/atari_m68k/cpu.h new file mode 100644 index 0000000000..f8eff4f44a --- /dev/null +++ b/src/system/boot/platform/atari_m68k/cpu.h @@ -0,0 +1,22 @@ +/* + * Copyright 2004-2005, Axel Dörfler, axeld@pinc-software.de. All rights reserved. + * Distributed under the terms of the MIT License. + */ +#ifndef CPU_H +#define CPU_H + + +#include + + +#ifdef __cplusplus +extern "C" { +#endif + +extern void cpu_init(void); + +#ifdef __cplusplus +} +#endif + +#endif /* CPU_H */