11.3SreinoudREM > bb_NetBSD
21.4Sbjh21REM $NetBSD: bb_netbsd,v 1.4 2006/08/31 20:59:24 bjh21 Exp $
31.3SreinoudREM
41.3SreinoudREM Copyright (c) 1995 Mark Brinicombe
51.3SreinoudREM All rights reserved
61.3SreinoudREM
71.3SreinoudREM Redistribution and use in source and binary forms, with or without
81.3SreinoudREM modification, are permitted provided that the following conditions
91.3SreinoudREM are met:
101.3SreinoudREM 1. Redistributions of source code must retain the above copyright
111.3SreinoudREM    notice, this list of conditions and the following disclaimer.
121.3SreinoudREM 2. Redistributions in binary form must reproduce the above copyright
131.3SreinoudREM    notice, this list of conditions and the following disclaimer in the
141.3SreinoudREM    documentation and/or other materials provided with the distribution.
151.3SreinoudREM 3. All advertising materials mentioning features or use of this software
161.3SreinoudREM    must display the following acknowledgement:
171.3SreinoudREM        This product includes software developed by Mark Brinicombe.
181.3SreinoudREM 4. The name of the company nor the name of the author may be used to
191.3SreinoudREM    endorse or promote products derived from this software without specific
201.3SreinoudREM    prior written permission.
211.3SreinoudREM
221.3SreinoudREM THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
231.3SreinoudREM IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
241.3SreinoudREM OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
251.3SreinoudREM IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
261.3SreinoudREM INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
271.3SreinoudREM BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
281.3SreinoudREM OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
291.3SreinoudREM ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
301.3SreinoudREM OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
311.3SreinoudREM THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
321.3SreinoudREM DAMAGE.
331.3SreinoudREM
341.3SreinoudREM NetBSD kernel project
351.3SreinoudREM
361.3SreinoudREM bb_NetBSD
371.3SreinoudREM
381.3SreinoudREM Modifies the filecore bootblock to point to a section of
391.3SreinoudREM the disc reserved for NetBSD.
401.3SreinoudREM
411.3SreinoudREM Created      : 24/11/94
421.3SreinoudREM Last updated : 12/07/95
431.3SreinoudREM
441.3Sreinoud
451.3SreinoudDIM buf% 512
461.3Sreinoud
471.3SreinoudREM Get Filesystem type
481.3Sreinoud
491.3SreinoudREPEAT
501.3Sreinoud  PRINT "ADFS, ATAFS, IDEFS, SCSI or SCSIFS (A/T/I/S/F) ? ";
511.3Sreinoud  filesys% = GET AND &DF
521.3Sreinoud  PRINT CHR$(filesys%)
531.3SreinoudUNTIL filesys%=ASC"A" OR filesys%=ASC"T" OR filesys%=ASC"S" OR filesys%=ASC"I" OR filesys%=ASC"F"
541.3Sreinoud
551.3SreinoudCASE filesys% OF
561.3Sreinoud  WHEN ASC"A" : discop$="ADFS_DiscOp"
571.3Sreinoud  WHEN ASC"I" : discop$="IDEFS_DiscOp"
581.3Sreinoud  WHEN ASC"T" : discop$="ATAFS_DiscOp"
591.3Sreinoud  WHEN ASC"S" : discop$="SCSI_DiscOp"
601.3Sreinoud  WHEN ASC"F" : discop$="SCSIFS_DiscOp"
611.3SreinoudENDCASE
621.3Sreinoud
631.3SreinoudREM Get the drive number
641.3Sreinoud
651.3SreinoudINPUT "Drive "d%
661.3Sreinoud
671.3SreinoudREM Read in current filecore bootblock
681.3Sreinoud
691.3SreinoudSYS discop$,, 1, &c00 + (d% << 29), buf%, 512
701.3Sreinoud
711.3SreinoudSYS "OS_File", 10, "<Wimp$ScrapDir>.OldBB", &FFD,, buf%, buf%+512
721.3SreinoudPRINT "Old boot block saved in <Wimp$ScrapDir>.OldBB"
731.3Sreinoud
741.3SreinoudREM Get the byte size of the filecore partition and the number
751.3SreinoudREM of bytes per cylinder
761.3Sreinoud
771.3Sreinoudsize=buf%!&1d0
781.3Sreinoudclsize=buf%?&1c2 * buf%?&1c1 * (1 << buf%?&1c0)
791.3Sreinoud
801.3SreinoudREM A bit of info to the user
811.3Sreinoud
821.3SreinoudPRINT "Filecore partition size = ";~size;" bytes"
831.3Sreinoud
841.3SreinoudREM Convert the size into cylinders
851.3Sreinoud
861.3Sreinoudsize = (size + clsize - 1) / clsize
871.3Sreinoudsize = INT(size+0.5)
881.3Sreinoud
891.3SreinoudPRINT "Filecore partition size = ";size; " cylinders (0-";size-1;")"
901.3Sreinoud
911.4Sbjh21REM Check for a RISC iX partition table (e.g. put there by scsidm).
921.4Sbjh21
931.4Sbjh21IF buf%?&1fc = 1 OR buf%?&1fc = 2 THEN
941.4Sbjh21  PRINT "RISC iX partition starts at cylinder "; buf%?&1fd + (buf%?&1fe<<8)
951.4Sbjh21ENDIF
961.4Sbjh21
971.3SreinoudREM We should be clever about here and read the real geometry
981.3SreinoudREM of the disc so that we know the maximum cylinder number
991.3Sreinoud
1001.3SreinoudREM Get the starting cylinder for the NetBSD part of the disc
1011.3Sreinoud
1021.3SreinoudINPUT "NetBSD Starting Cyl "c%
1031.3Sreinoud
1041.3SreinoudREM Make sure it is after the filecore partition
1051.3Sreinoud
1061.3SreinoudIF (c% < size) THEN
1071.3Sreinoud  PRINT "Filecore occupies cylinders upto ";size-1
1081.3Sreinoud  INPUT "Are you sure you mean this value "a$
1091.3Sreinoud  IF (a$ <> "yes" AND a$ <> "YES") THEN END
1101.3Sreinoud  PRINT "This will allow NetBSD to overwrite part of the ADFS partition"
1111.3Sreinoud  INPUT "Are you really sure you mean this value "a$
1121.3Sreinoud  IF (a$ <> "yes" AND a$ <> "YES") THEN END
1131.3SreinoudENDIF
1141.3Sreinoud
1151.3SreinoudPRINT "Initialising NetBSD partition offset at ";c%
1161.3SreinoudPRINT "On drive ";d%;", using ";discop$;" to access drive"
1171.3SreinoudPRINT "Press any key to continue, escape to abort"
1181.3Sreinoud
1191.3Sreinouddummy%=GET
1201.3Sreinoud
1211.3SreinoudREM Modifiy the non-ADFS partition descriptor to describe the
1221.3SreinoudREM start of the NetBSD part of the disc
1231.3Sreinoud
1241.3Sreinoudbuf%?&1FC = &42             : REM NetBSD identifier
1251.3Sreinoudbuf%?&1FD = c% AND 255      : REM low byte of start cylinder
1261.3Sreinoudbuf%?&1FE = c% >> 8         : REM high byte of start cylinder
1271.3Sreinoud
1281.3SreinoudREM Recalculate the filecore boot block checksum
1291.3Sreinoud
1301.3Sreinoudbuf%?&1FF = FNCheckSum(buf%,511)
1311.3Sreinoud
1321.3SreinoudREM Write the boot block back to disc
1331.3Sreinoud
1341.3SreinoudSYS discop$,, 2, &c00 + (d% << 29), buf%, 512
1351.3Sreinoud
1361.3SreinoudEND
1371.3Sreinoud
1381.3Sreinoud
1391.3SreinoudDEF FNCheckSum(addr%, length%)
1401.3Sreinoudsum% = 0
1411.3SreinoudFOR n% = 0 TO length% - 1
1421.3Sreinoud  sum% += addr%?n%
1431.3Sreinoud  IF sum% > 255 THEN
1441.3Sreinoud    sum% -= 255
1451.3Sreinoud  ENDIF
1461.3SreinoudNEXT
1471.3Sreinoud= sum%
148