1 /*---------------------------------------------------------------------------*
2 Project: TwlSDK - OS - include
3 File: ownerInfoEx.h
4
5 Copyright 2003-2008 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 $Date:: 2008-12-22#$
14 $Rev: 9714 $
15 $Author: okubata_ryoma $
16 *---------------------------------------------------------------------------*/
17
18 #ifndef TWL_OS_COMMON_OWNERINFO_EX_H_
19 #define TWL_OS_COMMON_OWNERINFO_EX_H_
20
21 #ifdef __cplusplus
22 extern "C" {
23 #endif
24
25 /*===========================================================================*/
26
27 #include <twl/types.h>
28 #include <twl/spec.h>
29 #include <nitro/std.h>
30 #ifdef SDK_NITRO
31 #include <nitro/hw/common/mmap_shared.h>
32 #else
33 #include <twl/hw/common/mmap_shared.h>
34 #endif
35
36 #include <nitro/os/common/ownerInfo.h>
37
38
39 /*---------------------------------------------------------------------------*
40 Constants
41 *---------------------------------------------------------------------------*/
42 // Region code
43 typedef enum OSTWLRegionCode
44 {
45 OS_TWL_REGION_JAPAN = 0,
46 OS_TWL_REGION_AMERICA = 1,
47 OS_TWL_REGION_EUROPE = 2,
48 OS_TWL_REGION_AUSTRALIA = 3,
49 OS_TWL_REGION_CHINA = 4,
50 OS_TWL_REGION_KOREA = 5,
51 OS_TWL_REGION_MAX
52 } OSTWLRegion;
53
54 #define OS_TWL_HWINFO_SERIALNO_LEN_MAX 15 // The maximum length for a system's serial number (this can extend as far as 14 bytes because it includes the terminating character)
55 #define OS_TWL_HWINFO_MOVABLE_UNIQUE_ID_LEN 16 // A unique ID that can be moved
56 #define OS_TWL_NICKNAME_LENGTH OS_OWNERINFO_NICKNAME_MAX // Nickname Length
57 #define OS_TWL_COMMENT_LENGTH OS_OWNERINFO_COMMENT_MAX // Comment Length
58 #define OS_TWL_PCTL_PASSWORD_LENGTH 4 // Number of password digits
59 #define OS_TWL_PCTL_SECRET_ANSWER_LENGTH_MAX 64 // The maximum (MAX) number of UTF-16 characters in the answer to the secret question
60
61
62 /*---------------------------------------------------------------------------*
63 Structures
64 *---------------------------------------------------------------------------*/
65
66 // TWL owner information
67 typedef struct OSOwnerInfoEx
68 {
69 u8 language; // Language code
70 u8 favoriteColor; // Favorite color (0 to 15)
71 OSBirthday birthday; // Birthdate
72 u16 nickName[OS_OWNERINFO_NICKNAME_MAX + 1];
73 // Nickname (maximum 10 characters of Unicode (UTF16), no terminal code)
74 u16 nickNameLength; // Number of characters in nickname (0 to 10)
75 u16 comment[OS_OWNERINFO_COMMENT_MAX + 1];
76 // Comment (maximum 26 characters of Unicode (UTF16), no terminal code)
77 u16 commentLength; // Number of characters in comment (0 to 26)
78 // Data only available on a TWL system
79 u8 country; // Country and region code
80 u8 padding;
81
82 }
83 OSOwnerInfoEx;
84
85
86 // Parental Controls
87 // Rating organizations
88 typedef enum OSTWLRatingOgn
89 {
90 OS_TWL_PCTL_OGN_CERO = 0, // CERO // Japan
91 OS_TWL_PCTL_OGN_ESRB = 1, // ESRB // North America
92 OS_TWL_PCTL_OGN_RESERVED2 = 2, // BBFC [obsolete]
93 OS_TWL_PCTL_OGN_USK = 3, // USK // Germany
94 OS_TWL_PCTL_OGN_PEGI_GEN = 4, // PEGI general // Europe
95 OS_TWL_PCTL_OGN_RESERVED5 = 5, // PEGI Finland [obsolete]
96 OS_TWL_PCTL_OGN_PEGI_PRT = 6, // PEGI Portugal // Portugal
97 OS_TWL_PCTL_OGN_PEGI_BBFC = 7, // PEGI and BBFC Great Britain // England
98 OS_TWL_PCTL_OGN_OFLC = 8, // OFLC // Australia, New Zealand
99 OS_TWL_PCTL_OGN_GRB = 9, // GRB // South Korea
100
101 OS_TWL_PCTL_OGN_MAX = 16
102
103 } OSTWLRatingOgn;
104
105
106 // Parental Controls information
107 typedef struct OSTWLParentalControl
108 {
109 struct {
110 u32 isSetParentalControl : 1; // Have Parental Controls already been set?
111 u32 pictoChat :1; // Is starting PictoChat restricted?
112 u32 dsDownload :1; // Is starting DS Download Play restricted?
113 u32 browser :1; // Is starting a full browser restricted?
114 u32 prepaidPoint :1; // Is the use of points restricted?
115 u32 photoExchange : 1; // Is exchanging photos restricted?
116 u32 ugc : 1; // Is user-created content restricted?
117 u32 rsv :25;
118 } flags;
119 u8 rsv1[ 3 ];
120 u8 ogn; // Rating organizations
121 u8 ratingAge; // Rating value (age)
122 u8 secretQuestionID; // Secret question ID
123 u8 secretAnswerLength; // Number of characters in the answer to the secret question
124 u8 rsv[ 2 ];
125 char password[ OS_TWL_PCTL_PASSWORD_LENGTH + 1 ]; // Password (with terminating character)
126 u16 secretAnswer[ OS_TWL_PCTL_SECRET_ANSWER_LENGTH_MAX + 1 ]; // UTF-16 answer (with terminating character) to the secret question
127 } OSTWLParentalControl; // 148 bytes
128
129 // Format of ratings information in the application
130 #define OS_TWL_PCTL_OGNINFO_ENABLE_MASK 0x80
131 #define OS_TWL_PCTL_OGNINFO_ALWAYS_MASK 0x40
132 #define OS_TWL_PCTL_OGNINFO_AGE_MASK 0x1f
133
134
135 /*---------------------------------------------------------------------------*
136 Function Declarations
137 *---------------------------------------------------------------------------*/
138 /*---------------------------------------------------------------------------*
139 Name: OS_GetOwnerInfoEx
140
141 Description: Gets the owner information. TWL version.
142 Information that also exists on NITRO systems is taken from the same location as the NITRO version.
143 The language code ('language') may differ between NITRO and TWL systems and will therefore be taken from the TWL information.
144
145
146 Arguments: info: Pointer to the buffer getting the owner information.
147 Data gets written to this buffer.
148 (*) TWL information only available in TWL mode.
149 (It is always 0 when the program is not running on a TWL system)
150
151 Returns: None.
152 *---------------------------------------------------------------------------*/
153 void OS_GetOwnerInfoEx(OSOwnerInfoEx *info);
154
155 /*---------------------------------------------------------------------------*
156 Name: OS_IsAvailableWireless
157
158 Description: Gets information on whether the wireless module's RF unit is enabled.
159
160 Arguments: None.
161
162 Returns: TRUE when enabled and FALSE when disabled.
163 This is always TRUE when the program is not running on a TWL system.
164 *---------------------------------------------------------------------------*/
165 BOOL OS_IsAvailableWireless(void);
166
167 /*---------------------------------------------------------------------------*
168 Name: OS_IsAgreeEULA
169
170 Description: Gets a value indicating whether the EULA has been accepted on this system.
171
172 Arguments: None.
173
174 Returns: BOOL - TRUE if the EULA has been already accepted and FALSE otherwise.
175 This is always FALSE when the program is not running on a TWL system.
176 *---------------------------------------------------------------------------*/
177 BOOL OS_IsAgreeEULA(void);
178
179 /*---------------------------------------------------------------------------*
180 Name: OS_GetAgreeEULAVersion
181
182 Description: Gets the version of the EULA that was accepted on this system.
183
184 Arguments: None.
185
186 Returns: agreedEulaVersion: The accepted EULA version (0-255).
187 *---------------------------------------------------------------------------*/
188 u8 OS_GetAgreedEULAVersion( void );
189
190 /*---------------------------------------------------------------------------*
191 Name: OS_GetROMHeaderEULAVersion
192
193 Description: Gets the EULA version registered in the application's ROM header.
194
195 Arguments: None.
196
197 Returns: cardEulaVersion: The EULA version (0-255) registered in the application's ROM header.
198 *---------------------------------------------------------------------------*/
199 u8 OS_GetROMHeaderEULAVersion( void );
200
201 /*---------------------------------------------------------------------------*
202 Name: OS_GetParentalControlPtr
203
204 Description: Gets a pointer to Parental Controls information.
205
206 Arguments: None.
207
208 Returns: Returns a pointer.
209 Returns NULL when the program is not running on a TWL system.
210 *---------------------------------------------------------------------------*/
211 const OSTWLParentalControl* OS_GetParentalControlInfoPtr(void);
212
213 /*---------------------------------------------------------------------------*
214 Name: OS_IsParentalControledApp
215
216 Description: Determines whether Parental Controls should restrict application startup.
217
218
219 Arguments: appRatingInfo: Offset into the application's ROM header
220 Specifies a pointer to the 16-byte ratings information placed at 0x2f0.
221
222
223 Returns: Returns TRUE when this is restricted by Parental Controls and the player should be prompted to enter a password.
224 Returns FALSE if the application may be started without restriction.
225
226 *---------------------------------------------------------------------------*/
227 BOOL OS_IsParentalControledApp(u8* appRatingInfo);
228
229 /*---------------------------------------------------------------------------*
230 Name: OS_GetMovableUniqueID
231
232 Description: Gets the unique ID (included in the hardware information) that can be moved between systems.
233
234 Arguments: pUniqueID: Storage location (stores OS_TWL_HWINFO_MOVABLE_UNIQUE_ID_LEN bytes).
235 (This is filled in with 0's when the program is not running on a TWL system)
236
237 Returns: None.
238 *---------------------------------------------------------------------------*/
239 void OS_GetMovableUniqueID(u8 *pUniqueID);
240
241 /*---------------------------------------------------------------------------*
242 Name: OS_GetUniqueIDPtr
243
244 Description: Gets a pointer to a unique ID (included in the hardware information) that can be moved between systems.
245
246 Arguments: None.
247
248 Returns: Returns a pointer.
249 Returns NULL when the program is not running on a TWL system.
250 *---------------------------------------------------------------------------*/
251 const u8* OS_GetMovableUniqueIDPtr(void);
252
253 /*---------------------------------------------------------------------------*
254 Name: OS_IsForceDisableWireless
255
256 Description: Gets information on whether wireless features are to be forcibly disabled (this is included in secure hardware information).
257
258
259 Arguments: None.
260
261 Returns: TRUE when it is forcibly disabled and FALSE when it is not disabled.
262 This is always FALSE when the program is not running on a TWL system.
263 *---------------------------------------------------------------------------*/
264 BOOL OS_IsForceDisableWireless(void);
265
266 /*---------------------------------------------------------------------------*
267 Name: OS_GetRegion
268
269 Description: Gets region information.
270
271 Arguments: None.
272
273 Returns: Returns the region number.
274 Always returns 0 when the program is not running on a TWL system.
275 *---------------------------------------------------------------------------*/
276 OSTWLRegion OS_GetRegion(void);
277
278 /*---------------------------------------------------------------------------*
279 Name: OS_GetRegionCodeA3
280
281 Description: Gets the string that corresponds to a region code.
282
283 Arguments: region: Region code
284
285 Returns: Returns a pointer to the string that corresponds to the region code.
286 *---------------------------------------------------------------------------*/
287 const char* OS_GetRegionCodeA3(OSTWLRegion region);
288
289 /*---------------------------------------------------------------------------*
290 Name: OS_GetISOCountryCodeA2
291
292 Description: Converts a TWL-specific country or region code into ISO 3166-1 alpha-2.
293
294 Arguments: twlCountry: Country or region code
295
296 Returns: Returns a pointer to the string that corresponds to the country or region code.
297 *---------------------------------------------------------------------------*/
298 const char* OS_GetISOCountryCodeA2(u8 twlCountry);
299
300 /*---------------------------------------------------------------------------*
301 Name: OS_IsRestrictPictoChatBoot
302
303 Description: Determines whether a Parental Controls setting has been applied to restrict PictoChat from starting.
304
305
306 Arguments: None.
307
308 Returns: TRUE if restrictions have been applied and FALSE otherwise.
309 *---------------------------------------------------------------------------*/
OS_IsRestrictPictoChatBoot(void)310 static inline BOOL OS_IsRestrictPictoChatBoot( void )
311 {
312 return (BOOL)OS_GetParentalControlInfoPtr()->flags.isSetParentalControl && (BOOL)OS_GetParentalControlInfoPtr()->flags.pictoChat;
313 }
314
315 /*---------------------------------------------------------------------------*
316 Name: OS_IsRestrictDSDownloadBoot
317
318 Description: Determines whether a Parental Controls setting has been applied to restrict DS Download Play from starting.
319
320
321 Arguments: None.
322
323 Returns: TRUE if restrictions have been applied and FALSE otherwise.
324 *---------------------------------------------------------------------------*/
OS_IsRestrictDSDownloadBoot(void)325 static inline BOOL OS_IsRestrictDSDownloadBoot( void )
326 {
327 return (BOOL)OS_GetParentalControlInfoPtr()->flags.isSetParentalControl && (BOOL)OS_GetParentalControlInfoPtr()->flags.dsDownload;
328 }
329
330 /*---------------------------------------------------------------------------*
331 Name: OS_IsRestrictBrowserBoot
332
333 Description: Determines whether a Parental Controls setting has been applied to restrict the Nintendo DSi Browser from starting.
334
335
336 Arguments: None.
337
338 Returns: TRUE if restrictions have been applied and FALSE otherwise.
339 *---------------------------------------------------------------------------*/
OS_IsRestrictBrowserBoot(void)340 static inline BOOL OS_IsRestrictBrowserBoot( void )
341 {
342 return (BOOL)OS_GetParentalControlInfoPtr()->flags.isSetParentalControl && (BOOL)OS_GetParentalControlInfoPtr()->flags.browser;
343 }
344
345
346 /*---------------------------------------------------------------------------*
347 Name: OS_IsRestrictPrepaidPoint
348
349 Description: Determines whether a Parental Controls setting has been applied to restrict behavior related to Nintendo DSi Points specifications.
350
351
352 Arguments: None.
353
354 Returns: TRUE if restrictions have been applied and FALSE otherwise.
355 *---------------------------------------------------------------------------*/
OS_IsRestrictPrepaidPoint(void)356 static inline BOOL OS_IsRestrictPrepaidPoint( void )
357 {
358 return (BOOL)OS_GetParentalControlInfoPtr()->flags.isSetParentalControl && (BOOL)OS_GetParentalControlInfoPtr()->flags.prepaidPoint;
359 }
360
361 /*---------------------------------------------------------------------------*
362 Name: OS_IsRestrictPhotoExchange
363
364 Description: Determines whether a Parental Controls setting has been applied to restrict the exchange of photo data.
365
366
367 Arguments: None.
368
369 Returns: TRUE if restrictions have been applied and FALSE otherwise.
370 *---------------------------------------------------------------------------*/
OS_IsRestrictPhotoExchange(void)371 static inline BOOL OS_IsRestrictPhotoExchange( void )
372 {
373 return (BOOL)OS_GetParentalControlInfoPtr()->flags.isSetParentalControl && (BOOL)OS_GetParentalControlInfoPtr()->flags.photoExchange;
374 }
375
376 /*---------------------------------------------------------------------------*
377 Name: OS_IsRestrictUGC
378
379 Description: Determines whether a Parental Controls setting has been applied to restrict sending and receiving some user-created content.
380
381
382 Arguments: None.
383
384 Returns: TRUE if restrictions have been applied and FALSE otherwise.
385 *---------------------------------------------------------------------------*/
OS_IsRestrictUGC(void)386 static inline BOOL OS_IsRestrictUGC( void )
387 {
388 return (BOOL)OS_GetParentalControlInfoPtr()->flags.isSetParentalControl && (BOOL)OS_GetParentalControlInfoPtr()->flags.ugc;
389 }
390
391 /*---------------------------------------------------------------------------*
392 Name: OS_CheckParentalControlPassword
393
394 Description: Determines whether the given string matches the password that removes Parental Controls.
395
396
397 Arguments: password: The string to be checked
398
399 Returns: TRUE if they match and FALSE otherwise.
400 *---------------------------------------------------------------------------*/
OS_CheckParentalControlPassword(const char * password)401 static inline BOOL OS_CheckParentalControlPassword( const char *password )
402 {
403 return password && (STD_CompareLString(password, OS_GetParentalControlInfoPtr()->password, OS_TWL_PCTL_PASSWORD_LENGTH) == 0);
404 }
405
406 /*===========================================================================*/
407
408 #ifdef __cplusplus
409 } /* extern "C" */
410 #endif
411
412 #endif /* TWL_OS_COMMON_OWNERINFO_EX_H_ */
413
414 /*---------------------------------------------------------------------------*
415 End of file
416 *---------------------------------------------------------------------------*/
417