2 * Copyright (c) 2007 The Hewlett-Packard Development Company
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:
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.
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
24 * Palo Alto, California 94304
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.
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.
58 #ifndef __ARCH_X86_MISCREGS_HH__
59 #define __ARCH_X86_MISCREGS_HH__
61 #include "arch/x86/x86_traits.hh"
62 #include "base/bitunion.hh"
64 //These get defined in some system headers (at least termbits.h). That confuses
65 //things here significantly.
87 // Most of these are invalid.
89 MISCREG_CR0 = MISCREG_CR_BASE,
107 MISCREG_DR_BASE = MISCREG_CR_BASE + NumCRegs,
108 MISCREG_DR0 = MISCREG_DR_BASE,
118 MISCREG_RFLAGS = MISCREG_DR_BASE + NumDRegs,
120 // Extended feature enable register
124 MISCREG_SEG_SEL_BASE,
125 MISCREG_ES = MISCREG_SEG_SEL_BASE,
132 // Hidden segment base field
133 MISCREG_SEG_BASE_BASE = MISCREG_SEG_SEL_BASE + NumSegments,
134 MISCREG_ES_BASE = MISCREG_SEG_BASE_BASE,
141 // Hidden segment limit field
142 MISCREG_SEG_LIMIT_BASE = MISCREG_SEG_BASE_BASE + NumSegments,
143 MISCREG_ES_LIMIT = MISCREG_SEG_LIMIT_BASE,
150 // Hidden segment limit attributes
151 MISCREG_SEG_ATTR_BASE = MISCREG_SEG_LIMIT_BASE + NumSegments,
152 MISCREG_ES_ATTR = MISCREG_SEG_ATTR_BASE,
159 // System segment selectors
160 MISCREG_SYSSEG_SEL_BASE = MISCREG_SEG_ATTR_BASE + NumSegments,
161 MISCREG_LDTR = MISCREG_SYSSEG_SEL_BASE,
164 // Hidden system segment base field
165 MISCREG_SYSSEG_BASE_BASE = MISCREG_SYSSEG_SEL_BASE + NumSysSegments,
166 MISCREG_LDTR_BASE = MISCREG_SYSSEG_BASE_BASE,
171 // Hidden system segment limit field
172 MISCREG_SYSSEG_LIMIT_BASE = MISCREG_SYSSEG_BASE_BASE + NumSysSegments,
173 MISCREG_LDTR_LIMIT = MISCREG_SYSSEG_LIMIT_BASE,
178 // Hidden system segment attribute field
179 MISCREG_SYSSEG_ATTR_BASE = MISCREG_SYSSEG_LIMIT_BASE + NumSysSegments,
180 MISCREG_LDTR_ATTR = MISCREG_SYSSEG_ATTR_BASE,
183 // Floating point control registers
184 MISCREG_X87_TOP = MISCREG_SYSSEG_ATTR_BASE + NumSysSegments,
186 //XXX Add "Model-Specific Registers"
191 static inline MiscRegIndex
192 MISCREG_CR(int index)
194 return (MiscRegIndex)(MISCREG_CR_BASE + index);
197 static inline MiscRegIndex
198 MISCREG_DR(int index)
200 return (MiscRegIndex)(MISCREG_DR_BASE + index);
203 static inline MiscRegIndex
204 MISCREG_SEG_SEL(int index)
206 return (MiscRegIndex)(MISCREG_SEG_SEL_BASE + index);
209 static inline MiscRegIndex
210 MISCREG_SEG_BASE(int index)
212 return (MiscRegIndex)(MISCREG_SEG_BASE_BASE + index);
215 static inline MiscRegIndex
216 MISCREG_SEG_LIMIT(int index)
218 return (MiscRegIndex)(MISCREG_SEG_LIMIT_BASE + index);
221 static inline MiscRegIndex
222 MISCREG_SEG_ATTR(int index)
224 return (MiscRegIndex)(MISCREG_SEG_ATTR_BASE + index);
227 static inline MiscRegIndex
228 MISCREG_SYSSEG_SEL(int index)
230 return (MiscRegIndex)(MISCREG_SYSSEG_SEL_BASE + index);
233 static inline MiscRegIndex
234 MISCREG_SYSSEG_BASE(int index)
236 return (MiscRegIndex)(MISCREG_SYSSEG_BASE_BASE + index);
239 static inline MiscRegIndex
240 MISCREG_SYSSEG_LIMIT(int index)
242 return (MiscRegIndex)(MISCREG_SYSSEG_LIMIT_BASE + index);
245 static inline MiscRegIndex
246 MISCREG_SYSSEG_ATTR(int index)
248 return (MiscRegIndex)(MISCREG_SYSSEG_ATTR_BASE + index);
252 * A type to describe the condition code bits of the RFLAGS register,
253 * plus two flags, EZF and ECF, which are only visible to microcode.
255 BitUnion64(CCFlagBits)
264 EndBitUnion(CCFlagBits)
270 Bitfield<21> ID; // ID Flag
271 Bitfield<20> VIP; // Virtual Interrupt Pending
272 Bitfield<19> VIF; // Virtual Interrupt Flag
273 Bitfield<18> AC; // Alignment Check
274 Bitfield<17> VM; // Virtual-8086 Mode
275 Bitfield<16> RF; // Resume Flag
276 Bitfield<14> NT; // Nested Task
277 Bitfield<13, 12> IOPL; // I/O Privilege Level
278 Bitfield<11> OF; // Overflow Flag
279 Bitfield<10> DF; // Direction Flag
280 Bitfield<9> IF; // Interrupt Flag
281 Bitfield<8> TF; // Trap Flag
282 Bitfield<7> SF; // Sign Flag
283 Bitfield<6> ZF; // Zero Flag
284 Bitfield<4> AF; // Auxiliary Flag
285 Bitfield<2> PF; // Parity Flag
286 Bitfield<0> CF; // Carry Flag
293 Bitfield<31> PG; // Paging
294 Bitfield<30> CD; // Cache Disable
295 Bitfield<29> NW; // Not Writethrough
296 Bitfield<18> AM; // Alignment Mask
297 Bitfield<16> WP; // Write Protect
298 Bitfield<5> NE; // Numeric Error
299 Bitfield<4> ET; // Extension Type
300 Bitfield<3> TS; // Task Switched
301 Bitfield<2> EM; // Emulation
302 Bitfield<1> MP; // Monitor Coprocessor
303 Bitfield<0> PE; // Protection Enabled
306 // Page Fault Virtual Address
308 Bitfield<31, 0> legacy;
312 Bitfield<51, 12> longPDTB; // Long Mode Page-Directory-Table
314 Bitfield<31, 12> PDTB; // Non-PAE Addressing Page-Directory-Table
316 Bitfield<31, 5> PAEPDTB; // PAE Addressing Page-Directory-Table
318 Bitfield<4> PCD; // Page-Level Cache Disable
319 Bitfield<3> PWT; // Page-Level Writethrough
323 Bitfield<10> OSXMMEXCPT; // Operating System Unmasked
325 Bitfield<9> OSFXSR; // Operating System FXSave/FSRSTOR Support
326 Bitfield<8> PCE; // Performance-Monitoring Counter Enable
327 Bitfield<7> PGE; // Page-Global Enable
328 Bitfield<6> MCE; // Machine Check Enable
329 Bitfield<5> PAE; // Physical-Address Extension
330 Bitfield<4> PSE; // Page Size Extensions
331 Bitfield<3> DE; // Debugging Extensions
332 Bitfield<2> TSD; // Time Stamp Disable
333 Bitfield<1> PVI; // Protected-Mode Virtual Interrupts
334 Bitfield<0> VME; // Virtual-8086 Mode Extensions
338 Bitfield<3, 0> TPR; // Task Priority Register
344 BitUnion64(SegSelector)
345 Bitfield<15, 3> SI; // Selector Index
346 Bitfield<2> TI; // Table Indicator
347 Bitfield<1, 0> RPL; // Requestor Privilege Level
348 EndBitUnion(SegSelector)
351 * Segment Descriptors
354 BitUnion64(SegDescriptor)
355 Bitfield<63, 56> baseHigh;
356 Bitfield<39, 16> baseLow;
357 Bitfield<55> G; // Granularity
358 Bitfield<54> D; // Default Operand Size
359 Bitfield<54> B; // Default Operand Size
360 Bitfield<53> L; // Long Attribute Bit
361 Bitfield<52> AVL; // Available To Software
362 Bitfield<51, 48> limitHigh;
363 Bitfield<15, 0> limitLow;
364 Bitfield<47> P; // Present
365 Bitfield<46, 45> DPL; // Descriptor Privilege-Level
366 Bitfield<44> S; // System
367 SubBitUnion(type, 43, 40)
368 // Specifies whether this descriptor is for code or data.
369 Bitfield<43> codeOrData;
371 // These bit fields are for code segments
372 Bitfield<42> C; // Conforming
373 Bitfield<41> R; // Readable
375 // These bit fields are for data segments
376 Bitfield<42> E; // Expand-Down
377 Bitfield<41> W; // Writable
379 // This is used for both code and data segments.
380 Bitfield<40> A; // Accessed
382 EndBitUnion(SegDescriptor)
384 BitUnion64(GateDescriptor)
385 Bitfield<63, 48> offsetHigh; // Target Code-Segment Offset
386 Bitfield<15, 0> offsetLow; // Target Code-Segment Offset
387 Bitfield<31, 16> selector; // Target Code-Segment Selector
388 Bitfield<47> P; // Present
389 Bitfield<46, 45> DPL; // Descriptor Privilege-Level
390 Bitfield<43, 40> type;
391 Bitfield<36, 32> count; // Parameter Count
392 EndBitUnion(GateDescriptor)
395 * Descriptor-Table Registers
413 #endif // __ARCH_X86_INTREGS_HH__