X86: Reorganize segmentation and implement segment selector movs.
[gem5.git] / src / arch / x86 / miscregs.hh
1 /*
2 * Copyright (c) 2007 The Hewlett-Packard Development Company
3 * All rights reserved.
4 *
5 * Redistribution and use of this software in source and binary forms,
6 * with or without modification, are permitted provided that the
7 * following conditions are met:
8 *
9 * The software must be used only for Non-Commercial Use which means any
10 * use which is NOT directed to receiving any direct monetary
11 * compensation for, or commercial advantage from such use. Illustrative
12 * examples of non-commercial use are academic research, personal study,
13 * teaching, education and corporate research & development.
14 * Illustrative examples of commercial use are distributing products for
15 * commercial advantage and providing services using the software for
16 * commercial advantage.
17 *
18 * If you wish to use this software or functionality therein that may be
19 * covered by patents for commercial use, please contact:
20 * Director of Intellectual Property Licensing
21 * Office of Strategy and Technology
22 * Hewlett-Packard Company
23 * 1501 Page Mill Road
24 * Palo Alto, California 94304
25 *
26 * Redistributions of source code must retain the above copyright notice,
27 * this list of conditions and the following disclaimer. Redistributions
28 * in binary form must reproduce the above copyright notice, this list of
29 * conditions and the following disclaimer in the documentation and/or
30 * other materials provided with the distribution. Neither the name of
31 * the COPYRIGHT HOLDER(s), HEWLETT-PACKARD COMPANY, nor the names of its
32 * contributors may be used to endorse or promote products derived from
33 * this software without specific prior written permission. No right of
34 * sublicense is granted herewith. Derivatives of the software and
35 * output created using the software may be prepared, but only for
36 * Non-Commercial Uses. Derivatives of the software may be shared with
37 * others provided: (i) the others agree to abide by the list of
38 * conditions herein which includes the Non-Commercial Use restrictions;
39 * and (ii) such Derivatives of the software include the above copyright
40 * notice to acknowledge the contribution from this software where
41 * applicable, this list of conditions and the disclaimer below.
42 *
43 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
44 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
45 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
46 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
47 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
48 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
49 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
50 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
51 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
52 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
53 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
54 *
55 * Authors: Gabe Black
56 */
57
58 #ifndef __ARCH_X86_MISCREGS_HH__
59 #define __ARCH_X86_MISCREGS_HH__
60
61 #include "arch/x86/segmentregs.hh"
62 #include "arch/x86/x86_traits.hh"
63 #include "base/bitunion.hh"
64
65 //These get defined in some system headers (at least termbits.h). That confuses
66 //things here significantly.
67 #undef CR0
68 #undef CR2
69 #undef CR3
70
71 namespace X86ISA
72 {
73 enum CondFlagBit {
74 CFBit = 1 << 0,
75 PFBit = 1 << 2,
76 ECFBit = 1 << 3,
77 AFBit = 1 << 4,
78 EZFBit = 1 << 5,
79 ZFBit = 1 << 6,
80 SFBit = 1 << 7,
81 DFBit = 1 << 10,
82 OFBit = 1 << 11
83 };
84
85 enum MiscRegIndex
86 {
87 // Control registers
88 // Most of these are invalid.
89 MISCREG_CR_BASE,
90 MISCREG_CR0 = MISCREG_CR_BASE,
91 MISCREG_CR1,
92 MISCREG_CR2,
93 MISCREG_CR3,
94 MISCREG_CR4,
95 MISCREG_CR5,
96 MISCREG_CR6,
97 MISCREG_CR7,
98 MISCREG_CR8,
99 MISCREG_CR9,
100 MISCREG_CR10,
101 MISCREG_CR11,
102 MISCREG_CR12,
103 MISCREG_CR13,
104 MISCREG_CR14,
105 MISCREG_CR15,
106
107 // Debug registers
108 MISCREG_DR_BASE = MISCREG_CR_BASE + NumCRegs,
109 MISCREG_DR0 = MISCREG_DR_BASE,
110 MISCREG_DR1,
111 MISCREG_DR2,
112 MISCREG_DR3,
113 MISCREG_DR4,
114 MISCREG_DR5,
115 MISCREG_DR6,
116 MISCREG_DR7,
117
118 // Flags register
119 MISCREG_RFLAGS = MISCREG_DR_BASE + NumDRegs,
120
121 /*
122 * Model Specific Registers
123 */
124 // Time stamp counter
125 MISCREG_TSC,
126
127 MISCREG_MTRRCAP,
128
129 MISCREG_SYSENTER_CS,
130 MISCREG_SYSENTER_ESP,
131 MISCREG_SYSENTER_EIP,
132
133 MISCREG_MCG_CAP,
134 MISCREG_MCG_STATUS,
135 MISCREG_MCG_CTL,
136
137 MISCREG_DEBUG_CTL_MSR,
138
139 MISCREG_LAST_BRANCH_FROM_IP,
140 MISCREG_LAST_BRANCH_TO_IP,
141 MISCREG_LAST_EXCEPTION_FROM_IP,
142 MISCREG_LAST_EXCEPTION_TO_IP,
143
144 MISCREG_MTRR_PHYS_BASE_BASE,
145 MISCREG_MTRR_PHYS_BASE_0 = MISCREG_MTRR_PHYS_BASE_BASE,
146 MISCREG_MTRR_PHYS_BASE_1,
147 MISCREG_MTRR_PHYS_BASE_2,
148 MISCREG_MTRR_PHYS_BASE_3,
149 MISCREG_MTRR_PHYS_BASE_4,
150 MISCREG_MTRR_PHYS_BASE_5,
151 MISCREG_MTRR_PHYS_BASE_6,
152 MISCREG_MTRR_PHYS_BASE_7,
153
154 MISCREG_MTRR_PHYS_MASK_BASE,
155 MISCREG_MTRR_PHYS_MASK_0 = MISCREG_MTRR_PHYS_MASK_BASE,
156 MISCREG_MTRR_PHYS_MASK_1,
157 MISCREG_MTRR_PHYS_MASK_2,
158 MISCREG_MTRR_PHYS_MASK_3,
159 MISCREG_MTRR_PHYS_MASK_4,
160 MISCREG_MTRR_PHYS_MASK_5,
161 MISCREG_MTRR_PHYS_MASK_6,
162 MISCREG_MTRR_PHYS_MASK_7,
163
164 MISCREG_MTRR_FIX_64K_00000,
165 MISCREG_MTRR_FIX_16K_80000,
166 MISCREG_MTRR_FIX_16K_A0000,
167 MISCREG_MTRR_FIX_4K_C0000,
168 MISCREG_MTRR_FIX_4K_C8000,
169 MISCREG_MTRR_FIX_4K_D0000,
170 MISCREG_MTRR_FIX_4K_D8000,
171 MISCREG_MTRR_FIX_4K_E0000,
172 MISCREG_MTRR_FIX_4K_E8000,
173 MISCREG_MTRR_FIX_4K_F0000,
174 MISCREG_MTRR_FIX_4K_F8000,
175
176 MISCREG_PAT,
177
178 MISCREG_DEF_TYPE,
179
180 MISCREG_MC_CTL_BASE,
181 MISCREG_MC0_CTL = MISCREG_MC_CTL_BASE,
182 MISCREG_MC1_CTL,
183 MISCREG_MC2_CTL,
184 MISCREG_MC3_CTL,
185 MISCREG_MC4_CTL,
186
187 MISCREG_MC_STATUS_BASE,
188 MISCREG_MC0_STATUS = MISCREG_MC_STATUS_BASE,
189 MISCREG_MC1_STATUS,
190 MISCREG_MC2_STATUS,
191 MISCREG_MC3_STATUS,
192 MISCREG_MC4_STATUS,
193
194 MISCREG_MC_ADDR_BASE,
195 MISCREG_MC0_ADDR = MISCREG_MC_ADDR_BASE,
196 MISCREG_MC1_ADDR,
197 MISCREG_MC2_ADDR,
198 MISCREG_MC3_ADDR,
199 MISCREG_MC4_ADDR,
200
201 MISCREG_MC_MISC_BASE,
202 MISCREG_MC0_MISC = MISCREG_MC_MISC_BASE,
203 MISCREG_MC1_MISC,
204 MISCREG_MC2_MISC,
205 MISCREG_MC3_MISC,
206 MISCREG_MC4_MISC,
207
208 // Extended feature enable register
209 MISCREG_EFER,
210
211 MISCREG_STAR,
212 MISCREG_LSTAR,
213 MISCREG_CSTAR,
214
215 MISCREG_SF_MASK,
216
217 MISCREG_KERNEL_GS_BASE,
218
219 MISCREG_TSC_AUX,
220
221 MISCREG_PERF_EVT_SEL_BASE,
222 MISCREG_PERF_EVT_SEL0 = MISCREG_PERF_EVT_SEL_BASE,
223 MISCREG_PERF_EVT_SEL1,
224 MISCREG_PERF_EVT_SEL2,
225 MISCREG_PERF_EVT_SEL3,
226
227 MISCREG_PERF_EVT_CTR_BASE,
228 MISCREG_PERF_EVT_CTR0 = MISCREG_PERF_EVT_CTR_BASE,
229 MISCREG_PERF_EVT_CTR1,
230 MISCREG_PERF_EVT_CTR2,
231 MISCREG_PERF_EVT_CTR3,
232
233 MISCREG_SYSCFG,
234
235 MISCREG_IORR_BASE_BASE,
236 MISCREG_IORR_BASE0 = MISCREG_IORR_BASE_BASE,
237 MISCREG_IORR_BASE1,
238
239 MISCREG_IORR_MASK_BASE,
240 MISCREG_IORR_MASK0 = MISCREG_IORR_MASK_BASE,
241 MISCREG_IORR_MASK1,
242
243 MISCREG_TOP_MEM,
244 MISCREG_TOP_MEM2,
245
246 MISCREG_VM_CR,
247 MISCREG_IGNNE,
248 MISCREG_SMM_CTL,
249 MISCREG_VM_HSAVE_PA,
250
251 /*
252 * Segment registers
253 */
254 // Segment selectors
255 MISCREG_SEG_SEL_BASE,
256 MISCREG_ES = MISCREG_SEG_SEL_BASE,
257 MISCREG_CS,
258 MISCREG_SS,
259 MISCREG_DS,
260 MISCREG_FS,
261 MISCREG_GS,
262 MISCREG_HS,
263 MISCREG_TSL,
264 MISCREG_TSG,
265 MISCREG_LS,
266 MISCREG_MS,
267 MISCREG_TR,
268 MISCREG_IDTR,
269
270 // Hidden segment base field
271 MISCREG_SEG_BASE_BASE = MISCREG_SEG_SEL_BASE + NUM_SEGMENTREGS,
272 MISCREG_ES_BASE = MISCREG_SEG_BASE_BASE,
273 MISCREG_CS_BASE,
274 MISCREG_SS_BASE,
275 MISCREG_DS_BASE,
276 MISCREG_FS_BASE,
277 MISCREG_GS_BASE,
278 MISCREG_HS_BASE,
279 MISCREG_TSL_BASE,
280 MISCREG_TSG_BASE,
281 MISCREG_LS_BASE,
282 MISCREG_MS_BASE,
283 MISCREG_TR_BASE,
284 MISCREG_IDTR_BASE,
285
286 // The effective segment base, ie what is actually added to an
287 // address. In 64 bit mode this can be different from the above,
288 // namely 0.
289 MISCREG_SEG_EFF_BASE_BASE = MISCREG_SEG_BASE_BASE + NUM_SEGMENTREGS,
290 MISCREG_ES_EFF_BASE = MISCREG_SEG_EFF_BASE_BASE,
291 MISCREG_CS_EFF_BASE,
292 MISCREG_SS_EFF_BASE,
293 MISCREG_DS_EFF_BASE,
294 MISCREG_FS_EFF_BASE,
295 MISCREG_GS_EFF_BASE,
296 MISCREG_HS_EFF_BASE,
297 MISCREG_TSL_EFF_BASE,
298 MISCREG_TSG_EFF_BASE,
299 MISCREG_LS_EFF_BASE,
300 MISCREG_MS_EFF_BASE,
301 MISCREG_TR_EFF_BASE,
302 MISCREG_IDTR_EFF_BASE,
303
304 // Hidden segment limit field
305 MISCREG_SEG_LIMIT_BASE = MISCREG_SEG_EFF_BASE_BASE + NUM_SEGMENTREGS,
306 MISCREG_ES_LIMIT = MISCREG_SEG_LIMIT_BASE,
307 MISCREG_CS_LIMIT,
308 MISCREG_SS_LIMIT,
309 MISCREG_DS_LIMIT,
310 MISCREG_FS_LIMIT,
311 MISCREG_GS_LIMIT,
312 MISCREG_HS_LIMIT,
313 MISCREG_TSL_LIMIT,
314 MISCREG_TSG_LIMIT,
315 MISCREG_LS_LIMIT,
316 MISCREG_MS_LIMIT,
317 MISCREG_TR_LIMIT,
318 MISCREG_IDTR_LIMIT,
319
320 // Hidden segment limit attributes
321 MISCREG_SEG_ATTR_BASE = MISCREG_SEG_LIMIT_BASE + NUM_SEGMENTREGS,
322 MISCREG_ES_ATTR = MISCREG_SEG_ATTR_BASE,
323 MISCREG_CS_ATTR,
324 MISCREG_SS_ATTR,
325 MISCREG_DS_ATTR,
326 MISCREG_FS_ATTR,
327 MISCREG_GS_ATTR,
328 MISCREG_HS_ATTR,
329 MISCREG_TSL_ATTR,
330 MISCREG_TSG_ATTR,
331 MISCREG_LS_ATTR,
332 MISCREG_MS_ATTR,
333 MISCREG_TR_ATTR,
334 MISCREG_IDTR_ATTR,
335
336 // Floating point control registers
337 MISCREG_X87_TOP =
338 MISCREG_SEG_ATTR_BASE + NUM_SEGMENTREGS,
339
340 //XXX Add "Model-Specific Registers"
341
342 NUM_MISCREGS
343 };
344
345 static inline MiscRegIndex
346 MISCREG_CR(int index)
347 {
348 return (MiscRegIndex)(MISCREG_CR_BASE + index);
349 }
350
351 static inline MiscRegIndex
352 MISCREG_DR(int index)
353 {
354 return (MiscRegIndex)(MISCREG_DR_BASE + index);
355 }
356
357 static inline MiscRegIndex
358 MISCREG_MTRR_PHYS_BASE(int index)
359 {
360 return (MiscRegIndex)(MISCREG_MTRR_PHYS_BASE_BASE + index);
361 }
362
363 static inline MiscRegIndex
364 MISCREG_MTRR_PHYS_MASK(int index)
365 {
366 return (MiscRegIndex)(MISCREG_MTRR_PHYS_MASK_BASE + index);
367 }
368
369 static inline MiscRegIndex
370 MISCREG_MC_CTL(int index)
371 {
372 return (MiscRegIndex)(MISCREG_MC_CTL_BASE + index);
373 }
374
375 static inline MiscRegIndex
376 MISCREG_MC_STATUS(int index)
377 {
378 return (MiscRegIndex)(MISCREG_MC_STATUS_BASE + index);
379 }
380
381 static inline MiscRegIndex
382 MISCREG_MC_ADDR(int index)
383 {
384 return (MiscRegIndex)(MISCREG_MC_ADDR_BASE + index);
385 }
386
387 static inline MiscRegIndex
388 MISCREG_MC_MISC(int index)
389 {
390 return (MiscRegIndex)(MISCREG_MC_MISC_BASE + index);
391 }
392
393 static inline MiscRegIndex
394 MISCREG_PERF_EVT_SEL(int index)
395 {
396 return (MiscRegIndex)(MISCREG_PERF_EVT_SEL_BASE + index);
397 }
398
399 static inline MiscRegIndex
400 MISCREG_PERF_EVT_CTR(int index)
401 {
402 return (MiscRegIndex)(MISCREG_PERF_EVT_CTR_BASE + index);
403 }
404
405 static inline MiscRegIndex
406 MISCREG_IORR_BASE(int index)
407 {
408 return (MiscRegIndex)(MISCREG_IORR_BASE_BASE + index);
409 }
410
411 static inline MiscRegIndex
412 MISCREG_IORR_MASK(int index)
413 {
414 return (MiscRegIndex)(MISCREG_IORR_MASK_BASE + index);
415 }
416
417 static inline MiscRegIndex
418 MISCREG_SEG_SEL(int index)
419 {
420 return (MiscRegIndex)(MISCREG_SEG_SEL_BASE + index);
421 }
422
423 static inline MiscRegIndex
424 MISCREG_SEG_BASE(int index)
425 {
426 return (MiscRegIndex)(MISCREG_SEG_BASE_BASE + index);
427 }
428
429 static inline MiscRegIndex
430 MISCREG_SEG_EFF_BASE(int index)
431 {
432 return (MiscRegIndex)(MISCREG_SEG_EFF_BASE_BASE + index);
433 }
434
435 static inline MiscRegIndex
436 MISCREG_SEG_LIMIT(int index)
437 {
438 return (MiscRegIndex)(MISCREG_SEG_LIMIT_BASE + index);
439 }
440
441 static inline MiscRegIndex
442 MISCREG_SEG_ATTR(int index)
443 {
444 return (MiscRegIndex)(MISCREG_SEG_ATTR_BASE + index);
445 }
446
447 /**
448 * A type to describe the condition code bits of the RFLAGS register,
449 * plus two flags, EZF and ECF, which are only visible to microcode.
450 */
451 BitUnion64(CCFlagBits)
452 Bitfield<11> of;
453 Bitfield<7> sf;
454 Bitfield<6> zf;
455 Bitfield<5> ezf;
456 Bitfield<4> af;
457 Bitfield<3> ecf;
458 Bitfield<2> pf;
459 Bitfield<0> cf;
460 EndBitUnion(CCFlagBits)
461
462 /**
463 * RFLAGS
464 */
465 BitUnion64(RFLAGS)
466 Bitfield<21> id; // ID Flag
467 Bitfield<20> vip; // Virtual Interrupt Pending
468 Bitfield<19> vif; // Virtual Interrupt Flag
469 Bitfield<18> ac; // Alignment Check
470 Bitfield<17> vm; // Virtual-8086 Mode
471 Bitfield<16> rf; // Resume Flag
472 Bitfield<14> nt; // Nested Task
473 Bitfield<13, 12> iopl; // I/O Privilege Level
474 Bitfield<11> of; // Overflow Flag
475 Bitfield<10> df; // Direction Flag
476 Bitfield<9> intf; // Interrupt Flag
477 Bitfield<8> tf; // Trap Flag
478 Bitfield<7> sf; // Sign Flag
479 Bitfield<6> zf; // Zero Flag
480 Bitfield<4> af; // Auxiliary Flag
481 Bitfield<2> pf; // Parity Flag
482 Bitfield<0> cf; // Carry Flag
483 EndBitUnion(RFLAGS)
484
485 /**
486 * Control registers
487 */
488 BitUnion64(CR0)
489 Bitfield<31> pg; // Paging
490 Bitfield<30> cd; // Cache Disable
491 Bitfield<29> nw; // Not Writethrough
492 Bitfield<18> am; // Alignment Mask
493 Bitfield<16> wp; // Write Protect
494 Bitfield<5> ne; // Numeric Error
495 Bitfield<4> et; // Extension Type
496 Bitfield<3> ts; // Task Switched
497 Bitfield<2> em; // Emulation
498 Bitfield<1> mp; // Monitor Coprocessor
499 Bitfield<0> pe; // Protection Enabled
500 EndBitUnion(CR0)
501
502 // Page Fault Virtual Address
503 BitUnion64(CR2)
504 Bitfield<31, 0> legacy;
505 EndBitUnion(CR2)
506
507 BitUnion64(CR3)
508 Bitfield<51, 12> longPdtb; // Long Mode Page-Directory-Table
509 // Base Address
510 Bitfield<31, 12> pdtb; // Non-PAE Addressing Page-Directory-Table
511 // Base Address
512 Bitfield<31, 5> paePdtb; // PAE Addressing Page-Directory-Table
513 // Base Address
514 Bitfield<4> pcd; // Page-Level Cache Disable
515 Bitfield<3> pwt; // Page-Level Writethrough
516 EndBitUnion(CR3)
517
518 BitUnion64(CR4)
519 Bitfield<10> osxmmexcpt; // Operating System Unmasked
520 // Exception Support
521 Bitfield<9> osfxsr; // Operating System FXSave/FSRSTOR Support
522 Bitfield<8> pce; // Performance-Monitoring Counter Enable
523 Bitfield<7> pge; // Page-Global Enable
524 Bitfield<6> mce; // Machine Check Enable
525 Bitfield<5> pae; // Physical-Address Extension
526 Bitfield<4> pse; // Page Size Extensions
527 Bitfield<3> de; // Debugging Extensions
528 Bitfield<2> tsd; // Time Stamp Disable
529 Bitfield<1> pvi; // Protected-Mode Virtual Interrupts
530 Bitfield<0> vme; // Virtual-8086 Mode Extensions
531 EndBitUnion(CR4)
532
533 BitUnion64(CR8)
534 Bitfield<3, 0> tpr; // Task Priority Register
535 EndBitUnion(CR8)
536
537 // MTRR capabilities
538 BitUnion64(MTRRcap)
539 Bitfield<7, 0> vcnt; // Variable-Range Register Count
540 Bitfield<8> fix; // Fixed-Range Registers
541 Bitfield<10> wc; // Write-Combining
542 EndBitUnion(MTRRcap)
543
544 /**
545 * SYSENTER configuration registers
546 */
547 BitUnion64(SysenterCS)
548 Bitfield<15, 0> targetCS;
549 EndBitUnion(SysenterCS)
550
551 BitUnion64(SysenterESP)
552 Bitfield<31, 0> targetESP;
553 EndBitUnion(SysenterESP)
554
555 BitUnion64(SysenterEIP)
556 Bitfield<31, 0> targetEIP;
557 EndBitUnion(SysenterEIP)
558
559 /**
560 * Global machine check registers
561 */
562 BitUnion64(McgCap)
563 Bitfield<7, 0> count; // Number of error reporting register banks
564 Bitfield<8> MCGCP; // MCG_CTL register present.
565 EndBitUnion(McgCap)
566
567 BitUnion64(McgStatus)
568 Bitfield<0> ripv; // Restart-IP valid
569 Bitfield<1> eipv; // Error-IP valid
570 Bitfield<2> mcip; // Machine check in-progress
571 EndBitUnion(McgStatus)
572
573 BitUnion64(DebugCtlMsr)
574 Bitfield<0> lbr; // Last-branch record
575 Bitfield<1> btf; // Branch single step
576 Bitfield<2> pb0; // Performance monitoring pin control 0
577 Bitfield<3> pb1; // Performance monitoring pin control 1
578 Bitfield<4> pb2; // Performance monitoring pin control 2
579 Bitfield<5> pb3; // Performance monitoring pin control 3
580 /*uint64_t pb(int index)
581 {
582 return bits(__data, index + 2);
583 }*/
584 EndBitUnion(DebugCtlMsr)
585
586 BitUnion64(MtrrPhysBase)
587 Bitfield<7, 0> type; // Default memory type
588 Bitfield<51, 12> physbase; // Range physical base address
589 EndBitUnion(MtrrPhysBase)
590
591 BitUnion64(MtrrPhysMask)
592 Bitfield<11> valid; // MTRR pair enable
593 Bitfield<51, 12> physmask; // Range physical mask
594 EndBitUnion(MtrrPhysMask)
595
596 BitUnion64(MtrrFixed)
597 /*uint64_t type(int index)
598 {
599 return bits(__data, index * 8 + 7, index * 8);
600 }*/
601 EndBitUnion(MtrrFixed)
602
603 BitUnion64(Pat)
604 /*uint64_t pa(int index)
605 {
606 return bits(__data, index * 8 + 2, index * 8);
607 }*/
608 EndBitUnion(Pat)
609
610 BitUnion64(MtrrDefType)
611 Bitfield<7, 0> type; // Default type
612 Bitfield<10> fe; // Fixed range enable
613 Bitfield<11> e; // MTRR enable
614 EndBitUnion(MtrrDefType)
615
616 /**
617 * Machine check
618 */
619 BitUnion64(McStatus)
620 Bitfield<15,0> mcaErrorCode;
621 Bitfield<31,16> modelSpecificCode;
622 Bitfield<56,32> otherInfo;
623 Bitfield<57> pcc; // Processor-context corrupt
624 Bitfield<58> addrv; // Error-address register valid
625 Bitfield<59> miscv; // Miscellaneous-error register valid
626 Bitfield<60> en; // Error condition enabled
627 Bitfield<61> uc; // Uncorrected error
628 Bitfield<62> over; // Status register overflow
629 Bitfield<63> val; // Valid
630 EndBitUnion(McStatus)
631
632 BitUnion64(McCtl)
633 /*uint64_t en(int index)
634 {
635 return bits(__data, index);
636 }*/
637 EndBitUnion(McCtl)
638
639 // Extended feature enable register
640 BitUnion64(Efer)
641 Bitfield<0> sce; // System call extensions
642 Bitfield<8> lme; // Long mode enable
643 Bitfield<10> lma; // Long mode active
644 Bitfield<11> nxe; // No-execute enable
645 Bitfield<12> svme; // Secure virtual machine enable
646 Bitfield<14> ffxsr; // Fast fxsave/fxrstor
647 EndBitUnion(Efer)
648
649 BitUnion64(Star)
650 Bitfield<31,0> targetEip;
651 Bitfield<47,32> syscallCsAndSs;
652 Bitfield<63,48> sysretCsAndSs;
653 EndBitUnion(Star)
654
655 BitUnion64(SfMask)
656 Bitfield<31,0> mask;
657 EndBitUnion(SfMask)
658
659 BitUnion64(PerfEvtSel)
660 Bitfield<7,0> eventMask;
661 Bitfield<15,8> unitMask;
662 Bitfield<16> usr; // User mode
663 Bitfield<17> os; // Operating-system mode
664 Bitfield<18> e; // Edge detect
665 Bitfield<19> pc; // Pin control
666 Bitfield<20> intEn; // Interrupt enable
667 Bitfield<22> en; // Counter enable
668 Bitfield<23> inv; // Invert mask
669 Bitfield<31,24> counterMask;
670 EndBitUnion(PerfEvtSel)
671
672 BitUnion32(Syscfg)
673 Bitfield<18> mfde; // MtrrFixDramEn
674 Bitfield<19> mfdm; // MtrrFixDramModEn
675 Bitfield<20> mvdm; // MtrrVarDramEn
676 Bitfield<21> tom2; // MtrrTom2En
677 EndBitUnion(Syscfg)
678
679 BitUnion64(IorrBase)
680 Bitfield<3> wr; // WrMem Enable
681 Bitfield<4> rd; // RdMem Enable
682 Bitfield<51,12> physbase; // Range physical base address
683 EndBitUnion(IorrBase)
684
685 BitUnion64(IorrMask)
686 Bitfield<11> v; // I/O register pair enable (valid)
687 Bitfield<51,12> physmask; // Range physical mask
688 EndBitUnion(IorrMask)
689
690 BitUnion64(Tom)
691 Bitfield<51,23> physAddr; // Top of memory physical address
692 EndBitUnion(Tom)
693
694 BitUnion64(VmCrMsr)
695 Bitfield<0> dpd;
696 Bitfield<1> rInit;
697 Bitfield<2> disA20M;
698 EndBitUnion(VmCrMsr)
699
700 BitUnion64(IgnneMsr)
701 Bitfield<0> ignne;
702 EndBitUnion(IgnneMsr)
703
704 BitUnion64(SmmCtlMsr)
705 Bitfield<0> dismiss;
706 Bitfield<1> enter;
707 Bitfield<2> smiCycle;
708 Bitfield<3> exit;
709 Bitfield<4> rsmCycle;
710 EndBitUnion(SmmCtlMsr)
711
712 /**
713 * Segment Selector
714 */
715 BitUnion64(SegSelector)
716 // The following bitfield is not defined in the ISA, but it's useful
717 // when checking selectors in larger data types to make sure they
718 // aren't too large.
719 Bitfield<63, 3> esi; // Extended selector
720 Bitfield<15, 3> si; // Selector Index
721 Bitfield<2> ti; // Table Indicator
722 Bitfield<1, 0> rpl; // Requestor Privilege Level
723 EndBitUnion(SegSelector)
724
725 /**
726 * Segment Descriptors
727 */
728
729 BitUnion64(SegDescriptor)
730 Bitfield<63, 56> baseHigh;
731 Bitfield<39, 16> baseLow;
732 Bitfield<55> g; // Granularity
733 Bitfield<54> d; // Default Operand Size
734 Bitfield<54> b; // Default Operand Size
735 Bitfield<53> l; // Long Attribute Bit
736 Bitfield<52> avl; // Available To Software
737 Bitfield<51, 48> limitHigh;
738 Bitfield<15, 0> limitLow;
739 Bitfield<47> p; // Present
740 Bitfield<46, 45> dpl; // Descriptor Privilege-Level
741 Bitfield<44> s; // System
742 SubBitUnion(type, 43, 40)
743 // Specifies whether this descriptor is for code or data.
744 Bitfield<43> codeOrData;
745
746 // These bit fields are for code segments
747 Bitfield<42> c; // Conforming
748 Bitfield<41> r; // Readable
749
750 // These bit fields are for data segments
751 Bitfield<42> e; // Expand-Down
752 Bitfield<41> w; // Writable
753
754 // This is used for both code and data segments.
755 Bitfield<40> a; // Accessed
756 EndSubBitUnion(type)
757 EndBitUnion(SegDescriptor)
758
759 BitUnion64(SegAttr)
760 Bitfield<0> writable;
761 Bitfield<1> readable;
762 Bitfield<2> expandDown;
763 Bitfield<4, 3> dpl;
764 Bitfield<5> defaultSize;
765 Bitfield<6> longMode;
766 EndBitUnion(SegAttr)
767
768 BitUnion64(GateDescriptor)
769 Bitfield<63, 48> offsetHigh; // Target Code-Segment Offset
770 Bitfield<15, 0> offsetLow; // Target Code-Segment Offset
771 Bitfield<31, 16> selector; // Target Code-Segment Selector
772 Bitfield<47> p; // Present
773 Bitfield<46, 45> dpl; // Descriptor Privilege-Level
774 Bitfield<43, 40> type;
775 Bitfield<36, 32> count; // Parameter Count
776 EndBitUnion(GateDescriptor)
777
778 /**
779 * Descriptor-Table Registers
780 */
781 BitUnion64(GDTR)
782 EndBitUnion(GDTR)
783
784 BitUnion64(IDTR)
785 EndBitUnion(IDTR)
786
787 BitUnion64(LDTR)
788 EndBitUnion(LDTR)
789
790 /**
791 * Task Register
792 */
793 BitUnion64(TR)
794 EndBitUnion(TR)
795 };
796
797 #endif // __ARCH_X86_INTREGS_HH__