annotate level1/modules/boot_burke.asm @ 1286:d5839bc79972

Set rev to 0
author boisy
date Wed, 27 Aug 2003 23:58:52 +0000
parents df263e490f85
children 10957d54bf16
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1187
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
1 ********************************************************************
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
2 * Boot - Burke & Burke Boot Module
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
3 *
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
4 * $Id$
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
5 *
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
6 * Burke & Burke boot module... needs to be patched for OS9Boots that are
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
7 * far into the device.
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
8 * Track is the literal cylinder #, Cylinder would be including all heads
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
9 * of that track
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
10 *
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
11 * Ed. Comments Who YY/MM/DD
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
12 * ------------------------------------------------------------------
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
13
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
14 nam Boot
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
15 ttl Burke & Burke Boot Module
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
16
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
17 org 0
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
18 buffptr rmb 2 Pointer to sector buffer in memory
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
19 numcyl rmb 2 Number of tracks for drive geometry init
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
20 sechead rmb 2 # of logical sectors/physical sector
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
21 numhead rmb 1 # of heads (sides)
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
22 seccyl rmb 2 # of sectors/cylinder (# of heads*sectors per head)
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
23 track rmb 2 Cylinder number last calculated ($9 - $A)
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
24 head rmb 1 Drive/head number (drive always 0)
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
25 sector rmb 1 Sector number (0-63)
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
26 vars equ 13-buffptr Size of stack variables buffer
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
27
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
28
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
29 ifp1
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
30 use defsfile
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
31 use rbfdefs
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
32 endc
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
33
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
34 tylg set Systm+Objct
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
35 atrv set ReEnt+rev
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
36 rev set $02
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
37 edition set 2
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
38
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
39 mod eom,name,tylg,atrv,start,size
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
40
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
41 u0000 rmb 0
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
42 size equ .
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
43
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
44 name fcs /Boot/
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
45 fcb edition
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
46
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
47 start ldb >MPI.Slct Set up Multipak properly for us
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
48 lda #$10
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
49 mul
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
50 ldb #$11
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
51 mul
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
52 stb >MPI.Slct
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
53 leas -vars,s Reserve work area on stack of 13 bytes
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
54 tfr s,u U points to beginning of 13 byte buffer
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
55 pshs u,y,x,b,a Preserve registers
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
56 ldd #$0200 512 bytes for each read from XT-GEN
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
57 std numcyl,u # of cyls on drive
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
58 sta sechead+1,u # of sectors/head
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
59 sta numhead,u # of heads on drive
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
60 os9 F$SRqMem Request 512 byte buffer from OS9P1
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
61 lbcs L00B6 Error
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
62 tfr u,d d=Starting address of 512 byte block
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
63 ldu $06,s Get back pointer to 13 byte buffer
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
64 std buffptr,u Preserve buffer pointer
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
65
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
66 clr >$FF51 Reset controller
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
67
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
68 clr >$FF53 Set controller mode to 0 (part of init)
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
69 lbsr drvtype Set drive geometry (type of drive)
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
70 clrb Set initial LSN to 0
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
71 ldx #$0000
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
72 lbsr GetSect Figure out track/head/sector for LSN0
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
73 bcs L00B6 Error occured in read
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
74 ldy buffptr,u Get buffer pointer
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
75 ldd DD.NAM+PD.CYL,y Get real # cylinders on drive
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
76 std numcyl,u Preserve
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
77 ldd DD.NAM+PD.SCT,y Get real # sectors/track
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
78 std sechead,u Preserve
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
79 lda DD.NAM+PD.SID,y Get real # heads
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
80 sta numhead,u Preserve
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
81 leay DD.BT,y Point to OS9Boot information
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
82 ldd DD.BSZ-DD.BT,y Get size of OS9Boot
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
83 std ,s Preserve on stack
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
84 ldb DD.BT-DD.BT,y Get MSB of starting LSN of OS9Boot
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
85 ldx DD.BT-DD.BT+1,y Get LSW of starting LSN of OS9Boot
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
86 pshs x,b Push on stack
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
87 lbsr drvtype Set up drive for real drive specs
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
88 ldd #$0200 Get size of our buffer
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
89 ldu buffptr,u Get pointer to our 512 byte buffer
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
90 os9 F$SRtMem Deallocate our old sector buffer
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
91 ldd $03,s Get back size of OS9Boot
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
92 inca Increase size by 1 block (256 bytes)
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
93 IFEQ Level-1
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
94 os9 F$SRqMem
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
95 ELSE
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
96 os9 F$BtMem Allocate memory for boot file
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
97 ENDC
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
98 bcs L00B0 Error
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
99 stu $05,s Preserve pointer to start of OS9boot memory
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
100 ldu $09,s Get back pointer to local variables
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
101 ldd $05,s Get pointer to start of OS9Boot memory
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
102 std buffptr,u Move disk buffer pointer to there
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
103 ldd $03,s Get size of bootfile
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
104 beq L00A9 If zero, do someting
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
105 pshs b,a Otherwise push on stack
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
106 ReadBt std ,s Store # bytes left in boot on stack
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
107 ldb $02,s Get MSB of start sector of boot
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
108 ldx $03,s Get LSW of start sector of boot
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
109 bsr GetSect Convert to track/head/sector
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
110 bcs L00B4 If an error in getting, do something
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
111 inc buffptr,u Bump up buffer pointer by a page
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
112 ldx $03,s Bump up LSW of sector number
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
113 leax $01,x
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
114 stx $03,s And put it back
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
115 bne L00A0 If no carry over needed, proceed
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
116 inc $02,s Bump up MSB of sector number
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
117 L00A0 ldd ,s Get current boot size left to do
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
118 subd #$0100 Subtract 256 from it
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
119 bhi ReadBt If not zero yet, keep reading
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
120 leas $02,s Eat our temporary size left
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
121 L00A9 leas $03,s Eat our current LSN to get
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
122 clrb Clear carry (No error)
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
123 puls b,a pull off multipak settings (?)
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
124 bra BtExit
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
125 L00B0 leas $03,s Purge stack
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
126 bra L00B6
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
127 L00B4 leas $05,s Purge stack
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
128
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
129 L00B6 leas $02,s Purge stack
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
130
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
131 BtExit pshs a
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
132 lda #$FF
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
133 sta >$FF51 Reset controller
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
134 sta >MPI.Slct Reset multipak
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
135 sta >$FFD9 Double speed on
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
136 puls u,y,x,a Get exit parameters for Boot
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
137 leas vars,s Reset stack
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
138 rts Exit from Boot
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
139
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
140 * Get 512 byte sector from controller
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
141 * Entry X:B = 24 bit Logical sector number to get
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
142
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
143 GetSect pshs x,b Preserve registers
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
144 ldx #$FFFF (Init X so it will be 0 in loop)
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
145
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
146 * 24 bit divide routine. Stack=LSN (3 bytes)
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
147 * Entry: u=pointer to our local variable list
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
148
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
149 cyldiv leax $01,x # of loops through subtract
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
150 ldd $01,s Get original x (0)
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
151 subd seccyl,u Subtract # sector/cylinder
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
152 std $01,s Preserve it back
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
153 ldb ,s Continue subtract with borrow for 24 bit
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
154 sbcb #$00
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
155 stb ,s
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
156 bcc cyldiv If not trying to borrow again, continue
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
157 stx track,u Got track #
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
158 ldd $01,s Reset value to last in loop
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
159 addd seccyl,u
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
160 clr head,u Set head # to 0?
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
161 hddiv inc head,u Increase head #?
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
162 subd sechead,u Subtract # sectors/head?
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
163 bcc hddiv Continue subtracting until it wraps
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
164 dec head,u Adjust head to not include wrap
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
165 addd sechead,u Adjust leftover to not include wrap
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
166 lsrb Divide b by 2 (256 byte sector to 512)
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
167 stb sector,u Preserve sector #
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
168 leas $03,s Clear stack of 24 bit number
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
169
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
170 pshs cc Preserve odd sector flag (carry bit)
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
171
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
172 bsr cmdstrt Set up controller for new command
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
173 lda #$08 Read sector command
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
174 ldb head,u Drive/head byte (Drive always 0)
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
175 bsr dblsend Send to controller
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
176 ldd track,u Get msb of track
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
177 lsra Move right 2 bits into left two for the
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
178 rora controller
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
179 rora
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
180 ora sector,u mask in the sector number into remaining 6 bits
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
181 * ldb track+1,u Get LSB of track
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
182 bsr dblsend Send to controller
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
183 ldd #$0100 1 sector to read/no error correction/3 ms step
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
184 bsr dblsend Send that to controller
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
185 ldx buffptr,u Get pointer to sector buffer
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
186 * new code is here
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
187 puls cc Get back odd sector 1/2 indicator
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
188 bcc normal Even sector, use 1st half
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
189 bsr Eat256 Odd sector, use 2nd half
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
190 bsr Read256 Read 256 bytes off of controller
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
191 lbra chkcmplt See if command is complete
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
192 normal bsr Read256 Read 1/2 of sector
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
193 bsr Eat256 Eat half of sector
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
194 lbra chkcmplt See if command is complete
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
195
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
196 Eat256 clrb Eat 256 bytes off of controller
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
197 Eatlp lbsr nxtready Get byte from controller
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
198 decb counter
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
199 bne Eatlp Keep eating until 256 bytes done
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
200 clrb
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
201 rts
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
202
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
203 * Read 256 bytes from controller
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
204 * Entry: X=Pointer to current position in 512 physical sector buffer
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
205
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
206 Read256 clrb Set counter for 256 byte read
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
207 ReadLp lbsr nxtready Go get a byte from controller
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
208 sta ,x+ Put in buffer
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
209 decb keep doing until all 256 are read
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
210 bne ReadLp
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
211
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
212 middle clrb Clear carry for no error & return
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
213 rts
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
214
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
215 * Send 2 bytes to the controller
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
216 * Entry: a=1st byte to send
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
217 * b=2nd byte to send
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
218
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
219 dblsend pshs b,a Preserve d for a moment
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
220 bsr sendbyte Go send what is in a to controller
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
221 tfr b,a Send what was in b to the controller
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
222 bsr sendbyte
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
223 puls pc,b,a Return with a and b intact
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
224
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
225 * Sends a byte to the controller when it is ready for it
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
226 * Entry: a=byte to send
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
227
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
228 sendbyte pshs a Preserve a for a moment
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
229 waitsend bsr stable Make sure status register is stable and get it
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
230 anda #%00001011 Mask out bits
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
231 cmpa #$09 Is it expecting next byte of data packet?
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
232 bne waitsend
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
233 puls a Yes, get the byte we are sending next
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
234 sta >$FF50 Store in data register
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
235 rts
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
236
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
237 * Sends out command packet (6 bytes). Hard coded for drive 0, head 0,
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
238 * track 0, sector 0, interleave 0, no error correction, 3 ms step rate
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
239
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
240 cmdpckt pshs a Preserve command for a moment
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
241 bsr cmdstrt Go initialize controller for command start
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
242 puls a Get back command byte
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
243 clrb 1st option byte to 0
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
244 bsr dblsend Send both to controller
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
245 clra
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
246 bsr dblsend Send 4 more 0's to controller
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
247 bsr dblsend (sent command byte and 5 zero bytes for command
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
248 rts packet)
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
249
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
250 cmdstrt bsr stable
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
251 anda #%00001001 Mask out all but bits 0 and 3
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
252 bne cmdstrt If controller command is not complete or expecting
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
253 clr >$FF52 data, keep reading status register until it is ready
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
254 rts Otherwise initialize command start
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
255
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
256 * Make sure controller's status register is stable
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
257
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
258 stable lda >$FF51 Get status from controller
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
259 cmpa >$FF51 Keep getting until it stabilizes
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
260 bne stable
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
261 rts
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
262
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
263 * Set the drive type (set to 512 track - may be the error)
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
264 * Using the initialize drive geometry command
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
265 * Exit: Carry set if non-recoverable error
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
266
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
267 drvtype lda #$0C Initialize drive geometry command
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
268 bsr cmdpckt Go init
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
269 ldd numcyl,u Get # of cylinders on media
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
270 bsr dblsend Send it out (indicates drive has 512 tracks)
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
271 ldb sechead+1,u Get # of sectors/head
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
272 lda numhead,u Get # of heads on media
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
273 lsrb Divide OS9 sectors by 2
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
274 bsr sendbyte Send out # of heads for drive geometry
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
275 lslb Multiply WD sectors by 2 to get OS9 sectors again.
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
276 mul
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
277 std seccyl,u # sectors per cylinder (all heads on a track)
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
278 ldd numcyl,u Get # of tracks back
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
279 subd #$0001 Reduce write track=last track-1
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
280 bsr dblsend Send out reduced write track #
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
281 bsr dblsend Also use as write precomp track #
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
282 lda #$04 Maximum ECC burst length correctable=4
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
283 bsr sendbyte Send it out
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
284
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
285 * Make sure command has completed
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
286 * Exit: Carry set if controller reported a non-recoverable error
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
287 * Carry clear if everything went fine
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
288
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
289 chkcmplt bsr stable When status register is stable get it
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
290 anda #%00000111 Keep checking until controller indicates that
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
291 cmpa #%00000111 command completion code is ready to be read
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
292 bne chkcmplt
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
293 lda >$FF50 Get command completion code
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
294 bita #%00000010 Was there in error in completing the command?
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
295 beq noerror Nope, everything fine setting drive geometry
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
296 lda #$03 Error, Request Sense Status from the drive
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
297 bsr cmdpckt send Request Sense Status code
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
298 bsr nxtready Go get response from controller
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
299 anda #%00111111 Mask out all but error type and error code
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
300 pshs a Preserve it for a second
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
301 bsr eat2 Go eat next 4 bytes from controller (remaining 3
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
302 bsr eat2 from Sense Status & command completion code)
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
303 puls a Get back original error byte
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
304 tsta No error occured?
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
305 beq noerror No error; exit without error
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
306 cmpa #%00011000 Type 1, error 8 (correctable data error)?
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
307 beq noerror Yes, return without error
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
308 comb Set carry to indicate error
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
309 rts return
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
310 noerror clrb
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
311 rts
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
312
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
313 * Reads two byte from controller without caring what they are
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
314
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
315 eat2 bsr nxtready
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
316
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
317 * Waits until next byte coming from controller is ready, then gets it
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
318 * Exit: a=byte from controller
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
319
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
320 nxtready bsr stable Make sure status register is stable and get it
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
321 anda #%00001011 Controller ready to send me next byte?
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
322 cmpa #%00001011
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
323 bne nxtready Nope, keep waiting
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
324 lda >$FF50 Yes, get byte and return
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
325 rts Padding to get $1D0 Size
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
326 * Pad to $1d0 bytes exactly
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
327 Pad fill $39,$1D0-3-*
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
328
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
329 emod
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
330 eom equ *
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
331 end