1 /*---------------------------------------------------------------------------*
2   Project:  Dolphin OS Reset API
3   File:     OSReset.h
4 
5   Copyright 2001-2003 Nintendo.  All rights reserved.
6 
7   These coded instructions, statements, and computer programs contain
8   proprietary information of Nintendo of America Inc. and/or Nintendo
9   Company Ltd., and are protected by Federal copyright law.  They may
10   not be disclosed to third parties or copied or duplicated in any form,
11   in whole or in part, without the prior written consent of Nintendo.
12 
13   $Log: OSReset.h,v $
14   Revision 1.16  2007/12/05 07:07:56  wada_jumpei
15   Added OSLaunchManualViewer.
16 
17   Revision 1.15  2007/06/29 00:25:57  carlmu
18   Added OS_SHUTDOWN_PRIO_KBD.
19 
20   Revision 1.14  2007/04/27 09:21:21  ooizumi
21   Added OSReturnToSetting.
22 
23   Revision 1.13  2007/04/12 08:46:24  ooizumi
24   Added reset code for channel installer.
25 
26   Revision 1.12  2007/02/28 04:10:54  ooizumi
27   Added OSReturnToDataManager.
28 
29   Revision 1.11  2007/02/23 07:24:39  ooizumi
30   Added definitions for launching disc app from channel app.
31 
32   Revision 1.10  2006/09/21 09:11:09  hirose
33   Added definition of OS_SD_LAUNCH.
34 
35   Revision 1.9  2006/09/20 13:42:32  hiratsu
36   Added NAND priority.
37 
38   Revision 1.8  2006/09/14 13:35:41  tojo
39   Added OS_SHUTDOWN_PRIO_WPAD.
40 
41   Revision 1.7  2006/08/29 05:20:08  ooizumi
42   Enabled OSExec APIs.
43 
44   Revision 1.6  2006/08/10 13:48:37  urata
45   Added OS_SHUTDOWN_PRIO_VI.
46 
47   Revision 1.5  2006/07/24 06:14:34  hirose
48   Cleanup.
49 
50   Revision 1.4  2006/07/24 00:23:34  hirose
51   Changes due to new reset/shutdown architecture.
52 
53   Revision 1.3  2006/06/16 12:45:42  ooizumi
54   Commented out definition of OSExec.
55 
56   Revision 1.2  2006/02/04 11:56:47  hashida
57   (none)
58 
59   Revision 1.1.1.1  2005/12/29 06:53:28  hiratsu
60   Initial import.
61 
62   Revision 1.1.1.1  2005/05/12 02:41:07  yasuh-to
63   Ported from dolphin sheath tree.
64 
65 
66     20    2004/01/30 16:42 Hashida
67     Added OSExec.
68 
69 
70     19    2003/11/28 19:04 Shiki
71     Removed OSGetRestartCode().
72 
73     18    2003/11/13 16:57 Shiki
74     Fixed OSIsRestart() macro for new OSGetResetCode().
75 
76     17    2003/11/13 14:20 Shiki
77     Added support for OSGetRestartCode().
78 
79     16    2003/10/24 9:33 Shiki
80     Defined OS_RESETCODE_NETCONFIG.
81 
82     15    2003/07/10 14:38 Shiki
83     Defined OS_RESET_PRIO_ALARM.
84 
85     14    2003/04/16 22:32 Hashida
86     Added OSSetBootDol.
87 
88     13    2003/03/12 11:28 Shiki
89     Defined OS_RESET_PRIO_SO and OS_RESET_PRIO_IP.
90 
91     12    2003/02/13 14:24 Shiki
92     Defined OS_RESET_TIMEOUT.
93 
94     11    2002/11/19 14:55 Hirose
95     Added OS_RESET_PRIO_GX.
96 
97     10    2002/10/28 20:28 Hashida
98     Added OSIsRestart().
99 
100     9    2002/04/11 17:59 Hashida
101     Added OSGetSavedRegion
102 
103     8     2001/09/15 3:31a Hashida
104     Added OS_RESET_SHUTDOWN
105 
106     7     2001/09/07 5:30a Hashida
107     Added OSSet/GetSaveRegion.
108 
109     6     2001/07/18 10:55p Hashida
110     Changed definitions.
111 
112     5     2001/07/11 10:19p Hashida
113     Added code definition for restarting.
114 
115     4     2001/05/17 8:20p Shiki
116     Modified priority from s32 to u32.
117 
118     3     2001/05/17 7:58p Shiki
119     Revised.
120 
121     2    2001/04/23 16:31 Shiki
122     Added menu param to OSResetSystem().
123 
124     1    2001/04/09 13:52 Shiki
125     Initial check-in.
126   $NoKeywords: $
127  *---------------------------------------------------------------------------*/
128 
129 #ifndef __OSRESET_H__
130 #define __OSRESET_H__
131 
132 #include <revolution/types.h>
133 
134 #ifdef __cplusplus
135 extern "C" {
136 #endif
137 
138 #define OS_RESETCODE_RESTART    0x80000000      // Not by cold/hot reset
139 #define OS_RESETCODE_SYSTEM     0x40000000      // Reserved by system
140 #define OS_RESETCODE_SWITCH     0x20000000      // Reserved by system
141 
142 // NETCONFIG ... 0x00010000
143 // INSTALLER ... 0x00020000
144 // XXXXXXXXX ... 0x00030000
145 // :
146 
147 #define OS_RESETCODE_EXEC       0xC0000000
148 #define OS_RESETCODE_NETCONFIG  0xC0010000
149 
150 #define OS_RESETCODE_LAUNCH     0xA0000000
151 #define OS_RESETCODE_INSTALLER  0xA0020000
152 
153 #define OS_RESET_TIMEOUT        OSMillisecondsToTicks(1000)
154 
155 #define OS_RESET_RESTART        0
156 #define OS_RESET_HOTRESET       1
157 #define OS_RESET_SHUTDOWN       2
158 
159 #define OS_SHUTDOWN_PRIO_SO         110     // SO API
160 #define OS_SHUTDOWN_PRIO_IP         111     // IP API
161 #define OS_SHUTDOWN_PRIO_MIDI       126     // MIDI API
162 #define OS_SHUTDOWN_PRIO_CARD       127     // CARD API
163 #define OS_SHUTDOWN_PRIO_PAD        127     // PAD API
164 #define OS_SHUTDOWN_PRIO_WPAD       127     // WPAD API
165 #define OS_SHUTDOWN_PRIO_STEERING   127     // SI Steering
166 #define OS_SHUTDOWN_PRIO_GX         127     // GX API
167 #define OS_SHUTDOWN_PRIO_MEMPROT    127     // OS Memory Protection
168 #define OS_SHUTDOWN_PRIO_ALARM      4294967295  // OSAlarm
169 #define OS_SHUTDOWN_PRIO_VI         127     // VI API
170 #define OS_SHUTDOWN_PRIO_NAND       255     // NAND API
171 #define OS_SHUTDOWN_PRIO_KBD        127     // KBD (keyboard)
172 
173 // Event types for __OSShutdownDevices()
174 #define OS_SD_FATALERR          0
175 #define OS_SD_REBOOT            1
176 #define OS_SD_SHUTDOWN          2
177 #define OS_SD_IDLE              3
178 #define OS_SD_RESTART           4
179 #define OS_SD_RETURNTOMENU      5
180 #define OS_SD_EXEC              6
181 #define OS_SD_LAUNCH            7
182 
183 
184 typedef BOOL (* OSShutdownFunction )( BOOL final, u32 event );
185 typedef struct OSShutdownFunctionInfo OSShutdownFunctionInfo;
186 
187 struct OSShutdownFunctionInfo
188 {
189     // public
190     OSShutdownFunction      func;
191     u32                     priority;
192 
193     // private
194     OSShutdownFunctionInfo* next;
195     OSShutdownFunctionInfo* prev;
196 };
197 
198 void OSRegisterShutdownFunction     ( OSShutdownFunctionInfo* info );
199 void OSUnregisterShutdownFunction   ( OSShutdownFunctionInfo* info );
200 
201 
202 void OSRebootSystem         ( void );
203 void OSShutdownSystem       ( void );
204 void OSRestart              ( u32 resetCode );
205 void OSReturnToMenu         ( void );
206 void OSReturnToDataManager  ( void );
207 
208 #define OS_SETTING_CALENDAR        1u
209 #define OS_SETTING_DISPLAY         2u
210 #define OS_SETTING_SOUND           3u
211 #define OS_SETTING_PARENTAL        4u
212 #define OS_SETTING_INTERNET        5u
213 #define OS_SETTING_WC24            6u
214 #define OS_SETTING_UPDATE          7u
215 
216 void OSReturnToSetting      ( u8 setting );
217 
218 u32  OSGetResetCode         ( void );
219 void OSGetSaveRegion        ( void** start, void** end );
220 void OSGetSavedRegion       ( void** start, void** end );
221 void OSSetSaveRegion        ( void* start, void* end );
222 
223 
224 // Obsoleted (implemented as stubs)
225 void OSResetSystem          ( int reset, u32 resetCode, BOOL forceMenu );
226 u32  OSSetBootDol           ( u32 dolOffset );
227 
228 // Obsoleted
229 #if 0
230 typedef BOOL (* OSResetFunction )(BOOL final);
231 typedef struct OSResetFunctionInfo OSResetFunctionInfo;
232 
233 struct OSResetFunctionInfo
234 {
235     // public
236     OSResetFunction      func;
237     u32                  priority;
238 
239     // private
240     OSResetFunctionInfo* next;
241     OSResetFunctionInfo* prev;
242 };
243 
244 void OSRegisterResetFunction  ( OSResetFunctionInfo* info );
245 void OSUnregisterResetFunction( OSResetFunctionInfo* info );
246 #endif
247 
248 void OSExecv                  ( const char* dolfile, char* const argv[] );
249 void OSExecl                  ( const char* dolfile,
250                                 const char* arg0, .../*, (char*)NULL */ );
251 
252 void OSLaunchManualViewer     ( const char* arg );
253 
254 /*---------------------------------------------------------------------------*
255   Name:         OSIsRestart
256 
257   Description:  Checks to see if it's restarted
258 
259   Arguments:    None
260 
261   Returns:      True if restarted, False if cold-started
262  *---------------------------------------------------------------------------*/
263 #define OSIsRestart()   \
264             ((OSGetResetCode() & OS_RESETCODE_RESTART) ? TRUE : FALSE)
265 
266 #ifdef __cplusplus
267 }
268 #endif
269 
270 #endif  // __OSRESET_H__
271