00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041 #ifndef __MACHDEP_SEGMENTS_H__
00042 #define __MACHDEP_SEGMENTS_H__
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054 #define ISRING(s) ((s) & SEL_RPL)
00055 #define RING0 0
00056 #define RING1 1
00057 #define RING2 2
00058 #define RING3 3
00059 #define SEL_RPL 3
00060 #define ISLDT(s) ((s) & SEL_LDT)
00061 #define SEL_LDT 4
00062 #define IDXSEL(s) (((s) >> 3) & 0x1fff)
00063 #define GSEL(s,r) (((s) << 3) | r)
00064 #define LSEL(s,r) (((s) << 3) | r | SEL_LDT)
00065
00066 #if defined(_KERNEL) && !defined(_LKM)
00067 #include "opt_vm86.h"
00068 #endif
00069
00070 #ifdef VM86
00071 #define USERMODE(c, f) (ISPL(c) == SEL_UPL || ((f) & PSL_VM) != 0)
00072 #define KERNELMODE(c, f) (ISPL(c) == SEL_KPL && ((f) & PSL_VM) == 0)
00073 #else
00074 #define USERMODE(c, f) (ISPL(c) == SEL_UPL)
00075 #define KERNELMODE(c, f) (ISPL(c) == SEL_KPL)
00076 #endif
00077
00078 #ifndef __LOCORE__
00079
00080 #if __GNUC__ == 2 && __GNUC_MINOR__ < 7
00081 #pragma pack(1)
00082 #endif
00083
00084
00085
00086
00087 struct segment_descriptor {
00088 unsigned sd_lolimit:16;
00089 unsigned sd_lobase:24;
00090 unsigned sd_type:5;
00091 unsigned sd_dpl:2;
00092 unsigned sd_p:1;
00093 unsigned sd_hilimit:4;
00094 unsigned sd_xx:2;
00095 unsigned sd_def32:1;
00096 unsigned sd_gran:1;
00097 unsigned sd_hibase:8;
00098 } __attribute__((packed));
00099
00100
00101
00102
00103 struct gate_descriptor {
00104 unsigned gd_looffset:16;
00105 unsigned gd_selector:16;
00106 unsigned gd_stkcpy:5;
00107 unsigned gd_xx:3;
00108 unsigned gd_type:5;
00109 unsigned gd_dpl:2;
00110 unsigned gd_p:1;
00111 unsigned gd_hioffset:16;
00112 } __attribute__((packed));
00113
00114
00115
00116
00117 union descriptor {
00118 struct segment_descriptor sd;
00119 struct gate_descriptor gd;
00120 } __attribute__((packed));
00121
00122
00123
00124
00125 struct region_descriptor {
00126 unsigned rd_limit:16;
00127 unsigned rd_base:32;
00128 } __attribute__((packed));
00129
00130 #if __GNUC__ == 2 && __GNUC_MINOR__ < 7
00131 #pragma pack(4)
00132 #endif
00133
00134 #endif
00135
00136
00137 #define SDT_SYSNULL 0
00138 #define SDT_SYS286TSS 1
00139 #define SDT_SYSLDT 2
00140 #define SDT_SYS286BSY 3
00141 #define SDT_SYS286CGT 4
00142 #define SDT_SYSTASKGT 5
00143 #define SDT_SYS286IGT 6
00144 #define SDT_SYS286TGT 7
00145 #define SDT_SYSNULL2 8
00146 #define SDT_SYS386TSS 9
00147 #define SDT_SYSNULL3 10
00148 #define SDT_SYS386BSY 11
00149 #define SDT_SYS386CGT 12
00150 #define SDT_SYSNULL4 13
00151 #define SDT_SYS386IGT 14
00152 #define SDT_SYS386TGT 15
00153
00154
00155 #define SDT_MEMRO 16
00156 #define SDT_MEMROA 17
00157 #define SDT_MEMRW 18
00158 #define SDT_MEMRWA 19
00159 #define SDT_MEMROD 20
00160 #define SDT_MEMRODA 21
00161 #define SDT_MEMRWD 22
00162 #define SDT_MEMRWDA 23
00163 #define SDT_MEME 24
00164 #define SDT_MEMEA 25
00165 #define SDT_MEMER 26
00166 #define SDT_MEMERA 27
00167 #define SDT_MEMEC 28
00168 #define SDT_MEMEAC 29
00169 #define SDT_MEMERC 30
00170 #define SDT_MEMERAC 31
00171
00172
00173 #define ISMEMSDP(s) ((s->d_type) >= SDT_MEMRO && \
00174 (s->d_type) <= SDT_MEMERAC)
00175
00176
00177 #define IS286GDP(s) ((s->d_type) >= SDT_SYS286CGT && \
00178 (s->d_type) < SDT_SYS286TGT)
00179
00180
00181 #define IS386GDP(s) ((s->d_type) >= SDT_SYS386CGT && \
00182 (s->d_type) < SDT_SYS386TGT)
00183
00184
00185 #define ISGDP(s) (IS286GDP(s) || IS386GDP(s))
00186
00187
00188 #define ISSDP(s) (ISMEMSDP(s) || !ISGDP(s))
00189
00190
00191 #define ISSYSSDP(s) (!ISMEMSDP(s) && !ISGDP(s))
00192
00193
00194
00195
00196 #define SEGEX_EXT 0x01
00197 #define SEGEX_IDT 0x02
00198 #define SEGEX_TI 0x04
00199
00200
00201
00202
00203 #define NIDT 256
00204
00205
00206
00207
00208 #define GNULL_IDXSEL 0
00209 #define GCODE_IDXSEL 1
00210 #define GDATA_IDXSEL 2
00211 #define GLDT_IDXSEL 3
00212 #define G1CODE_IDXSEL 4
00213 #define G1DATA_IDXSEL 5
00214 #define G2CODE_IDXSEL 6
00215 #define G2DATA_IDXSEL 7
00216 #define GUCODE_IDXSEL 8
00217 #define GUDATA_IDXSEL 9
00218
00219
00220
00221
00222 #define GBSTRAP_TSS_IDXSEL 15
00223 #define GKERN0_TSS_IDXSEL 16
00224 #define GKERN1_TSS_IDXSEL 17
00225 #define GKERN2_TSS_IDXSEL 18
00226 #define GKERN3_TSS_IDXSEL 19
00227 #define GKERN4_TSS_IDXSEL 20
00228 #define GKERN5_TSS_IDXSEL 21
00229 #define GKERN6_TSS_IDXSEL 22
00230 #define GKERN7_TSS_IDXSEL 23
00231 #define GCORE0_TSS_IDXSEL 24
00232 #define GCORE1_TSS_IDXSEL 25
00233 #define GCORE2_TSS_IDXSEL 26
00234 #define GCORE3_TSS_IDXSEL 27
00235 #define GCORE4_TSS_IDXSEL 28
00236 #define GCORE5_TSS_IDXSEL 29
00237 #define GCORE6_TSS_IDXSEL 30
00238 #define GCORE7_TSS_IDXSEL 31
00239 #define GTRAP0_TSS_IDXSEL 32
00240 #define GTRAP1_TSS_IDXSEL 33
00241 #define GTRAP2_TSS_IDXSEL 34
00242 #define GTRAP3_TSS_IDXSEL 35
00243 #define GTRAP4_TSS_IDXSEL 36
00244 #define GTRAP5_TSS_IDXSEL 37
00245 #define GTRAP6_TSS_IDXSEL 38
00246 #define GTRAP7_TSS_IDXSEL 39
00247 #define GPGFLT0_TSS_IDXSEL 40
00248 #define GPGFLT1_TSS_IDXSEL 41
00249 #define GPGFLT2_TSS_IDXSEL 42
00250 #define GPGFLT3_TSS_IDXSEL 43
00251 #define GPGFLT4_TSS_IDXSEL 44
00252 #define GPGFLT5_TSS_IDXSEL 45
00253 #define GPGFLT6_TSS_IDXSEL 46
00254 #define GPGFLT7_TSS_IDXSEL 47
00255 #define GDBLFLT0_TSS_IDXSEL 48
00256 #define GDBLFLT1_TSS_IDXSEL 49
00257 #define GDBLFLT2_TSS_IDXSEL 50
00258 #define GDBLFLT3_TSS_IDXSEL 51
00259 #define GDBLFLT4_TSS_IDXSEL 52
00260 #define GDBLFLT5_TSS_IDXSEL 53
00261 #define GDBLFLT6_TSS_IDXSEL 54
00262 #define GDBLFLT7_TSS_IDXSEL 55
00263 #define GSTRAY0_TSS_IDXSEL 56
00264 #define GSTRAY1_TSS_IDXSEL 57
00265 #define GSTRAY2_TSS_IDXSEL 58
00266 #define GSTRAY3_TSS_IDXSEL 59
00267 #define GSTRAY4_TSS_IDXSEL 60
00268 #define GSTRAY5_TSS_IDXSEL 61
00269 #define GSTRAY6_TSS_IDXSEL 62
00270 #define GSTRAY7_TSS_IDXSEL 63
00271 #define GBREAKPOINT0_TSS_IDXSEL 64
00272 #define GBREAKPOINT1_TSS_IDXSEL 65
00273 #define GBREAKPOINT2_TSS_IDXSEL 66
00274 #define GBREAKPOINT3_TSS_IDXSEL 67
00275 #define GBREAKPOINT4_TSS_IDXSEL 68
00276 #define GBREAKPOINT5_TSS_IDXSEL 69
00277 #define GBREAKPOINT6_TSS_IDXSEL 70
00278 #define GBREAKPOINT7_TSS_IDXSEL 71
00279 #define GIDLE0_TSS_IDXSEL 72
00280 #define GIDLE1_TSS_IDXSEL 73
00281 #define GIDLE2_TSS_IDXSEL 74
00282 #define GIDLE3_TSS_IDXSEL 75
00283 #define GIDLE4_TSS_IDXSEL 76
00284 #define GIDLE5_TSS_IDXSEL 77
00285 #define GIDLE6_TSS_IDXSEL 78
00286 #define GIDLE7_TSS_IDXSEL 79
00287 #define GSOFTSW0_TSS_IDXSEL 80
00288 #define GSOFTSW1_TSS_IDXSEL 81
00289 #define GSOFTSW2_TSS_IDXSEL 82
00290 #define GSOFTSW3_TSS_IDXSEL 83
00291 #define GSOFTSW4_TSS_IDXSEL 84
00292 #define GSOFTSW5_TSS_IDXSEL 85
00293 #define GSOFTSW6_TSS_IDXSEL 86
00294 #define GSOFTSW7_TSS_IDXSEL 87
00295 #define GFIRST_IDXSEL 88
00296
00297 #endif