Difference between revisions of "System Menu/BS2"

From WiiBrew
Jump to navigation Jump to search
Line 1: Line 1:
States taken from System Menu 257 (3.1U)
+
States taken from System Menu 257 (3.1U); they may or may not be consistent across versions.
 +
This is a mess, because the state can be examined or modified by 9 different functions; only 1 is accounted for here (BS2Tick). Most of the complication seems to come from the desire to use asynchronous calls everywhere.
 +
 
 +
There is a similar (but simpler) state machine used in "recovery mode" -- BS2BootIRD.
  
 
== Types ==
 
== Types ==
Line 263: Line 266:
 
| bs2_issue_dvd_command?
 
| bs2_issue_dvd_command?
 
__DVDGetCoverStatusAsync
 
__DVDGetCoverStatusAsync
| 49/69/72 (?!){{check}}
+
| 49/69/72 (state changed by bs2_async_callback?)
 
|-
 
|-
 
| 50  
 
| 50  
|  
+
| bs2_issue_dvd_command
|
+
__DVDGetCoverStatusAsync
 +
| 50 (state changed by bs2_async_callback?)
 
|-
 
|-
 
| 51  
 
| 51  
|
+
| deallocate something?
|
+
| 2
 
|-
 
|-
| 52  
+
| 52/53
|
+
| deallocate something?
+
bs2_issue_dvd_command?
|-
+
__DVDGetCoverStatusAsync
| 53  
+
| 52/53 (state changed by bs2_async_callback?)
 
 
 
|-
 
|-
 
| 54  
 
| 54  
|
+
| deallocate something?
|
+
DVDChangeDiskAsyncForBS
 +
| 55
 
|-
 
|-
| 55  
+
| 55/56
|
+
| bs2_issue_dvd_command?
|
+
| 55/56 (?)
 
|-
 
|-
| 56
+
| 57/58
|   
+
| deallocate something?  
|
+
| 57/58?
 
|-
 
|-
| 57
+
| 59/63
+
| ?
+
| 58
|-
+
59
| 58  
+
64
 
 
|-
 
| 59  
 
 
 
 
|-
 
|-
 
| 60
 
| 60
|   
+
| something with disc cache?  
|
+
| 61
 
|-
 
|-
 
| 61
 
| 61
|
+
| DVDClosePartitionAsync
|
+
| 62
 
|-
 
|-
 
| 62  
 
| 62  
|
+
| something with disc cache?
 
|-
 
 
| 63
 
| 63
 
 
 
|-
 
|-
 
| 64  
 
| 64  
|   
+
| ?  
|
+
| 2
 +
3
 +
15
 +
57
 +
64
 
|-
 
|-
 
| 65  
 
| 65  
|
+
| deallocate something?
|
+
| 65 (?)
 
|-
 
|-
 
| 66
 
| 66
|
+
| __DVDGetCoverStatusAsync
|
+
| 66, 67
 
|-
 
|-
| 67
+
| 67/68
|
+
| bs2_issue_dvd_command?
+
| 67/68?
|-
 
| 68  
 
|
 
|
 
 
|-
 
|-
 
| 70
 
| 70
|
+
| DVDGetPartitionParamsAsync
|
+
| 71
 
|-
 
|-
 
| 71
 
| 71
|
+
| something with ticket?
|
+
DVDOpenPartitionWithParams
 +
| 38
 +
71
 
|}
 
|}

Revision as of 22:51, 18 May 2010

States taken from System Menu 257 (3.1U); they may or may not be consistent across versions. This is a mess, because the state can be examined or modified by 9 different functions; only 1 is accounted for here (BS2Tick). Most of the complication seems to come from the desire to use asynchronous calls everywhere.

There is a similar (but simpler) state machine used in "recovery mode" -- BS2BootIRD.

Types

State number action next states
0 prints out status flags ("No Disk", "Drive Reset", "Wait Spinup", "Boot from Cache"), delay?, enable waiting-for-disk? 2, 52
1 delay 2
2 delay, enable waiting-for-disk?, DVDResetAsync 3
3 bs2_issue_dvd_command, delay, __DVDGetCoverStatusAsync, create cache.dat? 4
4 ReadDriveInfo via cache.dat or DVDInquiryAsync 5
5 wait for dvd command to finish, update cache.dat if necessary, setup 800030E6 [16bit] based on drive info and console type 8
6 DVDDownRotationAsync 7
7 bs2_issue_dvd_command? 8
8 Read 0x20 bytes of disk id [from cache.dat or disk via DVDReadDiskID] 9
9/10 wait for dvd command to finish, update cache.dat if necessary, copy the 0x20 byte long disk id to 0x80000000.

if [disk_id + 0x18] is 0x5d1c9ea3, and the [disk_id + 0] is not 'RAAE', treat as a wii disc.

otherwise, if [disk_id + 0x1c] is 0xc2339f3d, treat as gamecube disk

otherwise, the disk type is unknown

gamecube disk = 11, wii disk = 15, unknown = 54
11 if not waiting for a disk, exit to state 50

if waiting, disable the waiting-for-disk and check streaming [0x80000008]

if streaming and no streaming buffer size defined [0x80000009], set to size 10

if streaming, setup via __DVDAudioBufferConfig

go to state 12

12, 50
12 wait for DVD command to finish 13
13 async unencrypted 0x2000 byte dvd read 14
14 wait for DVD command to finish

once finished, check game region

region ok = 50

region not match = 54

15 unknown check can switch to state 70

read 0x20 bytes from disk (game toc?)

16
16 wait for dvd command to finish, update cache.dat if necessary 17
17 read partition info from disk 18
18 wait for dvd command to finish, update cache.dat if necessary

go through the game partition, making note of those of type 0 and 1

19
19 read 0x2000 bytes from disk 20
20 wait for dvd command to finish, update cache.dat if necessary

if 0xc3f81a8e not found at the end of read block, go to state 54

if region check fails, go to state 54

if BS2IsValidDisc check fails, go to state 54

if booting from cache, go to state 37

if there's a partition of type 1, go to state 21

if there's a partition of type 0, go to state 37

otherwise, go to state 54

21,37,54
21 DVDOpenPartitionAsync 22
22 bs2_issue_dvd_command?, print out TMD info 23
23 DVDReadAbsAsyncForBS 24
24 bs2_issue_dvd_command? 24, 25 (non-wii disc), 35 (wii disc)
25 DVDReadAbsAsyncForBS 26
26 bs2_issue_dvd_command

print out appLoaderLength / appLoaderFunc1

27
27 DVDReadAbsAsyncForBS 28
28 call apploader init func 29
29 call apploader main func

print "Addr [0x%x] length [0x%x] offset [0x%x]" DVDReadAbsAsyncForBS

30 (apploader main returned non-zero)

31 (apploader main returned zero)

30 bs2_issue_dvd_command 29
31 __DVDFSInit

BS2UpdateInit

32
32 BS2UpdateState

if an update exists:

BS2GetUpdateEntryNum
BS2UpdateState
BS2GetUpdateEntryNum
BS2Report("%d entries")
__DVDGetCoverStatusAsync
state 33

otherwise:

__DVDGetDriveStatus
based on status (?), DVDCancelAllAsync
32

1 (no update) 33 (update present) 35 ("No Entry"?)

33 bs2_issue_dvd_command?

BS2UpdateState __DVDGetCoverStatusAsync

33 or 34
34 BS2UpdateState

__DVDGetDriveStatus based on status (?), DVDCancelAllAsync based on return code of BS2UpdateState, print "Update success", "Update success\nPlease reboot", or "Update failed"

34

35 (update success) 58 (update failed)

35 DVDClosePartitionAsync 36
36 bs2_issue_dvd_command?

BS2UpdateState

37

54 65

37 Open partition from cache.dat, or DVDPartitionOpenAsync 38
38 print TMD info? 39
39 read from cache? 40
40 print appLoaderLength / appLoaderFunc1 41
41 read from cache? 42
42 call apploader init func 43
43 call apploader main func 44 or 45
44 ? 43 or 44
45 check for banner; if present, open it and read it from disc 46 (banner)

47 (no banner)

46 ? 47
47 DVDClosePartitionAsync 48
48 ? 49

69 72

49/69/72 bs2_issue_dvd_command?

__DVDGetCoverStatusAsync

49/69/72 (state changed by bs2_async_callback?)
50 bs2_issue_dvd_command

__DVDGetCoverStatusAsync

50 (state changed by bs2_async_callback?)
51 deallocate something? 2
52/53 deallocate something?

bs2_issue_dvd_command? __DVDGetCoverStatusAsync

52/53 (state changed by bs2_async_callback?)
54 deallocate something?

DVDChangeDiskAsyncForBS

55
55/56 bs2_issue_dvd_command? 55/56 (?)
57/58 deallocate something? 57/58?
59/63 ? 58

59 64

60 something with disc cache? 61
61 DVDClosePartitionAsync 62
62 something with disc cache? 63
64 ? 2

3 15 57 64

65 deallocate something? 65 (?)
66 __DVDGetCoverStatusAsync 66, 67
67/68 bs2_issue_dvd_command? 67/68?
70 DVDGetPartitionParamsAsync 71
71 something with ticket?

DVDOpenPartitionWithParams

38

71