1 #include <aros/config.h>
2 #include <aros/symbolsets.h>
4 #include <exec/types.h>
5 #include <aros/i386/cpucontext.h>
7 #include "kernel_base.h"
8 #include "kernel_debug.h"
12 #ifndef SIZEOF_8087_FRAME
13 #define SIZEOF_8087_FRAME sizeof(struct FPUContext)
16 static int cpu_Init(struct KernelBase
*KernelBase
)
20 D(bug("[Kernel] cpu_Init(0x%p) for i386\n", KernelBase
));
22 KernelBase
->kb_ContextSize
= sizeof(struct AROSCPUContext
);
24 /* Evaluate CPU capabilities */
25 asm volatile("cpuid":"=a"(v1
),"=b"(v2
),"=c"(v3
),"=d"(v4
):"a"(1));
29 switch ((v4
>> 25) & 3)
36 #if (AROS_FLAVOUR & AROS_FLAVOUR_STANDALONE)
37 /* tell the CPU that we will support SSE */
38 wrcr(cr4
, rdcr(cr4
) | (3 << 9));
39 /* Clear the EM and MP flags of CR0 */
40 wrcr(cr0
, rdcr(cr0
) & ~6);
43 #ifdef USE_LEGACY_8087
44 KernelBase
->kb_ContextFlags
= ECF_FPU
|ECF_FPX
;
45 KernelBase
->kb_ContextSize
+= SIZEOF_8087_FRAME
; /* Legacy 8087 frame with private portion */
47 KernelBase
->kb_ContextFlags
= ECF_FPX
;
49 KernelBase
->kb_ContextSize
+= sizeof(struct FPXContext
) + 15; /* Add 15 bytes for alignment */
56 KernelBase
->kb_ContextFlags
= ECF_FPU
;
57 KernelBase
->kb_ContextSize
+= SIZEOF_8087_FRAME
;
60 D(bug("[Kernel] CPU context flags: 0x%08X\n", KernelBase
->kb_ContextFlags
));
65 ADD2INITLIB(cpu_Init
, 5);