bb_netbsd revision 1.4 1 REM > bb_NetBSD
2 REM $NetBSD: bb_netbsd,v 1.4 2006/08/31 20:59:24 bjh21 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 Check for a RISC iX partition table (e.g. put there by scsidm).
92
93 IF buf%?&1fc = 1 OR buf%?&1fc = 2 THEN
94 PRINT "RISC iX partition starts at cylinder "; buf%?&1fd + (buf%?&1fe<<8)
95 ENDIF
96
97 REM We should be clever about here and read the real geometry
98 REM of the disc so that we know the maximum cylinder number
99
100 REM Get the starting cylinder for the NetBSD part of the disc
101
102 INPUT "NetBSD Starting Cyl "c%
103
104 REM Make sure it is after the filecore partition
105
106 IF (c% < size) THEN
107 PRINT "Filecore occupies cylinders upto ";size-1
108 INPUT "Are you sure you mean this value "a$
109 IF (a$ <> "yes" AND a$ <> "YES") THEN END
110 PRINT "This will allow NetBSD to overwrite part of the ADFS partition"
111 INPUT "Are you really sure you mean this value "a$
112 IF (a$ <> "yes" AND a$ <> "YES") THEN END
113 ENDIF
114
115 PRINT "Initialising NetBSD partition offset at ";c%
116 PRINT "On drive ";d%;", using ";discop$;" to access drive"
117 PRINT "Press any key to continue, escape to abort"
118
119 dummy%=GET
120
121 REM Modifiy the non-ADFS partition descriptor to describe the
122 REM start of the NetBSD part of the disc
123
124 buf%?&1FC = &42 : REM NetBSD identifier
125 buf%?&1FD = c% AND 255 : REM low byte of start cylinder
126 buf%?&1FE = c% >> 8 : REM high byte of start cylinder
127
128 REM Recalculate the filecore boot block checksum
129
130 buf%?&1FF = FNCheckSum(buf%,511)
131
132 REM Write the boot block back to disc
133
134 SYS discop$,, 2, &c00 + (d% << 29), buf%, 512
135
136 END
137
138
139 DEF FNCheckSum(addr%, length%)
140 sum% = 0
141 FOR n% = 0 TO length% - 1
142 sum% += addr%?n%
143 IF sum% > 255 THEN
144 sum% -= 255
145 ENDIF
146 NEXT
147 = sum%
148