blob: e894f169d36a4bde76c258cd4c6701f43c498d4c [file] [log] [blame]
Elliott Hughes2faa5f12012-01-30 14:42:07 -08001/*
2 * Copyright (C) 2011 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 */
Ian Rogersbdb03912011-09-14 00:55:44 -070016
Ian Rogers166db042013-07-26 12:05:57 -070017#ifndef ART_RUNTIME_ARCH_ARM_CONTEXT_ARM_H_
18#define ART_RUNTIME_ARCH_ARM_CONTEXT_ARM_H_
Ian Rogersbdb03912011-09-14 00:55:44 -070019
Ian Rogers166db042013-07-26 12:05:57 -070020#include "arch/context.h"
21#include "base/logging.h"
22#include "registers_arm.h"
Ian Rogersbdb03912011-09-14 00:55:44 -070023
24namespace art {
25namespace arm {
26
27class ArmContext : public Context {
28 public:
Mathieu Chartier67022432012-11-29 18:04:50 -080029 ArmContext() {
30 Reset();
31 }
32
Ian Rogersbdb03912011-09-14 00:55:44 -070033 virtual ~ArmContext() {}
34
Sebastien Hertz0bcb2902014-06-17 15:52:45 +020035 void Reset() OVERRIDE;
Mathieu Chartier67022432012-11-29 18:04:50 -080036
Sebastien Hertz0bcb2902014-06-17 15:52:45 +020037 void FillCalleeSaves(const StackVisitor& fr) OVERRIDE SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Ian Rogersbdb03912011-09-14 00:55:44 -070038
Sebastien Hertz0bcb2902014-06-17 15:52:45 +020039 void SetSP(uintptr_t new_sp) OVERRIDE {
40 bool success = SetGPR(SP, new_sp);
41 CHECK(success) << "Failed to set SP register";
Ian Rogersbdb03912011-09-14 00:55:44 -070042 }
43
Sebastien Hertz0bcb2902014-06-17 15:52:45 +020044 void SetPC(uintptr_t new_pc) OVERRIDE {
45 bool success = SetGPR(PC, new_pc);
46 CHECK(success) << "Failed to set PC register";
Ian Rogersbdb03912011-09-14 00:55:44 -070047 }
48
Sebastien Hertz0bcb2902014-06-17 15:52:45 +020049 uintptr_t* GetGPRAddress(uint32_t reg) OVERRIDE {
Mathieu Chartier815873e2014-02-13 18:02:13 -080050 DCHECK_LT(reg, static_cast<uint32_t>(kNumberOfCoreRegisters));
51 return gprs_[reg];
52 }
53
Sebastien Hertz0bcb2902014-06-17 15:52:45 +020054 bool GetGPR(uint32_t reg, uintptr_t* val) OVERRIDE {
Ian Rogers166db042013-07-26 12:05:57 -070055 DCHECK_LT(reg, static_cast<uint32_t>(kNumberOfCoreRegisters));
Sebastien Hertz0bcb2902014-06-17 15:52:45 +020056 if (gprs_[reg] == nullptr) {
57 return false;
58 } else {
59 DCHECK(val != nullptr);
60 *val = *gprs_[reg];
61 return true;
62 }
Ian Rogersd6b1f612011-09-27 13:38:14 -070063 }
64
Sebastien Hertz0bcb2902014-06-17 15:52:45 +020065 bool SetGPR(uint32_t reg, uintptr_t value) OVERRIDE;
66
67 bool GetFPR(uint32_t reg, uintptr_t* val) OVERRIDE {
68 DCHECK_LT(reg, static_cast<uint32_t>(kNumberOfSRegisters));
69 if (fprs_[reg] == nullptr) {
70 return false;
71 } else {
72 DCHECK(val != nullptr);
73 *val = *fprs_[reg];
74 return true;
75 }
76 }
77
78 bool SetFPR(uint32_t reg, uintptr_t value) OVERRIDE;
79
80 void SmashCallerSaves() OVERRIDE;
81 void DoLongJump() OVERRIDE;
Ian Rogersbdb03912011-09-14 00:55:44 -070082
83 private:
Mathieu Chartier67022432012-11-29 18:04:50 -080084 // Pointers to register locations, initialized to NULL or the specific registers below.
85 uintptr_t* gprs_[kNumberOfCoreRegisters];
86 uint32_t* fprs_[kNumberOfSRegisters];
87 // Hold values for sp and pc if they are not located within a stack frame.
88 uintptr_t sp_, pc_;
Ian Rogersbdb03912011-09-14 00:55:44 -070089};
90
91} // namespace arm
92} // namespace art
93
Ian Rogers166db042013-07-26 12:05:57 -070094#endif // ART_RUNTIME_ARCH_ARM_CONTEXT_ARM_H_