0
|
1 ********************************************************************
|
|
2 * Cobbler - Boot generation utility
|
|
3 *
|
|
4 * $Id$
|
|
5 *
|
|
6 * Ed. Comments Who YY/MM/DD
|
|
7 * ------------------------------------------------------------------
|
|
8 * 7 Reworked AD
|
|
9 * 8 Fixed error where $40+C$CR should have been BGP 98/10/20
|
|
10 * $40*256+C$CR
|
|
11
|
|
12 nam Cobbler
|
|
13 ttl Boot generation utility
|
|
14
|
|
15 * Disassembled 94/10/23 11:19:48 by Alan DeKok
|
|
16
|
|
17 * WARNING: This is a LEVEL II Cobbler only!
|
|
18
|
|
19 ifp1
|
|
20 use os9defs
|
|
21 use scfdefs
|
|
22 use rbfdefs
|
|
23 endc
|
|
24
|
|
25 tylg set Prgrm+Objct
|
|
26 atrv set ReEnt+rev
|
|
27 rev set $01
|
|
28 edition set 8
|
|
29
|
|
30 mod eom,name,tylg,atrv,start,size
|
|
31 u0000 rmb 3
|
|
32 u0003 rmb 1
|
|
33 u0004 rmb 12
|
|
34 u0010 rmb 5
|
|
35
|
|
36 u0015 rmb 1
|
|
37 u0016 rmb 2
|
|
38 u0018 rmb 2
|
|
39 * Everything before here is the DD.foo equivalent
|
|
40 PathO rmb 1 path output to OS9boot file
|
|
41 Path rmb 3 path to /DEVICE@
|
|
42 KernelF rmb 1 0=write kernel track, 1= don't
|
|
43 BootF rmb 1 0=write boot track, 1=don't
|
|
44 FileNm rmb 20 /DEVICE/OS9Boot memory
|
|
45 rmb 16
|
|
46 SysDAT rmb 16 copy of the system DAT image
|
|
47 FileDesc rmb $20 room for first bit of file descriptor
|
|
48 AllMap rmb 1024 allocation map is entirely too large...
|
|
49 Buffer rmb $2000 only copy 8k at a time
|
|
50 rmb 200 room for the stack
|
|
51 size equ .
|
|
52
|
|
53 name fcs /Cobbler/
|
|
54 fcb edition my version of cobbler
|
|
55
|
|
56 L0015 fdb $0000 minimal DAT image for checking out the system.
|
|
57
|
|
58 OS9Boot fcs '/OS9Boot'
|
|
59 Rel fcc /Rel/
|
|
60
|
|
61 start clr <KernelF force a write of the kernel track
|
|
62 clr <BootF force a write of the boot track
|
|
63 skip ldd ,x+
|
|
64 cmpa #C$SPAC space?
|
|
65 beq skip
|
|
66 cmpa #'- hyphen?
|
|
67 bne s.001
|
|
68
|
|
69 andb #$DF make it uppercase
|
|
70 cmpb #'K force no write of kernel track?
|
|
71 bne check.b no, check for the boot track stuff
|
|
72 stb <KernelF save the kernel flag
|
|
73 bra s.000
|
|
74
|
|
75 check.b cmpb #'B don't write boot?
|
|
76 bne go.help no, print out help message
|
|
77 stb <BootF save the boot flag
|
|
78
|
|
79 s.000 leax 1,x skip the character
|
|
80 lda ,x++ get the next character, and point to the next one
|
|
81 cmpa #$20 space?
|
|
82 bne go.help no, print out a help message
|
|
83
|
|
84 s.001 leax -1,x
|
|
85 lda #'/
|
|
86 cmpa ,x is the first character a slash?
|
|
87 Go.help lbne Help not a device name, error out
|
|
88 os9 F$PrsNam parse the name
|
|
89 lbcs Exit exit on error
|
|
90 lda #'/ is the next character a slash?
|
|
91 cmpa ,y check it
|
|
92 lbeq Help yes, dump out a help message
|
|
93 ldy #FileNm point to the filename buffer
|
|
94 L013C sta ,y+ make first character a slash
|
|
95 lda ,x+ copy the name over
|
|
96 decb
|
|
97 bpl L013C
|
|
98 ldd #$40*256+C$CR '@+CR'
|
|
99 std ,y save in the buffer
|
|
100 ldx #FileNm point to the filename again
|
|
101 lda #UPDAT.
|
|
102 os9 I$Open open /DEVICE@
|
|
103 sta <Path save the path to the file
|
|
104 lbcs Exit dump out help on an error
|
|
105 leax ,y point to end of '/DEVICE' name
|
|
106 leay >OS9Boot,pcr point to the OS9Boot name
|
|
107 L0162 lda ,y+ get a byte from the name
|
|
108 sta ,x+ save in my buffer
|
|
109 bpl L0162 copy it over
|
|
110
|
|
111 leax ,u both are zero in a level II system
|
|
112 lda <Path
|
|
113 os9 I$Seek seek to LSN0
|
|
114 lbcs Exit dump out error if encountered
|
|
115
|
|
116 * X is implicitely zero from the call above
|
|
117 ldy #DD.BSZ+2 read everything up to the boot size
|
|
118 lda <Path
|
|
119 os9 I$Read get it
|
|
120 lbcs Exit
|
|
121
|
|
122 tst <BootF replace OS9Boot?
|
|
123 lbne no.boot no, go write the kernel track
|
|
124
|
|
125 ldd <DD.BSZ get the boot size
|
|
126 lbeq L019F if non-existent, don't delete it
|
|
127 ldx #FileNm point to /DEVICE/OS9boot
|
|
128 os9 I$Delete delete it, if it exists
|
|
129 clra
|
|
130 clrb
|
|
131 sta <DD.BT NO OS9boot file on this disk
|
|
132 std <DD.BT+1
|
|
133 std <DD.BSZ
|
|
134 lbsr L045A dump out LSN0 information again
|
|
135
|
|
136 L019F ldd #(UPDAT.*256)+UPDAT.
|
|
137 ldx #FileNm create a /DEVICE/OS9Boot file
|
|
138 os9 I$Create
|
|
139 lbcs Exit
|
|
140 sta <PathO
|
|
141
|
|
142 leax >L0015,pcr temporary DAT image
|
|
143 tfr x,d
|
|
144 ldx #$0000 get copy of direct page
|
|
145 ldy #$0090 first $90 bytes
|
|
146 ldu #Buffer to a buffer
|
|
147 os9 F$CpyMem copy memory
|
|
148 lbcs Exit
|
|
149
|
|
150 leax >L0015,pcr
|
|
151 tfr x,d use it as temporary DAT image
|
|
152 ldx >Buffer+D.SysDAT get pointer to system DAT image
|
|
153 ldy #$0010 get a copy of it
|
|
154 ldu #SysDAT point to room for the system DAT image
|
|
155 os9 F$CpyMem get the system DAT image
|
|
156 lbcs Exit
|
|
157 ldx #Buffer
|
|
158 ldd <D.BtPtr,x address of boot in system memory
|
|
159 pshs d save a copy of it
|
|
160 ldd <D.BtSz,x size of the OS9Boot file in system memory
|
|
161 std <DD.BSZ save in the boot size info for LSN0
|
|
162 pshs d save the size
|
|
163 L01F7 ldy #$2000 only do 8k at a time
|
|
164 cmpy ,s default to one block???
|
|
165 bls L0203
|
|
166 ldy ,s get the actual boot size
|
|
167 L0203 pshs y save a copy of it
|
|
168 ldx #SysDAT get dat image
|
|
169 tfr x,d save it
|
|
170 ldx $04,s get start of boot in memory
|
|
171 ldu #Buffer
|
|
172 os9 F$CpyMem copy one block at a time
|
|
173 lbcs Exit
|
|
174 ldy ,s get how much we're copying
|
|
175 ldx #Buffer point to the buffer
|
|
176 lda <PathO dump it to /DEVICE/OS9Boot file
|
|
177 os9 I$Write
|
|
178 lbcs Exit
|
|
179 puls d get size of what we're copying
|
|
180 ldy $02,s get start address of boot file in system memory
|
|
181 leay d,y go to the next group of data
|
|
182 sty $02,s save new start a address
|
|
183 nega
|
|
184 negb
|
|
185 sbca #$00
|
|
186 ldy ,s get size of boot file left
|
|
187 leay d,y take out what we've done
|
|
188 sty ,s save it
|
|
189 bne L01F7 if not done, continue
|
|
190 leas $04,s remove start,size from the stack
|
|
191
|
|
192 lda <PathO path to OS9Boot
|
|
193 ldb #SS.FD get FD information
|
|
194 ldx #FileDesc read the file descriptor sector
|
|
195 ldy #$0020 only get the first 32 bytes of it
|
|
196 os9 I$GetStt
|
|
197 lbcs Exit
|
|
198
|
|
199 os9 I$Close close the path
|
|
200 lbcs Exit
|
|
201
|
|
202 ldd <FD.SEG+3+2+3,x get size of SECOND segment in file
|
|
203 lbne L0488 if not zero, the file is fragmented
|
|
204 ldb <FD.SEG,x get first byte of address
|
|
205 stb <DD.BT save starting sector of the bootstrap file
|
|
206 ldd <FD.SEG+1,x
|
|
207 std <DD.BT+1 save the rest of the LSN#
|
|
208 lbsr L045A seek to LSN0 and dump out this information, too
|
|
209
|
|
210 lda <KernelF do we do a kernel track?
|
|
211 bne ClnExit no, don't even check for floppy stuff
|
|
212
|
|
213 lda <DD.FMT is it a HD? (Bit 7 set)
|
|
214 bpl Floppy if bit 7 is clear, go do track 34 stuff.
|
|
215
|
|
216 ClnExit clrb no error
|
|
217 Exit1 OS9 F$Exit and exit
|
|
218
|
|
219 no.boot lda <DD.FMT is it a HD? (bit 7 set)
|
|
220 bpl Floppy if OK, go write it
|
|
221 coma set carry
|
|
222 ldb #E$BTyp bad media type
|
|
223 bra Exit1
|
|
224
|
|
225 Floppy ldd #$0001 track 0, sector 1: LSN 1
|
|
226 lbsr L0440 seek to it
|
|
227
|
|
228 ldx #AllMap point to the allocation map buffer
|
|
229 ldy <DD.MAP get the size of the map
|
|
230 lda <Path
|
|
231 os9 I$Read read in the allocation map
|
|
232 bcs Exit1
|
|
233
|
|
234 ldd <DD.MAP get number of bytes in the map
|
|
235 leau d,x point to the END of the map
|
|
236 ldd #$2200 track 34, sector 0
|
|
237 lbsr Tk2LSN get LSN of this in D
|
|
238 pshs d save it for later
|
|
239 ldy #0018 force the boot track to be 18 sectors long
|
|
240 OS9 F$SchBit search for 18 free sectors at D,X: ending at U
|
|
241 cmpd ,s++ did we find bits at the starting bit number?
|
|
242 bne Check no, check for REL on the disk
|
|
243 cmpy #0018 if found at the right spot, did we find 18 bits?
|
|
244 beq AllClr if so, go allocate them
|
|
245
|
|
246 Check ldd #$2200 track 34, sector 0
|
|
247 lbsr L0440 seek to it
|
|
248
|
|
249 ldx #Buffer
|
|
250 ldy #$0100 read one sector
|
|
251 lda <Path
|
|
252 os9 I$Read get the first sector of the boot track
|
|
253 lbcs Exit
|
|
254
|
|
255 ldd ,x++ get the first 2 bytes
|
|
256 cmpd #$4F53 is it 'OS'?
|
|
257 lbne L0496 files present on track 34, give error
|
|
258 ldd ,x++
|
|
259 cmpa #$20 is it a BRA?
|
|
260 lbne L0496
|
|
261 ldd ,x get some bytes from the sector
|
|
262 cmpd #M$ID12 is it a module header?
|
|
263 beq map.blk yes, go write out the kernel track
|
|
264 leax 2,x skip the $1205 sync bytes
|
|
265 ldd ,x grab the header
|
|
266 cmpd #M$ID12 is there a module here?
|
|
267 lbne L0496 no, error out
|
|
268 bra map.blk don't allocate track 34, REL already exists on it
|
|
269
|
|
270 * We've found 18 bytes at D,X in the allocation bit map
|
|
271 * D,X,Y are set up from above
|
|
272 AllClr OS9 F$AllBit allocate the bits in the bitmap
|
|
273
|
|
274 * possible problems here, as the r/w of the allocation bitmap is NOT atomic.
|
|
275 * some other process may come along and grab the sectors we want.
|
|
276 L0315 ldd #$0001 track 0, sector 1
|
|
277 bsr L0440 seek to it
|
|
278 ldx #AllMap
|
|
279 ldy <DD.MAP
|
|
280 lda <Path
|
|
281 os9 I$Write dump out the allocation map again
|
|
282 lbcs Exit
|
|
283
|
|
284 * Do a F$Link to REL?
|
|
285 map.blk ldx #$003F the boot track is in block 63
|
|
286 ldb #1 one block
|
|
287 OS9 F$MapBlk map the block in
|
|
288 lbcs L049D error finding boot track in memory
|
|
289
|
|
290 ldd #$2200 track 34, sector 0
|
|
291 bsr L0440 seek to it
|
|
292 lda <Path
|
|
293 leax $0D00,u the boot track starts out at $ED00
|
|
294 ldy #$1200 dump out 18 sectors
|
|
295 os9 I$Write dump out REL, Boot, OS9p1
|
|
296 pshs cc,b
|
|
297 ldb #1
|
|
298 OS9 F$ClrBlk un-map block $3F
|
|
299 puls cc,b restore possible error code
|
|
300 bcs L048F if there was an error, print it out and exit
|
|
301 os9 I$Close close the path
|
|
302 clrb no erros
|
|
303 bra Exit
|
|
304
|
|
305 ******************************
|
|
306 * Convert track,sector to LSN
|
|
307 *
|
|
308 * Entry: A = track number
|
|
309 * B = sector number
|
|
310 * Exit : D = LSN# of that sector
|
|
311 Tk2LSN pshs b
|
|
312 ldb <DD.FMT
|
|
313 andb #$01
|
|
314 beq L037F
|
|
315 ldb #$02 disk is 2-sided
|
|
316 bra L0381
|
|
317
|
|
318 L037F ldb #$01 disk is 1-sided
|
|
319 L0381 mul multiply sides by tracks
|
|
320 lda <DD.TKS track size in sectors
|
|
321 mul get LSN of the track
|
|
322 addb ,s add in the sector
|
|
323 adca #$00 make it 16-bit
|
|
324 leas $01,s dumb dumb dumb people...
|
|
325 rts
|
|
326
|
|
327 L0440 pshs u,y,x,d
|
|
328 bsr Tk2LSN convert track,sector to LSN
|
|
329 pshs a
|
|
330 tfr b,a
|
|
331 clrb shuffle so 16-bit LSN goes to
|
|
332 tfr d,u 32-bit address, with the lower
|
|
333 puls b 16 bits all zero
|
|
334 clra
|
|
335 tfr d,x
|
|
336 lda <Path
|
|
337 os9 I$Seek seek to it
|
|
338 bcs L048F
|
|
339 puls pc,u,y,x,d
|
|
340
|
|
341 L045A clra
|
|
342 clrb
|
|
343 tfr d,x
|
|
344 tfr d,u go to LSN0
|
|
345
|
|
346 lda <Path
|
|
347 os9 I$Seek seek to LSN0
|
|
348
|
|
349 ldy #DD.DAT X=$0000 already...
|
|
350 lda <Path
|
|
351 os9 I$Write dump it out
|
|
352 bcs Exit
|
|
353 rts
|
|
354
|
|
355 Help leax <HelpMsg,pcr
|
|
356 clrb
|
|
357
|
|
358 Print pshs b,cc
|
|
359 lda #$02
|
|
360 ldy #$0200
|
|
361 os9 I$WritLn
|
|
362 comb
|
|
363 puls b,cc
|
|
364
|
|
365 Exit os9 F$Exit
|
|
366
|
|
367 L0488 leax >L00D1,pcr
|
|
368 clrb
|
|
369 bra Print
|
|
370
|
|
371 L048F leax >L0051,pcr
|
|
372 clrb
|
|
373 bra Print
|
|
374
|
|
375 L0496 leax >L008E,pcr
|
|
376 clrb
|
|
377 bra Print
|
|
378
|
|
379 L049D leax >L00F2,pcr
|
|
380 bra Print
|
|
381
|
|
382 HelpMsg fcb C$LF
|
|
383 fcc 'Use: COBBLER [-k] [-b] </devname>'
|
|
384 fcb C$LF
|
|
385 fcc / to create a new system disk by writing an OS9Boot file/
|
|
386 fcb C$LF
|
|
387 fcc / and a boot (kernel) track to the specified drive./
|
|
388 fcb C$LF,C$LF
|
|
389 fcc / -k = don't write the kernel track/
|
|
390 fcb C$LF
|
|
391 fcc / Hard disk drives never have the kernel track written./
|
|
392 fcb C$LF
|
|
393 fcc / -b = don't write the OS9Boot file/
|
|
394 fcb C$CR
|
|
395
|
|
396 L0051 fcb C$LF
|
|
397 fcc /Error writing kernel track or LSN0./
|
|
398 fcb C$CR
|
|
399
|
|
400 L008E fcb C$LF
|
|
401 fcc /Warning - file(s) present on track 34/
|
|
402 fcb C$LF
|
|
403 fcc / - this track not rewritten./
|
|
404 fcb C$CR
|
|
405
|
|
406 L00D1 fcb C$LF
|
|
407 fcc /Error - OS9boot file fragmented/
|
|
408 fcb C$CR
|
|
409
|
|
410 L00F2 fcb C$LF
|
|
411 fcc /Error - can't find boot track in memory/
|
|
412 fcb C$CR
|
|
413
|
|
414 emod
|
|
415 eom equ *
|
|
416 end
|