TEMU  4.4
The Terma Emulator
PowerPC.h
Go to the documentation of this file.
1 //===-- temu-c/PowerPC.h - PowerPC Architecture Interfaces --------*- C++
2 //-*-===//
3 //
4 // TEMU: The Terma Emulator
5 // (c) Terma 2018
6 // Authors: Mattias Holm <maho (at) terma.com>
7 //
8 //===----------------------------------------------------------------------===//
9 
10 #ifndef TEMU_POWERPC_H
11 #define TEMU_POWERPC_H
12 
13 #include "temu-c/Memory/Memory.h"
14 #include "temu-c/Support/Objsys.h"
15 #include <stdint.h>
16 
17 #ifdef __cplusplus
18 extern "C" {
19 #endif
20 
21 /*!
22  Interface for PowerPC specific functionality
23  */
24 typedef struct temu_PowerPCIface {
25  uint64_t (*getXER)(const void *Cpu); //!< Get XER register
26  void (*setXER)(void *Cpu, uint64_t Value); //!< Set XER register
27  uint32_t (*getCR)(const void *Cpu); //!< Get CR register
28  void (*setCR)(void *Cpu, uint32_t Value); //!< Set XER register
29  uint64_t (*getMSR)(const void *Cpu); //!< Get MSR register
30  void (*setMSR)(void *Cpu, uint64_t Value); //!< Set MSR register
31  uint64_t (*getReserveAddress)(
32  const void *Obj); //!< Get reserved address as used by `lwarx` and `stwcx`
33  void (*setReserveAddress)(const void *Obj,
34  uint64_t address); //!< Set reserved address as used
35  //!< by `lwarx` and `stwcx`
37  const void *Obj); //!< Check if reserved address as used by `lwarx` and
38  //!< `stwcx` is set
40  const void
41  *Obj); //!< Clear reserved address as used by `lwarx` and `stwcx`
42  uint32_t (*getCTR)(const void *Cpu); //!< Get CTR register
43  void (*setCTR)(void *Cpu, uint32_t Value); //!< Set CTR register
44  uint64_t (*getLR)(const void *Cpu); //!< Get LR register
45  void (*setLR)(void *Cpu, uint64_t Value); //!< Set LR register
46  uint32_t (*getFPSCR)(const void *Cpu); //!< Get FPSCR register
47  void (*setFPSCR)(void *Cpu, uint32_t Value); //!< Set FPSCR register
49  void *Obj, unsigned RID,
50  temu_MemAccessIfaceRef Device); //!< Install EA resource
51 } temu_PowerPCIface;
52 
53 #define TEMU_POWERPC_IFACE_TYPE "temu::PowerPCIface"
54 TEMU_IFACE_REFERENCE_TYPE(temu_PowerPC);
55 
56 // TLB entries for the E500 MMU are defined to contain a certain number of bits.
57 // These bits are essentially the contents of the MAS1, 2, 3 and 7 registers.
58 // These are the only SW visible parts of the MMU TLBs,
59 typedef struct {
60  unsigned V : 1;
61  unsigned TS : 1;
62  unsigned TID : 2;
63  unsigned EPN : 20;
64  unsigned RPN : 20;
65  unsigned SIZE : 4;
66  unsigned SX : 1;
67  unsigned SR : 1;
68  unsigned SW : 1;
69  unsigned UX : 1;
70  unsigned UR : 1;
71  unsigned UW : 1;
72  unsigned WIMGE : 5;
73  unsigned X0 : 1;
74  unsigned X1 : 1;
75  unsigned U0 : 1;
76  unsigned U1 : 1;
77  unsigned U2 : 1;
78  unsigned U3 : 1;
79  unsigned IPROT : 1;
80 } temu_E500TLBEntry;
81 
82 typedef struct {
83  temu_E500TLBEntry (*getTLB0Entry)(void *obj, int set, int way);
84  void (*setTLB0Entry)(void *obj, int set, int way,
85  const temu_E500TLBEntry *entry);
86 
87  temu_E500TLBEntry (*getTLB1Entry)(void *obj, int entryId);
88  void (*setTLB1Entry)(void *obj, int entryId, const temu_E500TLBEntry *entry);
89 } temu_E500MMUIface;
90 #define TEMU_E500_MMU_IFACE_TYPE "temu::E500MMUIface"
91 TEMU_IFACE_REFERENCE_TYPE(temu_E500MMU);
92 
93 #ifdef __cplusplus
94 }
95 #endif
96 
97 #endif /* ! TEMU_POWERPC_H */
temu_E500TLBEntry::UW
unsigned UW
Definition: PowerPC.h:71
temu_PowerPCIface::installEAResource
void(* installEAResource)(void *Obj, unsigned RID, temu_MemAccessIfaceRef Device)
Install EA resource.
Definition: PowerPC.h:48
temu_E500TLBEntry::U3
unsigned U3
Definition: PowerPC.h:78
temu_E500TLBEntry::SW
unsigned SW
Definition: PowerPC.h:68
temu_E500TLBEntry::IPROT
unsigned IPROT
Definition: PowerPC.h:79
temu_E500TLBEntry::WIMGE
unsigned WIMGE
Definition: PowerPC.h:72
temu_PowerPCIface::setCR
void(* setCR)(void *Cpu, uint32_t Value)
Set XER register.
Definition: PowerPC.h:28
temu_E500TLBEntry::U0
unsigned U0
Definition: PowerPC.h:75
temu_PowerPCIface::setFPSCR
void(* setFPSCR)(void *Cpu, uint32_t Value)
Set FPSCR register.
Definition: PowerPC.h:47
temu_PowerPCIface::setLR
void(* setLR)(void *Cpu, uint64_t Value)
Set LR register.
Definition: PowerPC.h:45
temu_E500TLBEntry::U1
unsigned U1
Definition: PowerPC.h:76
temu_PowerPCIface::setMSR
void(* setMSR)(void *Cpu, uint64_t Value)
Set MSR register.
Definition: PowerPC.h:30
temu_E500TLBEntry::UR
unsigned UR
Definition: PowerPC.h:70
temu_E500TLBEntry::U2
unsigned U2
Definition: PowerPC.h:77
temu_E500TLBEntry::EPN
unsigned EPN
Definition: PowerPC.h:63
temu_E500MMUIface::setTLB1Entry
void(* setTLB1Entry)(void *obj, int entryId, const temu_E500TLBEntry *entry)
Definition: PowerPC.h:88
temu_PowerPCIface
Definition: PowerPC.h:24
temu_E500TLBEntry::SIZE
unsigned SIZE
Definition: PowerPC.h:65
temu_PowerPCIface::clearAddressReservation
void(* clearAddressReservation)(const void *Obj)
Clear reserved address as used by lwarx and stwcx
Definition: PowerPC.h:39
temu_E500TLBEntry::TID
unsigned TID
Definition: PowerPC.h:62
temu_E500TLBEntry::TS
unsigned TS
Definition: PowerPC.h:61
temu_E500TLBEntry::X1
unsigned X1
Definition: PowerPC.h:74
temu_E500TLBEntry::SR
unsigned SR
Definition: PowerPC.h:67
temu_PowerPCIface::setReserveAddress
void(* setReserveAddress)(const void *Obj, uint64_t address)
Definition: PowerPC.h:33
temu_E500TLBEntry::SX
unsigned SX
Definition: PowerPC.h:66
temu_E500TLBEntry::RPN
unsigned RPN
Definition: PowerPC.h:64
temu_PowerPCIface::setCTR
void(* setCTR)(void *Cpu, uint32_t Value)
Set CTR register.
Definition: PowerPC.h:43
temu_E500TLBEntry::X0
unsigned X0
Definition: PowerPC.h:73
temu_E500MMUIface::setTLB0Entry
void(* setTLB0Entry)(void *obj, int set, int way, const temu_E500TLBEntry *entry)
Definition: PowerPC.h:84
temu_PowerPCIface::isReservationBitSet
int(* isReservationBitSet)(const void *Obj)
Definition: PowerPC.h:36
temu_PowerPCIface::setXER
void(* setXER)(void *Cpu, uint64_t Value)
Set XER register.
Definition: PowerPC.h:26
temu_E500TLBEntry::V
unsigned V
Definition: PowerPC.h:60
temu_E500TLBEntry::UX
unsigned UX
Definition: PowerPC.h:69