home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 15 / 15.iso / s / s053 / 8.ddi / usr / include / sys / seg.h < prev    next >
Encoding:
C/C++ Source or Header  |  1990-12-08  |  5.6 KB  |  152 lines

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