The Pedigree Project  0.1
mips32/state.cc
1 /*
2  * Copyright (c) 2008-2014, Pedigree Developers
3  *
4  * Please see the CONTRIB file in the root of the source tree for a full
5  * list of contributors.
6  *
7  * Permission to use, copy, modify, and distribute this software for any
8  * purpose with or without fee is hereby granted, provided that the above
9  * copyright notice and this permission notice appear in all copies.
10  *
11  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18  */
19 
20 #include "pedigree/kernel/processor/state.h"
21 
22 const char *MIPS32InterruptStateRegisterName[34] = {
23  "at", "v0", "v1", "a0", "a1", "a2", "a3", "t0", "t1",
24  "t2", "t3", "t4", "t5", "t6", "t7", "s0", "s1", "s2",
25  "s3", "s4", "s5", "s6", "s7", "t8", "t9", "gp", "sp",
26  "fp", "ra", "SR", "Cause", "EPC", "BadVaddr", "Context"};
27 
29  : m_At(), m_V0(), m_V1(), m_A0(), m_A1(), m_A2(), m_A3(), m_T0(), m_T1(),
30  m_T2(), m_T3(), m_T4(), m_T5(), m_T6(), m_T7(), m_S0(), m_S1(), m_S2(),
31  m_S3(), m_S4(), m_S5(), m_S6(), m_S7(), m_T8(), m_T9(), m_Gp(), m_Sp(),
32  m_Fp(), m_Ra(), m_Sr(), m_Epc(), m_BadVAddr(), m_Context()
33 {
34 }
35 
37  : m_At(is.m_At), m_V0(is.m_V0), m_V1(is.m_V1), m_A0(is.m_A0), m_A1(is.m_A1),
38  m_A2(is.m_A2), m_A3(is.m_A3), m_T0(is.m_T0), m_T1(is.m_T1), m_T2(is.m_T2),
39  m_T3(is.m_T3), m_T4(is.m_T4), m_T5(is.m_T5), m_T6(is.m_T6), m_T7(is.m_T7),
40  m_S0(is.m_S0), m_S1(is.m_S1), m_S2(is.m_S2), m_S3(is.m_S3), m_S4(is.m_S4),
41  m_S5(is.m_S5), m_S6(is.m_S6), m_S7(is.m_S7), m_T8(is.m_T8), m_T9(is.m_T9),
42  m_Gp(is.m_Gp), m_Sp(is.m_Sp), m_Fp(is.m_Fp), m_Ra(is.m_Ra), m_Sr(is.m_Sr),
44 {
45 }
46 
49 {
50  m_At = is.m_At;
51  m_V0 = is.m_V0;
52  m_V1 = is.m_V1;
53  m_A0 = is.m_A0;
54  m_A1 = is.m_A1;
55  m_A2 = is.m_A2;
56  m_A3 = is.m_A3;
57  m_T0 = is.m_T0;
58  m_T1 = is.m_T1;
59  m_T2 = is.m_T2;
60  m_T3 = is.m_T3;
61  m_T4 = is.m_T4;
62  m_T5 = is.m_T5;
63  m_T6 = is.m_T6;
64  m_T7 = is.m_T7;
65  m_S0 = is.m_S0;
66  m_S1 = is.m_S1;
67  m_S2 = is.m_S2;
68  m_S3 = is.m_S3;
69  m_S4 = is.m_S4;
70  m_S5 = is.m_S5;
71  m_S6 = is.m_S6;
72  m_S7 = is.m_S7;
73  m_T8 = is.m_T8;
74  m_T9 = is.m_T9;
75  m_Gp = is.m_Gp;
76  m_Sp = is.m_Sp;
77  m_Fp = is.m_Fp;
78  m_Ra = is.m_Ra;
79  m_Sr = is.m_Sr;
80  m_Epc = is.m_Epc;
82  m_Context = is.m_Context;
83  return *this;
84 }
85 
87 {
88  return 34;
89 }
90 processor_register_t MIPS32InterruptState::getRegister(size_t index) const
91 {
92  switch (index)
93  {
94  case 0:
95  return m_At;
96  case 1:
97  return m_V0;
98  case 2:
99  return m_V1;
100  case 3:
101  return m_A0;
102  case 4:
103  return m_A1;
104  case 5:
105  return m_A2;
106  case 6:
107  return m_A3;
108  case 7:
109  return m_T0;
110  case 8:
111  return m_T1;
112  case 9:
113  return m_T2;
114  case 10:
115  return m_T3;
116  case 11:
117  return m_T4;
118  case 12:
119  return m_T5;
120  case 13:
121  return m_T6;
122  case 14:
123  return m_T7;
124  case 15:
125  return m_S0;
126  case 16:
127  return m_S1;
128  case 17:
129  return m_S2;
130  case 18:
131  return m_S3;
132  case 19:
133  return m_S4;
134  case 20:
135  return m_S5;
136  case 21:
137  return m_S6;
138  case 22:
139  return m_S7;
140  case 23:
141  return m_T8;
142  case 24:
143  return m_T9;
144  case 25:
145  return m_Gp;
146  case 26:
147  return m_Sp;
148  case 27:
149  return m_Fp;
150  case 28:
151  return m_Ra;
152  case 29:
153  return m_Sr;
154  case 30:
155  return m_Cause;
156  case 31:
157  return m_Epc;
158  case 32:
159  return m_BadVAddr;
160  case 33:
161  return m_Context;
162  default:
163  return 0;
164  }
165 }
166 const char *MIPS32InterruptState::getRegisterName(size_t index) const
167 {
168  return MIPS32InterruptStateRegisterName[index];
169 }
processor_register_t getRegister(size_t index) const
Definition: mips32/state.cc:90
const char * getRegisterName(size_t index) const
size_t getRegisterCount() const
Definition: mips32/state.cc:86
MIPS32InterruptState & operator=(const MIPS32InterruptState &)
Definition: mips32/state.cc:48