1REM > bb_NetBSD 2REM $NetBSD: bb_netbsd,v 1.3 2002/07/10 15:42:15 reinoud 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 We should be clever about here and read the real geometry 92REM of the disc so that we know the maximum cylinder number 93 94REM Get the starting cylinder for the NetBSD part of the disc 95 96INPUT "NetBSD Starting Cyl "c% 97 98REM Make sure it is after the filecore partition 99 100IF (c% < size) THEN 101 PRINT "Filecore occupies cylinders upto ";size-1 102 INPUT "Are you sure you mean this value "a$ 103 IF (a$ <> "yes" AND a$ <> "YES") THEN END 104 PRINT "This will allow NetBSD to overwrite part of the ADFS partition" 105 INPUT "Are you really sure you mean this value "a$ 106 IF (a$ <> "yes" AND a$ <> "YES") THEN END 107ENDIF 108 109PRINT "Initialising NetBSD partition offset at ";c% 110PRINT "On drive ";d%;", using ";discop$;" to access drive" 111PRINT "Press any key to continue, escape to abort" 112 113dummy%=GET 114 115REM Modifiy the non-ADFS partition descriptor to describe the 116REM start of the NetBSD part of the disc 117 118buf%?&1FC = &42 : REM NetBSD identifier 119buf%?&1FD = c% AND 255 : REM low byte of start cylinder 120buf%?&1FE = c% >> 8 : REM high byte of start cylinder 121 122REM Recalculate the filecore boot block checksum 123 124buf%?&1FF = FNCheckSum(buf%,511) 125 126REM Write the boot block back to disc 127 128SYS discop$,, 2, &c00 + (d% << 29), buf%, 512 129 130END 131 132 133DEF FNCheckSum(addr%, length%) 134sum% = 0 135FOR n% = 0 TO length% - 1 136 sum% += addr%?n% 137 IF sum% > 255 THEN 138 sum% -= 255 139 ENDIF 140NEXT 141= sum% 142