fpu_system.h
上传用户:lgb322
上传日期:2013-02-24
资源大小:30529k
文件大小:4k
源码类别:

嵌入式Linux

开发平台:

Unix_Linux

  1. /*---------------------------------------------------------------------------+
  2.  |  fpu_system.h                                                             |
  3.  |                                                                           |
  4.  | Copyright (C) 1992,1994,1997                                              |
  5.  |                       W. Metzenthen, 22 Parker St, Ormond, Vic 3163,      |
  6.  |                       Australia.  E-mail   billm@suburbia.net             |
  7.  |                                                                           |
  8.  +---------------------------------------------------------------------------*/
  9. #ifndef _FPU_SYSTEM_H
  10. #define _FPU_SYSTEM_H
  11. /* system dependent definitions */
  12. #include <linux/sched.h>
  13. #include <linux/kernel.h>
  14. #include <linux/mm.h>
  15. /* This sets the pointer FPU_info to point to the argument part
  16.    of the stack frame of math_emulate() */
  17. #define SETUP_DATA_AREA(arg) FPU_info = (struct info *) &arg
  18. #define LDT_DESCRIPTOR(s) (((struct desc_struct *)current->mm->context.segments)[(s) >> 3])
  19. #define SEG_D_SIZE(x) ((x).b & (3 << 21))
  20. #define SEG_G_BIT(x) ((x).b & (1 << 23))
  21. #define SEG_GRANULARITY(x) (((x).b & (1 << 23)) ? 4096 : 1)
  22. #define SEG_286_MODE(x) ((x).b & ( 0xff000000 | 0xf0000 | (1 << 23)))
  23. #define SEG_BASE_ADDR(s) (((s).b & 0xff000000) 
  24.  | (((s).b & 0xff) << 16) | ((s).a >> 16))
  25. #define SEG_LIMIT(s) (((s).b & 0xff0000) | ((s).a & 0xffff))
  26. #define SEG_EXECUTE_ONLY(s) (((s).b & ((1 << 11) | (1 << 9))) == (1 << 11))
  27. #define SEG_WRITE_PERM(s) (((s).b & ((1 << 11) | (1 << 9))) == (1 << 9))
  28. #define SEG_EXPAND_DOWN(s) (((s).b & ((1 << 11) | (1 << 10))) 
  29.  == (1 << 10))
  30. #define I387 (current->thread.i387)
  31. #define FPU_info (I387.soft.info)
  32. #define FPU_CS (*(unsigned short *) &(FPU_info->___cs))
  33. #define FPU_SS (*(unsigned short *) &(FPU_info->___ss))
  34. #define FPU_DS (*(unsigned short *) &(FPU_info->___ds))
  35. #define FPU_EAX (FPU_info->___eax)
  36. #define FPU_EFLAGS (FPU_info->___eflags)
  37. #define FPU_EIP (FPU_info->___eip)
  38. #define FPU_ORIG_EIP (FPU_info->___orig_eip)
  39. #define FPU_lookahead           (I387.soft.lookahead)
  40. /* nz if ip_offset and cs_selector are not to be set for the current
  41.    instruction. */
  42. #define no_ip_update (*(u_char *)&(I387.soft.no_update))
  43. #define FPU_rm (*(u_char *)&(I387.soft.rm))
  44. /* Number of bytes of data which can be legally accessed by the current
  45.    instruction. This only needs to hold a number <= 108, so a byte will do. */
  46. #define access_limit (*(u_char *)&(I387.soft.alimit))
  47. #define partial_status (I387.soft.swd)
  48. #define control_word (I387.soft.cwd)
  49. #define fpu_tag_word (I387.soft.twd)
  50. #define registers (I387.soft.st_space)
  51. #define top (I387.soft.ftop)
  52. #define instruction_address (*(struct address *)&I387.soft.fip)
  53. #define operand_address (*(struct address *)&I387.soft.foo)
  54. #define FPU_verify_area(x,y,z) if ( verify_area(x,y,z) ) 
  55. math_abort(FPU_info,SIGSEGV)
  56. #undef FPU_IGNORE_CODE_SEGV
  57. #ifdef FPU_IGNORE_CODE_SEGV
  58. /* verify_area() is very expensive, and causes the emulator to run
  59.    about 20% slower if applied to the code. Anyway, errors due to bad
  60.    code addresses should be much rarer than errors due to bad data
  61.    addresses. */
  62. #define FPU_code_verify_area(z)
  63. #else
  64. /* A simpler test than verify_area() can probably be done for
  65.    FPU_code_verify_area() because the only possible error is to step
  66.    past the upper boundary of a legal code area. */
  67. #define FPU_code_verify_area(z) FPU_verify_area(VERIFY_READ,(void *)FPU_EIP,z)
  68. #endif
  69. #define FPU_get_user(x,y)       get_user((x),(y))
  70. #define FPU_put_user(x,y)       put_user((x),(y))
  71. #endif