RetroArch
system.h
Go to the documentation of this file.
1 /*-------------------------------------------------------------
2 
3 system.h -- OS functions and initialization
4 
5 Copyright (C) 2004
6 Michael Wiedenbauer (shagkur)
7 Dave Murphy (WinterMute)
8 
9 This software is provided 'as-is', without any express or implied
10 warranty. In no event will the authors be held liable for any
11 damages arising from the use of this software.
12 
13 Permission is granted to anyone to use this software for any
14 purpose, including commercial applications, and to alter it and
15 redistribute it freely, subject to the following restrictions:
16 
17 1. The origin of this software must not be misrepresented; you
18 must not claim that you wrote the original software. If you use
19 this software in a product, an acknowledgment in the product
20 documentation would be appreciated but is not required.
21 
22 2. Altered source versions must be plainly marked as such, and
23 must not be misrepresented as being the original software.
24 
25 3. This notice may not be removed or altered from any source
26 distribution.
27 
28 
29 -------------------------------------------------------------*/
30 
31 
32 #ifndef __SYSTEM_H__
33 #define __SYSTEM_H__
34 
35 
41 #include <gctypes.h>
42 #include <gcutil.h>
43 #include <time.h>
44 #include <ogc/lwp_queue.h>
45 #include "gx_struct.h"
46 
47 #define SYS_BASE_CACHED (0x80000000)
48 #define SYS_BASE_UNCACHED (0xC0000000)
49 
50 #define SYS_WD_NULL 0xffffffff
51 
57 #define SYS_RESTART 0
58 #define SYS_HOTRESET 1
59 #define SYS_SHUTDOWN 2
61 #define SYS_RETURNTOMENU 3
62 #define SYS_POWEROFF 4
63 #define SYS_POWEROFF_STANDBY 5
64 #define SYS_POWEROFF_IDLE 6
76 #define SYS_PROTECTCHAN0 0
77 #define SYS_PROTECTCHAN1 1
78 #define SYS_PROTECTCHAN2 2
79 #define SYS_PROTECTCHAN3 3
80 #define SYS_PROTECTCHANMAX 4
92 #define SYS_PROTECTNONE 0x00000000
93 #define SYS_PROTECTREAD 0x00000001
94 #define SYS_PROTECTWRITE 0x00000002
95 #define SYS_PROTECTRDWR (SYS_PROTECTREAD|SYS_PROTECTWRITE)
101 #define SYS_FONTSIZE_ANSI (288 + 131072)
102 #define SYS_FONTSIZE_SJIS (3840 + 1179648)
103 
104 
105 
111 #define MEM_VIRTUAL_TO_PHYSICAL(x) (((u32)(x)) & ~SYS_BASE_UNCACHED)
112 #define MEM_PHYSICAL_TO_K0(x) (void*)((u32)(x) + SYS_BASE_CACHED)
113 #define MEM_PHYSICAL_TO_K1(x) (void*)((u32)(x) + SYS_BASE_UNCACHED)
114 #define MEM_K0_TO_PHYSICAL(x) (void*)((u32)(x) - SYS_BASE_CACHED)
115 #define MEM_K1_TO_PHYSICAL(x) (void*)((u32)(x) - SYS_BASE_UNCACHED)
116 #define MEM_K0_TO_K1(x) (void*)((u32)(x) + (SYS_BASE_UNCACHED - SYS_BASE_CACHED))
117 #define MEM_K1_TO_K0(x) (void*)((u32)(x) - (SYS_BASE_UNCACHED - SYS_BASE_CACHED))
123 #define SYS_GetArenaLo SYS_GetArena1Lo
124 #define SYS_SetArenaLo SYS_SetArena1Lo
125 #define SYS_GetArenaHi SYS_GetArena1Hi
126 #define SYS_SetArenaHi SYS_SetArena1Hi
127 #define SYS_GetArenaSize SYS_GetArena1Size
128 
129 #ifdef __cplusplus
130  extern "C" {
131 #endif /* __cplusplus */
132 
133 
138 typedef u32 syswd_t;
139 
140 
154 typedef struct _syssram syssram;
155 
156 struct _syssram {
167 
168 
180 typedef struct _syssramex syssramex;
181 
182 struct _syssramex {
183  u8 flash_id[2][12];
191 
192 typedef void (*alarmcallback)(syswd_t alarm,void *cb_arg);
193 
195 
221 
222 typedef void (*resetcallback)(void);
223 typedef void (*powercallback)(void);
224 typedef s32 (*resetfunction)(s32 final);
226 
231 };
232 
238 void SYS_Init();
239 
240 
248 void* SYS_AllocateFramebuffer(GXRModeObj *rmode);
249 
250 
251 void SYS_ProtectRange(u32 chan,void *addr,u32 bytes,u32 cntrl);
252 void SYS_StartPMC(u32 mcr0val,u32 mcr1val);
253 void SYS_DumpPMC();
254 void SYS_StopPMC();
255 
256 
263 s32 SYS_CreateAlarm(syswd_t *thealarm);
264 
265 
274 s32 SYS_SetAlarm(syswd_t thealarm,const struct timespec *tp,alarmcallback cb,void *cbarg);
275 
276 
286 s32 SYS_SetPeriodicAlarm(syswd_t thealarm,const struct timespec *tp_start,const struct timespec *tp_period,alarmcallback cb,void *cbarg);
287 
288 
295 s32 SYS_RemoveAlarm(syswd_t thealarm);
296 
297 
304 s32 SYS_CancelAlarm(syswd_t thealarm);
305 
306 
307 void SYS_SetWirelessID(u32 chan,u32 id);
310 u32 SYS_InitFont(sys_fontheader *font_data);
311 void SYS_GetFontTexture(s32 c,void **image,s32 *xpos,s32 *ypos,s32 *width);
312 void SYS_GetFontTexel(s32 c,void *image,s32 pos,s32 stride,s32 *width);
313 void SYS_ResetSystem(s32 reset,u32 reset_code,s32 force_menu);
316 void SYS_SwitchFiber(u32 arg0,u32 arg1,u32 arg2,u32 arg3,u32 pc,u32 newsp);
317 
318 void* SYS_GetArena1Lo();
319 void SYS_SetArena1Lo(void *newLo);
320 void* SYS_GetArena1Hi();
321 void SYS_SetArena1Hi(void *newHi);
323 
325 
327 
328 #if defined(HW_RVL)
329 u32 SYS_GetHollywoodRevision();
330 void* SYS_GetArena2Lo();
331 void SYS_SetArena2Lo(void *newLo);
332 void* SYS_GetArena2Hi();
333 void SYS_SetArena2Hi(void *newHi);
334 u32 SYS_GetArena2Size();
335 powercallback SYS_SetPowerCallback(powercallback cb);
336 #endif
337 
338 /* \fn u64 SYS_Time()
339 \brief Returns the current time in ticks since 2000 (proper Dolphin/Wii time)
340 \return ticks since 2000
341 */
342 u64 SYS_Time();
343 
344 void kprintf(const char *str, ...);
345 
346 #ifdef __cplusplus
347  }
348 #endif /* __cplusplus */
349 
350 #endif
u16 sheet_format
Definition: system.h:208
u32 SYS_GetArena1Size()
Definition: system.c:1298
s32 SYS_SetAlarm(syswd_t thealarm, const struct timespec *tp, alarmcallback cb, void *cbarg)
Definition: system.c:1538
u16 sheet_height
Definition: system.h:212
int32_t s32
32bit signed integer
Definition: gctypes.h:24
Definition: system.h:196
u8 __padding1[4]
Definition: system.h:189
u32 ead0
Definition: system.h:159
resetfunction func
Definition: system.h:229
u32 SYS_GetWirelessID(u32 chan)
Definition: system.c:1685
s32 SYS_CancelAlarm(syswd_t thealarm)
Cancel the alarm, but do not remove from the list of contexts.
Definition: system.c:1596
Data type definitions.
u16 width_table
Definition: system.h:213
u32 sheet_image
Definition: system.h:214
Definition: libretro.h:2275
void SYS_GetFontTexel(s32 c, void *image, s32 pos, s32 stride, s32 *width)
Definition: system.c:1479
resetcallback SYS_SetResetCallback(resetcallback cb)
Definition: system.c:1613
u8 dvderr_code
Definition: system.h:186
u32 syswd_t
handle typedef for the alarm context
Definition: system.h:138
u8 __padding0
Definition: system.h:187
int8_t s8
8bit signed integer
Definition: gctypes.h:22
u32 prio
Definition: system.h:230
void * SYS_GetArena1Hi()
Definition: system.c:1286
Definition: lwp_queue.h:16
u16 last_char
Definition: system.h:199
u16 desc
Definition: system.h:202
u16 leading
Definition: system.h:204
Definition: gx_struct.h:58
typedef void(__stdcall *PFN_DESTRUCTION_CALLBACK)(void *pData)
u16 sheet_width
Definition: system.h:211
GLuint GLuint GLuint GLuint GLuint GLuint GLuint GLuint GLuint GLuint arg3
Definition: glext.h:10422
void SYS_UnregisterResetFunc(sys_resetinfo *info)
Definition: system.c:1242
u64 SYS_Time()
Definition: system.c:1707
GLuint GLuint GLuint GLuint GLuint GLuint GLuint arg2
Definition: glext.h:10421
void SYS_ResetSystem(s32 reset, u32 reset_code, s32 force_menu)
u16 cell_height
Definition: system.h:206
const GLubyte * c
Definition: glext.h:9812
u16 asc
Definition: system.h:201
u32 SYS_InitFont(sys_fontheader *font_data)
Definition: system.c:1436
s8 display_offsetH
Definition: system.h:162
lwp_node node
Definition: system.h:228
u16 first_char
Definition: system.h:198
Definition: system.h:182
u8 c3
Definition: system.h:219
u16 font_type
Definition: system.h:197
u32 SYS_ResetButtonDown()
Definition: system.c:1113
support header
uint16_t u16
16bit unsigned integer
Definition: gctypes.h:18
void(* alarmcallback)(syswd_t alarm, void *cb_arg)
Definition: system.h:192
void * SYS_GetArena1Lo()
Definition: system.c:1265
struct _syssram ATTRIBUTE_PACKED
GLuint GLuint GLuint GLuint arg1
Definition: glext.h:10420
void(* resetcallback)(void)
Definition: system.h:222
GLenum const GLvoid * addr
Definition: glext.h:10528
u32 sheet_fullsize
Definition: system.h:215
Definition: system.h:227
GLboolean reset
Definition: glext.h:6318
u8 lang
Definition: system.h:164
void kprintf(const char *str,...)
Definition: kprintf.c:278
void SYS_StartPMC(u32 mcr0val, u32 mcr1val)
Definition: system.c:1646
GLenum GLsizei GLenum GLenum const GLvoid * image
Definition: glext.h:6305
Definition: system.h:156
u32 wirelessKbd_id
Definition: system.h:184
u8 c0
Definition: system.h:216
u32 sheet_size
Definition: system.h:207
u16 width
Definition: system.h:203
void * SYS_AllocateFramebuffer(GXRModeObj *rmode)
Allocate cacheline aligned memory for the external framebuffer based on the rendermode object.
Definition: system.c:1418
u16 flashID_chksum[2]
Definition: system.h:188
u8 c1
Definition: system.h:217
void SYS_GetFontTexture(s32 c, void **image, s32 *xpos, s32 *ypos, s32 *width)
Definition: system.c:1459
s32 SYS_CreateAlarm(syswd_t *thealarm)
Create/initialize sysalarm structure.
Definition: system.c:1521
u16 inval_char
Definition: system.h:200
u8 ntd
Definition: system.h:163
s32 SYS_SetPeriodicAlarm(syswd_t thealarm, const struct timespec *tp_start, const struct timespec *tp_period, alarmcallback cb, void *cbarg)
Definition: system.c:1558
u8 flags
Definition: system.h:165
uint64_t u64
64bit unsigned integer
Definition: gctypes.h:20
u16 cell_width
Definition: system.h:205
void SYS_SetArena1Hi(void *newHi)
Definition: system.c:1277
u16 sheet_row
Definition: system.h:210
GLint GLint GLsizei width
Definition: glext.h:6293
u16 checksum_inv
Definition: system.h:158
u16 wirelessPad_id[4]
Definition: system.h:185
void SYS_DumpPMC()
Definition: system.c:1666
void SYS_StopPMC()
Definition: system.c:1652
void SYS_SetArena1Lo(void *newLo)
Definition: system.c:1256
u32 ead1
Definition: system.h:160
u32 counter_bias
Definition: system.h:161
void(* powercallback)(void)
Definition: system.h:223
s32(* resetfunction)(s32 final)
Definition: system.h:224
u16 sheet_column
Definition: system.h:209
GLsizei stride
Definition: glext.h:6488
u8 flash_id[2][12]
Definition: system.h:183
void SYS_Init()
Definition: system.c:1036
void SYS_ProtectRange(u32 chan, void *addr, u32 bytes, u32 cntrl)
Definition: system.c:1390
u8 c2
Definition: system.h:218
uint8_t u8
8bit unsigned integer
Definition: gctypes.h:17
uint32_t u32
32bit unsigned integer
Definition: gctypes.h:19
u16 checksum
Definition: system.h:157
void SYS_RegisterResetFunc(sys_resetinfo *info)
Definition: system.c:1230
void SYS_SwitchFiber(u32 arg0, u32 arg1, u32 arg2, u32 arg3, u32 pc, u32 newsp)
const char *const str
Definition: portlistingparse.c:18
u32 SYS_GetFontEncoding()
Definition: system.c:1423
s32 SYS_RemoveAlarm(syswd_t thealarm)
Remove the given alarm context from the list of contexts and destroy it.
Definition: system.c:1578
void SYS_SetWirelessID(u32 chan, u32 id)
Definition: system.c:1671