The Pedigree Project  0.1
arm_926e/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_ARM926E_STATE_H
21 #define KERNEL_PROCESSOR_ARM926E_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  private:
94  public:
96 
106  {
107  }
108 
110  uint32_t m_r0;
111  uint32_t m_r1;
112  uint32_t m_r2;
113  uint32_t m_r3;
114  uint32_t m_r4;
115  uint32_t m_r5;
116  uint32_t m_r6;
117  uint32_t m_r7;
118  uint32_t m_r8;
119  uint32_t m_r9;
120  uint32_t m_r10;
121  uint32_t m_Fp;
122  uint32_t m_r12;
123  uint32_t m_Sp;
124  uint32_t m_Lnk;
125  uint32_t m_Pc;
126  uint32_t
127  m_Cpsr; // holds cpu mode, IRQ and FIQ status, and 4 flags (32-bit)
128 } PACKED;
129 
132 
133 class __attribute__((aligned(16))) ARM926ESchedulerState
134 {
135  public:
136  uint32_t edi;
137  uint32_t esi;
138  uint32_t ebx;
139  uint32_t ebp;
140  uint32_t esp;
141  uint32_t eip;
142 
143  // bit 0: Has FPU
144  // bit 1: Used SSE
145  uint32_t flags;
146 
147  uint8_t x87FPU_MMX_XMM_MXCSR_State[512 + 16] __attribute__((aligned(16)));
148 } __attribute__((aligned(16)));
149 
152 //
153 // Part of the Implementation
154 //
155 
157 {
158  return m_Sp;
159 }
160 void ARM926EInterruptState::setStackPointer(uintptr_t stackPointer)
161 {
162 }
164 {
165  return m_Pc;
166 }
167 void ARM926EInterruptState::setInstructionPointer(uintptr_t instructionPointer)
168 {
169 }
171 {
172  return m_Fp; // assume frame pointer = base pointer
173 }
174 void ARM926EInterruptState::setBasePointer(uintptr_t basePointer)
175 {
176  m_Fp = basePointer; // TODO: some form of casting? Not sure which to use...
177 }
178 size_t ARM926EInterruptState::getRegisterSize(size_t index) const
179 {
180 #if defined(BITS_32)
181  return 4;
182 #else
183  return 4; // TODO: handle other bits sizes (this is mainly here)
184  // in order to help future development if ARM ends up
185  // requiring 64-bit or something
186 #endif
187 }
188 
190 {
191  // TODO: the ARM926E is NOT always in kernel mode, handle this properly
192  // This'll require some reading up on the CPSR mode bits
193  return true;
194 }
196 {
197  // TODO: implement
198  return 0;
199 }
200 
202 {
203  // TODO: implement
204  return 0;
205 }
207 {
208  // TODO: implement
209  return 0;
210 }
211 
212 #endif
processor_register_t getRegister(size_t index) const
uintptr_t getBasePointer() const
size_t getRegisterSize(size_t index) const
void setStackPointer(uintptr_t stackPointer)
size_t getSyscallService() const
size_t getSyscallNumber() const
size_t getRegisterCount() const
const char * getRegisterName(size_t index) const
size_t getInterruptNumber() const
void setInstructionPointer(uintptr_t instructionPointer)
ARM926EInterruptState & operator=(const ARM926EInterruptState &)
void setBasePointer(uintptr_t basePointer)
bool kernelMode() const
uintptr_t getInstructionPointer() const
uintptr_t getStackPointer() const