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