1REM > bb_NetBSD 2REM $NetBSD: bb_netbsd,v 1.4 2006/08/31 20:59:24 bjh21 Exp $ 3REM 4REM Copyright (c) 1995 Mark Brinicombe 5REM All rights reserved 6REM 7REM Redistribution and use in source and binary forms, with or without 8REM modification, are permitted provided that the following conditions 9REM are met: 10REM 1. Redistributions of source code must retain the above copyright 11REM notice, this list of conditions and the following disclaimer. 12REM 2. Redistributions in binary form must reproduce the above copyright 13REM notice, this list of conditions and the following disclaimer in the 14REM documentation and/or other materials provided with the distribution. 15REM 3. All advertising materials mentioning features or use of this software 16REM must display the following acknowledgement: 17REM This product includes software developed by Mark Brinicombe. 18REM 4. The name of the company nor the name of the author may be used to 19REM endorse or promote products derived from this software without specific 20REM prior written permission. 21REM 22REM THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 23REM IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 24REM OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 25REM IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 26REM INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 27REM BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 28REM OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 29REM ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 30REM OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF 31REM THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 32REM DAMAGE. 33REM 34REM NetBSD kernel project 35REM 36REM bb_NetBSD 37REM 38REM Modifies the filecore bootblock to point to a section of 39REM the disc reserved for NetBSD. 40REM 41REM Created : 24/11/94 42REM Last updated : 12/07/95 43REM 44 45DIM buf% 512 46 47REM Get Filesystem type 48 49REPEAT 50 PRINT "ADFS, ATAFS, IDEFS, SCSI or SCSIFS (A/T/I/S/F) ? "; 51 filesys% = GET AND &DF 52 PRINT CHR$(filesys%) 53UNTIL filesys%=ASC"A" OR filesys%=ASC"T" OR filesys%=ASC"S" OR filesys%=ASC"I" OR filesys%=ASC"F" 54 55CASE filesys% OF 56 WHEN ASC"A" : discop$="ADFS_DiscOp" 57 WHEN ASC"I" : discop$="IDEFS_DiscOp" 58 WHEN ASC"T" : discop$="ATAFS_DiscOp" 59 WHEN ASC"S" : discop$="SCSI_DiscOp" 60 WHEN ASC"F" : discop$="SCSIFS_DiscOp" 61ENDCASE 62 63REM Get the drive number 64 65INPUT "Drive "d% 66 67REM Read in current filecore bootblock 68 69SYS discop$,, 1, &c00 + (d% << 29), buf%, 512 70 71SYS "OS_File", 10, "<Wimp$ScrapDir>.OldBB", &FFD,, buf%, buf%+512 72PRINT "Old boot block saved in <Wimp$ScrapDir>.OldBB" 73 74REM Get the byte size of the filecore partition and the number 75REM of bytes per cylinder 76 77size=buf%!&1d0 78clsize=buf%?&1c2 * buf%?&1c1 * (1 << buf%?&1c0) 79 80REM A bit of info to the user 81 82PRINT "Filecore partition size = ";~size;" bytes" 83 84REM Convert the size into cylinders 85 86size = (size + clsize - 1) / clsize 87size = INT(size+0.5) 88 89PRINT "Filecore partition size = ";size; " cylinders (0-";size-1;")" 90 91REM Check for a RISC iX partition table (e.g. put there by scsidm). 92 93IF buf%?&1fc = 1 OR buf%?&1fc = 2 THEN 94 PRINT "RISC iX partition starts at cylinder "; buf%?&1fd + (buf%?&1fe<<8) 95ENDIF 96 97REM We should be clever about here and read the real geometry 98REM of the disc so that we know the maximum cylinder number 99 100REM Get the starting cylinder for the NetBSD part of the disc 101 102INPUT "NetBSD Starting Cyl "c% 103 104REM Make sure it is after the filecore partition 105 106IF (c% < size) THEN 107 PRINT "Filecore occupies cylinders upto ";size-1 108 INPUT "Are you sure you mean this value "a$ 109 IF (a$ <> "yes" AND a$ <> "YES") THEN END 110 PRINT "This will allow NetBSD to overwrite part of the ADFS partition" 111 INPUT "Are you really sure you mean this value "a$ 112 IF (a$ <> "yes" AND a$ <> "YES") THEN END 113ENDIF 114 115PRINT "Initialising NetBSD partition offset at ";c% 116PRINT "On drive ";d%;", using ";discop$;" to access drive" 117PRINT "Press any key to continue, escape to abort" 118 119dummy%=GET 120 121REM Modifiy the non-ADFS partition descriptor to describe the 122REM start of the NetBSD part of the disc 123 124buf%?&1FC = &42 : REM NetBSD identifier 125buf%?&1FD = c% AND 255 : REM low byte of start cylinder 126buf%?&1FE = c% >> 8 : REM high byte of start cylinder 127 128REM Recalculate the filecore boot block checksum 129 130buf%?&1FF = FNCheckSum(buf%,511) 131 132REM Write the boot block back to disc 133 134SYS discop$,, 2, &c00 + (d% << 29), buf%, 512 135 136END 137 138 139DEF FNCheckSum(addr%, length%) 140sum% = 0 141FOR n% = 0 TO length% - 1 142 sum% += addr%?n% 143 IF sum% > 255 THEN 144 sum% -= 255 145 ENDIF 146NEXT 147= sum% 148