1/**
2 * \file
3 * \brief FPU accessor functions.
4 */
5
6/*
7 * Copyright (c) 2010, 2011, ETH Zurich.
8 * All rights reserved.
9 *
10 * This file is distributed under the terms in the attached LICENSE file.
11 * If you do not find this file, copies can be found by writing to:
12 * ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group.
13 */
14
15#ifndef X86_32_FPU_H
16#define X86_32_FPU_H
17
18/// Exception number for FPU (device) not available
19#define FPU_UNAVAILABLE_TRAP    7
20
21static inline
22// XXX: workaround utterly bizarre compiler bug in gcc 4.5.3 (possibly others)
23// the src and dst arguments were getting swapped in the call to this function
24#if defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ == 5
25__attribute__((always_inline))
26#endif
27void fpu_copy(struct registers_fpu_x86_32 *dst,
28              struct registers_fpu_x86_32 *src)
29{
30    // XXX: Round to next 16-byte boundary
31    uint8_t *dregs = dst->registers, *sregs = src->registers;
32    dregs += 16 - ((uintptr_t)dregs % 16);
33    sregs += 16 - ((uintptr_t)sregs % 16);
34
35    memcpy(dregs, sregs, 512);
36}
37
38#endif
39