1 /* 2 * Copyright (c) 2000-2019 Apple Computer, Inc. All rights reserved. 3 * 4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ 5 * 6 * This file contains Original Code and/or Modifications of Original Code 7 * as defined in and that are subject to the Apple Public Source License 8 * Version 2.0 (the 'License'). You may not use this file except in 9 * compliance with the License. The rights granted to you under the License 10 * may not be used to create, or enable the creation or redistribution of, 11 * unlawful or unlicensed copies of an Apple operating system, or to 12 * circumvent, violate, or enable the circumvention or violation of, any 13 * terms of an Apple operating system software license agreement. 14 * 15 * Please obtain a copy of the License at 16 * http://www.opensource.apple.com/apsl/ and read it before using this file. 17 * 18 * The Original Code and all software distributed under the License are 19 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 22 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 23 * Please see the License for the specific language governing rights and 24 * limitations under the License. 25 * 26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ 27 */ 28 /* 29 * Copyright (c) 1992 NeXT Computer, Inc. 30 * 31 * Intel386 Family: Segment descriptors. 32 * 33 * HISTORY 34 * 35 * 29 March 1992 ? at NeXT 36 * Created. 37 */ 38 39 /* 40 * Code segment descriptor. 41 */ 42 43 typedef struct code_desc { 44 unsigned short limit00; 45 unsigned short base00; 46 unsigned char base16; 47 unsigned char type :5, 48 #define DESC_CODE_EXEC 0x18 49 #define DESC_CODE_READ 0x1a 50 dpl :2, 51 present :1; 52 unsigned char limit16 :4, 53 :1, 54 Lflag :1, 55 opsz :1, 56 #define DESC_CODE_16B 0 57 #define DESC_CODE_32B 1 58 granular:1; 59 #define DESC_GRAN_BYTE 0 60 #define DESC_GRAN_PAGE 1 61 unsigned char base24; 62 } code_desc_t; 63 64 /* 65 * Data segment descriptor. 66 */ 67 68 typedef struct data_desc { 69 unsigned short limit00; 70 unsigned short base00; 71 unsigned char base16; 72 unsigned char type :5, 73 #define DESC_DATA_RONLY 0x10 74 #define DESC_DATA_WRITE 0x12 75 dpl :2, 76 present :1; 77 unsigned char limit16 :4, 78 :2, 79 stksz :1, 80 #define DESC_DATA_16B 0 81 #define DESC_DATA_32B 1 82 granular:1; 83 unsigned char base24; 84 } data_desc_t; 85 86 /* 87 * LDT segment descriptor. 88 */ 89 90 typedef struct ldt_desc { 91 unsigned short limit00; 92 unsigned short base00; 93 unsigned char base16; 94 unsigned char type :5, 95 #define DESC_LDT 0x02 96 :2, 97 present :1; 98 unsigned char limit16 :4, 99 :3, 100 granular:1; 101 unsigned char base24; 102 } ldt_desc_t; 103 104 #include <architecture/i386/sel.h> 105 106 /* 107 * Call gate descriptor. 108 */ 109 110 typedef struct call_gate { 111 unsigned short offset00; 112 sel_t seg; 113 unsigned int argcnt :5, 114 :3, 115 type :5, 116 #define DESC_CALL_GATE 0x0c 117 dpl :2, 118 present :1, 119 offset16:16; 120 } call_gate_t; 121 122 /* 123 * Trap gate descriptor. 124 */ 125 126 typedef struct trap_gate { 127 unsigned short offset00; 128 sel_t seg; 129 unsigned int :8, 130 type :5, 131 #define DESC_TRAP_GATE 0x0f 132 dpl :2, 133 present :1, 134 offset16:16; 135 } trap_gate_t; 136 137 138 /* 139 * Interrupt gate descriptor. 140 */ 141 142 typedef struct intr_gate { 143 unsigned short offset00; 144 sel_t seg; 145 unsigned int :8, 146 type :5, 147 #define DESC_INTR_GATE 0x0e 148 dpl :2, 149 present :1, 150 offset16:16; 151 } intr_gate_t; 152