REM > bb_NetBSD
REM $NetBSD: bb_netbsd,v 1.4 2006/08/31 20:59:24 bjh21 Exp $
REM
REM Copyright (c) 1995 Mark Brinicombe
REM All rights reserved
REM
REM Redistribution and use in source and binary forms, with or without
REM modification, are permitted provided that the following conditions
REM are met:
REM 1. Redistributions of source code must retain the above copyright
REM notice, this list of conditions and the following disclaimer.
REM 2. Redistributions in binary form must reproduce the above copyright
REM notice, this list of conditions and the following disclaimer in the
REM documentation and/or other materials provided with the distribution.
REM 3. All advertising materials mentioning features or use of this software
REM must display the following acknowledgement:
REM This product includes software developed by Mark Brinicombe.
REM 4. The name of the company nor the name of the author may be used to
REM endorse or promote products derived from this software without specific
REM prior written permission.
REM
REM THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
REM IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
REM OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
REM IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
REM INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
REM BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
REM OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
REM ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
REM OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
REM THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
REM DAMAGE.
REM
REM NetBSD kernel project
REM
REM bb_NetBSD
REM
REM Modifies the filecore bootblock to point to a section of
REM the disc reserved for NetBSD.
REM
REM Created : 24/11/94
REM Last updated : 12/07/95
REM
DIM buf% 512
REM Get Filesystem type
REPEAT
PRINT "ADFS, ATAFS, IDEFS, SCSI or SCSIFS (A/T/I/S/F) ? ";
filesys% = GET AND &DF
PRINT CHR$(filesys%)
UNTIL filesys%=ASC"A" OR filesys%=ASC"T" OR filesys%=ASC"S" OR filesys%=ASC"I" OR filesys%=ASC"F"
CASE filesys% OF
WHEN ASC"A" : discop$="ADFS_DiscOp"
WHEN ASC"I" : discop$="IDEFS_DiscOp"
WHEN ASC"T" : discop$="ATAFS_DiscOp"
WHEN ASC"S" : discop$="SCSI_DiscOp"
WHEN ASC"F" : discop$="SCSIFS_DiscOp"
ENDCASE
REM Get the drive number
INPUT "Drive "d%
REM Read in current filecore bootblock
SYS discop$,, 1, &c00 + (d% << 29), buf%, 512
SYS "OS_File", 10, "<Wimp$ScrapDir>.OldBB", &FFD,, buf%, buf%+512
PRINT "Old boot block saved in <Wimp$ScrapDir>.OldBB"
REM Get the byte size of the filecore partition and the number
REM of bytes per cylinder
size=buf%!&1d0
clsize=buf%?&1c2 * buf%?&1c1 * (1 << buf%?&1c0)
REM A bit of info to the user
PRINT "Filecore partition size = ";~size;" bytes"
REM Convert the size into cylinders
size = (size + clsize - 1) / clsize
size = INT(size+0.5)
PRINT "Filecore partition size = ";size; " cylinders (0-";size-1;")"
REM Check for a RISC iX partition table (e.g. put there by scsidm).
IF buf%?&1fc = 1 OR buf%?&1fc = 2 THEN
PRINT "RISC iX partition starts at cylinder "; buf%?&1fd + (buf%?&1fe<<8)
ENDIF
REM We should be clever about here and read the real geometry
REM of the disc so that we know the maximum cylinder number
REM Get the starting cylinder for the NetBSD part of the disc
INPUT "NetBSD Starting Cyl "c%
REM Make sure it is after the filecore partition
IF (c% < size) THEN
PRINT "Filecore occupies cylinders upto ";size-1
INPUT "Are you sure you mean this value "a$
IF (a$ <> "yes" AND a$ <> "YES") THEN END
PRINT "This will allow NetBSD to overwrite part of the ADFS partition"
INPUT "Are you really sure you mean this value "a$
IF (a$ <> "yes" AND a$ <> "YES") THEN END
ENDIF
PRINT "Initialising NetBSD partition offset at ";c%
PRINT "On drive ";d%;", using ";discop$;" to access drive"
PRINT "Press any key to continue, escape to abort"
dummy%=GET
REM Modifiy the non-ADFS partition descriptor to describe the
REM start of the NetBSD part of the disc
buf%?&1FC = &42 : REM NetBSD identifier
buf%?&1FD = c% AND 255 : REM low byte of start cylinder
buf%?&1FE = c% >> 8 : REM high byte of start cylinder
REM Recalculate the filecore boot block checksum
buf%?&1FF = FNCheckSum(buf%,511)
REM Write the boot block back to disc
SYS discop$,, 2, &c00 + (d% << 29), buf%, 512
END
DEF FNCheckSum(addr%, length%)
sum% = 0
FOR n% = 0 TO length% - 1
sum% += addr%?n%
IF sum% > 255 THEN
sum% -= 255
ENDIF
NEXT
= sum%