dml@loral.UUCP (Dave Lewis) (01/16/86)
---------------------------------------- Here is my new version of OS9Gen. It will work equally well on single- or double-sided disks. Use it just like the old version. If you anticipate your bootfile will run over 16 Kbytes, change the value of BOOTSECT to more sectors than you expect your bootfile to need. This program hunts for enough free space for the bootfile BEFORE writing it, so you won't get any disks cluttered up with a useless, fragmented bootfile. I have also rewritten Cobbler. ***************************************************************** * Copyright 1985 by Dave Lewis. * * UUCP address is loral!dml; in S. Cal. use ihnp4!sdcc3!loral * * I'm releasing this program to public domain. Copy it, share * it, but don't you DARE sell it! I worked hard on it. Include * this header with all copies. * * If you like this program, send me 5 bucks to encourage me to * write more stuff - or at least to release it. If you send * me 10 bucks I'll send you a good (Dysan) double side disk * formatted 35 track single side with both sourcecode and * executable binary files of the following: * * - NewDisk -- single or double sided disks, any number of * tracks within reason, step rate set in device descriptor * - OS9Gen -- rewritten version that automatically senses for * single/double sided disk and puts all the boot data in * the right places. Also enters the kernel file in the * root directory, which makes Dcheck happy. * - Separate -- breaks up your bootfile into its component * modules for modification. Replace or remove any module * individually. * - Diskdescr -- sourcecode for an OS-9 disk device descriptor * with EQUates at the beginning for step rate, #tracks, * and single or double sided. * - Documentation and procedure files for installing all of * the above in most common system configurations. * - Other stuff I've written that you may find useful. * * Send to: * Dave Lewis * 4417 Idaho Apt. 4 * San Diego CA 92116 ***************************************************************** * * OS9Gen2 copyright 1986 by Dave Lewis * Released to public domain January, 1986 * * Rewritten OS9Gen utility for single or double sided system * disks. * * Usage: OS9Gen /Dn * reads filenames from stdin, combining files into OS9Boot * file on target disk * ***************************************************************** * NAM OS9Gen TTL System disk generator * * Copyright 1986 by Dave Lewis * 4417 Idaho apt. 4 * San Diego, CA 92116 * Released to public domain January, 1986 * IFP1 USE /D0/DEFS/OS9Defs USE /D0/DEFS/SCFDefs USE /D0/DEFS/RBFDefs ENDC * REV EQU 2 TYPE EQU PRGRM+OBJCT ATTR EQU REENT+REV VERSION EQU 1 Version of OS-9 to generate BOOTSECT EQU 64 Free space to hunt for * IFEQ VERSION-2 KERNSECT EQU 18 Number of sectors for kernel KERNADDR EQU $ED00 Address of kernel in memory KERNSIZE EQU $1200 Size of kernel ELSE KERNSECT EQU 15 Number of sectors for kernel KERNADDR EQU $F000 Kernel address in memory KERNSIZE EQU $F00 Size of kernel file ENDC * MOD SIZE,NAME,TYPE,ATTR,EXEC,STORG NAME FCS 'OS9Gen' Still the same module name FCB $01 Version number * MEMPTR RMB 2 Memory origin pointer DEVPATH RMB 1 /Dn@ path number TEMPPATH RMB 1 Temporary file path number SRCPTHNM RMB 1 Source file path number DBLSIDE RMB 1 Nonzero for double sided disk TRACKNUM RMB 1 Current track number FREESECT RMB 1 Free sectors to find SECTOR.N RMB 1 Sector number in track BOOTSIZE RMB 2 Cumulative size of bootfile SEGMENT RMB 2 Pointer to segment entry TRACKEND RMB 2 Bytes left in current track DEVICEND RMB 2 End of device name FDS.LSN RMB 3 File Descriptor sector # PATHBUF RMB 32 Pathlist buffer PATHOPTS RMB 20 File path options buffer PTHOPTFD RMB 30 File Descriptor sector number GPBUFFER RMB 16 Main data buffer - 1Kbyte SEG1PTR RMB 10 Segment 1 LSN of FD MOREBUFR RMB 1000 The rest of GPBUFFER RMB 280 Stack space RMB 120 Parameter area STORG EQU . * USEOS9G FCB C$LF FCC 'Use (CAUTION): OS9GEN </devname>' FCB C$LF FCC ' ..reads (std input) pathnames ' FCB C$LF FCC 'until EOF, combining files' FCB C$LF FCC 'into new OS9Boot file.' FCB C$CR CANTFIND FCC "Can't find: " FCB C$CR KERNERR FCB C$LF FCC 'Error writing kernel track' FCB C$CR TK34NFRE FCB C$LF FCC 'Warning - file(s) or kernel' FCB C$LF FCC 'present on track 34 - this' FCB C$LF FCC 'track not rewritten.' FCB C$CR FRAGERR FCB C$LF FCC 'ERROR - not enough contiguous ' FCB C$LF FCC 'free space for OS9boot file' FCB C$CR KERNELFN FCC 'Kernel ' FCB 0 OS9BOOT FCC 'OS9Boot' FCB C$CR,0 * EXEC STU MEMPTR Save start of memory pointer LDA #'/ Test first character of args CMPA ,X for device name BNE PARAMERR Error if not a device name OS9 F$PRSNAM Parse the name BCS PARAMERR Error if name is bad LDA #'/ Test for more of pathlist CMPA ,Y BNE MOVEARG Move device name to buffer PARAMERR LEAX USEOS9G,PCR Point to error string LBRA COMPLAIN Write out error and quit * MOVEARG LEAY PATHBUF,U Point to pathlist buffer MOVLOOP1 STA ,Y+ Move device name into the LDA ,X+ pathlist buffer DECB Length from PARSE NAME call BPL MOVLOOP1 Move the whole thing STY DEVICEND Save end of device name LDD #$4020 '@ in A and C$SPACE in B STD ,Y Store it after device name LEAX PATHBUF,U Point to pathname buffer LDA #UPDAT. Access mode: read and write OS9 I$OPEN Open the entire disk BCS PARAMERR Error if can't open STA DEVPATH Save path number * LBSR READSECT Read identification sector LDA SEG1PTR Get disk format byte ANDA #1 Bit zero is set if disk STA DBLSIDE is double sided LBSR READSECT Read allocation sector #1 LDX #$264 Track 34, sector 1 TST DBLSIDE If disk is single sided, use BEQ T34FREE1 logical sector #264 LDX #$4C8 Track 68, sector 1 T34FREE1 STX TRACKEND Save logical sector number LDA #KERNSECT Look for free sectors STA FREESECT Set sector counter T34FREE2 LBSR SECTINFO Identify sector BITA ,Y Test for free LBNE KERNWARN Warn if not free ORA ,Y Mark sector as allocated STA ,Y Store updated byte LEAX 1,X Count sector just tested DEC FREESECT Test for done BNE T34FREE2 Continue until done * LDX TRACKEND Get logical sector number LBSR SEEKSECT Seek to start of sector LDX #KERNADDR Point to kernel in memory LDY #KERNSIZE Bytes to be written OS9 I$WRITE Write kernel data BCS ERR.KERN Quit if error * LDX #1 Seek to first sector of LBSR SEEKSECT disk allocation map LBSR WRITSECT Write updated allocation map LEAY KERNELFN,PCR Point to kernel file name LDX DEVICEND Point to end of device name LDA #'/ Prepare to extend pathlist MOVLOOP2 STA ,X+ Move `Kernel ' into pathlist LDA ,Y+ buffer BNE MOVLOOP2 Stop at the null LBSR NAMEFILE Make a file descriptor LDX FDS.LSN+1 Seek to start of file BSR SEEKSECT descriptor sector LEAX PATHOPTS,U Point to buffer LDY #32 Bytes to be read LDA DEVPATH Get path number OS9 I$READ Read part of descriptor BCS ERR.KERN Quit if error * LDD TRACKEND Get kernel file sector number STD PATHOPTS+17 First segment sector number LDD #KERNSIZE Size of Kernel file STD PATHOPTS+11 File size STA PTHOPTFD Size of first segment LDX FDS.LSN+1 File descriptor sector number BSR SEEKSECT Seek to start of sector LEAX PATHOPTS,U Point to descriptor data LDY #32 Bytes to write LDA DEVPATH Path number OS9 I$WRITE Set up kernel file descriptor LBCC MAIN2 Continue if no error ERR.KERN LEAX KERNERR,PCR Point to error string COMPLAIN LDY #255 Real long strings FILERROR LDA #2 Outpath: stderr OS9 I$WRITLN Write out the message QUIT OS9 F$EXIT Quit * READSECT LDA DEVPATH Get /Dn@ path number LDY #$100 One sector READFILE LEAX GPBUFFER,U Point to data buffer OS9 I$READ Read the data BCS QUIT.SUB Quit if error RTS * SECTINFO TFR X,D Get sector number LSRA Divide sector number by 8 RORB to get byte offset into LSRA sector allocation map RORB LSRA RORB LEAY GPBUFFER,U Point to allocation map LEAY D,Y Offset into allocation map CLR ,-S Push a zero on the stack TFR X,D Get sector number FINDTRAK INC ,S Increment track number SUBD #18 Subtract sectors in one track BPL FINDTRAK Loop until negative ADDB #18 Restore sector number DEC ,S Compensate for extra count STB SECTOR.N Store sector number TFR X,D Get sector number again LDA #$80 Bit 7 set ANDB #7 Mask off upper 5 bits BEQ BITSEVEN Skip loop if zero FINDBIT LSRA Indicate bit corresponding DECB to current sector BNE FINDBIT BITSEVEN PULS B,PC Pull and return * SEEKSECT CLR ,-S Push a zero on stack PSHS X Push logical sector number CLR ,-S Push a zero on stack PULS X,U Pull file position pointer LDA DEVPATH Get /Dn@ path number OS9 I$SEEK Position file pointer LDU MEMPTR Restore U! BCC RETURN Return if no error QUIT.SUB LEAS 2,S Quit from within a subroutine BRA QUIT * NAMEFILE LEAX PATHBUF,U Point to pathname buffer LDD #$203 Access: write Attribs: r w OS9 I$CREATE Create file BCS QUIT.SUB Quit if error STA TEMPPATH Save path number LEAX PATHOPTS,U Point to path options buffer LDB #SS.OPT Get Options code OS9 I$GETSTT Read path descriptor options BCS QUIT.SUB Quit if error LDA PTHOPTFD Get LSN of File Descriptor STA FDS.LSN Store it LDD PTHOPTFD+1 There's three bytes so STD FDS.LSN+1 get all of them LDA TEMPPATH Get path number OS9 I$CLOSE Close the file BCS QUIT.SUB Quit if error LDX FDS.LSN+1 Get logical sector number of BSR SECTINFO file descriptor just ORA ,Y created and mark that STA ,Y sector as allocated RETURN RTS * WRITSECT LDY #$100 Bytes in one sector WRITFILE LEAX GPBUFFER,U Point to data buffer LDA DEVPATH Get /Dn@ path number OS9 I$WRITE Write the data BCS QUIT.SUB Quit if error RTS * KERNWARN LEAX TK34NFRE,PCR Point to warning message LDY #255 Long string LDA #2 Output path: stderr OS9 I$WRITLN Print out message LBCS QUIT Quit if error * MAIN2 LDX DEVICEND Point to end of device name LEAY OS9BOOT,PCR Point to `OS9Boot' string LDA #'/ Prepare to extend pathlist MOVLOOP3 STA ,X+ Move `OS9Boot' into LDA ,Y+ pathlist buffer BNE MOVLOOP3 String terminated with NULL LEAX PATHBUF,U Point to start of buffer OS9 I$DELETE Delete any existing bootfile BSR NAMEFILE Create a file descriptor * LDX #0 Start at sector 0 FINDFREE LEAY PATHOPTS,U Point to segment list area LDB #49 Number of bytes -1 WIPELOOP CLR B,Y Clear out segment list DECB Count one byte BPL WIPELOOP Continue through zero LDB #BOOTSECT Number of free sectors to find STB FREESECT Set free sector counter FINDFR.2 STY SEGMENT Save pointer to segment STX 1,Y Store first sector number FINDFR.3 LBSR SECTINFO Get sector data CMPB #113 Has it reached track 113? BHS NOTFREE No free block found if so LEAX 1,X Point to next sector TST DBLSIDE Is disk double sided? BEQ FINDFR.4 Continue if not BITB #1 Was it an odd track number? BEQ FINDFR.4 Continue if not LEAX 17,X Skip the odd tracks LDY SEGMENT Get segment pointer LEAY 5,Y Point to next segment BRA FINDFR.2 Start a new segment * FINDFR.4 BITA ,Y Is current sector allocated? BNE FINDFREE Start over if it is LDY SEGMENT Point to current segment INC 4,Y Add one sector to size DEC FREESECT Count another free sector BNE FINDFR.3 Repeat if not done * LEAX PATHOPTS,U Point to first segment entry STX SEGMENT Store segment pointer CLRA Initialize BOOTSIZE to zero CLRB STD BOOTSIZE LDA 4,X Get size of first segment STD TRACKEND Store size limit LDX 1,X Get logical sector number LBSR SEEKSECT Seek to start of segment BRA READSRC Go get first sourcefile name * NOTFREE LEAX FRAGERR,PCR Point to error message COMPL.2 LBRA COMPLAIN Write message and quit * MAKOS9.1 OS9 I$OPEN Open source file STA SRCPTHNM Save path number BCC MAKOS9.2 Continue if no error CMPB #E$PNNF Error = file not found? BNE QUIT.2 Something else; quit LEAX CANTFIND,PCR Point to message string LDY #12 It's 12 characters long LDA #2 Outpath: stderr OS9 I$WRITLN Start the error message LEAX GPBUFFER,U Point to offending filename BRA COMPL.2 Tell the world about it * MAKOS9.2 LDD #$400 Size of GPBUFFER CMPD TRACKEND Compare to segment size limit BLS MAKOS9.3 Plenty of room, use full size LDD TRACKEND Don't go over size limit MAKOS9.3 TFR D,Y Number of bytes to read LDA SRCPTHNM Get path number LEAX GPBUFFER,U Point to data buffer OS9 I$READ Read the data BCC MAKOS9.4 Continue if no error CMPB #E$EOF Is it end of file? BEQ MAKOS9.5 Close source file QUIT.2 COMA Make sure carry is set OS9 F$EXIT Exit with error * MAKOS9.4 LBSR WRITFILE Write it on destination disk PSHS Y Save number of bytes written LDD BOOTSIZE Get total size of bootfile ADDD ,S Add bytes just written STD BOOTSIZE Store updated bootsize LDD TRACKEND Get size left in segment SUBD ,S++ Subtract bytes just used STD TRACKEND Store updated segment size BNE MAKOS9.2 Continue until out of space * LDX SEGMENT Get segment pointer LEAX 5,X Point to next segment STX SEGMENT Store updated segment pointer LDA 4,X Get segment size limit CLRB Convert sectors to bytes STD TRACKEND Store size variable LDX 1,X Get logical sector number LBSR SEEKSECT Seek to start of segment BRA MAKOS9.2 Start writing on new segment * MAKOS9.5 LDA SRCPTHNM Get source path number OS9 I$CLOSE Close the file READSRC LEAX GPBUFFER,U Point to data buffer LDY #255 Maximum bytes to read CLRA Inpath: stdin OS9 I$READLN Read next filename BCC MAKOS9.6 Continue if no error CMPB #E$EOF End of file error? BEQ LASTSEG Go set last segment size BRA QUIT.2 Other error, quit * MAKOS9.6 LDA ,X Get first character CMPA #C$CR Is it a <CR>? BNE MAKOS9.1 Use the file if not * LASTSEG LDY SEGMENT Point to last segment LDA 4,Y Get segment size limit CLRB Convert sectors to bytes SUBD TRACKEND Subtract unused capacity ADDD #$FF Count last partial sector STA 4,Y Store size used BNE SETSEG.3 Continue if not zero SETSEG.1 LDB #4 Clear out segment data SETSEG.2 CLR B,Y DECB BPL SETSEG.2 Do all the bytes SETSEG.3 LEAY 5,Y Point to next segment TST 4,Y Test segment size BNE SETSEG.1 Clear it if not zero * LDX #0 Disk identification sector LBSR SEEKSECT Set file pointer LBSR READSECT Read the sector LDD BOOTSIZE Get total size of bootfile STD DD.BSZ,X Store bootfile size LDD PATHOPTS+1 Get bootfile first sector # TST DBLSIDE Is disk single sided? BEQ SETBOOT Sector number correct if so * PSHS D Save raw sector number CLR ,-S Push a zero on stack SECTLOOP INC ,S Increment track counter SUBD #36 Subtract sectors in 2 tracks BPL SECTLOOP Continue until negative PULS B Get number of tracks DECB Compensate for extra count LDA #18 Find number of unused sectors MUL in odd-numbered tracks PSHS D Put number on stack LDD 2,S Get raw sector number SUBD ,S++ Subtract skipped sectors LEAS 2,S Adjust stack * SETBOOT STD DD.BT+1,X Store sector number LDX #0 Identification sector number LBSR SEEKSECT Point to start of sector LBSR WRITSECT Write updated data to disk LBSR READSECT Read disk allocation sector LEAY PATHOPTS,U Point to first segment ALLOC.1 STY SEGMENT Store segment pointer LDX 1,Y Get first sector of segment LDA 4,Y Get segment size STA TRACKEND Save total segment size ALLOC.2 LBSR SECTINFO Point to allocation bit LEAX 1,X Advance to next sector ORA ,Y Mark sector as allocated STA ,Y Store updated byte DEC TRACKEND Count off sector BNE ALLOC.2 Repeat until end of segment LDY SEGMENT Get segment pointer LEAY 5,Y Point to next segment TST 4,Y Test segment size BNE ALLOC.1 Mark sectors if size not zero * LDX #1 Point to allocation sector LBSR SEEKSECT Seek to start of sector LBSR WRITSECT Write updated allocation data LDX FDS.LSN+1 Point to file descriptor LBSR SEEKSECT Seek to start of sector LBSR READSECT Read file descriptor sector LDD BOOTSIZE Get bootfile size STD GPBUFFER+11 Store in file descriptor LEAX PATHOPTS,U Point to segment list LEAY SEG1PTR,U Point into file descriptor LDB #50 Size of segment list MOVLOOP4 LDA ,X+ Move bootfile segment list STA ,Y+ into appropriate place DECB in the file descriptor BNE MOVLOOP4 Move it all LDX FDS.LSN+1 Point to file descriptor LBSR SEEKSECT Seek to start of sector LBSR WRITSECT Write updated descriptor OS9 F$EXIT Done; quit * EMOD CRC bytes SIZE EQU * END ------------------------------- Dave Lewis Loral Instrumentation San Diego sdcc6 ---\ gould9 --\ ihnp4 ---->-->!sdcc3 ---->--->!loral!dml (uucp) sdcrdcf -/ sdcsvax -/ A portable program is one which exhibits the same bugs on many different computers.
dml@loral.UUCP (Dave Lewis) (01/20/86)
------------------------------- There are a few wrong symbols in the posted version of OS9Gen2. At the beginning, the Version 2 kernel equates should be: IFEQ VERSION-2 KERNSECT EQU 16 Number of sectors required by kernel file KERNADDR EQU $EF00 Address of kernel in memory KERNSIZE EQU $1000 Size of kernel file ELSE The stuff after ELSE is for Version 1 and is OK as is. NewDisk does not work under Version 2. The V2 CCDisk uses the new virtual interrupt scheme to time-out the disk spindle motors; I tried sticking the code into NewDisk but it locked up the system after the first access. I'll need the Version 2 system call documentation to do anything further, and the local Radio Shack professes total ignorance when asked about it. The newsgroup is silent once more. These programs are the only traffic I've seen in two weeks. Where is everybody? ------------------------------- Dave Lewis Loral Instrumentation San Diego sdcc6 ---\ gould9 --\ ihnp4 ---->-->!sdcc3 ---->--->!loral!dml (uucp) sdcrdcf -/ sdcsvax -/ A portable program is one that will exhibit the same bugs on many different computers. -------------------------------
jimomura@lsuc.UUCP (Jim Omura) (01/24/86)
Dave asked what's going on. Well, OS-9 messages should now go to the moderators of 'mod.os.os9'. You may have missed the announcement somehow, but you should have had the new mod group Arriving. Messages should go to 'nyit!os9'. Cheers! -- Jim O. -- James Omura, Barrister & Solicitor, Toronto ihnp4!utzoo!lsuc!jimomura Byte Information eXchange: jimomura (416) 652-3880