Research V7 development
[unix-history] / usr / mdec / hpuboot.s
CommitLineData
736d93cd
KT
1/ disk boot program to load and transfer
2/ to a unix entry
3
4/ entry is made by jsr pc,*$0
5/ so return can be rts pc
6
7core = 28.
8.. = [core*2048.]-512.
9
10/ establish sp and check if running below
11/ intended origin, if so, copy
12/ program up to 'core' K words.
13start:
14 mov $..,sp
15 mov sp,r1
16 cmp pc,r1
17 bhis 2f
18 clr r0
19 cmp (r0),$407
20 bne 1f
21 mov $20,r0
221:
23 mov (r0)+,(r1)+
24 cmp r1,$end
25 blo 1b
26 jmp (sp)
27
28/ clear core to make things clean
292:
30 clr (r0)+
31 cmp r0,sp
32 blo 2b
33
34/ at origin, read pathname,
35/ initialize rp
36 mov $drive,*$hpcs2
37 mov $preset+go,*$hpcs1
38 mov $fmt22,*$hpof
39
40/ spread out in array 'names', one
41/ component every 14 bytes.
42 mov $names,r1
431:
44 mov r1,r2
452:
46 jsr pc,getc
47 cmp r0,$'\n
48 beq 1f
49 cmp r0,$'/
50 beq 3f
51 movb r0,(r2)+
52 br 2b
533:
54 cmp r1,r2
55 beq 2b
56 add $14.,r1
57 br 1b
58
59/ now start reading the inodes
60/ starting at the root and
61/ going through directories
621:
63 mov $names,r1
64 mov $2,r0
651:
66 clr bno
67 jsr pc,iget
68 tst (r1)
69 beq 1f
702:
71 jsr pc,rmblk
72 br start
73 mov $buf,r2
743:
75 mov r1,r3
76 mov r2,r4
77 add $16.,r2
78 tst (r4)+
79 beq 5f
804:
81 cmpb (r3)+,(r4)+
82 bne 5f
83 cmp r4,r2
84 blo 4b
85 mov -16.(r2),r0
86 add $14.,r1
87 br 1b
885:
89 cmp r2,$buf+512.
90 blo 3b
91 br 2b
92
93/ read file into core until
94/ a mapping error, (no disk address)
951:
96 clr r1
971:
98 jsr pc,rmblk
99 br 1f
100 mov $buf,r2
1012:
102 mov (r2)+,(r1)+
103 cmp r2,$buf+512.
104 blo 2b
105 br 1b
106/ relocate core around
107/ assembler header
1081:
109 clr r0
110 cmp (r0),$407
111 bne 2f
1121:
113 mov 20(r0),(r0)+
114 cmp r0,sp
115 blo 1b
116/ enter program and
117/ restart if return
1182:
119 jsr pc,*$0
120 br start
121
122/ get the inode specified in r0
123iget:
124 add $15.,r0
125 mov r0,r5
126 ash $-3.,r0
127 bic $!17777,r0
128 mov r0,dno
129 clr r0
130 jsr pc,rblk
131 bic $!7,r5
132 ash $6,r5
133 add $buf,r5
134 mov $inod,r4
1351:
136 mov (r5)+,(r4)+
137 cmp r4,$inod+64.
138 blo 1b
139 rts pc
140
141/ read a mapped block
142/ offset in file is in bno.
143/ skip if success, no skip if fail
144/ the algorithm only handles a single
145/ indirect block. that means that
146/ files longer than 10+128 blocks cannot
147/ be loaded.
148rmblk:
149 add $2,(sp)
150 mov bno,r0
151 cmp r0,$10.
152 blt 1f
153 mov $10.,r0
1541:
155 mov r0,-(sp)
156 asl r0
157 add (sp)+,r0
158 add $addr+1,r0
159 movb (r0)+,dno
160 movb (r0)+,dno+1
161 movb -3(r0),r0
162 bne 1f
163 tst dno
164 beq 2f
1651:
166 jsr pc,rblk
167 mov bno,r0
168 inc bno
169 sub $10.,r0
170 blt 1f
171 ash $2,r0
172 mov buf+2(r0),dno
173 mov buf(r0),r0
174 bne rblk
175 tst dno
176 bne rblk
1772:
178 sub $2,(sp)
1791:
180 rts pc
181
182drive = 0
183cyl = 0.
184read = 70
185preset = 20
186go = 1
187fmt22 = 10000
188
189hpcs1 = 176700
190hpda = hpcs1+6
191hpcs2 = hpcs1+10
192hpds = hpcs1+12
193hpof = hpcs1+32
194hpca = hpcs1+34
195
196/ rp0456 disk driver.
197/ low order address in dno,
198/ high order in r0.
199rblk:
200 mov r1,-(sp)
201 mov dno,r1
202 div $22.*19.,r0
203 add $cyl,r0
204 mov r0,*$hpca
205 clr r0
206 div $22.,r0
207 swab r0
208 bis r1,r0
209 mov $hpda,r1
210 mov r0,(r1)
211 mov $buf,-(r1)
212 mov $-256.,-(r1)
213 mov $read+go,-(r1)
2141:
215 tstb (r1)
216 bge 1b
217 mov (sp)+,r1
218 rts pc
219
220tks = 177560
221tkb = 177562
222/ read and echo a teletype character
223getc:
224 mov $tks,r0
225 inc (r0)
2261:
227 tstb (r0)
228 bge 1b
229 mov tkb,r0
230 bic $!177,r0
231 cmp r0,$'A
232 blo 1f
233 cmp r0,$'Z
234 bhi 1f
235 add $'a-'A,r0
2361:
237
238tps = 177564
239tpb = 177566
240/ print a teletype character
241putc:
242 tstb *$tps
243 bge putc
244 mov r0,*$tpb
245 cmp r0,$'\r
246 bne 1f
247 mov $'\n,r0
248 br putc
2491:
250 rts pc
251
252end:
253inod = ..-1024.
254addr = inod+12.
255buf = inod+64.
256bno = buf+512.
257dno = bno+2
258names = dno+2
259reset = 5