1 /* 2 * Copyright 2004-2005, Axel Dörfler, axeld@pinc-software.de. All rights reserved. 3 * Distributed under the terms of the MIT License. 4 */ 5 6 7 #include "cpu.h" 8 #include "nextrom.h" 9 10 #include <OS.h> 11 #include <boot/platform.h> 12 #include <boot/stdio.h> 13 #include <boot/kernel_args.h> 14 #include <boot/stage2.h> 15 #include <arch/cpu.h> 16 #include <arch_kernel.h> 17 #include <arch_platform.h> 18 #include <arch_system_info.h> 19 20 #include <string.h> 21 22 23 //#define TRACE_CPU 24 #ifdef TRACE_CPU 25 # define TRACE(x) dprintf x 26 #else 27 # define TRACE(x) ; 28 #endif 29 30 #warning M68K: add set_vbr() 31 32 33 static status_t 34 check_cpu_features() 35 { 36 int cpu = 0; 37 int fpu = 0; 38 39 //TODO: The ROM only tells which machine. NetBSD probes using CACR instead. 40 cpu = fpu = 68040; 41 if (!cpu || !fpu) 42 return B_ERROR; 43 44 gKernelArgs.arch_args.cpu_type = cpu; 45 gKernelArgs.arch_args.mmu_type = cpu; 46 gKernelArgs.arch_args.fpu_type = fpu; 47 48 // if ((flags & AFF_68060) != 0) true 49 gKernelArgs.arch_args.has_lpstop = false; 50 51 gKernelArgs.arch_args.platform = M68K_PLATFORM_NEXT; 52 gKernelArgs.arch_args.machine = 0; //XXX 53 54 return B_OK; 55 } 56 57 #warning M68K: move and implement system_time() 58 static bigtime_t gSystemTimeCounter = 0; //HACK 59 extern "C" bigtime_t 60 system_time(void) 61 { 62 return gSystemTimeCounter++; 63 } 64 65 66 // #pragma mark - 67 68 69 extern "C" void 70 spin(bigtime_t microseconds) 71 { 72 bigtime_t time = system_time(); 73 while ((system_time() - time) < microseconds) 74 asm volatile ("nop;"); 75 } 76 77 78 extern "C" void 79 cpu_init() 80 { 81 if (check_cpu_features() != B_OK) 82 panic("You need a 68030 or higher in order to boot!\n"); 83 84 gKernelArgs.num_cpus = 1; 85 // this will eventually be corrected later on 86 // ...or not! 87 } 88 89 90 extern "C" void 91 platform_load_ucode(BootVolume& volume) 92 { 93 } 94 95