summaryrefslogtreecommitdiff
path: root/include/JSystem/JKernel/JKRAramStream.h
blob: ee36d5fcf73e35792756e9e8ce9c4f1fb18c32b9 (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
#ifndef JKRARAMSTREAM_H
#define JKRARAMSTREAM_H

#include "JSystem/JKernel/JKRThread.h"

class JSUFileInputStream;

class JKRAramStreamCommand {
public:
    enum Type {
        UNKNOWN = 0,
        READ = 1,
        WRITE = 2,
    };

    JKRAramStreamCommand();

public:
    /* 0x00 */ Type mType;
    /* 0x04 */ u32 mAddress;
    /* 0x08 */ u32 mSize;
    /* 0x0C */ u32 field_0x0c;
    /* 0x10 */ JSUFileInputStream* mStream;
    /* 0x14 */ u32 mOffset;
    /* 0x18 */ u8* mTransferBuffer;
    /* 0x1C */ u32 mTransferBufferSize;
    /* 0x20 */ JKRHeap* mHeap;
    /* 0x24 */ bool mAllocatedTransferBuffer;
    /* 0x25 */ u8 padding_0x29[3];
    /* 0x28 */ u32 field_0x2c;
    /* 0x2C */ OSMessageQueue mMessageQueue;
    /* 0x4C */ OSMessage mMessage;
    /* 0x50 */ u32 field_0x54;
    /* 0x54 */ u32 field_0x58;
};

class JKRAramStream : public JKRThread {
private:
    JKRAramStream(s32);
    virtual ~JKRAramStream();

    /* vt[03] */ void* run(void); /* override */

public:
    static JKRAramStream* create(s32);

    static s32 readFromAram(void);
    static s32 writeToAram(JKRAramStreamCommand*);
    static JKRAramStreamCommand* write_StreamToAram_Async(JSUFileInputStream*, u32, u32, u32);
    static JKRAramStreamCommand* sync(JKRAramStreamCommand*, BOOL);
    static void setTransBuffer(u8*, u32, JKRHeap*);

private:
    static JKRAramStream* sAramStreamObject;
    static OSMessage sMessageBuffer[4];
    static OSMessageQueue sMessageQueue;

    static u8* transBuffer;
    static u32 transSize;
    static JKRHeap* transHeap;
};

inline JKRAramStream* JKRCreateAramStreamManager(s32 priority) {
    return JKRAramStream::create(priority);
}

inline JKRAramStreamCommand* JKRStreamToAram_Async(JSUFileInputStream *stream, u32 addr, u32 size, u32 offset, void (*callback)(u32)) {
    return JKRAramStream::write_StreamToAram_Async(stream, addr, size, offset);
}

#endif /* JKRARAMSTREAM_H */