blob: 4fec9ad5328ff52ddeb1add3d8fb20688d9eef1a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
#include "JSystem/JSystem.h" // IWYU pragma: keep
#include "JSystem/JHostIO/JHICommonMem.h"
#include "JSystem/JKernel/JKRHeap.h"
#ifdef __REVOLUTION_SDK__
#include <revolution.h>
#else
#include <dolphin.h>
#endif
int JHIMemBuf::create() {
int rt = 1;
if (mp_buffer == NULL) {
mp_buffer = new (32) u8[0x20000];
if (mp_buffer == NULL) {
rt = 0;
OS_REPORT("ERROR: hioSync Alloc Mem NG!\n");
} else {
OS_REPORT("INFO: hioSync Alloc Mem OK! %08x\n", mp_buffer);
}
}
return rt;
}
int JHIMemBuf::open() {
return 1;
}
void JHIMemBuf::close() {
if (mp_buffer != NULL) {
delete[] mp_buffer;
}
}
JHIMemBuf::~JHIMemBuf() {
close();
}
u8* JHIMemBuf::getPointer() const {
return mp_buffer;
}
u32 JHIMemBuf::readIO(u32 position) const {
u32 data;
readIO(position, &data);
return data;
}
void JHIMemBuf::readIO(u32 position, u32* out_data) const {
u8* read_ptr = getPointer() + position;
*out_data = (read_ptr[0] << 0x18) |
(read_ptr[1] << 0x10) |
(read_ptr[2] << 0x08) |
(read_ptr[3] << 0x00);
}
void JHIMemBuf::writeIO(u32 position, u8* src_data, u32 length) const {
u8* write_ptr = getPointer() + position;
while (--length != 0) {
*write_ptr = *src_data++;
write_ptr++;
}
}
void JHIMemBuf::writeIO(u32 position, u32 data) const {
u8* write_ptr = getPointer() + position;
*write_ptr++ = data >> 0x18;
*write_ptr++ = data >> 0x10;
*write_ptr++ = data >> 0x08;
*write_ptr++ = data >> 0x00;
}
|