Home | History | Annotate | Download | only in arm
      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 
     17 #ifndef ART_RUNTIME_ARCH_ARM_CONTEXT_ARM_H_
     18 #define ART_RUNTIME_ARCH_ARM_CONTEXT_ARM_H_
     19 
     20 #include "locks.h"
     21 #include "arch/context.h"
     22 #include "base/logging.h"
     23 #include "registers_arm.h"
     24 
     25 namespace art {
     26 namespace arm {
     27 
     28 class ArmContext : public Context {
     29  public:
     30   ArmContext() {
     31     Reset();
     32   }
     33 
     34   virtual ~ArmContext() {}
     35 
     36   virtual void Reset();
     37 
     38   virtual void FillCalleeSaves(const StackVisitor& fr);
     39 
     40   virtual void SetSP(uintptr_t new_sp) {
     41     SetGPR(SP, new_sp);
     42   }
     43 
     44   virtual void SetPC(uintptr_t new_pc) {
     45     SetGPR(PC, new_pc);
     46   }
     47 
     48   virtual uintptr_t GetGPR(uint32_t reg) {
     49     DCHECK_LT(reg, static_cast<uint32_t>(kNumberOfCoreRegisters));
     50     return *gprs_[reg];
     51   }
     52 
     53   virtual void SetGPR(uint32_t reg, uintptr_t value);
     54   virtual void SmashCallerSaves();
     55   virtual void DoLongJump();
     56 
     57  private:
     58   // Pointers to register locations, initialized to NULL or the specific registers below.
     59   uintptr_t* gprs_[kNumberOfCoreRegisters];
     60   uint32_t* fprs_[kNumberOfSRegisters];
     61   // Hold values for sp and pc if they are not located within a stack frame.
     62   uintptr_t sp_, pc_;
     63 };
     64 
     65 }  // namespace arm
     66 }  // namespace art
     67 
     68 #endif  // ART_RUNTIME_ARCH_ARM_CONTEXT_ARM_H_
     69