2 Copyright © 1995-2014, The AROS Development Team. All rights reserved.
6 #include <aros/config.h>
7 #include <aros/symbolsets.h>
9 #include <exec/types.h>
10 #include <aros/i386/cpucontext.h>
12 #include "kernel_base.h"
13 #include "kernel_debug.h"
17 #ifndef SIZEOF_8087_FRAME
18 #define SIZEOF_8087_FRAME sizeof(struct FPUContext)
21 static int cpu_Init(struct KernelBase
*KernelBase
)
25 D(bug("[Kernel] cpu_Init(0x%p) for i386\n", KernelBase
));
27 KernelBase
->kb_ContextSize
= sizeof(struct AROSCPUContext
);
29 /* Evaluate CPU capabilities */
30 asm volatile("cpuid":"=a"(v1
),"=b"(v2
),"=c"(v3
),"=d"(v4
):"a"(1));
34 switch ((v4
>> 25) & 3)
41 #if (AROS_FLAVOUR & AROS_FLAVOUR_STANDALONE)
42 /* tell the CPU that we will support SSE */
43 wrcr(cr4
, rdcr(cr4
) | (3 << 9));
44 /* Clear the EM and MP flags of CR0 */
45 wrcr(cr0
, rdcr(cr0
) & ~6);
48 #ifdef USE_LEGACY_8087
49 KernelBase
->kb_ContextFlags
= ECF_FPU
|ECF_FPX
;
50 KernelBase
->kb_ContextSize
+= SIZEOF_8087_FRAME
; /* Legacy 8087 frame with private portion */
52 KernelBase
->kb_ContextFlags
= ECF_FPX
;
54 KernelBase
->kb_ContextSize
+= sizeof(struct FPXContext
) + 15; /* Add 15 bytes for alignment */
61 KernelBase
->kb_ContextFlags
= ECF_FPU
;
62 KernelBase
->kb_ContextSize
+= SIZEOF_8087_FRAME
;
65 D(bug("[Kernel] CPU context flags: 0x%08X\n", KernelBase
->kb_ContextFlags
));
70 ADD2INITLIB(cpu_Init
, 5);