The Pedigree Project  0.1
mips32/state.h
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 #ifndef KERNEL_PROCESSOR_MIPS32_STATE_H
21 #define KERNEL_PROCESSOR_MIPS32_STATE_H
22 
23 #include "pedigree/kernel/compiler.h"
24 #include "pedigree/kernel/processor/types.h"
25 
31 {
32  public:
33  //
34  // General Interface (both InterruptState and SyscallState)
35  //
38  inline uintptr_t getStackPointer() const;
41  inline void setStackPointer(uintptr_t stackPointer);
45  inline uintptr_t getInstructionPointer() const;
48  inline void setInstructionPointer(uintptr_t instructionPointer);
51  inline uintptr_t getBasePointer() const;
54  inline void setBasePointer(uintptr_t basePointer);
57  size_t getRegisterCount() const;
61  processor_register_t getRegister(size_t index) const;
65  const char *getRegisterName(size_t index) const;
69  inline size_t getRegisterSize(size_t index) const;
70 
71  //
72  // InterruptState Interface
73  //
76  inline bool kernelMode() const;
79  inline size_t getInterruptNumber() const;
80 
81  //
82  // SyscallState Interface
83  //
86  inline size_t getSyscallService() const;
89  inline size_t getSyscallNumber() const;
90 
91  //
92  // MIPS-specific interface.
93  //
96  inline bool branchDelay() const;
97 
98  private:
101  public:
103 
113  {
114  }
115 
117  uint32_t m_At;
119  uint32_t m_V0;
121  uint32_t m_V1;
123  uint32_t m_A0;
125  uint32_t m_A1;
127  uint32_t m_A2;
129  uint32_t m_A3;
131  uint32_t m_T0;
133  uint32_t m_T1;
135  uint32_t m_T2;
137  uint32_t m_T3;
139  uint32_t m_T4;
141  uint32_t m_T5;
143  uint32_t m_T6;
145  uint32_t m_T7;
147  uint32_t m_S0;
149  uint32_t m_S1;
151  uint32_t m_S2;
153  uint32_t m_S3;
155  uint32_t m_S4;
157  uint32_t m_S5;
159  uint32_t m_S6;
161  uint32_t m_S7;
163  uint32_t m_T8;
165  uint32_t m_T9;
167  uint32_t m_Gp;
169  uint32_t m_Sp;
171  uint32_t m_Fp;
173  uint32_t m_Ra;
175  uint32_t m_Sr;
177  uint32_t m_Cause;
179  uint32_t m_Epc;
181  uint32_t m_BadVAddr;
183  uint32_t m_Context;
184 } PACKED;
185 
188 
191 //
192 // Part of the Implementation
193 //
194 
196 {
197  return m_Sp;
198 }
199 void MIPS32InterruptState::setStackPointer(uintptr_t stackPointer)
200 {
201 }
203 {
204  return m_Epc;
205 }
206 void MIPS32InterruptState::setInstructionPointer(uintptr_t instructionPointer)
207 {
208 }
210 {
211  return 0xdeadbaba;
212 }
213 void MIPS32InterruptState::setBasePointer(uintptr_t basePointer)
214 {
215 }
216 size_t MIPS32InterruptState::getRegisterSize(size_t index) const
217 {
218  return 4;
219 }
220 
222 {
223  return true;
224 }
226 {
227  return (m_Cause >> 2) &
228  0x1F; // Return the ExcCode field of the Cause register.
229 }
230 
232 {
233  return 0;
234 }
236 {
237  return 0;
238 }
239 
241 {
242  return (m_Cause & 0x80000000); // Test bit 31 of Cause.
243 }
244 
245 #endif
void setStackPointer(uintptr_t stackPointer)
Definition: mips32/state.h:199
void setBasePointer(uintptr_t basePointer)
Definition: mips32/state.h:213
uintptr_t getStackPointer() const
Definition: mips32/state.h:195
void setInstructionPointer(uintptr_t instructionPointer)
Definition: mips32/state.h:206
size_t getSyscallNumber() const
Definition: mips32/state.h:235
bool kernelMode() const
Definition: mips32/state.h:221
uintptr_t getBasePointer() const
Definition: mips32/state.h:209
size_t getRegisterSize(size_t index) const
Definition: mips32/state.h:216
processor_register_t getRegister(size_t index) const
Definition: mips32/state.cc:90
size_t getInterruptNumber() const
Definition: mips32/state.h:225
size_t getSyscallService() const
Definition: mips32/state.h:231
uintptr_t getInstructionPointer() const
Definition: mips32/state.h:202
const char * getRegisterName(size_t index) const
size_t getRegisterCount() const
Definition: mips32/state.cc:86
bool branchDelay() const
Definition: mips32/state.h:240
MIPS32InterruptState & operator=(const MIPS32InterruptState &)
Definition: mips32/state.cc:48