Mercurial > hg > Members > kono > nitros9-code
changeset 264:1ced4acebe44
edition 7 - from CoCo OS-9 Level Two version of cobbler with additions for
OS-9 Level One, now places boot track in proper place on double-sided disk
author | boisy |
---|---|
date | Sun, 21 Jul 2002 03:00:31 +0000 |
parents | 7d918106054d |
children | 4b547814b192 |
files | level1/cmds/cobbler.asm |
diffstat | 1 files changed, 433 insertions(+), 198 deletions(-) [+] |
line wrap: on
line diff
--- a/level1/cmds/cobbler.asm Sat Jul 20 23:28:28 2002 +0000 +++ b/level1/cmds/cobbler.asm Sun Jul 21 03:00:31 2002 +0000 @@ -1,18 +1,18 @@ ******************************************************************** -* Cobbler - Make a bootstrap file +* Cobbler - Write OS9Boot to a disk * * $Id$ * * Ed. Comments Who YY/MM/DD * ------------------------------------------------------------------ -* 5 From Tandy OS-9 Level One VR 02.00.00 -* 6 Allocation bitmap bug fixed, as per Rainbow BGP 02/07/20 -* Magazine, January 1987, Page 203 +* 7 From Tandy OS-9 Level Two Vr. 2.00.01 +* Modified source to allow for OS-9 Level One BGP 02/07/20 +* and OS-9 Level Two assembly nam Cobbler - ttl Make a bootstrap file + ttl Write OS9Boot to a disk -* Disassembled 02/07/06 23:26:00 by Disasm v1.6 (C) 1988 by RML +* Disassembled 02/07/06 13:08:41 by Disasm v1.6 (C) 1988 by RML ifp1 use defsfile @@ -22,266 +22,501 @@ tylg set Prgrm+Objct atrv set ReEnt+rev rev set $01 -edition set 6 +edition set 7 -os9start equ $EF00 -os9size equ $0F80 +os9l1start equ $EF00 +os9l1size equ $0F80 mod eom,name,tylg,atrv,start,size -BFPath rmb 1 -DevFd rmb 3 -BTLSN rmb 1 -u0005 rmb 2 -BtSiz rmb 2 -u0009 rmb 7 -sttbuf rmb 32 -u0030 rmb 2 -devnam rmb 32 -bootfd rmb 16 -u0062 rmb 1 -u0063 rmb 7 -u006A rmb 432 +LSN0Buff rmb 26 +NewBPath rmb 1 +DevPath rmb 3 +u001E rmb 2 +FullBName rmb 20 this buffer hodls the entire name (i.e. /D0/OS9Boot) +u0034 rmb 16 +u0044 rmb 7 +u004B rmb 2 +u004D rmb 1 +u004E rmb 16 +PathOpts rmb 20 +u0072 rmb 2 +u0074 rmb 10 +BFFDBuf rmb 16 +u008E rmb 1 +u008F rmb 7 +u0096 rmb 232 +BitMBuf rmb 1024 + ifgt Level-1 +u057E rmb 76 +u05CA rmb 8316 + endc size equ . name fcs /Cobbler/ fcb edition -L0015 fcb C$LF +L0015 fcb $00 + fcb $00 + +Help fcb C$LF fcc "Use: COBBLER </devname>" fcb C$LF fcc " to create a new system disk" fcb C$CR -L004F fcb C$LF +WritErr fcb C$LF fcc "Error writing kernel track" fcb C$CR -NoHard fcb C$LF + fcb C$LF fcc "Error - cannot gen to hard disk" fcb C$CR -L008C fcb C$LF +FileWarn fcb C$LF fcc "Warning - file(s) present" fcb C$LF fcc "on track 34 - this track" fcb C$LF fcc "not rewritten." fcb C$CR -L00CF fcb C$LF +BootFrag fcb C$LF fcc "Error - OS9boot file fragmented" fcb C$CR -BfNam fcc "OS9Boot " + ifgt Level-1 +RelMsg fcb C$LF + fcc "Error - can't link to Rel module" + fcb C$CR + endc +BootName fcc "OS9Boot " + fcb $FF +RelNam fcc "Rel" fcb $FF start clrb lda #PDELIM cmpa ,x - lbne Usage + lbne L0473 os9 F$PrsNam - lbcs Usage + lbcs L0473 lda #PDELIM cmpa ,y - lbeq Usage - leay <devnam,u -L0114 sta ,y+ + lbeq L0473 + leay <FullBName,u +L013C sta ,y+ lda ,x+ decb - bpl L0114 - sty <u0030 + bpl L013C + sty <u001E lda #PENTIR ldb #C$SPAC std ,y++ - leax <devnam,u + leax <FullBName,u lda #UPDAT. os9 I$Open - sta <DevFd - lbcs Usage - ldx <u0030 - leay >BfNam,pcr + sta <DevPath + lbcs L0473 + ldx <u001E + leay >BootName,pcr lda #PDELIM -L013A sta ,x+ +L0162 sta ,x+ lda ,y+ - bpl L013A - lda <DevFd - leax <sttbuf,u - ldb #SS.Opt - os9 I$GetStt - lbcs Exit - leax <sttbuf,u - lda <sttbuf+(PD.TYP-PD.OPT),u get PD.TYP - bpl L015E if not hard drive, branch - leax >NoHard,pcr - clrb - lbra wrerr -L015E lda <DevFd + bpl L0162 pshs u - ldx #$0000 - ldu #DD.BT probably DD.BT - os9 I$Seek + clra + clrb + tfr d,x + tfr d,u + lda <DevPath + os9 I$Seek seek to 0 + lbcs Bye puls u - lbcs Exit - leax BTLSN,u - ldy #DD.DAT-DD.BT - os9 I$Read Read bootstrap sector + size = 5 bytes - lbcs Exit - ldd <BtSiz - beq L0193 - leax <devnam,u - os9 I$Delete delete existing OS9Boot file + leax LSN0Buff,u + ldy #DD.DAT $1A + lda <DevPath + os9 I$Read read LSN0 + lbcs Bye + ldd <DD.BSZ get size of bootfile currently + beq L019F branch if none + leax <FullBName,u + os9 I$Delete delete existing bootfile clra clrb - sta <BTLSN - std <u0005 - std <BtSiz - lbsr UpLSN0 -L0193 lda #WRITE. - ldb #UPDAT. - leax <devnam,u - os9 I$Create create OS9Boot file - sta <BFPath - lbcs Exit - ldd >D.BTHI get bootfile size + sta <DD.BT + std <DD.BT+1 + std <DD.BSZ + lbsr WriteLSN0 +L019F lda #WRITE. + ldb #READ.+WRITE. + leax <FullBName,u + os9 I$Create create new bootfile + sta <NewBPath + lbcs Bye branch if error + + ifgt Level-1 +* OS-9 Level Two: Copy first 90 bytes of system direct page into our space +* so we can figure out boot location and size, then copy to our space + leax >L0015,pcr + tfr x,d + ldx #$0000 + ldy #$0090 + pshs u + leau >u057E,u + os9 F$CpyMem + lbcs Bye + puls u + leax >L0015,pcr + tfr x,d + ldx >u05CA,u + ldy #$0010 + pshs u + leau <u004E,u + os9 F$CpyMem + puls u + lbcs Bye + leax >u057E,u + ldd <D.BtPtr,x + pshs b,a + ldd <D.BtSz,x + std <DD.BSZ + pshs b,a +L01F7 ldy #$2000 + cmpy ,s + bls L0203 + ldy ,s +L0203 pshs y + leax <u004E,u + tfr x,d + ldx $04,s + pshs u + leau >u057E,u + os9 F$CpyMem + lbcs Bye + puls u + ldy ,s + leax >u057E,u + lda <NewBPath + os9 I$Write + lbcs Bye + puls b,a + ldy $02,s + leay d,y + sty $02,s + nega + negb + sbca #$00 + ldy ,s + leay d,y + sty ,s + bne L01F7 + leas $04,s + + else + +* OS-9 Level One: Write out bootfile + ldd >D.BTHI get bootfile size subd >D.BTLO - tfr d,y in D, tfr to Y - std <BtSiz save it - ldx >D.BTLO get pointer to boot in mem - lda <BFPath - os9 I$Write write out boot to file - lbcs Exit - leax <sttbuf,u - ldb #SS.OPT + tfr d,y in D, tfr to Y + std <DD.BSZ save it + ldx >D.BTLO get pointer to boot in mem + lda <NewBPath + os9 I$Write write out boot to file + lbcs Bye + + endc + + leax <PathOpts,u + ldb #SS.Opt + lda <NewBPath os9 I$GetStt - lbcs Exit - lda <BFPath - os9 I$Close - lbcs Usage + lbcs Bye + lda <NewBPath + os9 I$Close + lbcs L0473 pshs u - ldx <sttbuf+(PD.FD-PD.OPT),u - lda <sttbuf+(PD.FD+2-PD.OPT),u + ldx <PathOpts+(PD.FD-PD.OPT),u + lda <PathOpts+(PD.FD+2-PD.OPT),u +* Now X and A hold file descriptor sector LSN of newly created OS9Boot clrb tfr d,u - lda <DevFd - os9 I$Seek seek to file descriptor of bootfile + lda <DevPath + os9 I$Seek seek to os9boot file descriptor puls u - lbcs Exit - leax <bootfd,u - ldy #256 read FD sector - os9 I$Read - lbcs Exit - ldd <bootfd+FD.SEG+FDSL.S+3,u - lbne Fragd branch if fragmented - ldb <bootfd+FD.SEG,u get LSN of first (only) segment - stb <BTLSN save off - ldd <bootfd+FD.SEG+1,u - std <u0005 - lbsr UpLSN0 - lbsr SkLSN1 - leax <bootfd,u + lbcs Bye + leax <BFFDBuf,u ldy #256 - os9 I$Read read bitmap sector - lbcs wrerr - leax <bootfd,u - lda <(34*18)/8,x get byte in bitmap corresponding to kernel track - bita #$0F bits 3-0 set? - beq L0273 branch if not - lda <DevFd - pshs u - ldx #$0002 - ldu #$6400 - os9 I$Seek Jump to LSN 612 - puls u - leax u0009,u + os9 I$Read read in filedes sector + lbcs Bye + ldd >BFFDBuf+(FD.SEG+FDSL.S+FDSL.B),u + lbne IsFragd branch if fragmented +* Get and save bootfile's LSN + ldb >BFFDBuf+(FD.SEG),u + stb <DD.BT + ldd >BFFDBuf+(FD.SEG+1),u + std <DD.BT+1 + lbsr WriteLSN0 + lda #$00 + ldb #$01 + lbsr Seek2LSN + leax >BitMBuf,u + ldy <DD.MAP + lda <DevPath + os9 I$Read read bitmap sector(s) + lbcs Bye + lda #$22 + clrb + ldy #$0004 + lbsr L03A7 + bcc L0304 + lda #$22 + ldb #$00 + lbsr Seek2LSN + leax <u0044,u ldy #$0007 - os9 I$Read read first 7 bytes of boot track - lbcs L02ED - leax u0009,u - ldd #$4F53 D = "OS" - cmpd ,x same as first two bytes of boot track? - lbne L02ED branch if not - lda 4,x - leax <bootfd,u - nop - cmpa #$12 is it a nop? - beq L025C branch if so - lda <$4E,x - bita #$1C - lbne L02ED -L025C lda <(34*18)/8,x - ora #$0F - sta <(34*18)/8,x - lda #$FF - sta <(34*18)/8+1,x - lda <(34*18)/8+2,x - ora #$FC - sta <(34*18)/8+2,x - bra L028C -L0273 ora #$0F - sta <$4C,x - tst <$4D,x - bne L02ED - com <$4D,x - lda <$4E,x - bita #$FC - bne L02ED - ora #$FC - sta <$4E,x -L028C bsr SkLSN1 - leax <bootfd,u - ldy #$0064 + lda <DevPath + os9 I$Read + lbcs Bye + leax <u0044,u + ldd ,x + cmpa #'O + lbne TrkAlloc + cmpb #'S + lbne TrkAlloc + lda $04,x + cmpa #$12 + beq L02F7 + lda #$22 + ldb #$0F + ldy #$0003 + lbsr L03A7 + lbcs TrkAlloc +L02F7 clra + ldb <DD.TKS + tfr d,y + lda #$22 + clrb + lbsr L03FD + bra L0315 +L0304 lda #$22 + ldb #$04 + ldy #$000E + lbsr L03A7 + lbcs TrkAlloc + bra L02F7 + +L0315 clra + ldb #$01 + lbsr Seek2LSN Seek to bitmap sector on disk + leax >BitMBuf,u + ldy <DD.MAP + lda <DevPath + os9 I$Write write updated bitmap + lbcs Bye + + ifgt Level-1 +* OS-9 Level Two: Link to Rel, which brings in boot code + pshs u + lda #Systm+Objct + leax >RelNam,pcr + os9 F$Link + lbcs NoRel + tfr u,d tfr module header to D + puls u get statics ptr + subd #$0006 + std <u004B,u save pointer + lda #$E0 + anda <u004B,u + ora #$1E + ldb #$FF + subd <u004B,u + addd #$0001 + tfr d,y + lda #$22 + ldb #$00 + lbsr Seek2LSN + lda <DevPath + ldx <u004B,u + + else + +* OS-9 Level One: Write out data at $EF00 + lda #$22 + ldb #$00 + lbsr Seek2LSN + lda <DevPath + ldx #os9l1start + ldy #os9l1size + + endc + os9 I$Write - bcs wrerr - pshs u - ldx #$0002 - ldu #$6400 - os9 I$Seek Jump to LSN 612 - puls u - ldx #os9start Address of kernel in RAM - ldy #os9size Amount to write - os9 I$Write - bcs ETrack + lbcs WriteBad os9 I$Close - bcs Usage + lbcs Bye clrb - bra Exit + lbra Bye + +* Get absolute LSN +* Returns in D +AbsLSN pshs b + ldb <DD.FMT get format byte + andb #$01 check how many sides? + beq L037F branch if 1 + ldb #$02 else assume 2 + bra L0381 +L037F ldb #$01 +L0381 mul + lda <DD.TKS + mul + addb ,s + adca #$00 + leas $01,s + rts + +* Returns bit in bitmap corresponding to LSN in A +L038C pshs y,b +* Divide D by 8 + lsra + rorb + lsra + rorb + lsra + rorb + leax d,x + puls b + leay <L03A1,pcr + andb #$07 + lda b,y + puls pc,y + +L03A1 fcb $80,$40,$20,$10,$08,$04,$02,$01 -SkLSN1 pshs u - lda <DevFd - ldx #$0000 - ldu #$0100 - os9 I$Seek Seek to allocation map at LSN 1 - puls pc,u +L03A7 pshs y,x,b,a + bsr AbsLSN go get absolute LSN + leax >BitMBuf,u point X to our bitmap buffer + bsr L038C + sta ,-s save off + bmi L03CB + lda ,x + sta <u004D +L03BB anda ,s + bne L03F7 + leay -$01,y + beq L03F3 + lda <u004D + lsr ,s + bcc L03BB + leax $01,x +L03CB lda #$FF + sta ,s + bra L03DB +L03D1 lda ,x + anda ,s + bne L03F7 + leax $01,x + leay -$08,y +L03DB cmpy #$0008 + bhi L03D1 + beq L03ED + lda ,s +L03E5 lsra + leay -$01,y + bne L03E5 + coma + sta ,s +L03ED lda ,x + anda ,s + bne L03F7 +L03F3 andcc #^Carry + bra L03F9 +L03F7 orcc #Carry +L03F9 leas $01,s + puls pc,y,x,b,a +L03FD pshs y,x,b,a + lbsr AbsLSN get absolute LSN + leax >BitMBuf,u + bsr L038C + sta ,-s + bmi L041C + lda ,x +L040E ora ,s + leay -$01,y + beq L043A + lsr ,s + bcc L040E + sta ,x + leax $01,x +L041C lda #$FF + bra L0426 +L0420 sta ,x + leax $01,x + leay -$08,y +L0426 cmpy #$0008 + bhi L0420 + beq L043A +L042E lsra + leay -$01,y + bne L042E + coma + sta ,s + lda ,x + ora ,s +L043A sta ,x + leas $01,s + puls pc,y,x,b,a -Usage leax >L0015,pcr -wrerr pshs b +Seek2LSN pshs u,y,x,b,a + lbsr AbsLSN + pshs a + tfr b,a + clrb + tfr d,u + puls b + clra + tfr d,x + lda <DevPath + os9 I$Seek + bcs WriteBad + puls pc,u,y,x,b,a + +WriteLSN0 + pshs u added for OS-9 Level One +BGP+ + clra + clrb + tfr d,x + tfr d,u + lda <DevPath + os9 I$Seek Seek to LSN0 + puls u added for OS-9 Level One +BGP+ + leax LSN0Buff,u Point to our LSN buffer + ldy #DD.DAT + lda <DevPath + os9 I$Write Write to disk + bcs Bye branch if error + rts + +L0473 leax >Help,pcr +L0477 pshs b lda #$02 - ldy #$0100 + ldy #256 os9 I$WritLn comb puls b -Exit os9 F$Exit - -Fragd leax >L00CF,pcr - clrb - bra wrerr +Bye os9 F$Exit -ETrack leax >L004F,pcr +IsFragd leax >BootFrag,pcr clrb - bra wrerr + bra L0477 -L02ED leax >L008C,pcr +WriteBad leax >WritErr,pcr clrb - bra wrerr + bra L0477 -UpLSN0 pshs u - ldx #$0000 - ldu #DD.BT - lda <DevFd - os9 I$Seek - puls u - bcs Exit - leax BTLSN,u - ldy #$0005 - os9 I$Write - bcs Exit - rts +TrkAlloc leax >FileWarn,pcr + clrb + bra L0477 + + ifgt Level-1 +NoRel leax >RelMsg,pcr + bra L0477 + endc emod eom equ *