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