2180
|
1 ********************************************************************
|
|
2 * Boot - DriveWire 3 Boot Module
|
|
3 *
|
|
4 * $Id$
|
|
5 *
|
|
6 * Edt/Rev YYYY/MM/DD Modified by
|
|
7 * Comment
|
|
8 * ------------------------------------------------------------------
|
|
9 * 1 2008/02/09 Boisy G. Pitre
|
|
10 * Created.
|
|
11
|
|
12 NAM Boot
|
|
13 TTL DriveWire Boot Module
|
|
14
|
|
15 IFP1
|
|
16 USE defsfile
|
|
17 USE dwdefs.d
|
|
18 ENDC
|
|
19
|
|
20 tylg SET Systm+Objct
|
|
21 atrv SET ReEnt+rev
|
|
22 rev SET 0
|
|
23 edition SET 1
|
|
24
|
|
25 MOD eom,name,tylg,atrv,start,size
|
|
26
|
|
27 * on-stack buffer to use
|
|
28 ORG 0
|
|
29 seglist RMB 2 pointer to segment list
|
|
30 blockloc RMB 2 pointer to memory requested
|
|
31 blockimg RMB 2 duplicate of the above
|
|
32 bootloc RMB 3 sector pointer; not byte pointer
|
|
33 bootsize RMB 2 size in bytes
|
|
34 LSN0Ptr RMB 2 LSN0 pointer
|
|
35 size EQU .
|
|
36
|
|
37 name EQU *
|
|
38 FCS /Boot/
|
|
39 FCB edition
|
|
40
|
|
41
|
|
42 * Common booter-required defines
|
|
43 LSN24BIT EQU 1
|
|
44 FLOPPY EQU 0
|
|
45
|
|
46
|
|
47 USE boot_common.asm
|
|
48
|
|
49
|
|
50 ************************************************************
|
|
51 ************************************************************
|
|
52 * Hardware-Specific Booter Area *
|
|
53 ************************************************************
|
|
54 ************************************************************
|
|
55
|
|
56 * HWInit - Initialize the device
|
|
57 * Entry: Y = hardware address
|
|
58 * Exit: Carry Clear = OK, Set = Error
|
|
59 * B = error (Carry Set)
|
|
60 HWInit
|
|
61 * Set up DDR for side B
|
|
62 * ldx #PIA1Base get base address of PIA
|
|
63 * ldb 3,x
|
|
64 * andb #%11111011
|
|
65 * stb 3,x
|
|
66 * lda #%11111010
|
|
67 * sta 2,x
|
|
68 * orb #%00000100
|
|
69 * stb 3,x
|
|
70
|
|
71 * Set up DDR for side A
|
|
72 * ldb 1,x
|
|
73 * andb #%11111011
|
|
74 * stb 1,x $FF20 is now Data Direction Register
|
|
75 * lda #%11111110 data direction bits (1=out, 0=in)
|
|
76 * sta ,x tell HW
|
|
77 * orb #%00000100 reset $FF20 to I/O register
|
|
78 * stb 1,x $FF20 is now Data Direction Register
|
|
79 HWTerm clrb
|
|
80 rts
|
|
81
|
|
82
|
|
83 * HWRead - Read a 256 byte sector from the device
|
|
84 * Entry: Y = hardware address
|
|
85 * B = bits 23-16 of LSN
|
|
86 * X = bits 15-0 of LSN
|
|
87 * blockloc,u = ptr to 256 byte sector
|
|
88 * Exit: X = ptr to data (i.e. ptr in blockloc,u)
|
|
89 HWRead
|
|
90 pshs cc,d,x
|
|
91 * Send out op code and 3 byte LSN
|
|
92 lda #OP_READEX load A with READ opcode
|
|
93 Read2 ldb WhichDrv,pcr
|
|
94 std ,s
|
|
95 leax ,s
|
|
96 ldy #5
|
2182
|
97 lbsr DWWrite send it to server
|
2180
|
98 * Get 256 bytes of sector data
|
|
99 ldx blockloc,u
|
|
100 lda #255
|
2182
|
101 bsr DWRead read bytes from server
|
2180
|
102 bcs ReadEr branch if framing error
|
|
103 cmpd #256
|
|
104 bne ReadEr2
|
|
105
|
|
106 * Send two byte checksum
|
|
107 pshs y
|
|
108 leax ,s
|
|
109 ldy #2
|
2182
|
110 lbsr DWWrite
|
2180
|
111 lda #255
|
2182
|
112 bsr DWRead
|
2180
|
113 leas 2,s
|
|
114 bcs ReadEx
|
|
115 cmpd #1
|
|
116 bne ReadEr2
|
|
117 ldb ,s
|
|
118 beq ReadEx
|
|
119 cmpb #E_CRC
|
|
120 bne ReadEr
|
|
121 lda #OP_REREADEX
|
|
122 bra Read2
|
|
123 ReadEx EQU *
|
|
124 leas 5,s eat stack
|
|
125 ldx blockloc,u
|
|
126 clrb
|
|
127 rts
|
|
128 ReadEr2 ldb #E$Read
|
|
129 ReadEr
|
|
130 leas 5,s eat stack
|
|
131 orcc #Carry
|
|
132 rts
|
|
133
|
|
134 USE dwread.asm
|
|
135 USE dwwrite.asm
|
|
136
|
|
137 IFGT Level-1
|
|
138 Pad FILL $39,$1D0-3-2-1-*
|
|
139 ENDC
|
|
140
|
|
141 Address FDB $0000
|
|
142 WhichDrv FCB $00
|
|
143 EMOD
|
|
144 eom EQU *
|
|
145 END
|