blob: 104672348b7c3d636e8fa2d02487a7cf19ac5d24 [file] [log] [blame]
Andreas Gampe1a5c4062015-01-15 12:10:47 -08001/*
2 * Copyright (C) 2014 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef ART_RUNTIME_ARCH_MIPS64_CONTEXT_MIPS64_H_
18#define ART_RUNTIME_ARCH_MIPS64_CONTEXT_MIPS64_H_
19
20#include "arch/context.h"
21#include "base/logging.h"
22#include "registers_mips64.h"
23
24namespace art {
25namespace mips64 {
26
27class Mips64Context : public Context {
28 public:
29 Mips64Context() {
30 Reset();
31 }
32 virtual ~Mips64Context() {}
33
34 void Reset() OVERRIDE;
35
36 void FillCalleeSaves(const StackVisitor& fr) OVERRIDE SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
37
38 void SetSP(uintptr_t new_sp) OVERRIDE {
Sebastien Hertz96ba8dc2015-01-22 18:57:14 +010039 SetGPR(SP, new_sp);
Andreas Gampe1a5c4062015-01-15 12:10:47 -080040 }
41
42 void SetPC(uintptr_t new_pc) OVERRIDE {
Sebastien Hertz96ba8dc2015-01-22 18:57:14 +010043 SetGPR(RA, new_pc);
44 }
45
46 bool IsAccessibleGPR(uint32_t reg) OVERRIDE {
47 DCHECK_LT(reg, static_cast<uint32_t>(kNumberOfGpuRegisters));
48 return gprs_[reg] != nullptr;
Andreas Gampe1a5c4062015-01-15 12:10:47 -080049 }
50
51 uintptr_t* GetGPRAddress(uint32_t reg) OVERRIDE {
52 DCHECK_LT(reg, static_cast<uint32_t>(kNumberOfGpuRegisters));
53 return gprs_[reg];
54 }
55
Sebastien Hertz96ba8dc2015-01-22 18:57:14 +010056 uintptr_t GetGPR(uint32_t reg) OVERRIDE {
Andreas Gampe1a5c4062015-01-15 12:10:47 -080057 CHECK_LT(reg, static_cast<uint32_t>(kNumberOfGpuRegisters));
Sebastien Hertz96ba8dc2015-01-22 18:57:14 +010058 DCHECK(IsAccessibleGPR(reg));
59 return *gprs_[reg];
Andreas Gampe1a5c4062015-01-15 12:10:47 -080060 }
61
Sebastien Hertz96ba8dc2015-01-22 18:57:14 +010062 void SetGPR(uint32_t reg, uintptr_t value) OVERRIDE;
Andreas Gampe1a5c4062015-01-15 12:10:47 -080063
Sebastien Hertz96ba8dc2015-01-22 18:57:14 +010064 bool IsAccessibleFPR(uint32_t reg) OVERRIDE {
Andreas Gampe1a5c4062015-01-15 12:10:47 -080065 CHECK_LT(reg, static_cast<uint32_t>(kNumberOfFpuRegisters));
Sebastien Hertz96ba8dc2015-01-22 18:57:14 +010066 return fprs_[reg] != nullptr;
Andreas Gampe1a5c4062015-01-15 12:10:47 -080067 }
68
Sebastien Hertz96ba8dc2015-01-22 18:57:14 +010069 uintptr_t GetFPR(uint32_t reg) OVERRIDE {
70 CHECK_LT(reg, static_cast<uint32_t>(kNumberOfFpuRegisters));
71 DCHECK(IsAccessibleFPR(reg));
72 return *fprs_[reg];
73 }
74
75 void SetFPR(uint32_t reg, uintptr_t value) OVERRIDE;
Andreas Gampe1a5c4062015-01-15 12:10:47 -080076
77 void SmashCallerSaves() OVERRIDE;
78 void DoLongJump() OVERRIDE;
79
80 private:
81 // Pointers to registers in the stack, initialized to NULL except for the special cases below.
82 uintptr_t* gprs_[kNumberOfGpuRegisters];
83 uint64_t* fprs_[kNumberOfFpuRegisters];
84 // Hold values for sp and ra (return address) if they are not located within a stack frame.
85 uintptr_t sp_, ra_;
86};
87} // namespace mips64
88} // namespace art
89
90#endif // ART_RUNTIME_ARCH_MIPS64_CONTEXT_MIPS64_H_