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