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 "rom_calls.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 check_cpu_features()34check_cpu_features() 35 { 36 uint16 flags = SysBase->AttnFlags; 37 int cpu = 0; 38 int fpu = 0; 39 40 // check fpu flags first, since they are also set for 040 41 42 if ((flags & AFF_68881) != 0) 43 fpu = 68881; 44 if ((flags & AFF_68882) != 0) 45 fpu = 68882; 46 47 //if ((flags & AFF_68010) != 0) 48 // return B_ERROR; 49 //if ((flags & AFF_68020) != 0) 50 // return B_ERROR; 51 if ((flags & AFF_68030) != 0) 52 cpu = 68030; 53 if ((flags & AFF_68040) != 0) 54 cpu = fpu = 68040; 55 //if ((flags & AFF_FPU40) != 0) 56 // ; 57 58 //panic("cpu %d fpu %d flags 0x%04x", cpu, fpu, flags); 59 cpu = fpu = 68040; //XXX 60 if (!cpu || !fpu) 61 return B_ERROR; 62 63 gKernelArgs.arch_args.cpu_type = cpu; 64 gKernelArgs.arch_args.mmu_type = cpu; 65 gKernelArgs.arch_args.fpu_type = fpu; 66 67 // if ((flags & AFF_68060) != 0) true 68 gKernelArgs.arch_args.has_lpstop = false; 69 70 gKernelArgs.arch_args.platform = M68K_PLATFORM_AMIGA; 71 gKernelArgs.arch_args.machine = 0; //XXX 72 73 return B_OK; 74 } 75 76 #warning M68K: move and implement system_time() 77 static bigtime_t gSystemTimeCounter = 0; //HACK 78 extern "C" bigtime_t system_time(void)79system_time(void) 80 { 81 return gSystemTimeCounter++; 82 } 83 84 85 // #pragma mark - 86 87 88 extern "C" void spin(bigtime_t microseconds)89spin(bigtime_t microseconds) 90 { 91 bigtime_t time = system_time(); 92 while ((system_time() - time) < microseconds) 93 asm volatile ("nop;"); 94 } 95 96 97 extern "C" void cpu_init()98cpu_init() 99 { 100 if (check_cpu_features() != B_OK) 101 panic("You need a 68030 or higher in order to boot!\n"); 102 103 gKernelArgs.num_cpus = 1; 104 // this will eventually be corrected later on 105 // ...or not! 106 } 107 108 109 extern "C" void platform_load_ucode(BootVolume & volume)110platform_load_ucode(BootVolume& volume) 111 { 112 } 113 114