11a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe/* 21a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe * Copyright (C) 2014 The Android Open Source Project 31a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe * 41a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe * Licensed under the Apache License, Version 2.0 (the "License"); 51a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe * you may not use this file except in compliance with the License. 61a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe * You may obtain a copy of the License at 71a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe * 81a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe * http://www.apache.org/licenses/LICENSE-2.0 91a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe * 101a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe * Unless required by applicable law or agreed to in writing, software 111a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe * distributed under the License is distributed on an "AS IS" BASIS, 121a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 131a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe * See the License for the specific language governing permissions and 141a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe * limitations under the License. 151a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe */ 161a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe 171a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe#ifndef ART_RUNTIME_ARCH_MIPS64_CONTEXT_MIPS64_H_ 181a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe#define ART_RUNTIME_ARCH_MIPS64_CONTEXT_MIPS64_H_ 191a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe 201a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe#include "arch/context.h" 211a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe#include "base/logging.h" 22794ad76e8d5b5b9132819d5b08a0570e27615644Andreas Gampe#include "base/macros.h" 231a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe#include "registers_mips64.h" 241a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe 251a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampenamespace art { 261a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampenamespace mips64 { 271a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe 281a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampeclass Mips64Context : public Context { 291a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe public: 301a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe Mips64Context() { 311a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe Reset(); 321a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe } 331a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe virtual ~Mips64Context() {} 341a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe 351a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe void Reset() OVERRIDE; 361a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe 371a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe void FillCalleeSaves(const StackVisitor& fr) OVERRIDE SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); 381a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe 391a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe void SetSP(uintptr_t new_sp) OVERRIDE { 4096ba8dc82e7bd859106af837623fe8b2e9e772c3Sebastien Hertz SetGPR(SP, new_sp); 411a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe } 421a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe 431a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe void SetPC(uintptr_t new_pc) OVERRIDE { 4496ba8dc82e7bd859106af837623fe8b2e9e772c3Sebastien Hertz SetGPR(RA, new_pc); 4596ba8dc82e7bd859106af837623fe8b2e9e772c3Sebastien Hertz } 4696ba8dc82e7bd859106af837623fe8b2e9e772c3Sebastien Hertz 4796ba8dc82e7bd859106af837623fe8b2e9e772c3Sebastien Hertz bool IsAccessibleGPR(uint32_t reg) OVERRIDE { 4896ba8dc82e7bd859106af837623fe8b2e9e772c3Sebastien Hertz DCHECK_LT(reg, static_cast<uint32_t>(kNumberOfGpuRegisters)); 4996ba8dc82e7bd859106af837623fe8b2e9e772c3Sebastien Hertz return gprs_[reg] != nullptr; 501a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe } 511a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe 521a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe uintptr_t* GetGPRAddress(uint32_t reg) OVERRIDE { 531a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe DCHECK_LT(reg, static_cast<uint32_t>(kNumberOfGpuRegisters)); 541a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe return gprs_[reg]; 551a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe } 561a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe 5796ba8dc82e7bd859106af837623fe8b2e9e772c3Sebastien Hertz uintptr_t GetGPR(uint32_t reg) OVERRIDE { 581a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe CHECK_LT(reg, static_cast<uint32_t>(kNumberOfGpuRegisters)); 5996ba8dc82e7bd859106af837623fe8b2e9e772c3Sebastien Hertz DCHECK(IsAccessibleGPR(reg)); 6096ba8dc82e7bd859106af837623fe8b2e9e772c3Sebastien Hertz return *gprs_[reg]; 611a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe } 621a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe 6396ba8dc82e7bd859106af837623fe8b2e9e772c3Sebastien Hertz void SetGPR(uint32_t reg, uintptr_t value) OVERRIDE; 6496ba8dc82e7bd859106af837623fe8b2e9e772c3Sebastien Hertz 6596ba8dc82e7bd859106af837623fe8b2e9e772c3Sebastien Hertz bool IsAccessibleFPR(uint32_t reg) OVERRIDE { 6696ba8dc82e7bd859106af837623fe8b2e9e772c3Sebastien Hertz CHECK_LT(reg, static_cast<uint32_t>(kNumberOfFpuRegisters)); 6796ba8dc82e7bd859106af837623fe8b2e9e772c3Sebastien Hertz return fprs_[reg] != nullptr; 6896ba8dc82e7bd859106af837623fe8b2e9e772c3Sebastien Hertz } 691a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe 7096ba8dc82e7bd859106af837623fe8b2e9e772c3Sebastien Hertz uintptr_t GetFPR(uint32_t reg) OVERRIDE { 711a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe CHECK_LT(reg, static_cast<uint32_t>(kNumberOfFpuRegisters)); 7296ba8dc82e7bd859106af837623fe8b2e9e772c3Sebastien Hertz DCHECK(IsAccessibleFPR(reg)); 7396ba8dc82e7bd859106af837623fe8b2e9e772c3Sebastien Hertz return *fprs_[reg]; 741a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe } 751a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe 7696ba8dc82e7bd859106af837623fe8b2e9e772c3Sebastien Hertz void SetFPR(uint32_t reg, uintptr_t value) OVERRIDE; 771a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe 781a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe void SmashCallerSaves() OVERRIDE; 79794ad76e8d5b5b9132819d5b08a0570e27615644Andreas Gampe NO_RETURN void DoLongJump() OVERRIDE; 801a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe 811a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe private: 822cebb24bfc3247d3e9be138a3350106737455918Mathieu Chartier // Pointers to registers in the stack, initialized to null except for the special cases below. 831a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe uintptr_t* gprs_[kNumberOfGpuRegisters]; 841a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe uint64_t* fprs_[kNumberOfFpuRegisters]; 851a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe // Hold values for sp and ra (return address) if they are not located within a stack frame. 861a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe uintptr_t sp_, ra_; 871a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe}; 881a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe} // namespace mips64 891a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe} // namespace art 901a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe 911a5c40672783fac98aca5a04ac798a0a0014de65Andreas Gampe#endif // ART_RUNTIME_ARCH_MIPS64_CONTEXT_MIPS64_H_ 92