faults.hh (5851:7bd73614dc1d) faults.hh (5857:8cd8e1393990)
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 *

--- 44 unchanged lines hidden (view full) ---

53 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
54 *
55 * Authors: Gabe Black
56 */
57
58#ifndef __ARCH_X86_FAULTS_HH__
59#define __ARCH_X86_FAULTS_HH__
60
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 *

--- 44 unchanged lines hidden (view full) ---

53 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
54 *
55 * Authors: Gabe Black
56 */
57
58#ifndef __ARCH_X86_FAULTS_HH__
59#define __ARCH_X86_FAULTS_HH__
60
61#include "base/bitunion.hh"
61#include "base/misc.hh"
62#include "sim/faults.hh"
63
64namespace X86ISA
65{
66 // Base class for all x86 "faults" where faults is in the m5 sense
67 class X86FaultBase : public FaultBase
68 {
69 protected:
70 const char * faultName;
71 const char * mnem;
72 uint8_t vector;
73 uint64_t errorCode;
74
75 X86FaultBase(const char * _faultName, const char * _mnem,
62#include "base/misc.hh"
63#include "sim/faults.hh"
64
65namespace X86ISA
66{
67 // Base class for all x86 "faults" where faults is in the m5 sense
68 class X86FaultBase : public FaultBase
69 {
70 protected:
71 const char * faultName;
72 const char * mnem;
73 uint8_t vector;
74 uint64_t errorCode;
75
76 X86FaultBase(const char * _faultName, const char * _mnem,
76 const uint8_t _vector, uint64_t _errorCode = 0) :
77 const uint8_t _vector, uint64_t _errorCode = -1) :
77 faultName(_faultName), mnem(_mnem),
78 vector(_vector), errorCode(_errorCode)
79 {
80 }
81
82 const char * name() const
83 {
84 return faultName;

--- 17 unchanged lines hidden (view full) ---

102 };
103
104 // Base class for x86 faults which behave as if the underlying instruction
105 // didn't happen.
106 class X86Fault : public X86FaultBase
107 {
108 protected:
109 X86Fault(const char * name, const char * mnem,
78 faultName(_faultName), mnem(_mnem),
79 vector(_vector), errorCode(_errorCode)
80 {
81 }
82
83 const char * name() const
84 {
85 return faultName;

--- 17 unchanged lines hidden (view full) ---

103 };
104
105 // Base class for x86 faults which behave as if the underlying instruction
106 // didn't happen.
107 class X86Fault : public X86FaultBase
108 {
109 protected:
110 X86Fault(const char * name, const char * mnem,
110 const uint8_t vector, uint64_t _errorCode = 0) :
111 const uint8_t vector, uint64_t _errorCode = -1) :
111 X86FaultBase(name, mnem, vector, _errorCode)
112 {}
113 };
114
115 // Base class for x86 traps which behave as if the underlying instruction
116 // completed.
117 class X86Trap : public X86FaultBase
118 {
119 protected:
120 X86Trap(const char * name, const char * mnem,
112 X86FaultBase(name, mnem, vector, _errorCode)
113 {}
114 };
115
116 // Base class for x86 traps which behave as if the underlying instruction
117 // completed.
118 class X86Trap : public X86FaultBase
119 {
120 protected:
121 X86Trap(const char * name, const char * mnem,
121 const uint8_t vector, uint64_t _errorCode = 0) :
122 const uint8_t vector, uint64_t _errorCode = -1) :
122 X86FaultBase(name, mnem, vector, _errorCode)
123 {}
124
125#if FULL_SYSTEM
126 void invoke(ThreadContext * tc);
127#endif
128 };
129
130 // Base class for x86 aborts which seem to be catastrophic failures.
131 class X86Abort : public X86FaultBase
132 {
133 protected:
134 X86Abort(const char * name, const char * mnem,
123 X86FaultBase(name, mnem, vector, _errorCode)
124 {}
125
126#if FULL_SYSTEM
127 void invoke(ThreadContext * tc);
128#endif
129 };
130
131 // Base class for x86 aborts which seem to be catastrophic failures.
132 class X86Abort : public X86FaultBase
133 {
134 protected:
135 X86Abort(const char * name, const char * mnem,
135 const uint8_t vector, uint64_t _errorCode = 0) :
136 const uint8_t vector, uint64_t _errorCode = -1) :
136 X86FaultBase(name, mnem, vector, _errorCode)
137 {}
138
139#if FULL_SYSTEM
140 void invoke(ThreadContext * tc);
141#endif
142 };
143
144 // Base class for x86 interrupts.
145 class X86Interrupt : public X86FaultBase
146 {
147 protected:
148 X86Interrupt(const char * name, const char * mnem,
137 X86FaultBase(name, mnem, vector, _errorCode)
138 {}
139
140#if FULL_SYSTEM
141 void invoke(ThreadContext * tc);
142#endif
143 };
144
145 // Base class for x86 interrupts.
146 class X86Interrupt : public X86FaultBase
147 {
148 protected:
149 X86Interrupt(const char * name, const char * mnem,
149 const uint8_t _vector, uint64_t _errorCode = 0) :
150 const uint8_t _vector, uint64_t _errorCode = -1) :
150 X86FaultBase(name, mnem, _vector, _errorCode)
151 {}
152
153#if FULL_SYSTEM
154 void invoke(ThreadContext * tc);
155#endif
156 };
157

--- 110 unchanged lines hidden (view full) ---

268 X86Fault("Device-Not-Available", "#NM", 7)
269 {}
270 };
271
272 class DoubleFault : public X86Abort
273 {
274 public:
275 DoubleFault() :
151 X86FaultBase(name, mnem, _vector, _errorCode)
152 {}
153
154#if FULL_SYSTEM
155 void invoke(ThreadContext * tc);
156#endif
157 };
158

--- 110 unchanged lines hidden (view full) ---

269 X86Fault("Device-Not-Available", "#NM", 7)
270 {}
271 };
272
273 class DoubleFault : public X86Abort
274 {
275 public:
276 DoubleFault() :
276 X86Abort("Double-Fault", "#DF", 8)
277 X86Abort("Double-Fault", "#DF", 8, 0)
277 {}
278 };
279
280 class InvalidTSS : public X86Fault
281 {
282 public:
278 {}
279 };
280
281 class InvalidTSS : public X86Fault
282 {
283 public:
283 InvalidTSS() :
284 X86Fault("Invalid-TSS", "#TS", 10)
284 InvalidTSS(uint32_t _errorCode) :
285 X86Fault("Invalid-TSS", "#TS", 10, _errorCode)
285 {}
286 };
287
288 class SegmentNotPresent : public X86Fault
289 {
290 public:
286 {}
287 };
288
289 class SegmentNotPresent : public X86Fault
290 {
291 public:
291 SegmentNotPresent() :
292 X86Fault("Segment-Not-Present", "#NP", 11)
292 SegmentNotPresent(uint32_t _errorCode) :
293 X86Fault("Segment-Not-Present", "#NP", 11, _errorCode)
293 {}
294 };
295
296 class StackFault : public X86Fault
297 {
298 public:
294 {}
295 };
296
297 class StackFault : public X86Fault
298 {
299 public:
299 StackFault() :
300 X86Fault("Stack", "#SS", 12)
300 StackFault(uint32_t _errorCode) :
301 X86Fault("Stack", "#SS", 12, _errorCode)
301 {}
302 };
303
304 class GeneralProtection : public X86Fault
305 {
306 public:
302 {}
303 };
304
305 class GeneralProtection : public X86Fault
306 {
307 public:
307 GeneralProtection(uint64_t _errorCode) :
308 GeneralProtection(uint32_t _errorCode) :
308 X86Fault("General-Protection", "#GP", 13, _errorCode)
309 {}
310 };
311
312 class PageFault : public X86Fault
313 {
309 X86Fault("General-Protection", "#GP", 13, _errorCode)
310 {}
311 };
312
313 class PageFault : public X86Fault
314 {
315 protected:
316 BitUnion32(PageFaultErrorCode)
317 Bitfield<0> present;
318 Bitfield<1> write;
319 Bitfield<2> user;
320 Bitfield<3> reserved;
321 Bitfield<4> fetch;
322 EndBitUnion(PageFaultErrorCode)
323
314 public:
324 public:
315 PageFault() :
316 X86Fault("Page-Fault", "#PF", 14)
325 PageFault(uint32_t _errorCode) :
326 X86Fault("Page-Fault", "#PF", 14, _errorCode)
317 {}
327 {}
328 PageFault(bool present, bool write, bool user,
329 bool reserved, bool fetch) :
330 X86Fault("Page-Fault", "#PF", 14, 0)
331 {
332 PageFaultErrorCode code = 0;
333 code.present = present;
334 code.write = write;
335 code.user = user;
336 code.reserved = reserved;
337 code.fetch = fetch;
338 errorCode = code;
339 }
318 };
319
320 class X87FpExceptionPending : public X86Fault
321 {
322 public:
323 X87FpExceptionPending() :
324 X86Fault("x87 Floating-Point Exception Pending", "#MF", 16)
325 {}
326 };
327
328 class AlignmentCheck : public X86Fault
329 {
330 public:
331 AlignmentCheck() :
340 };
341
342 class X87FpExceptionPending : public X86Fault
343 {
344 public:
345 X87FpExceptionPending() :
346 X86Fault("x87 Floating-Point Exception Pending", "#MF", 16)
347 {}
348 };
349
350 class AlignmentCheck : public X86Fault
351 {
352 public:
353 AlignmentCheck() :
332 X86Fault("Alignment-Check", "#AC", 17)
354 X86Fault("Alignment-Check", "#AC", 17, 0)
333 {}
334 };
335
336 class MachineCheck : public X86Abort
337 {
338 public:
339 MachineCheck() :
340 X86Abort("Machine-Check", "#MC", 18)

--- 82 unchanged lines hidden ---
355 {}
356 };
357
358 class MachineCheck : public X86Abort
359 {
360 public:
361 MachineCheck() :
362 X86Abort("Machine-Check", "#MC", 18)

--- 82 unchanged lines hidden ---