2001-04-10 05:04:59 +04:00
|
|
|
/*---------------------------------------------------------------------------+
|
|
|
|
| fpu_system.h |
|
2003-04-20 23:20:08 +04:00
|
|
|
| $Id: fpu_system.h,v 1.9 2003-04-20 19:20:07 sshwarts Exp $
|
2001-04-10 05:04:59 +04:00
|
|
|
| |
|
|
|
|
| Copyright (C) 1992,1994,1997 |
|
|
|
|
| W. Metzenthen, 22 Parker St, Ormond, Vic 3163, |
|
|
|
|
| Australia. E-mail billm@suburbia.net |
|
|
|
|
| |
|
|
|
|
+---------------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
#ifndef _FPU_SYSTEM_H
|
|
|
|
#define _FPU_SYSTEM_H
|
|
|
|
|
2003-04-13 01:02:08 +04:00
|
|
|
/* Get data sizes from config.h generated from simulator's
|
|
|
|
* configure script
|
|
|
|
*/
|
|
|
|
#include "config.h"
|
|
|
|
typedef Bit8u u8; /* for FPU only */
|
|
|
|
typedef Bit8s s8;
|
|
|
|
typedef Bit16u u16;
|
|
|
|
typedef Bit16s s16;
|
|
|
|
typedef Bit32u u32;
|
|
|
|
typedef Bit32s s32;
|
|
|
|
typedef Bit64u u64;
|
|
|
|
typedef Bit64s s64;
|
2001-04-10 05:04:59 +04:00
|
|
|
|
|
|
|
/* -----------------------------------------------------------
|
|
|
|
* Slimmed down version used to compile against a CPU simulator
|
|
|
|
* rather than a kernel (ported by Kevin Lawton)
|
|
|
|
* ------------------------------------------------------------ */
|
|
|
|
|
2002-09-09 20:11:25 +04:00
|
|
|
#include <cpu/i387.h>
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2001-04-10 05:43:09 +04:00
|
|
|
/* bbd: include ported linux headers after config.h for GCC_ATTRIBUTE macro */
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/mm.h>
|
|
|
|
#include <linux/types.h>
|
|
|
|
|
2001-04-10 05:04:59 +04:00
|
|
|
#ifndef WORDS_BIGENDIAN
|
|
|
|
#error "WORDS_BIGENDIAN not defined in config.h"
|
|
|
|
#elif WORDS_BIGENDIAN == 1
|
|
|
|
#define EMU_BIG_ENDIAN 1
|
|
|
|
#else
|
|
|
|
/* Nothing needed. Lack of defining EMU_BIG_ENDIAN means
|
|
|
|
* small endian
|
|
|
|
*/
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2003-03-03 02:59:12 +03:00
|
|
|
extern unsigned fpu_get_user(void *ptr, unsigned len) BX_CPP_AttrRegparmN(2);
|
|
|
|
extern void fpu_put_user(unsigned val, void *ptr, unsigned len) BX_CPP_AttrRegparmN(2);
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2003-03-03 02:59:12 +03:00
|
|
|
extern void fpu_verify_area(unsigned what, void *ptr, unsigned n) BX_CPP_AttrRegparmN(3);
|
2001-04-10 05:04:59 +04:00
|
|
|
extern unsigned fpu_get_ds(void);
|
|
|
|
extern void fpu_set_ax(u16);
|
|
|
|
|
|
|
|
#ifndef __ASSEMBLY__
|
|
|
|
|
|
|
|
struct info {
|
2001-04-10 05:43:09 +04:00
|
|
|
#ifdef BX_NO_EMPTY_STRUCTS
|
|
|
|
unsigned char donotindexme;
|
|
|
|
#endif
|
2001-04-10 05:04:59 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
#define FPU_info ((struct info *) NULL)
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define SIGSEGV 11
|
|
|
|
|
2003-04-13 01:02:08 +04:00
|
|
|
extern struct i387_t *current_i387;
|
2002-09-09 20:11:25 +04:00
|
|
|
|
|
|
|
#define i387 (*current_i387)
|
2001-04-10 05:04:59 +04:00
|
|
|
|
|
|
|
#define SET_AX(val16) fpu_set_ax(val16);
|
|
|
|
|
2003-04-13 01:02:08 +04:00
|
|
|
#define no_ip_update (*(u_char *)&(i387.no_update))
|
|
|
|
#define FPU_rm (*(u_char *)&(i387.rm))
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2003-04-13 01:02:08 +04:00
|
|
|
#define partial_status (i387.swd)
|
|
|
|
#define control_word (i387.cwd)
|
|
|
|
#define fpu_tag_word (i387.twd)
|
|
|
|
#define registers (i387.st_space)
|
|
|
|
#define top (i387.tos)
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2003-04-13 01:02:08 +04:00
|
|
|
#define instruction_address (*(struct address *)&i387.fip)
|
|
|
|
#define operand_address (*(struct address *)&i387.foo)
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2003-04-16 22:38:53 +04:00
|
|
|
#define FPU_verify_area(x,y,z) fpu_verify_area((x),(y),(z))
|
2001-04-10 05:04:59 +04:00
|
|
|
#define FPU_get_user(x,y) ((x) = fpu_get_user((y), sizeof(*(y))))
|
|
|
|
#define FPU_put_user(val,ptr) fpu_put_user((val),(ptr),sizeof(*(ptr)))
|
|
|
|
|
|
|
|
#define FPU_DS (fpu_get_ds())
|
|
|
|
|
2001-04-10 05:43:09 +04:00
|
|
|
// bbd: Change a pointer to an int, with type conversions that make it legal.
|
|
|
|
// First make it a void pointer, then convert to an integer of the same
|
|
|
|
// size as the pointer. Otherwise, on machines with 64-bit pointers,
|
|
|
|
// compilers complain when you typecast a 64-bit pointer into a 32-bit integer.
|
|
|
|
#define PTR2INT(x) ((bx_ptr_equiv_t)(void *)(x))
|
|
|
|
|
|
|
|
// bbd: Change an int to a pointer, with type conversions that make it legal.
|
|
|
|
// Same strategy as PTR2INT: change to bx_ptr_equiv_t which is an integer
|
|
|
|
// type of the same size as FPU_REG*. Then the conversion to pointer
|
|
|
|
// is legal.
|
|
|
|
#define REGNO2PTR(x) ((FPU_REG*)((bx_ptr_equiv_t)(x)))
|
|
|
|
|
2001-04-10 05:04:59 +04:00
|
|
|
#endif
|