2 Copyright © 1995-2014, The AROS Development Team. All rights reserved.
6 #include <aros/kernel.h>
7 #include <aros/libcall.h>
8 #include <aros/i386/cpucontext.h>
10 #include <kernel_base.h>
11 #include <kernel_objects.h>
13 #ifndef SIZEOF_8087_FRAME
14 #define SIZEOF_8087_FRAME sizeof(struct FPUContext)
17 AROS_LH0(void *, KrnCreateContext
,
18 struct KernelBase
*, KernelBase
, 18, Kernel
)
23 struct ExceptionContext
*ctx
;
26 * Allocate common data block and FPU data block in one chunk.
27 * On native ports AROSCPUContext can be simply #define'd to ExceptionContext,
28 * so we refer struct AROSCPUContext only for size calculation.
30 ctx
= krnAllocCPUContext();
33 IPTR fpdata
= (IPTR
)ctx
+ sizeof(struct AROSCPUContext
);
35 ctx
->Flags
= KernelBase
->kb_ContextFlags
; /* kb_ContextFlags on i386 hold only FPU bits */
36 ctx
->eflags
= 0x3202; /* Set up default values for some registers */
38 /* These definitions may come from machine-specific kernel_cpu.h */
40 ctx
->Flags
|= ECF_SEGMENTS
;
49 if (!KernelBase
->kb_ContextFlags
)
51 /* Don't do any of the following if we don't support FPU at all */
55 if (ctx
->Flags
& ECF_FPU
)
57 ctx
->FPData
= (struct FPUContext
*)fpdata
;
58 fpdata
+= SIZEOF_8087_FRAME
;
61 if (ctx
->Flags
& ECF_FPX
)
63 UBYTE current_xmm
[512+15];
64 UBYTE
*curr
= (UBYTE
*)(((IPTR
)current_xmm
+ 15) & ~15);
66 fpdata
= (fpdata
+ 15) & ~15;
67 ctx
->FXData
= (struct FPXContext
*)fpdata
;
78 ::"r"(curr
), "r"(ctx
->FXData
), "r"(ctx
->FPData
):"cc");
80 else if (ctx
->Flags
& ECF_FPU
)
84 /* fnsave implies fninit, so we don't need to do it explicitly */
89 ::"r"(curr
), "r"(ctx
->FPData
):"cc");