processor-i386.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /*
  2. * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
  3. * Licensed under the GPL
  4. */
  5. #ifndef __UM_PROCESSOR_I386_H
  6. #define __UM_PROCESSOR_I386_H
  7. #include "linux/string.h"
  8. #include "asm/host_ldt.h"
  9. #include "asm/segment.h"
  10. extern int host_has_xmm;
  11. extern int host_has_cmov;
  12. /* include faultinfo structure */
  13. #include "sysdep/faultinfo.h"
  14. struct uml_tls_struct {
  15. struct user_desc tls;
  16. unsigned flushed:1;
  17. unsigned present:1;
  18. };
  19. struct arch_thread {
  20. struct uml_tls_struct tls_array[GDT_ENTRY_TLS_ENTRIES];
  21. unsigned long debugregs[8];
  22. int debugregs_seq;
  23. struct faultinfo faultinfo;
  24. };
  25. #define INIT_ARCH_THREAD { \
  26. .tls_array = { [ 0 ... GDT_ENTRY_TLS_ENTRIES - 1 ] = \
  27. { .present = 0, .flushed = 0 } }, \
  28. .debugregs = { [ 0 ... 7 ] = 0 }, \
  29. .debugregs_seq = 0, \
  30. .faultinfo = { 0, 0, 0 } \
  31. }
  32. static inline void arch_flush_thread(struct arch_thread *thread)
  33. {
  34. /* Clear any TLS still hanging */
  35. memset(&thread->tls_array, 0, sizeof(thread->tls_array));
  36. }
  37. static inline void arch_copy_thread(struct arch_thread *from,
  38. struct arch_thread *to)
  39. {
  40. memcpy(&to->tls_array, &from->tls_array, sizeof(from->tls_array));
  41. }
  42. #include "asm/arch/user.h"
  43. /* REP NOP (PAUSE) is a good thing to insert into busy-wait loops. */
  44. static inline void rep_nop(void)
  45. {
  46. __asm__ __volatile__("rep;nop": : :"memory");
  47. }
  48. #define cpu_relax() rep_nop()
  49. /*
  50. * Default implementation of macro that returns current
  51. * instruction pointer ("program counter"). Stolen
  52. * from asm-i386/processor.h
  53. */
  54. #define current_text_addr() \
  55. ({ void *pc; __asm__("movl $1f,%0\n1:":"=g" (pc)); pc; })
  56. #define ARCH_IS_STACKGROW(address) \
  57. (address + 32 >= UPT_SP(&current->thread.regs.regs))
  58. #define KSTK_EIP(tsk) KSTK_REG(tsk, EIP)
  59. #define KSTK_ESP(tsk) KSTK_REG(tsk, UESP)
  60. #define KSTK_EBP(tsk) KSTK_REG(tsk, EBP)
  61. #include "asm/processor-generic.h"
  62. #endif