processor_32.h 1.5 KB

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