jeffhao | 7fbee07 | 2012-08-24 17:56:54 -0700 | [diff] [blame] | 1 | /* |
| 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 | */ |
| 16 | |
Ian Rogers | 166db04 | 2013-07-26 12:05:57 -0700 | [diff] [blame] | 17 | #ifndef ART_RUNTIME_ARCH_MIPS_CONTEXT_MIPS_H_ |
| 18 | #define ART_RUNTIME_ARCH_MIPS_CONTEXT_MIPS_H_ |
jeffhao | 7fbee07 | 2012-08-24 17:56:54 -0700 | [diff] [blame] | 19 | |
Ian Rogers | 166db04 | 2013-07-26 12:05:57 -0700 | [diff] [blame] | 20 | #include "arch/context.h" |
| 21 | #include "base/logging.h" |
| 22 | #include "registers_mips.h" |
jeffhao | 7fbee07 | 2012-08-24 17:56:54 -0700 | [diff] [blame] | 23 | |
| 24 | namespace art { |
| 25 | namespace mips { |
| 26 | |
| 27 | class MipsContext : public Context { |
| 28 | public: |
Mathieu Chartier | 6702243 | 2012-11-29 18:04:50 -0800 | [diff] [blame] | 29 | MipsContext() { |
| 30 | Reset(); |
| 31 | } |
jeffhao | 7fbee07 | 2012-08-24 17:56:54 -0700 | [diff] [blame] | 32 | virtual ~MipsContext() {} |
| 33 | |
Sebastien Hertz | 0bcb290 | 2014-06-17 15:52:45 +0200 | [diff] [blame] | 34 | void Reset() OVERRIDE; |
Mathieu Chartier | 6702243 | 2012-11-29 18:04:50 -0800 | [diff] [blame] | 35 | |
Sebastien Hertz | 0bcb290 | 2014-06-17 15:52:45 +0200 | [diff] [blame] | 36 | void FillCalleeSaves(const StackVisitor& fr) OVERRIDE SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
jeffhao | 7fbee07 | 2012-08-24 17:56:54 -0700 | [diff] [blame] | 37 | |
Sebastien Hertz | 0bcb290 | 2014-06-17 15:52:45 +0200 | [diff] [blame] | 38 | void SetSP(uintptr_t new_sp) OVERRIDE { |
Sebastien Hertz | 96ba8dc | 2015-01-22 18:57:14 +0100 | [diff] [blame^] | 39 | SetGPR(SP, new_sp); |
jeffhao | 7fbee07 | 2012-08-24 17:56:54 -0700 | [diff] [blame] | 40 | } |
| 41 | |
Sebastien Hertz | 0bcb290 | 2014-06-17 15:52:45 +0200 | [diff] [blame] | 42 | void SetPC(uintptr_t new_pc) OVERRIDE { |
Sebastien Hertz | 96ba8dc | 2015-01-22 18:57:14 +0100 | [diff] [blame^] | 43 | SetGPR(RA, new_pc); |
| 44 | } |
| 45 | |
| 46 | bool IsAccessibleGPR(uint32_t reg) OVERRIDE { |
| 47 | CHECK_LT(reg, static_cast<uint32_t>(kNumberOfCoreRegisters)); |
| 48 | return gprs_[reg] != nullptr; |
jeffhao | 7fbee07 | 2012-08-24 17:56:54 -0700 | [diff] [blame] | 49 | } |
| 50 | |
Sebastien Hertz | 0bcb290 | 2014-06-17 15:52:45 +0200 | [diff] [blame] | 51 | uintptr_t* GetGPRAddress(uint32_t reg) OVERRIDE { |
Mathieu Chartier | 815873e | 2014-02-13 18:02:13 -0800 | [diff] [blame] | 52 | DCHECK_LT(reg, static_cast<uint32_t>(kNumberOfCoreRegisters)); |
| 53 | return gprs_[reg]; |
| 54 | } |
| 55 | |
Sebastien Hertz | 96ba8dc | 2015-01-22 18:57:14 +0100 | [diff] [blame^] | 56 | uintptr_t GetGPR(uint32_t reg) OVERRIDE { |
Brian Carlstrom | 8b1ce16 | 2013-03-31 00:17:54 -0700 | [diff] [blame] | 57 | CHECK_LT(reg, static_cast<uint32_t>(kNumberOfCoreRegisters)); |
Sebastien Hertz | 96ba8dc | 2015-01-22 18:57:14 +0100 | [diff] [blame^] | 58 | DCHECK(IsAccessibleGPR(reg)); |
| 59 | return *gprs_[reg]; |
jeffhao | 7fbee07 | 2012-08-24 17:56:54 -0700 | [diff] [blame] | 60 | } |
| 61 | |
Sebastien Hertz | 96ba8dc | 2015-01-22 18:57:14 +0100 | [diff] [blame^] | 62 | void SetGPR(uint32_t reg, uintptr_t value) OVERRIDE; |
Sebastien Hertz | 0bcb290 | 2014-06-17 15:52:45 +0200 | [diff] [blame] | 63 | |
Sebastien Hertz | 96ba8dc | 2015-01-22 18:57:14 +0100 | [diff] [blame^] | 64 | bool IsAccessibleFPR(uint32_t reg) OVERRIDE { |
Sebastien Hertz | 0bcb290 | 2014-06-17 15:52:45 +0200 | [diff] [blame] | 65 | CHECK_LT(reg, static_cast<uint32_t>(kNumberOfFRegisters)); |
Sebastien Hertz | 96ba8dc | 2015-01-22 18:57:14 +0100 | [diff] [blame^] | 66 | return fprs_[reg] != nullptr; |
Sebastien Hertz | 0bcb290 | 2014-06-17 15:52:45 +0200 | [diff] [blame] | 67 | } |
| 68 | |
Sebastien Hertz | 96ba8dc | 2015-01-22 18:57:14 +0100 | [diff] [blame^] | 69 | uintptr_t GetFPR(uint32_t reg) OVERRIDE { |
| 70 | CHECK_LT(reg, static_cast<uint32_t>(kNumberOfFRegisters)); |
| 71 | DCHECK(IsAccessibleFPR(reg)); |
| 72 | return *fprs_[reg]; |
| 73 | } |
| 74 | |
| 75 | void SetFPR(uint32_t reg, uintptr_t value) OVERRIDE; |
Sebastien Hertz | 0bcb290 | 2014-06-17 15:52:45 +0200 | [diff] [blame] | 76 | |
| 77 | void SmashCallerSaves() OVERRIDE; |
| 78 | void DoLongJump() OVERRIDE; |
jeffhao | 7fbee07 | 2012-08-24 17:56:54 -0700 | [diff] [blame] | 79 | |
| 80 | private: |
Mathieu Chartier | 6702243 | 2012-11-29 18:04:50 -0800 | [diff] [blame] | 81 | // Pointers to registers in the stack, initialized to NULL except for the special cases below. |
| 82 | uintptr_t* gprs_[kNumberOfCoreRegisters]; |
| 83 | uint32_t* fprs_[kNumberOfFRegisters]; |
| 84 | // Hold values for sp and ra (return address) if they are not located within a stack frame. |
| 85 | uintptr_t sp_, ra_; |
jeffhao | 7fbee07 | 2012-08-24 17:56:54 -0700 | [diff] [blame] | 86 | }; |
| 87 | } // namespace mips |
| 88 | } // namespace art |
| 89 | |
Ian Rogers | 166db04 | 2013-07-26 12:05:57 -0700 | [diff] [blame] | 90 | #endif // ART_RUNTIME_ARCH_MIPS_CONTEXT_MIPS_H_ |