revert between 56095 -> 55830 in arch
[AROS.git] / arch / m68k-all / processor / processor_init.c
blob2ac1d8a189cc1ed51286587e0567bdaf3e83f94b
1 /*
2 Copyright © 2011-2017, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #include <exec/rawfmt.h>
7 #include <proto/exec.h>
8 #include <stdarg.h>
9 #include <aros/symbolsets.h>
11 #include "processor_intern.h"
12 #include "processor_arch_intern.h"
14 static VOID __sprintf(UBYTE *buffer, const UBYTE *format, ...)
16 va_list args;
18 va_start(args, format);
19 VNewRawDoFmt(format, RAWFMTFUNC_STRING, buffer, args);
20 va_end(args);
23 static VOID ReadProcessorInformation(struct M68KProcessorInformation * info)
26 * The inline assembler doesn't like the reference to the 68060 specific
27 * PCR register. So here we put the manually assembled code into ReadPCR[]
28 * and later we'll call it from Supervisor() to retrieve that PCR register
29 * contents. The assembled code is:
31 * movec PCR,d0 ; 4E7A0808
32 * rte ; 4E73
35 ULONG ReadPCR[2] = { 0x4E7A0808, 0x4E730000 };
36 register ULONG pcr asm("d0");
38 __sprintf(info->ModelStringBuffer, "%s", "68000");
39 info->ModelString = info->ModelStringBuffer;
41 info->CPUModel = CPUMODEL_68000;
42 info->FPUModel = FPUMODEL_UNKNOWN;
43 info->L1InstructionCacheSize = 0;
44 info->L1DataCacheSize = 0;
46 pcr = 0;
48 if (SysBase->AttnFlags & (AFF_68060 | AFF_68080)) {
49 pcr = Supervisor(ReadPCR);
52 if (SysBase->AttnFlags & AFF_68080)
54 info->CPUModel = CPUMODEL_68080;
55 // info->FPUModel = FPUMODEL_UNKNOWN;
56 __sprintf(info->ModelStringBuffer, "%s", "Apollo Core 68080");
58 if (pcr & 0x04400000) {
59 info->L1InstructionCacheSize = 16384;
60 info->L1DataCacheSize = 32768;
63 else if (SysBase->AttnFlags & AFF_68060)
65 info->CPUModel = CPUMODEL_68060;
66 if (SysBase->AttnFlags & AFF_FPU40) {
67 info->FPUModel = FPUMODEL_INTERNAL;
68 __sprintf(info->ModelStringBuffer, "%s", "68060");
69 } else {
70 if (SysBase->AttnFlags & AFB_PRIVATEB)
72 __sprintf(info->ModelStringBuffer, "%s", "68LC060");
74 else
76 __sprintf(info->ModelStringBuffer, "%s", "68EC060");
79 info->L1InstructionCacheSize = 8192;
80 info->L1DataCacheSize = 8192;
82 else if (SysBase->AttnFlags & AFF_68040)
84 info->CPUModel = CPUMODEL_68040;
85 if (SysBase->AttnFlags & AFF_FPU40) {
86 info->FPUModel = FPUMODEL_INTERNAL;
87 __sprintf(info->ModelStringBuffer, "%s", "68040");
88 } else {
89 if (SysBase->AttnFlags & AFB_PRIVATEB)
91 __sprintf(info->ModelStringBuffer, "%s", "68LC040");
93 else
95 __sprintf(info->ModelStringBuffer, "%s", "68EC040");
98 info->L1InstructionCacheSize = 4096;
99 info->L1DataCacheSize = 4096;
101 else if (SysBase->AttnFlags & AFF_68030)
103 info->CPUModel = CPUMODEL_68030;
104 if (SysBase->AttnFlags & AFB_PRIVATEB)
106 __sprintf(info->ModelStringBuffer, "%s", "68030");
108 else
110 __sprintf(info->ModelStringBuffer, "%s", "68EC030");
112 info->L1InstructionCacheSize = 256;
113 info->L1DataCacheSize = 256;
115 else if (SysBase->AttnFlags & AFF_68020)
117 info->CPUModel = CPUMODEL_68020;
118 if (SysBase->AttnFlags & AFF_ADDR32)
120 __sprintf(info->ModelStringBuffer, "%s", "68020");
122 else
124 __sprintf(info->ModelStringBuffer, "%s", "68EC020");
126 info->L1InstructionCacheSize = 256;
128 else if (SysBase->AttnFlags & AFF_68010)
130 info->CPUModel = CPUMODEL_68010;
131 __sprintf(info->ModelStringBuffer, "%s", "68010");
134 if (info->FPUModel != FPUMODEL_INTERNAL) {
135 UBYTE *s = info->ModelStringBuffer;
136 while (*s)
137 s++;
138 if (SysBase->AttnFlags & AFF_68882)
140 info->FPUModel = FPUMODEL_68882;
141 __sprintf(s, "%s", "/68882");
143 else if (SysBase->AttnFlags & AFF_68881)
145 info->FPUModel = FPUMODEL_68881;
146 __sprintf(s, "%s", "/68881");
148 else
149 info->FPUModel = FPUMODEL_NONE;
151 info->CPUFrequency = 0; /* TODO: Implement */
154 LONG Processor_Init(struct ProcessorBase * ProcessorBase)
156 struct SystemProcessors * sysprocs =
157 AllocVec(sizeof(struct SystemProcessors), MEMF_ANY | MEMF_CLEAR);
159 if (sysprocs == NULL)
160 return FALSE;
162 ProcessorBase->Private1 = sysprocs;
164 ReadProcessorInformation(&sysprocs->processor);
166 return TRUE;
169 ADD2INITLIB(Processor_Init, 1);