1 #include <aros/kernel.h>
2 #include <aros/libcall.h>
3 #include <aros/i386/cpucontext.h>
5 #include <kernel_base.h>
6 #include <kernel_objects.h>
8 #ifndef SIZEOF_8087_FRAME
9 #define SIZEOF_8087_FRAME sizeof(struct FPUContext)
12 AROS_LH0(void *, KrnCreateContext
,
13 struct KernelBase
*, KernelBase
, 18, Kernel
)
18 struct ExceptionContext
*ctx
;
21 * Allocate common data block and FPU data block in one chunk.
22 * On native ports AROSCPUContext can be simply #define'd to ExceptionContext,
23 * so we refer struct AROSCPUContext only for size calculation.
25 ctx
= krnAllocCPUContext();
28 IPTR fpdata
= (IPTR
)ctx
+ sizeof(struct AROSCPUContext
);
30 ctx
->Flags
= KernelBase
->kb_ContextFlags
; /* kb_ContextFlags on i386 hold only FPU bits */
31 ctx
->eflags
= 0x3202; /* Set up default values for some registers */
33 /* These definitions may come from machine-specific kernel_cpu.h */
35 ctx
->Flags
|= ECF_SEGMENTS
;
44 if (!KernelBase
->kb_ContextFlags
)
46 /* Don't do any of the following if we don't support FPU at all */
50 if (ctx
->Flags
& ECF_FPU
)
52 ctx
->FPData
= (struct FPUContext
*)fpdata
;
53 fpdata
+= SIZEOF_8087_FRAME
;
56 if (ctx
->Flags
& ECF_FPX
)
58 UBYTE current_xmm
[512+15];
59 UBYTE
*curr
= (UBYTE
*)(((IPTR
)current_xmm
+ 15) & ~15);
61 fpdata
= (fpdata
+ 15) & ~15;
62 ctx
->FXData
= (struct FPXContext
*)fpdata
;
73 ::"r"(curr
), "r"(ctx
->FXData
), "r"(ctx
->FPData
):"cc");
75 else if (ctx
->Flags
& ECF_FPU
)
79 /* fnsave implies fninit, so we don't need to do it explicitly */
84 ::"r"(curr
), "r"(ctx
->FPData
):"cc");