revert between 56095 -> 55830 in arch
[AROS.git] / arch / i386-all / kernel / cpu_init.c
blobc0633b3403e03cea3cf45bf5fc2ca55fdb9520fd
1 /*
2 Copyright © 1995-2014, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #include <aros/config.h>
7 #include <aros/symbolsets.h>
8 #include <asm/cpu.h>
9 #include <exec/types.h>
10 #include <aros/i386/cpucontext.h>
12 #include "kernel_base.h"
13 #include "kernel_debug.h"
15 #define D(x)
17 #ifndef SIZEOF_8087_FRAME
18 #define SIZEOF_8087_FRAME sizeof(struct FPUContext)
19 #endif
21 static int cpu_Init(struct KernelBase *KernelBase)
23 ULONG v1, v2, v3, v4;
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));
32 if (v4 & (1 << 24))
34 switch ((v4 >> 25) & 3)
36 case 3:
37 case 2:
38 case 1:
39 /* FPU + SSE */
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);
46 #endif
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 */
51 #else
52 KernelBase->kb_ContextFlags = ECF_FPX;
53 #endif
54 KernelBase->kb_ContextSize += sizeof(struct FPXContext) + 15; /* Add 15 bytes for alignment */
55 break;
58 else
60 /* FPU only */
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));
67 return TRUE;
70 ADD2INITLIB(cpu_Init, 5);