/
NeoWidEx_CMD_Soft_Reset.X68
73 lines (61 loc) · 3.06 KB
/
NeoWidEx_CMD_Soft_Reset.X68
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
*-----------------------------------------------------------
* Title : NeoWidEx_CMD_Soft_Reset
* Written by : Tom Stepleton
* Description:
* Formatting and diagnostic tool for Widget drives,
* inspired by the WidEx utility internal to Apple, and by
* Patrick Schäfer's UsbWidEx hardware tool.
* -- This file: issues the soft-reset command.
* Equates from NeoWidEx_DEFS must be defined.
* Macros from NeoWidEx_MACROS must be defined.
* Resources from NeoWidEx_IO must be defined.
* Resources from NeoWidEx_WIDGETINFO must be defined.
*-----------------------------------------------------------
* NeoWidEx Soft_Reset code =================================
; CMD_Soft_Reset -- Attempt the Soft_Reset command
; Args:
; (none)
; Notes:
; Trashes D0-D1/A0.
; If WIDGETINFO runs, has all of WIDGETINFO's side-effects.
CMD_Soft_Reset:
BSR WIDGETCHECK ; Is this a Widget? If not, bail
mPrint kCrtRow,kCrtCol,#kFirstCol,<$0D,' --- SOFT RESET ---'>
CLR.B zHaveInfo ; Resetting? May as well refresh our info
MOVE.B #2,D0 ; The command is two bytes long
LEA sCmdSoftReset,A0 ; Location of the command template in RAM
BSR WIDGETCMD ; Construct actual command in RAM
CLR.W zWIOReadLen ; There are no bytes to read
CLR.W zWIOWriteLen ; There are no bytes to write
BSR WIDGETIO ; Issue command
BEQ .ok ; All OK? Exit
; It would be weird if it were OK, since the drive should be busy resetting
; itself. So we poll it instead with successive requests for drive status.
MOVE.B #3,D0 ; The command is three bytes long
LEA s_CmdSoftResetStdStatus,A0 ; Location of the cmd. template in RAM
BSR WIDGETCMD ; Construct the actual command in RAM
MOVE.W #19,D1 ; We'll try the command 20 times
.lp BSR WIDGETIO ; Issue command
BEQ .ok ; All OK? Exit
DBEQ D1,.lp ; Otherwise, try again...
mPrtMem kCrtRow,kCrtCol,#kFirstCol,export,sCmdSoftResetFail
BSR WIDGETPERROR ; Error! Print error message
RTS ; Back to caller
.ok mPrint kCrtRow,kCrtCol,#kFirstCol,<$0D,'DONE.'>
RTS ; Back to caller
PAGE
* NeoWidEx Soft_Reset strings ===============================
SECTION kSecStrings
sCmdSoftReset:
DC.B $10,$07 ; Soft_Reset command (it's short!)
s_CmdSoftResetStdStatus:
DC.B $10,$01,$00 ; Command to request standard status
sCmdSoftResetFail:
DC.B $0D,'FAILED TO COMMUNICATE WITH DRIVE AFTER RESET. ATTEMPTED'
DC.B $0D,'TO RETRIEVE STANDARD STATUS 20 TIMES. LAST ERROR--'
** (Back to the code section) **
SECTION kSecCode
*~Font name~Courier New~
*~Font size~10~
*~Tab type~1~
*~Tab size~4~