annotate level1/modules/boot_wd1002.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 - Eliminator WD1002-05 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 * WD 1002-05 OS-9 Boot Subroutine (called by OS9p1)
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
7 * Copyright 1988, 1989 Bruce Isted
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
8 * All Rights Reserved
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
9 *
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
10 * Ed. Comments Who YY/MM/DD
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
11 * ------------------------------------------------------------------
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
12 * 2 Created by Bruce Isted BRI ??/??/??
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 Eliminator WD1002-05 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 * These equates should be set before assembly:
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
18 FDStep equ $09 see Step Rate Table
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
19 HDStep equ $0F see step rate table
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
20
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
21 *Step Rate Table:
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
22 *+------------------+------------------+------------------+------------------+
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
23 *! Value=FD/HD Rate ! Value=FD/HD Rate ! Value=FD/HD Rate ! Value=FD/HD Rate !
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
24 *+------------------+------------------+------------------+------------------+
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
25 *! $00=40mS/7.5mS ! $04=16mS/5.5mS ! $08=08mS/3.5mS ! $0C=03mS/1.5mS !
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
26 *! $01=25mS/7.0mS ! $05=14mS/5.0mS ! $09=06mS/3.0mS ! $0D=02mS/1.0mS !
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
27 *! $02=20mS/6.5mS ! $06=12mS/4.5mS ! $0A=05mS/2.5mS ! $0E=01mS/0.5mS !
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
28 *! $03=18mS/6.0mS ! $07=10mS/4.0mS ! $0B=04mS/2.0mS ! $0F=15uS/ 35uS !
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
29 *+------------------+------------------+------------------+------------------+
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
30
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
31 ifp1
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
32 use defsfile
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
33 use rbfdefs
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
34 endc
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
35
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
36 * These equates should not have to be changed:
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
37 BEdtn equ 2
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
38 BVrsn equ 1
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
39 MaxCyls equ 1024 maximum cylinders supported
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
40 MaxHeads equ 16 maximum heads supported
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
41 MaxSctrs equ 64 maximum sectors per track supported
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
42 PhysDrv0 equ %10000000 SDH register mask for HD0
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
43 PhysDrv1 equ %10001000 SDH register mask for HD1
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
44 PhysDrv2 equ %10010000 SDH register mask for HD2
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
45 PhysDrv3 equ %00011000 SDH register mask for FD0
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
46 PhysDrv4 equ %00011010 SDH register mask for FD1
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
47 PhysDrv5 equ %00011100 SDH register mask for FD2
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
48 PhysDrv6 equ %00011110 SDH register mask for FD3
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
49 ReadSctr equ %00100000 read sector command
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
50 Restore equ %00010000 base restore command
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
51 SelfTest equ %10010000 WD 1002-05 diagnostic test command
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
52
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
53 * HCA memory map:
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
54 org 0
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
55 WDData rmb 2 WD 1002-05 sector buffer/task files
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
56 rmb 2 reserved - do not use
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
57 PA equ . PIA PA offset
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
58 DDRA rmb 1 PIA DDRA offset
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
59 CRA rmb 1 PIA CRA offset
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
60 PB equ . PIA PB offset
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
61 DDRB rmb 1 PIA DDRB offset
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
62 CRB rmb 1 PIA CRB offset
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
63
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
64 * WD 1002-05 register definitions:
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
65 org 0
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
66 WDBuff rmb 1 WD 1002-05 sector buffer address
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
67 ErrReg equ . error register address (read)
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
68 WPCReg rmb 1 write precomp register address (write)
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
69 SctrCnt rmb 1 sector count register address
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
70 SctrReg rmb 1 sector number register address
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
71 CylLow rmb 1 cylinder LSB register address
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
72 CylHigh rmb 1 cylinder MSB register address
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
73 SDHReg rmb 1 Size/Drive/Head register address
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
74 StatReg equ . status register address (read)
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
75 CmdReg rmb 1 command register address (write)
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
76
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
77 org 0
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
78 U.BSZ rmb 2 boot file size
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
79 U.BSct rmb 1 number of sectors in boot file
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
80 U.BT rmb 3 boot file start LSN
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
81 U.BtStrt rmb 2 boot file start address
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
82 U.CrtCyl rmb 2 current cylinder number
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
83 U.CrtSct rmb 1 current sector number
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
84 U.CrtSid rmb 1 current side (head) number
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
85 U.Restor rmb 1 restore command incl. step rate code
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
86 U.SDH rmb 1 base WD Size/Drive/Head register copy
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
87 U.Sides rmb 1 number of disk sides (heads)
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
88 U.SPC rmb 2 sectors per cylinder
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
89 U.SPT rmb 2 sectors per track
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
90 U.StSctr rmb 1 start sector number (HD=0, FD=1)
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
91 BootMem equ .
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
92
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
93 mod BEnd,BNam,Systm+Objct,ReEnt+BVrsn,BExec,$00
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
94 BNam fcs "Boot"
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
95 fcb BEdtn edition number
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
96
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
97 * base SDH register table
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
98 SDHTable equ *
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
99 fcb PhysDrv0,PhysDrv1,PhysDrv2 base SDH for hard drives
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
100 fcb PhysDrv3,PhysDrv4,PhysDrv5,PhysDrv6 base SDH for floppys
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
101 ***
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
102 * Boot subroutine module
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
103 *
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
104 * INPUT: none
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
105 *
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
106 * OUTPUT: [D]=size of bootstrap file
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
107 * [X]=start address of bootstrap file in memory
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
108 * y,u registers altered
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
109 *
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
110 * ERROR OUTPUT: [CC]=carry set
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
111 * [B]=error code
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
112 BExec ldy <D.WDAddr get HCA base address (set by auto-boot EPROM)
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
113 cmpy #$FF40 base address too low?
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
114 blo UnitErr yes, go report error...
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
115 cmpy #$FF7F base address too high?
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
116 bhi UnitErr yes, go report error...
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
117 lda <D.WDBtDr get boot drive number (set by auto-boot EPROM
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
118 cmpa #$07 legal drive number?
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
119 blo InitPIA yes, go initialize PIA...
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
120 UnitErr ldb #E$Unit
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
121 coma
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
122 rts
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
123
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
124 DumpRead clr PB,y set WD address to sector buffer
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
125 DumpR0 lda WDData,y get a byte from WD sector buffer
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
126 decb done yet?
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
127 bne DumpR0 no, go dump another byte
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
128 rts
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
129 LSN0Info ldb #DD.FMT load number of bytes to dump
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
130 bsr DumpRead go dump LSN0 up to DD.FMT
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
131 lda WDData,y get DD.FMT (disk density, sides)
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
132 anda #$01 mask out all but disk sides bit
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
133 inca correction to bit coding
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
134 sta U.Sides,u save disk sides (not valid if HD > 2 heads)
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
135 ldd WDData,y get DD.SPT (sectors per track)
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
136 std U.SPT,u
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
137 ldb #DD.BT-DD.RES load number of bytes to dump
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
138 bsr DumpRead go dump LSN0 from DD.RES to DD.BT
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
139 lda WDData,y get DD.BT (boot file start LSN) MSB
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
140 sta U.BT,u
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
141 ldd WDData,y get DD.BT (boot file start LSN) LSBs
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
142 std U.BT+1,u
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
143 ldd WDData,y get DD.BSZ (boot file size)
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
144 std U.BSZ,u
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
145 ldb U.StSctr,u floppy drive? (start sector = 1)
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
146 bne GotInfo yes, sides info OK, go return
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
147 ldb #DD.OPT+(PD.SID-PD.OPT)-DD.DAT load number of bytes to dump
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
148 bsr DumpRead go dump LSN0 from DD.DAT to number of sides in option table
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
149 lda WDData,y get number of sides from DD.OPT section
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
150 sta U.Sides,u
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
151 GotInfo rts
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
152
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
153 InitPIA clr CRA,y enable PIA DDRA
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
154 ldd #$033E [A]=DDRA: PA bits 7-2 = inputs, bits 1-0 = outputs
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
155 std DDRA,y [B]=CRA: PIA CA2 out high, PA slct, CA1 low to high, no IRQs
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
156 clr CRB,y enable PIA DDRB
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
157 lda #$FF [A]=DDRB: PB bits 7-0 all outputs
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
158 std DDRB,y [B]=CRB: PIA CB2 out high, PB slct, CB1 low to high, no IRQs
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
159 leas -BootMem,s open up some space for variables
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
160 leau ,s point [U] to start of variables
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
161 ldb #BootMem number of bytes to clear
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
162 leax ,u point [X] to start of variables
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
163 ClrLoop clr ,x+ initialize a byte to 0
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
164 decb done yet?
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
165 bne ClrLoop no, go clear another byte
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
166 lda #SelfTest WD 1002-05 internal diagnostic command
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
167 lbsr CmdUpdat go issue WD command, ensure everything is ready...
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
168 bcs ReadErr error, go report it...
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
169 lda #Restore!($0F&^HDStep) default to Restore with HD step rate
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
170 ldb <D.WDBtDr get boot drive number
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
171 cmpb #$03 hard drive?
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
172 blo SaveRstr yes, go save HD Restore command...
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
173 inc U.StSctr,u set start sector to 1 for floppy disks
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
174 lda #Restore!($0F&^FDStep) get Restore with FD step rate
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
175 SaveRstr sta U.Restor,u
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
176 leax SDHTable,pc
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
177 lda b,x get base SDH register
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
178 sta U.SDH,u save it...
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
179 * restore head to track 0
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
180 lbsr SetupTF go update WD task files (except command)
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
181 lda U.Restor,u load WD restore command code
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
182 lbsr CmdUpdat go issue WD command
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
183 bcs ReadErr error, go report it...
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
184 * read cylinder 0, head 0, first sector
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
185 lbsr GetSctr go set up, issue read command
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
186 bcs ReadErr error, go report it...
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
187 bsr LSN0Info go get disk info from LSN0
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
188 ldd U.BSZ,u get boot file size/cylinder offset number
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
189 bne ChkInfo must be boot file size, go check other LSN0 info...
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
190 ldd U.BT+1,u get offset cylinder number
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
191 beq ReadErr must not be boot disk, go report error...
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
192 cmpd #MaxCyls offset cylinder number OK?
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
193 bhs ReadErr no, go return error...
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
194 std U.CrtCyl,u save offset cylinder
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
195 * read offset cylinder, head 0, first sector
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
196 lbsr GetSctr go set up, issue read command
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
197 bcs ReadErr error, go exit...
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
198 lbsr LSN0Info go get disk info from offset LSN0
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
199 ldd U.BSZ,u get boot file size
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
200 beq ReadErr must not be boot disk, go report error...
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
201 * check LSN0 info
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
202 ChkInfo ldd U.SPT,u get sectors per track
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
203 beq ReadErr 0 sectors per track, go return error
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
204 cmpd #MaxSctrs sectors per track OK?
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
205 bhi ReadErr no, go return error
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
206 lda U.Sides,u get disk sides (heads)
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
207 beq ReadErr 0 sides, go return error
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
208 cmpa #MaxHeads number of heads OK?
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
209 bhi ReadErr no, go return error
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
210 mul calculate sectors per cylinder
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
211 std U.SPC,u save sectors per cylinder
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
212 ldd U.BSZ,u get boot file size
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
213 addd #$00FF round up to even sector...
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
214 sta U.BSct,u save number of sectors in boot file
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
215 * calculate boot file start cylinder, head, & sector
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
216 ldd U.BT+1,u get boot file LSN LSBs
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
217 ldx U.CrtCyl,u get current (offset) cylinder number
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
218 CylLoop subd U.SPC,u subtract sectors/cylinder
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
219 blo ChkBtMSB [D] underflow, go check boot file LSN MSB
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
220 CylLoop0 leax 1,x increment current cylinder number
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
221 bne CylLoop no overflow, go do another subtraction
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
222 ReadErr ldb #E$Read
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
223 coma set Carry for error
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
224 leas BootMem,s restore stack pointer
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
225 rts
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
226 ChkBtMSB tst U.BT,u boot file LSN MSB = 0?
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
227 beq GotCyl yes, go determine head number
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
228 dec U.BT,u decrement boot file LSN MSB
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
229 bra CylLoop0 go on...
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
230 GotCyl addd U.SPC,u restore sector number
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
231 stx U.CrtCyl,u save current cylinder number
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
232 TrkLoop subd U.SPT,u subtract sectors/track
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
233 blo GotSide [D] underflow, go save current sector number
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
234 inc U.CrtSid,u increment current side number
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
235 bra TrkLoop go do another subtraction
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
236 GotSide addd U.SPT,u restore sector number
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
237 stb U.CrtSct,u save it
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
238 * request boot file memory
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
239 pshs u save data pointer
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
240 ldd U.BSZ,u get boot file size
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
241 os9 F$SRqMem
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
242 tfr u,x move start address into [X]
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
243 puls u recover data pointer
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
244 bcs BtExit0 go return F$SRqMem error
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
245 stx U.BtStrt,u save boot file start address
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
246 ldd U.CrtCyl,u get cylinder number
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
247 bra ChkCyl go check cylinder & get first sector
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
248
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
249 * load boot file into memory
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
250 BootLoad inc U.CrtSct,u move on to next sector
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
251 lda U.SPT+1,u get sectors per track LSB (MSB is always 0)
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
252 cmpa U.CrtSct,u done track?
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
253 bhi LoadSctr no, go get sector
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
254 clr U.CrtSct,u reset current sector number to 0
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
255 inc U.CrtSid,u move on to next side
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
256 lda U.CrtSid,u get side number
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
257 cmpa U.Sides,u done cylinder?
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
258 blo LoadSctr no, go get sector
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
259 clr U.CrtSid,u reset side number to 0
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
260 ldd U.CrtCyl,u get cylinder number
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
261 addd #1 move on to next cylinder
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
262 std U.CrtCyl,u save cylinder number
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
263 ChkCyl cmpd #MaxCyls cylinder number OK?
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
264 bhs ReadErr no, go return error
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
265 LoadSctr bsr GetSctr go get current sector from WD 1002-05
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
266 bcs ReadErr error, go exit
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
267 clrb transfer 256 bytes
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
268 stb PB,y set WD sector buffer address
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
269 ReadLoop lda WDData,y get byte from WD 1002-05
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
270 sta ,x+ save byte to buffer
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
271 decb done yet?
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
272 bne ReadLoop no, go get another byte
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
273 dec U.BSct,u count down boot file sectors remaining
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
274 bne BootLoad
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
275 clrb clear carry
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
276 ldd U.BSZ,u get boot file size
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
277 ldx U.BtStrt,u get boot file start address
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
278 BtExit0 leas BootMem,s restore stack pointer
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
279 rts
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
280
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
281 GetSctr bsr SetupTF go set up WD task files (except command)
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
282 lda #ReadSctr load WD read sector command code
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
283 CmdUpdat ldb #CmdReg load WD command register address
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
284 bsr TFUpdat go issue command...
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
285 BusyWait ldb #StatReg
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
286 stb PB,y set WD status register address
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
287 BusyW0 ldb WDData,y get WD 1002-05 status
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
288 bitb #%00000010 valid data? (WD 1002-05 powered & connected?)
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
289 bne BWErr no, go report error...
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
290 tstb ensure [CC] sign flag is current
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
291 bmi BusyW0 yes, go check again
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
292 ldb WDData,y get valid controller status
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
293 rorb rotate error bit into carry
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
294 bcc NoError
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
295 ldb #ErrReg
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
296 stb PB,y set WD error register address
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
297 ldb WDData,y get error register contents
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
298 bne BWErr
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
299 NoError clrb
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
300 rts
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
301 BWErr comb error, set [CC] Carry...
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
302 rts
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
303
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
304 SetupTF ldd #$01*256+SctrCnt single sector commands only
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
305 bsr TFUpdat
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
306 lda U.CrtCyl,u get current cylinder number MSB
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
307 ldb #CylHigh
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
308 bsr TFUpdat
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
309 lda U.CrtCyl+1,u get current cylinder number LSB
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
310 ldb #CylLow
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
311 bsr TFUpdat
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
312 lda U.CrtSct,u get current sector number
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
313 adda U.StSctr,u add offset...
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
314 ldb #SctrReg
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
315 bsr TFUpdat
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
316 clrb default extended head disabled
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
317 lda U.CrtSid,u get current side (head) number
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
318 cmpa #$08 extended head?
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
319 blo StdHead no, go on...
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
320 incb set enable code
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
321 anda #$07 mask out all but standard head number
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
322 StdHead stb PA,y set extended head enable/disable
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
323 ora U.SDH,u mask in base SDH copy
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
324 ldb #SDHReg
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
325 TfUpdat stb PB,y set WD register address
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
326 sta WDData,y write data to WD 1002-05
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
327 rts
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 * pad Boot module out to $01D0 exactly
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
330 Pad fill $39,$1D0-3-*
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
331
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
332 emod
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
333 BEnd equ *
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
334 end
df263e490f85 New booters added (moved from 3rdparty/booters)
boisy
parents:
diff changeset
335