ReXGlue SDK
Toggle main menu visibility
Loading...
Searching...
No Matches
mmio.h
Go to the documentation of this file.
1
11
12
#pragma once
13
14
#include <optional>
15
16
#include <
rex/platform.h
>
17
#include <
rex/types.h
>
18
19
namespace
rex::ppc
{
20
21
enum class
MMIOBlock
: u8 {
23
kGPU,
25
kAPU,
26
};
27
28
inline
constexpr
u32 kMMIOBlockSize = 0x10000;
29
30
constexpr
u32 MMIOBlockBase(
MMIOBlock
block) {
31
return
block ==
MMIOBlock::kGPU
? 0x7FC80000u : 0x7FEA0000u;
32
}
33
39
constexpr
std::optional<MMIOBlock>
MMIOBlockOf
(u32 address) {
40
if
(address - MMIOBlockBase(
MMIOBlock::kGPU
) < kMMIOBlockSize) {
41
return
MMIOBlock::kGPU
;
42
}
43
if
(address - MMIOBlockBase(
MMIOBlock::kAPU
) < kMMIOBlockSize) {
44
return
MMIOBlock::kAPU
;
45
}
46
return
std::nullopt;
47
}
48
54
constexpr
bool
IsMMIOBlockAddress
(u32 address) {
55
return
MMIOBlockOf
(address).has_value();
56
}
57
58
struct
MMIORecipient
{
60
void
*
context
;
62
u32 (*
read
)(
void
*
context
, u32 address);
64
void (*
write
)(
void
*
context
, u32 address, u32 value);
65
};
66
74
REX_PPC_API
void
AttachMMIO
(
MMIOBlock
block,
const
MMIORecipient
& recipient);
75
82
REX_PPC_API
void
DetachMMIO
(
MMIOBlock
block,
const
void
* context);
83
84
namespace
detail {
85
87
REX_PPC_API
extern
MMIORecipient
mmio_slots[2];
88
89
}
// namespace detail
90
96
REX_PPC_API
u32
MMIOLoad32
(u32 address);
97
99
REX_PPC_API
void
MMIOStore32
(u32 address, u32 value);
100
107
REX_PPC_API
u8
MMIOLoad8
(u32 address);
108
114
REX_PPC_API
u16
MMIOLoad16
(u32 address);
115
117
[[noreturn]]
REX_PPC_API
void
MMIONarrowStore
(u32 address, u32 size);
118
119
}
// namespace rex::ppc
rex::ppc
Definition
title_runtime.h:33
rex::ppc::MMIOLoad8
REX_PPC_API u8 MMIOLoad8(u32 address)
rex::ppc::MMIOLoad16
REX_PPC_API u16 MMIOLoad16(u32 address)
rex::ppc::IsMMIOBlockAddress
constexpr bool IsMMIOBlockAddress(u32 address)
Definition
mmio.h:54
rex::ppc::DetachMMIO
REX_PPC_API void DetachMMIO(MMIOBlock block, const void *context)
rex::ppc::MMIOBlockOf
constexpr std::optional< MMIOBlock > MMIOBlockOf(u32 address)
Definition
mmio.h:39
rex::ppc::MMIOStore32
REX_PPC_API void MMIOStore32(u32 address, u32 value)
rex::ppc::AttachMMIO
REX_PPC_API void AttachMMIO(MMIOBlock block, const MMIORecipient &recipient)
rex::ppc::MMIOLoad32
REX_PPC_API u32 MMIOLoad32(u32 address)
rex::ppc::MMIOBlock
MMIOBlock
Definition
mmio.h:21
rex::ppc::MMIOBlock::kGPU
@ kGPU
Definition
mmio.h:23
rex::ppc::MMIOBlock::kAPU
@ kAPU
Definition
mmio.h:25
rex::ppc::MMIONarrowStore
REX_PPC_API void MMIONarrowStore(u32 address, u32 size)
platform.h
Platform flags, packing macros and export markers.
REX_PPC_API
#define REX_PPC_API
Definition
platform.h:194
rex::ppc::MMIORecipient
Definition
mmio.h:58
rex::ppc::MMIORecipient::context
void * context
Definition
mmio.h:60
rex::ppc::MMIORecipient::read
u32(*) read(void *context, u32 address)
Definition
mmio.h:62
rex::ppc::MMIORecipient::write
void(*) write(void *context, u32 address, u32 value)
Definition
mmio.h:64
types.h
Integer types, byte order wrappers and size literals.
rex
ppc
mmio.h
Generated by
1.18.0