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