2001-04-10 05:04:59 +04:00
|
|
|
/*---------------------------------------------------------------------------+
|
|
|
|
| fpu_system.h |
|
2003-08-01 01:07:38 +04:00
|
|
|
| $Id: fpu_system.h,v 1.14 2003-07-31 21:07:38 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-07-25 12:59:46 +04:00
|
|
|
extern unsigned fpu_get_user(bx_address ptr, unsigned len) BX_CPP_AttrRegparmN(2);
|
|
|
|
extern void fpu_put_user(unsigned val, bx_address ptr, unsigned len) BX_CPP_AttrRegparmN(2);
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2003-07-25 12:59:46 +04:00
|
|
|
extern void fpu_verify_area(unsigned what, bx_address ptr, unsigned n) BX_CPP_AttrRegparmN(3);
|
|
|
|
extern void math_emulate_init(void);
|
2001-04-10 05:04:59 +04:00
|
|
|
extern unsigned fpu_get_ds(void);
|
|
|
|
extern void fpu_set_ax(u16);
|
|
|
|
|
|
|
|
#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-08-01 01:07:38 +04:00
|
|
|
#define FPU_partial_status (i387.swd)
|
|
|
|
#define FPU_control_word (i387.cwd)
|
|
|
|
#define FPU_tag_word (i387.twd)
|
|
|
|
#define FPU_registers (i387.st_space)
|
|
|
|
#define FPU_tos (i387.tos)
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2003-08-01 01:07:38 +04:00
|
|
|
#define FPU_register_base ((u_char *) FPU_registers)
|
|
|
|
|
|
|
|
#define FPU_instruction_address (*(struct address *)&i387.fip)
|
|
|
|
#define FPU_operand_address (*(struct address *)&i387.foo)
|
2001-04-10 05:04:59 +04:00
|
|
|
|
2003-07-25 12:59:46 +04:00
|
|
|
#define FPU_verify_area(x,y,z) fpu_verify_area(x,(bx_address)(y),z)
|
|
|
|
#define FPU_get_user(val,ptr,len) ((val) = fpu_get_user((ptr), (len)))
|
|
|
|
#define FPU_put_user(val,ptr,len) fpu_put_user((val),(ptr),(len))
|
2001-04-10 05:04:59 +04:00
|
|
|
|
|
|
|
#define FPU_DS (fpu_get_ds())
|
|
|
|
|
2003-07-25 15:44:06 +04:00
|
|
|
/*
|
2003-08-01 01:07:38 +04:00
|
|
|
* Change a pointer to an int, with type conversions that make it legal.
|
2003-07-25 15:44:06 +04:00
|
|
|
* 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))
|
|
|
|
|
|
|
|
/*
|
2003-08-01 01:07:38 +04:00
|
|
|
* Change an int to a pointer, with type conversions that make it legal.
|
2003-07-25 15:44:06 +04:00
|
|
|
* 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:43:09 +04:00
|
|
|
|
2001-04-10 05:04:59 +04:00
|
|
|
#endif
|