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