ReXGlue SDK
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
19namespace rex::ppc {
20
21enum class MMIOBlock : u8 {
23 kGPU,
25 kAPU,
26};
27
28inline constexpr u32 kMMIOBlockSize = 0x10000;
29
30constexpr u32 MMIOBlockBase(MMIOBlock block) {
31 return block == MMIOBlock::kGPU ? 0x7FC80000u : 0x7FEA0000u;
32}
33
39constexpr 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
54constexpr bool IsMMIOBlockAddress(u32 address) {
55 return MMIOBlockOf(address).has_value();
56}
57
60 void* context;
62 u32 (*read)(void* context, u32 address);
64 void (*write)(void* context, u32 address, u32 value);
65};
66
74REX_PPC_API void AttachMMIO(MMIOBlock block, const MMIORecipient& recipient);
75
82REX_PPC_API void DetachMMIO(MMIOBlock block, const void* context);
83
84namespace detail {
85
87REX_PPC_API extern MMIORecipient mmio_slots[2];
88
89} // namespace detail
90
96REX_PPC_API u32 MMIOLoad32(u32 address);
97
99REX_PPC_API void MMIOStore32(u32 address, u32 value);
100
107REX_PPC_API u8 MMIOLoad8(u32 address);
108
114REX_PPC_API u16 MMIOLoad16(u32 address);
115
117[[noreturn]] REX_PPC_API void MMIONarrowStore(u32 address, u32 size);
118
119} // namespace rex::ppc
Definition title_runtime.h:33
REX_PPC_API u8 MMIOLoad8(u32 address)
REX_PPC_API u16 MMIOLoad16(u32 address)
constexpr bool IsMMIOBlockAddress(u32 address)
Definition mmio.h:54
REX_PPC_API void DetachMMIO(MMIOBlock block, const void *context)
constexpr std::optional< MMIOBlock > MMIOBlockOf(u32 address)
Definition mmio.h:39
REX_PPC_API void MMIOStore32(u32 address, u32 value)
REX_PPC_API void AttachMMIO(MMIOBlock block, const MMIORecipient &recipient)
REX_PPC_API u32 MMIOLoad32(u32 address)
MMIOBlock
Definition mmio.h:21
@ kGPU
Definition mmio.h:23
@ kAPU
Definition mmio.h:25
REX_PPC_API void MMIONarrowStore(u32 address, u32 size)
Platform flags, packing macros and export markers.
#define REX_PPC_API
Definition platform.h:194
Definition mmio.h:58
void * context
Definition mmio.h:60
u32(*) read(void *context, u32 address)
Definition mmio.h:62
void(*) write(void *context, u32 address, u32 value)
Definition mmio.h:64
Integer types, byte order wrappers and size literals.