Rev 827 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 827 | Rev 906 | ||
---|---|---|---|
Line 32... | Line 32... | ||
32 | #include <cpu.h> |
32 | #include <cpu.h> |
33 | 33 | ||
34 | /** Save FPU (mmx, sse) context using fxsave instruction */ |
34 | /** Save FPU (mmx, sse) context using fxsave instruction */ |
35 | void fpu_context_save(fpu_context_t *fctx) |
35 | void fpu_context_save(fpu_context_t *fctx) |
36 | { |
36 | { |
37 | /* Align on 16-byte boundary */ |
- | |
38 | if (((__u64)fctx) & 0xf) |
- | |
39 | fctx = (fpu_context_t *)((((__u64)fctx) | 0xf) + 1); |
- | |
40 | - | ||
41 | __asm__ volatile ( |
37 | __asm__ volatile ( |
42 | "fxsave %0" |
38 | "fxsave %0" |
43 | : "=m"(*fctx) |
39 | : "=m"(*fctx) |
44 | ); |
40 | ); |
45 | } |
41 | } |
46 | 42 | ||
47 | /** Restore FPU (mmx,sse) context using fxrstor instruction */ |
43 | /** Restore FPU (mmx,sse) context using fxrstor instruction */ |
48 | void fpu_context_restore(fpu_context_t *fctx) |
44 | void fpu_context_restore(fpu_context_t *fctx) |
49 | { |
45 | { |
50 | /* Align on 16-byte boundary */ |
- | |
51 | if (((__u64)fctx) & 0xf) |
- | |
52 | fctx = (fpu_context_t *)((((__u64)fctx) | 0xf) + 1); |
- | |
53 | __asm__ volatile ( |
46 | __asm__ volatile ( |
54 | "fxrstor %0" |
47 | "fxrstor %0" |
55 | : "=m"(*fctx) |
48 | : "=m"(*fctx) |
56 | ); |
49 | ); |
57 | } |
50 | } |
58 | 51 | ||
59 | void fpu_init(fpu_context_t *fctx) |
52 | void fpu_init() |
60 | { |
53 | { |
61 | /* TODO: Zero all SSE, MMX etc. registers */ |
54 | /* TODO: Zero all SSE, MMX etc. registers */ |
62 | __asm__ volatile ( |
55 | __asm__ volatile ( |
63 | "fninit;" |
56 | "fninit;" |
64 | ); |
57 | ); |