2 * Copyright (c) 2003-2005 The Regents of The University of Michigan
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;
9 * redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution;
12 * neither the name of the copyright holders nor the names of its
13 * contributors may be used to endorse or promote products derived from
14 * this software without specific prior written permission.
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 #include "arch/mips/faults.hh"
33 #include "cpu/thread_context.hh"
34 #include "cpu/base.hh"
35 #include "base/trace.hh"
38 #include "sim/process.hh"
39 #include "mem/page_table.hh"
45 FaultName
MachineCheckFault::_name
= "Machine Check";
46 FaultVect
MachineCheckFault::_vect
= 0x0401;
47 FaultStat
MachineCheckFault::_count
;
49 FaultName
AlignmentFault::_name
= "Alignment";
50 FaultVect
AlignmentFault::_vect
= 0x0301;
51 FaultStat
AlignmentFault::_count
;
53 FaultName
ResetFault::_name
= "reset";
54 FaultVect
ResetFault::_vect
= 0x0001;
55 FaultStat
ResetFault::_count
;
57 FaultName
CoprocessorUnusableFault::_name
= "Coprocessor Unusable";
58 FaultVect
CoprocessorUnusableFault::_vect
= 0xF001;
59 FaultStat
CoprocessorUnusableFault::_count
;
61 FaultName
ReservedInstructionFault::_name
= "Reserved Instruction";
62 FaultVect
ReservedInstructionFault::_vect
= 0x0F01;
63 FaultStat
ReservedInstructionFault::_count
;
65 FaultName
ThreadFault::_name
= "thread";
66 FaultVect
ThreadFault::_vect
= 0x00F1;
67 FaultStat
ThreadFault::_count
;
70 FaultName
ArithmeticFault::_name
= "arith";
71 FaultVect
ArithmeticFault::_vect
= 0x0501;
72 FaultStat
ArithmeticFault::_count
;
74 FaultName
UnimplementedOpcodeFault::_name
= "opdec";
75 FaultVect
UnimplementedOpcodeFault::_vect
= 0x0481;
76 FaultStat
UnimplementedOpcodeFault::_count
;
79 //FaultName PageTableFault::_name = "page_table_fault";
80 //FaultVect PageTableFault::_vect = 0x0000;
81 //FaultStat PageTableFault::_count;
84 FaultName
InterruptFault::_name
= "interrupt";
85 FaultVect
InterruptFault::_vect
= 0x0101;
86 FaultStat
InterruptFault::_count
;
88 FaultName
NDtbMissFault::_name
= "dtb_miss_single";
89 FaultVect
NDtbMissFault::_vect
= 0x0201;
90 FaultStat
NDtbMissFault::_count
;
92 FaultName
PDtbMissFault::_name
= "dtb_miss_double";
93 FaultVect
PDtbMissFault::_vect
= 0x0281;
94 FaultStat
PDtbMissFault::_count
;
96 FaultName
DtbPageFault::_name
= "dfault";
97 FaultVect
DtbPageFault::_vect
= 0x0381;
98 FaultStat
DtbPageFault::_count
;
100 FaultName
DtbAcvFault::_name
= "dfault";
101 FaultVect
DtbAcvFault::_vect
= 0x0381;
102 FaultStat
DtbAcvFault::_count
;
104 FaultName
ItbMissFault::_name
= "itbmiss";
105 FaultVect
ItbMissFault::_vect
= 0x0181;
106 FaultStat
ItbMissFault::_count
;
108 FaultName
ItbPageFault::_name
= "itbmiss";
109 FaultVect
ItbPageFault::_vect
= 0x0181;
110 FaultStat
ItbPageFault::_count
;
112 FaultName
ItbAcvFault::_name
= "iaccvio";
113 FaultVect
ItbAcvFault::_vect
= 0x0081;
114 FaultStat
ItbAcvFault::_count
;
116 FaultName
FloatEnableFault::_name
= "fen";
117 FaultVect
FloatEnableFault::_vect
= 0x0581;
118 FaultStat
FloatEnableFault::_count
;
120 FaultName
IntegerOverflowFault::_name
= "intover";
121 FaultVect
IntegerOverflowFault::_vect
= 0x0501;
122 FaultStat
IntegerOverflowFault::_count
;
124 FaultName
DspStateDisabledFault::_name
= "intover";
125 FaultVect
DspStateDisabledFault::_vect
= 0x001a;
126 FaultStat
DspStateDisabledFault::_count
;
129 /*void PageTableFault::invoke(ThreadContext *tc)
131 Process *p = tc->getProcessPtr();
133 Addr page_addr = p->pTable->pageAlign(vaddr);
135 warn("%i: [tid:%i]: %s encountered @ addr %x. Allocating new page for address range %x - %x.\n",
136 curTick, tc->getThreadNum(), name(), vaddr, page_addr, page_addr+VMPageSize);
138 p->pTable->allocate(page_addr, VMPageSize);
143 /* address is higher than the stack region or in the current stack region
144 if (vaddr > p->stack_base || vaddr > p->stack_min)
145 FaultBase::invoke(tc);
147 // We've accessed the next page
148 if (vaddr > p->stack_min - PageBytes) {
149 p->stack_min -= PageBytes;
150 if (p->stack_base - p->stack_min > 8*1024*1024) {
151 warn("Already allocated Over max stack size for one thread\n");
153 warn("%i: Allocating page for range %x - %x",
154 curTick, p->stack_min, p->stack_min-PageBytes);
156 p->pTable->allocate(p->stack_min, PageBytes);
157 warn("Increasing stack size by one page.");
159 FaultBase::invoke(tc);
162 void ResetFault::invoke(ThreadContext
*tc
)
164 warn("[tid:%i]: %s encountered.\n", tc
->getThreadNum(), name());
165 //tc->getCpuPtr()->reset();
168 void CoprocessorUnusableFault::invoke(ThreadContext
*tc
)
170 panic("[tid:%i]: %s encountered.\n", tc
->getThreadNum(), name());
173 void ReservedInstructionFault::invoke(ThreadContext
*tc
)
175 panic("[tid:%i]: %s encountered.\n", tc
->getThreadNum(), name());
178 void ThreadFault::invoke(ThreadContext
*tc
)
180 panic("[tid:%i]: %s encountered.\n", tc
->getThreadNum(), name());
183 void DspStateDisabledFault::invoke(ThreadContext
*tc
)
185 panic("[tid:%i]: %s encountered.\n", tc
->getThreadNum(), name());
188 } // namespace MipsISA