ldt-i386.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /*
  2. * Copyright (C) 2004 Fujitsu Siemens Computers GmbH
  3. * Licensed under the GPL
  4. *
  5. * Author: Bodo Stroesser <bstroesser@fujitsu-siemens.com>
  6. */
  7. #ifndef __ASM_LDT_I386_H
  8. #define __ASM_LDT_I386_H
  9. #include "asm/semaphore.h"
  10. #include "asm/arch/ldt.h"
  11. struct mmu_context_skas;
  12. extern void ldt_host_info(void);
  13. extern long init_new_ldt(struct mmu_context_skas * to_mm,
  14. struct mmu_context_skas * from_mm);
  15. extern void free_ldt(struct mmu_context_skas * mm);
  16. #define LDT_PAGES_MAX \
  17. ((LDT_ENTRIES * LDT_ENTRY_SIZE)/PAGE_SIZE)
  18. #define LDT_ENTRIES_PER_PAGE \
  19. (PAGE_SIZE/LDT_ENTRY_SIZE)
  20. #define LDT_DIRECT_ENTRIES \
  21. ((LDT_PAGES_MAX*sizeof(void *))/LDT_ENTRY_SIZE)
  22. struct ldt_entry {
  23. __u32 a;
  24. __u32 b;
  25. };
  26. typedef struct uml_ldt {
  27. int entry_count;
  28. struct semaphore semaphore;
  29. union {
  30. struct ldt_entry * pages[LDT_PAGES_MAX];
  31. struct ldt_entry entries[LDT_DIRECT_ENTRIES];
  32. } u;
  33. } uml_ldt_t;
  34. /*
  35. * macros stolen from include/asm-i386/desc.h
  36. */
  37. #define LDT_entry_a(info) \
  38. ((((info)->base_addr & 0x0000ffff) << 16) | ((info)->limit & 0x0ffff))
  39. #define LDT_entry_b(info) \
  40. (((info)->base_addr & 0xff000000) | \
  41. (((info)->base_addr & 0x00ff0000) >> 16) | \
  42. ((info)->limit & 0xf0000) | \
  43. (((info)->read_exec_only ^ 1) << 9) | \
  44. ((info)->contents << 10) | \
  45. (((info)->seg_not_present ^ 1) << 15) | \
  46. ((info)->seg_32bit << 22) | \
  47. ((info)->limit_in_pages << 23) | \
  48. ((info)->useable << 20) | \
  49. 0x7000)
  50. #define LDT_empty(info) (\
  51. (info)->base_addr == 0 && \
  52. (info)->limit == 0 && \
  53. (info)->contents == 0 && \
  54. (info)->read_exec_only == 1 && \
  55. (info)->seg_32bit == 0 && \
  56. (info)->limit_in_pages == 0 && \
  57. (info)->seg_not_present == 1 && \
  58. (info)->useable == 0 )
  59. #endif