-
Notifications
You must be signed in to change notification settings - Fork 2
/
HDLGameSvr.h
executable file
·164 lines (141 loc) · 4.71 KB
/
HDLGameSvr.h
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
/* Server configuration */
#define MAX_CLIENTS 1
#define SERVER_PORT_NUM 45061
#define SERVER_DATA_PORT_NUM 45062
#define SERVER_MAIN_THREAD_PRIORITY 0x10
#define SERVER_CLIENT_THREAD_PRIORITY 0x11
#define SERVER_IO_THREAD_PRIORITY 0x12
#define SERVER_THREAD_STACK_SIZE 0xA00
#define CLIENT_THREAD_STACK_SIZE 0xA00
#define CLIENT_DATA_THREAD_STACK_SIZE 0xA00
struct HDDToolsPacketHdr
{
u32 command;
u32 PayloadLength;
int result;
} __attribute__((__packed__));
struct HDLGameInfo
{
char GameTitle[GAME_TITLE_MAX_LEN_BYTES + 1];
char DiscID[11]; /* E.g. SXXX-99999 */
char StartupFname[14]; /* E.g. "SXXX-999.99;1" */
u8 DiscType;
u32 SectorsInDiscLayer0;
u32 SectorsInDiscLayer1;
u8 CompatibilityFlags;
u8 TRType;
u8 TRMode;
} __attribute__((__packed__));
struct IOInitReq
{
u32 sectors, offset;
char partition[33];
} __attribute__((__packed__));
struct HDLGameEntryTransit
{
char PartName[33];
char GameTitle[GAME_TITLE_MAX_LEN_BYTES + 1];
char DiscID[11];
u8 CompatibilityModeFlags;
u8 TRType;
u8 TRMode;
u8 DiscType;
u32 sectors; // In 2048-byte units
} __attribute__((__packed__));
struct OSDResourceInitReq
{
int UseSaveData;
char OSDTitleLine1[OSD_TITLE_MAX_LEN_BYTES + 1]; // 16 characters maximum.
char OSDTitleLine2[OSD_TITLE_MAX_LEN_BYTES + 1]; // 16 characters maximum.
char DiscID[11];
char partition[33];
} __attribute__((__packed__));
struct OSDResourceWriteReq
{
int index;
u32 length;
} __attribute__((__packed__));
struct OSDResourceStat
{
u32 lengths[NUM_OSD_FILES_ENTS];
} __attribute__((__packed__));
struct OSDResourceStatReq
{
char partition[33];
} __attribute__((__packed__));
struct OSDResourceReadReq
{
char partition[33];
int index;
} __attribute__((__packed__));
struct OSD_TitlesTransit
{
char OSDTitleLine1[OSD_TITLE_MAX_LEN_BYTES + 1]; // 16 characters maximum.
char OSDTitleLine2[OSD_TITLE_MAX_LEN_BYTES + 1]; // 16 characters maximum.
} __attribute__((__packed__));
struct OSD_MC_ResourceStatReq
{
char DiscID[11];
} __attribute__((__packed__));
struct OSD_MC_ResourceReq
{
char DiscID[11];
char filename[32];
} __attribute__((__packed__));
struct OSD_MC_ResourceReadReq
{
char DiscID[11];
char filename[32];
u32 length;
} __attribute__((__packed__));
#define HDLGMAN_SERVER_VERSION 0x0C
#define HDLGMAN_CLIENT_VERSION 0x0C
enum HDLGMAN_ClientServerCommands {
// Server commands
HDLGMAN_SERVER_RESPONSE = 0x00,
HDLGMAN_SERVER_GET_VERSION,
// Client commands
HDLGMAN_CLIENT_SEND_VERSION,
HDLGMAN_CLIENT_VERSION_ERR, // Server rejects connection to client (version mismatch).
// Game installation commands
HDLGMAN_SERVER_PREP_GAME_INST = 0x10, // Creates a new partition and will also automatically invoke HDLGMAN_SERVER_INIT_GAME_WRITE.
HDLGMAN_SERVER_INIT_GAME_WRITE, // Opens an existing partition for writing.
HDLGMAN_SERVER_INIT_GAME_READ, // Opens an existing partition for reading.
HDLGMAN_SERVER_IO_STATUS,
HDLGMAN_SERVER_CLOSE_GAME,
HDLGMAN_SERVER_LOAD_GAME_LIST,
HDLGMAN_SERVER_READ_GAME_LIST,
HDLGMAN_SERVER_READ_GAME_LIST_ENTRY,
HDLGMAN_SERVER_READ_GAME_ENTRY,
HDLGMAN_SERVER_UPD_GAME_ENTRY,
HDLGMAN_SERVER_DEL_GAME_ENTRY,
HDLGMAN_SERVER_GET_GAME_PART_NAME,
HDLGMAN_SERVER_GET_FREE_SPACE,
// OSD-resource management
HDLGMAN_SERVER_INIT_OSD_RESOURCES = 0x20,
HDLGMAN_SERVER_OSD_RES_LOAD_INIT,
HDLGMAN_SERVER_OSD_RES_LOAD,
HDLGMAN_SERVER_WRITE_OSD_RESOURCES,
HDLGMAN_SERVER_OSD_RES_WRITE_CANCEL,
HDLGMAN_SERVER_GET_OSD_RES_STAT,
HDLGMAN_SERVER_OSD_RES_READ,
HDLGMAN_SERVER_OSD_RES_READ_TITLES,
HDLGMAN_SERVER_INIT_DEFAULT_OSD_RESOURCES, // Same as HDLGMAN_SERVER_INIT_OSD_RESOURCES, but doesn't require the OSD titles and is designed for subsequent pre-built OSD resource file uploading (with HDLGMAN_SERVER_OSD_RES_LOAD) from the client.
HDLGMAN_SERVER_OSD_MC_SAVE_CHECK,
HDLGMAN_SERVER_OSD_MC_GET_RES_STAT,
HDLGMAN_SERVER_OSD_MC_RES_READ,
HDLGMAN_SERVER_SHUTDOWN = 0xFF,
};
// Must be large enough to support sending & receiving all parameters and be a multiple of 64. Only game reading/writing will use external buffers.
#define HDLGMAN_RECV_MAX (128 * 1024)
#define HDLGMAN_SEND_MAX (128 * 1024)
/* Client status bits */
#define CLIENT_STATUS_VERSION_VERIFIED 0x01
#define CLIENT_STATUS_OPENED_FILE 0x02
#define CLIENT_STATUS_MOUNTED_FS 0x04
#define CLIENT_STATUS_CONNECTED 0x80
/* Server status bits */
#define SERVER_STATUS_THREAD_RUN 0x80
/* Function prototypes. */
int InitializeStartServer(void);
void DeinitializeServer(void); // Shut down the server.