processor.h 1.8 KB

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