processor_32.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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. #define STACKSLOTS_PER_LINE 8
  30. static inline void arch_flush_thread(struct arch_thread *thread)
  31. {
  32. /* Clear any TLS still hanging */
  33. memset(&thread->tls_array, 0, sizeof(thread->tls_array));
  34. }
  35. static inline void arch_copy_thread(struct arch_thread *from,
  36. struct arch_thread *to)
  37. {
  38. memcpy(&to->tls_array, &from->tls_array, sizeof(from->tls_array));
  39. }
  40. /*
  41. * Default implementation of macro that returns current
  42. * instruction pointer ("program counter"). Stolen
  43. * from asm-i386/processor.h
  44. */
  45. #define current_text_addr() \
  46. ({ void *pc; __asm__("movl $1f,%0\n1:":"=g" (pc)); pc; })
  47. #define current_sp() ({ void *sp; __asm__("movl %%esp, %0" : "=r" (sp) : ); sp; })
  48. #define current_bp() ({ unsigned long bp; __asm__("movl %%ebp, %0" : "=r" (bp) : ); bp; })
  49. #endif