1 //===-- RegisterContextPOSIX_powerpc.h --------------------------*- C++ -*-===// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 9 #ifndef LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_REGISTERCONTEXTPOSIX_POWERPC_H 10 #define LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_REGISTERCONTEXTPOSIX_POWERPC_H 11 12 #include "RegisterContext_powerpc.h" 13 #include "RegisterInfoInterface.h" 14 #include "lldb/Target/RegisterContext.h" 15 #include "lldb/Utility/Log.h" 16 17 // Internal codes for all powerpc registers. 18 enum { 19 k_first_gpr_powerpc, 20 gpr_r0_powerpc = k_first_gpr_powerpc, 21 gpr_r1_powerpc, 22 gpr_r2_powerpc, 23 gpr_r3_powerpc, 24 gpr_r4_powerpc, 25 gpr_r5_powerpc, 26 gpr_r6_powerpc, 27 gpr_r7_powerpc, 28 gpr_r8_powerpc, 29 gpr_r9_powerpc, 30 gpr_r10_powerpc, 31 gpr_r11_powerpc, 32 gpr_r12_powerpc, 33 gpr_r13_powerpc, 34 gpr_r14_powerpc, 35 gpr_r15_powerpc, 36 gpr_r16_powerpc, 37 gpr_r17_powerpc, 38 gpr_r18_powerpc, 39 gpr_r19_powerpc, 40 gpr_r20_powerpc, 41 gpr_r21_powerpc, 42 gpr_r22_powerpc, 43 gpr_r23_powerpc, 44 gpr_r24_powerpc, 45 gpr_r25_powerpc, 46 gpr_r26_powerpc, 47 gpr_r27_powerpc, 48 gpr_r28_powerpc, 49 gpr_r29_powerpc, 50 gpr_r30_powerpc, 51 gpr_r31_powerpc, 52 gpr_lr_powerpc, 53 gpr_cr_powerpc, 54 gpr_xer_powerpc, 55 gpr_ctr_powerpc, 56 gpr_pc_powerpc, 57 k_last_gpr_powerpc = gpr_pc_powerpc, 58 59 k_first_fpr, 60 fpr_f0_powerpc = k_first_fpr, 61 fpr_f1_powerpc, 62 fpr_f2_powerpc, 63 fpr_f3_powerpc, 64 fpr_f4_powerpc, 65 fpr_f5_powerpc, 66 fpr_f6_powerpc, 67 fpr_f7_powerpc, 68 fpr_f8_powerpc, 69 fpr_f9_powerpc, 70 fpr_f10_powerpc, 71 fpr_f11_powerpc, 72 fpr_f12_powerpc, 73 fpr_f13_powerpc, 74 fpr_f14_powerpc, 75 fpr_f15_powerpc, 76 fpr_f16_powerpc, 77 fpr_f17_powerpc, 78 fpr_f18_powerpc, 79 fpr_f19_powerpc, 80 fpr_f20_powerpc, 81 fpr_f21_powerpc, 82 fpr_f22_powerpc, 83 fpr_f23_powerpc, 84 fpr_f24_powerpc, 85 fpr_f25_powerpc, 86 fpr_f26_powerpc, 87 fpr_f27_powerpc, 88 fpr_f28_powerpc, 89 fpr_f29_powerpc, 90 fpr_f30_powerpc, 91 fpr_f31_powerpc, 92 fpr_fpscr_powerpc, 93 k_last_fpr = fpr_fpscr_powerpc, 94 95 k_first_vmx, 96 vmx_v0_powerpc = k_first_vmx, 97 vmx_v1_powerpc, 98 vmx_v2_powerpc, 99 vmx_v3_powerpc, 100 vmx_v4_powerpc, 101 vmx_v5_powerpc, 102 vmx_v6_powerpc, 103 vmx_v7_powerpc, 104 vmx_v8_powerpc, 105 vmx_v9_powerpc, 106 vmx_v10_powerpc, 107 vmx_v11_powerpc, 108 vmx_v12_powerpc, 109 vmx_v13_powerpc, 110 vmx_v14_powerpc, 111 vmx_v15_powerpc, 112 vmx_v16_powerpc, 113 vmx_v17_powerpc, 114 vmx_v18_powerpc, 115 vmx_v19_powerpc, 116 vmx_v20_powerpc, 117 vmx_v21_powerpc, 118 vmx_v22_powerpc, 119 vmx_v23_powerpc, 120 vmx_v24_powerpc, 121 vmx_v25_powerpc, 122 vmx_v26_powerpc, 123 vmx_v27_powerpc, 124 vmx_v28_powerpc, 125 vmx_v29_powerpc, 126 vmx_v30_powerpc, 127 vmx_v31_powerpc, 128 vmx_vrsave_powerpc, 129 vmx_vscr_powerpc, 130 k_last_vmx = vmx_vscr_powerpc, 131 132 k_num_registers_powerpc, 133 k_num_gpr_registers_powerpc = k_last_gpr_powerpc - k_first_gpr_powerpc + 1, 134 k_num_fpr_registers_powerpc = k_last_fpr - k_first_fpr + 1, 135 k_num_vmx_registers_powerpc = k_last_vmx - k_first_vmx + 1, 136 }; 137 138 class RegisterContextPOSIX_powerpc : public lldb_private::RegisterContext { 139 public: 140 RegisterContextPOSIX_powerpc( 141 lldb_private::Thread &thread, uint32_t concrete_frame_idx, 142 lldb_private::RegisterInfoInterface *register_info); 143 144 ~RegisterContextPOSIX_powerpc() override; 145 146 void Invalidate(); 147 148 void InvalidateAllRegisters() override; 149 150 size_t GetRegisterCount() override; 151 152 virtual size_t GetGPRSize(); 153 154 virtual unsigned GetRegisterSize(unsigned reg); 155 156 virtual unsigned GetRegisterOffset(unsigned reg); 157 158 const lldb_private::RegisterInfo *GetRegisterInfoAtIndex(size_t reg) override; 159 160 size_t GetRegisterSetCount() override; 161 162 const lldb_private::RegisterSet *GetRegisterSet(size_t set) override; 163 164 const char *GetRegisterName(unsigned reg); 165 166 protected: 167 uint64_t 168 m_gpr_powerpc[k_num_gpr_registers_powerpc]; // general purpose registers. 169 uint64_t 170 m_fpr_powerpc[k_num_fpr_registers_powerpc]; // floating point registers. 171 uint32_t m_vmx_powerpc[k_num_vmx_registers_powerpc][4]; 172 std::unique_ptr<lldb_private::RegisterInfoInterface> 173 m_register_info_up; // Register Info Interface (FreeBSD or Linux) 174 175 // Determines if an extended register set is supported on the processor 176 // running the inferior process. 177 virtual bool IsRegisterSetAvailable(size_t set_index); 178 179 virtual const lldb_private::RegisterInfo *GetRegisterInfo(); 180 181 bool IsGPR(unsigned reg); 182 183 bool IsFPR(unsigned reg); 184 185 bool IsVMX(unsigned reg); 186 187 virtual bool ReadGPR() = 0; 188 virtual bool ReadFPR() = 0; 189 virtual bool ReadVMX() = 0; 190 virtual bool WriteGPR() = 0; 191 virtual bool WriteFPR() = 0; 192 virtual bool WriteVMX() = 0; 193 }; 194 195 #endif // LLDB_SOURCE_PLUGINS_PROCESS_UTILITY_REGISTERCONTEXTPOSIX_POWERPC_H 196