home *** CD-ROM | disk | FTP | other *** search
/ Piper's Pit BBS/FTP: ibm 0010 - 0019 / ibm0010-0019 / ibm0010.tar / ibm0010 / UNIX3862.ZIP / U386-06.ZIP / U386-6.TD0 / usr / include / sys / seg.h < prev    next >
Encoding:
C/C++ Source or Header  |  1988-06-26  |  5.9 KB  |  155 lines

  1. /*    Copyright (c) 1984, 1986, 1987, 1988 AT&T    */
  2. /*      All Rights Reserved      */
  3.  
  4. /*    THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF AT&T    */
  5. /*    The copyright notice above does not evidence any       */
  6. /*    actual or intended publication of such source code.    */
  7.  
  8. /*    Copyright (c) 1987, 1988 Microsoft Corporation    */
  9. /*      All Rights Reserved    */
  10.  
  11. /*    This Module contains Proprietary Information of Microsoft  */
  12. /*    Corporation and should be treated as Confidential.       */
  13.  
  14. #ident    "@(#)head.sys:seg.h    1.5.1.2"
  15.  
  16. /*
  17.  * The segment structure is prototype and place holder for segment descriptors
  18.  * s_base contains the 32 bit base field of the descriptor.
  19.  * s_limacc contains 20 limit bits and 12 accbits in this order
  20.  *
  21.  * 0                      19  20  21      22   23   24  25,26 27-31
  22.  * _____________________________________________________________________________
  23.  * |                                                                           |
  24.  * |   20 bit limit field   | G | B or D | 0 | AVL | P | DPL | Other Attributes|
  25.  * |___________________________________________________________________________|
  26.  * 
  27.  *    The structure gets fixed up at run time to look like a descriptor
  28.  *
  29.  */
  30.  
  31. /* segment */
  32. struct seg_desc {
  33.     unsigned long s_base;    /* segment base */
  34.     unsigned long s_limacc;    /* 4 limit and access bytes */
  35. };
  36.  
  37. /* descriptor */
  38. struct dscr {
  39.     unsigned int    a_lim0015:16,
  40.              a_base0015:16,
  41.               a_base1623:8,
  42.             a_acc0007:8,
  43.             a_lim1619:4,
  44.             a_acc0811:4,
  45.             a_base2431:8;
  46. };
  47.  
  48. /* access rights for data segments */ 
  49. #define UDATA_ACC1    0xF2     /* present dpl=3 writable */
  50. #define KDATA_ACC1    0x92    /* present dpl=0 writable */
  51. #define DATA_ACC2    0xC    /* 4Kbyte gran. 4Gb limit avl=0 */
  52. #define DATA_ACC2_S    0x4    /* 1 byte gran., 32bit operands, avl=0 */
  53. #define UTEXT_ACC1    0xFA     /* present dpl=3 readable */
  54. #define KTEXT_ACC1    0x9A     /* present dpl=0 readable */
  55. #define TEXT_ACC2    0xC    /* 4Kbyte gran., 32 bit operands avl=0 */
  56. #define TEXT_ACC2_S    0x4    /* 1 byte gran., 32 bit operands avl=0 */
  57. #define LDT_UACC1    0xE2    /* present dpl=3 type=ldt */
  58. #define LDT_KACC1    0x82    /* present dpl=0 type=ldt */
  59. #define LDT_ACC2    0x0    /* G=0 avl=0*/
  60. #define TSS3_KACC1    0x89     /* present dpl=0 type=available 386 TSS */
  61. #define TSS3_KBACC1     0x8B    /* present dpl=0 type=busy 386 TSS      */
  62. #define    TSS2_KACC1    0x81     /* present dpl=0 type=available 286 TSS */
  63. #define TSS3_UACC1    0xE9     /* present dpl=3 type=available 386 TSS */
  64. #define TGATE_UACC1     0xE5    /* present dpl=3 type=task gate         */
  65. #define    TSS2_UACC1    0xE1     /* present dpl=3 type=available 286 TSS */
  66. #define TSS_ACC2    0x0    /* g=0 avl=0 */
  67. #define SEG_CONFORM    0X4    /* conforming bit in acc0007 */
  68.  
  69. #define MKDSCR(base, limit, acc1, acc2) {(long)base, ((long)limit|(acc2<<20)|(acc1<<24))}
  70.  
  71. /* selector definitions */
  72. /*#define LDTSEL        0x58    /* LDT for the current process */
  73. #define LDTSEL        0x140    /* LDT for the current process */
  74. /*#define UTSSSEL        0x60    /* TSS for the current process */
  75. #define UTSSSEL        0x148    /* TSS for the current process */
  76. /*#define KTSSSEL     0x68    /* TSS for the scheduler */
  77. #define KTSSSEL     0x150    /* TSS for the scheduler */
  78. /*#define KCSSEL        0x70    /* kernel code segment selector */
  79. #define KCSSEL        0x158    /* kernel code segment selector */
  80. /*#define KDSSEL        0x78    /* kernel data segment selector */
  81. #define KDSSEL        0x160    /* kernel data segment selector */
  82. /*#define DFTSSSEL    0x80    /* TSS for double fault handler */
  83. #define DFTSSSEL    0x168    /* TSS for double fault handler */
  84. /*#define JTSSSEL        0x88    /* Junk TSS to jump thru */
  85. #define JTSSSEL        0x170
  86. #define MON1SEL        0x178    /* Selector to get to monitor int 1 handler */
  87. #define MON3SEL        0x180    /* Selector to get to monitor int 3 handler */
  88. #define FPESEL        0x193    /* Selector for the FP emulator image */
  89. #define XTSSSEL         0x188   /* XTSS for dual-mode processes */
  90. #define GRANBIT        0x8    /* bit in acc0811 for granularity */
  91.  
  92. /* user selectors */
  93. #define    USER_CS        0x17    /* user's code segment */
  94. #define    USER_DS        0x1F    /* user's data segment */
  95. #define    USER_SCALL    0x07    /* call gate for system calls */
  96. #define    USER_SIGCALL    0x0F    /* call gate for sigreturn */
  97. #define USER_FPSTK    0x27    /* alias 32 bit stack selector for emulator */
  98. #define USER_FP        0x2F    /* selector for fp emulator to u area */
  99. #define CSALIAS_SEL    0x37    /* CS alias selector for USER_DS (for XENIX */
  100.                 /*     execseg()/unexecseg() system calls). */
  101.  
  102. #define IDTSZ        256
  103. #define MONIDTSZ    16
  104. #define MINLDTSZ        256    /* initial index of ldt */
  105. #define MAXLDTSZ        8192    /* maximum index of ldt */
  106. #define GDTSZ           90
  107. #define SEL_LDT        4    /* mask to determine if sel is GDT or LDT */
  108.  
  109. #define KTBASE          0xC0008000
  110. #define KDBASE          0xC0068000
  111.  
  112. /*
  113.  *  Call/Interrupt/Trap Gate table descriptions
  114.  *
  115.  *    This is the structure used for declaration of Gates.
  116.  *    If this is changed in any way, the code in uprt.s
  117.  *    must be changed to match.  It is especially important
  118.  *    that the type byte be in the last position so that the
  119.  *    real mode start up code can determine if the gate is
  120.  *    intended to be a gate or segment descriptor.
  121.  */
  122.  
  123. struct gate_desc {
  124.     unsigned long  g_off;        /* offset */
  125.     unsigned short g_sel;        /* selector */
  126.     unsigned char  g_wcount;    /* word count */
  127.     unsigned char  g_type;        /* type of gate and access rights */
  128. };
  129.  
  130. /* ...and the way the hardware sees it */
  131.  
  132. struct gdscr {
  133.     unsigned int    gd_off0015:16,
  134.              gd_selector:16,
  135.             gd_unused:8,
  136.             gd_acc0007:8,
  137.             gd_off1631:16;
  138. };
  139.  
  140. /* access rights field for gates */
  141.  
  142. #define GATE_UACC    0xE0        /* present and dpl = 3 */
  143. #define GATE_KACC    0x80        /* present and dpl = 0 */
  144. #define GATE_386CALL    0xC        /* 386 call gate */
  145. #define GATE_386INT    0xE        /* 386 int gate */
  146. #define GATE_386TRP    0xF        /* 386 trap gate */
  147. #define GATE_TSS    0x5        /* Task gate */
  148.  
  149. /* make an interrupt gate */
  150. #define MKINTG(rtn) {(long)rtn,(short)KCSSEL,(char)0,(char)(GATE_KACC|GATE_386INT)} 
  151. #define MKKTRPG(rtn) {(long)rtn,(short)KCSSEL,(char)0,(char)(GATE_KACC|GATE_386TRP)} 
  152. #define MKUTRPG(rtn) {(long)rtn,(short)KCSSEL,(char)0,(char)(GATE_UACC|GATE_386TRP)} 
  153.  
  154. #define    seltoi(sel)        ((unsigned short)(sel) >> 3)
  155.