NetBSD-5.0.2/distrib/notes/acorn32/prep.RISCOS

	$NetBSD: prep.RISCOS,v 1.19.6.1 2009/04/25 23:16:33 snj Exp $

These instructions are specific to NetBSD/acorn32 on Acorn RISCOS platforms
(RiscPC/A7000/A7000+/NC's).

Last updated for the BtNetBSD bootloader version 0.99a at 10 July 2002 by
Reinoud Zandijk (reinoud@NetBSD.org), portmaster of NetBSD/acorn32.

For a more detailed acknowledgement and list of contributors see Appendix B
at the bottom.



0 Before you start

Read this document and one of the INSTALL documents completely before
continuing. There might be some things mentioned twice, but this document
ought to help with the RISCOS installation specifically.



1 Requirements


1.1 Hardware

Refer to the NetBSD installation notes and/or the web site
http://www.NetBSD.org/ports/acorn32/ for a list of supported hardware.


1.2 Software

You will need the following RiscOS software:

	A program that will unpack sparchives. We recommend that you
	get David Pilling's !SparkPlug. A self-extracting version of this
	can be found at David Pilling's web site
	(http://www.davidpilling.net/free.html).

	A program to report your disk's geometry:

		Not really needed, you can simply boot the installation
		kernel and look for the geometry in the boot messages.

		Sergio Monesi's fsck suite (a good thing to have around
		anyway). Available from:
		http://www.monesi.com/sergio/fsck.html

		!Zap (The read disk facility). Available from HENSA.

	The partition software/formatter for your desired installation
	target:

		IDE disks on motherboard interface: !HForm
		IDE disks on Simtec interface: UNKNOWN
		IDE disks on ICS interface: UNKNOWN
		IDE disks on RapIDE interface: UNKNOWN
		Acorn SCSI cards: ScsiDM
		Power-tec SCSI cards: !PowerMgr
		Cumana SCSI-2: !SCSIMgr
		oak SCSI-1 card: UNKNOWN
		MCS Connect32 SCSI: UNKNOWN
		Morley SCSI: UNKNOWN

Additionally you will require the following:

	The Bootloader and RiscOS tools: BtNetBSD.tar.Z as found in
	the installation/misc directory. This archive, which can be
	unpacked with !SparcPlug, *includes the installation-kernel*
	so you don't have to download it separately.

	The NetBSD/acorn32 distribution sets (Will be on the CD-ROM, or
	available from your nearest NetBSD ftp site).

	A hardcopy of this document, along with a hardcopy of the
	NetBSD installation instructions "INSTALL").

1.3 Preliminary steps:

	Unpack your BtNetBSD archive in whatever way, set the type of
	the `Settype' file in the BtNetBSD directory to `Obey' and run
	it. This will make the files RISC OS typed correctly. This is
	also explained in a bit more detail in the enclosed README file.
	It will also type the `InstKern' file that is the installation
	kernel itself complete with embedded ramdisc.

2 Preparing your hard disk

Terms:

Device:		The actual physical hard disk
Partition:	A section of a device.
File system:	A structured partition that is able to hold files.
Disc:		A RiscOS file system in a partition. There can be
		more than one Disc per Device.

You will have to decide which device you wish to install NetBSD on.
You will also have to decide whether you want to split the device
between one or more RiscOS discs and NetBSD or dedicate a whole
Device for NetBSD.

In making this decision you should consider the possibility that if
NetBSD is incorrectly configured on a shared device then your shared
data is at risk.

It is still recommended that if you decide to dedicate a device to
NetBSD that you set aside a small RISC OS partition at the beginning
of the device. This is a useful place to store the RiscOS side of
NetBSD, and will make the use of UnixFS easier to configure. If you
do decide to create a minimal RiscOS partition at the beginning of
the device, a size of 10-20 MB is recommended (some partitioning
software has problems with partitions smaller than this).

The point is that you will have to repartition your device to make
room for a separate partition after the RISC OS one for NetBSD. This
means backing up your device, re-partitioning it and then copying all
the data back afterwards. We recommend that you only copy the needed
data back and put off installing the rest until you have NetBSD up
and running. This way you will save yourself a lot of work if
something goes wrong and you have to start all over again.


2.1 Sharing your device


2.1.1 Acorn IDE

Use !HForm for this interface. This is a program that is delivered
with your computer and is located in the Utilities directory on your
hard disk.

With this software you only have the possibility of using one
partition for RISC OS, so you have to set the rest aside for NetBSD.

Use this procedure to set up your device:

	Start !HForm by double-clicking on its icon.

	Choose the "custom" or "other" option when prompted (usually
	the last).

	Use the default values for the geometry but do not enter the
	full number of cylinders. Just enter the number you want to
	use for RISC OS. Make a note of this number.

	Continue to accept the default answers until you're asked
	whether you want to format or initialize, choose initialize.

	Go to the section about running bb_riscbsd.


2.1.2 Cumana SCSI-2 card

It is recommended that you use a newer version of !SCSIMgr (newer
than v1.55) since this will be easier to use when you want to leave
part of the device unused by RISC OS. You should check for the latest
version of this software at the following URL:
http://www.cumana.demon.co.uk

You need to create one or more RISC OS partitions, and you do it in
in the following way:
	Run !SCSIMgr by double-clicking on it.

	Select the device you wish to repartition.

	Click on the clear icon in the partitions subwindow.

	This will give you a dialogue box where you can specify the
	size of the RISC OS partitions. Do not select all since you
	want to use part of it for NetBSD.

	Enter the amount of the device you wish to reserve for
	RiscOS. This will be the whole device size less the amount
	you want to reserve for NetBSD. Make a note of this number.

	If you like, split the RISC OS portion of the device into
	several partition (you should only "see" the RiscOS portion).

	Click on Execute when you are happy with the partitions. This
	will create your partitions, and wipe your device.

	Go to the section about running bb_riscbsd.


2.1.3 Alsystems Power-tec SCSI-2 card

You must use the !PowerMgr program to partition the device.

The RISC OS partitions should be called RiscOs:, and the NetBSD one
should be called Empty:.

Here is the procedure you should use:
	Start !PowerMgr by double-clicking on its icon.

	Click on advanced in the main window

	Click on Define/create partitions
		Click on the device you want to set up for NetBSD.

		Set up the RISC OS partitions as "RiscOs:" and the
		remaining one as "Empty:".

		Click on each figure and press RETURN.

		Click on partition drive.

		Click on yes to warning as you really want to wipe
		the device.

		Click on yes to proceed, this will lead you to the
		partition init.

	Partition init
		Set a tick on all RiscOs: partitions, give them a name
		and set LFAU to auto.

		Unset the tick on your Empty: partition.

		Click on Initialize selected partitions.

		Click on yes to proceed init as you want to wipe the
		selected partitions.

		Click on yes to proceed to configure.

	Configure
		Here you should set up the RISC OS partitions as you
		like them. Normally the default will be ok.

		Click on configure. This will configure your computer
		and give you access to the Discs.

	You *Must Not* run bb_riscbsd.



2.1.4 Acorn SCSI card

You can only have one RISC OS partition with this card. The rest has
to be set aside for NetBSD.

This card does not have a friendly WIMP-based interface on the SCSI
management program, but the command line version is very good. You
should run this in a task window (press CTRL-F12):
	dir <location_of_scsidm>

	scsidm

You will get the following prompt:
scsidm>

Now you should enter the following commands:
	probe		(to see which devices are available)

	device <no>	(replace <no> with the no of your device)

	section		(to divide the device between RISC OS and
			NetBSD)
		Answer yes to the question:
			Include RISCiX partitions?

		Enter the size of the RISC OS area in blocks
		(sectors)

		SCSIDM will round this up to the nearest cylinder
		boundary.

		Answer yes to the question:
			Do you really want to section device <no>?

		This will section the device into two partitions.

	quit

	Go to the section on running bb_riscbsd.



2.1.5 Other interfaces

It may not be possible to partition devices on other interface. If
you are using a different interface you have 2 options:

	Try to work out how to partition devices on it

	Use the entire device for NetBSD


2.2 Using a whole device for NetBSD

As a safety precaution NetBSD/acorn32 looks for a filecore bootblock
at the beginning of any device it labels. If it finds one and it
looks as though it is in use then NetBSD/acorn32 will not touch it.

Because of this, if you've ever used your device for RiscOS, you will
need to invalidate this bootblock.

To do this you need to:

	Be absolutely sure you want to do this.

	Run bb_trash and follow the instructions.

Ensure that this device is now not configured for RiscOS.

You are now ready to boot NetBSD and continue the installation.



3 Running bb_riscbsd

When you run this program, you will first be asked whether you are
installing to an ADFS drive or a SCSI drive. You can just press A or
S respectively. (The bb_riscbsd program assumes that you are using a
non-Acorn SCSI card, so if you are using an Acorn card, then you may
have to edit this program and replace SCSI_DiscOp with SCSIFS_DiscOp.)

Then you will be asked which disc you want to install NetBSD on. This
*must* be the first disc on the device. bb_riscbsd will now
scrutinize the device and see how it has been laid out.

It will then tell you how much of the device is occupied by RiscOS in
cylinders, and you will then be asked for the NetBSD starting
cylinder. Normally you should just enter the number given to you
since the RISC OS starting cylinder is 0 and therefore the last
cylinder in use is one less than the figure given. If no figure is
displayed, then your partitioning software failed to fill in the
bootblock completely (it doesn't have to do this for you but most do)
or you selected the wrong device. If you are convinced that this is
the correct device then you must calculate a cylinder offset using
the numbers noted down during partitioning (if it is not a whole
number *always* round up, you might waste a little of the device but
it'll be safer).

Make a note of this number.

bb_riscbsd will make a backup of the original bootblock, but it
can be non-trivial to put it back.



4 Booting

Now that your device is ready for the installation you need to
unpack the bootloader archive.

In the archive you'll find the tools mentioned in this document as well as
the bootloader !BtNetBSD itself and a file called `InstKern'
which is the actual installation kernel with embedded ramdisk containing the
NetBSD userland necessary for installation.


4.1 [Optional] Configuring the !BtNetBSD bootloader before installation

Open the !BtNetBSD application and edit the `fastboot' file to specify
a known kernel location; an example is already given.

You can also set other details like tweaking with the amount of memory in
the WimpSlot of the bootloader when this is too much. Remember however that
this shouldn't be set too low for it can crash the bootloader.

When you think you've filled in the proper details save the file again
and proceed.


4.2 Starting the installation!

To start the installation just double click on the InstKern file. This will
startup !BtNetBSD with the proper kernel argument and start its installation.

NetBSD should now start to boot, install NetBSD as per the NetBSD
installation notes.

When you finish the installation you can restarted the computer as
instructed.


4.3 [Optional] Configuring !BtNetBSD after installation

Open the !BtNetBSD application again and edit the `fastboot' file again
to customise details like the mode definition file you want to use.

Save the file and run !BtNetBSD again (see above).



5 Advanced stuff


5.1 Using UnixFS to copy the sets.

Once the required sets are installed and you can boot from your
newly installed NetBSD setup, you can use UnixFS to copy the
remaining sets from RiscOS to NetBSD.

In order to be able to use unixfs to transfer the sets you must have
a certain setup.

1) You must have the RiscOS disc that corresponds to the NetBSD
   device configured (e.g., *con. IDEdiscs 2) even if it has no RiscOS
   section.
2) If you have RISC OS 3.5 without the new FileCore, then you must
   also have the NetBSD file system *completely* below the 511 MB
   boundary of the device.
3) You must know the SWI base of the <filesys>_DiscOp SWI. Here
   <filesys> is SCSIFS, SCSI or ADFS depending upon which controller
   type you have you NetBSD device on.
   Some common ones:
   	Power-tec SCSI-2 card:	&40980
	RapIDE:			&4BBC0

   There are small obey files for some interfaces supplied with UnixFS.
4) Have given the directory you want to write into write permission for
   everyone. This should have been done above. For example to make
   /usr/distrib world writable type (as root):
	chmod 1777 /usr/distrib

To mount a Unix partition:

1) Double-click on the unixfs_res module to load it.
2) Run a unixfs_mount command to mount the partition.
3) Open the root directory by double-clicking on the openroot file.
4) Open the distrib directory and just copy the sets to this.
5) Shut down unixfs by double-clicking on the kill_unixfs file.
   THIS STEP IS VERY IMPORTANT as it works like dismount on MS-DOS floppies.

The difficult step here is step number 2). If you are using an
ADFS IDE disc, then you can just double-click on one of the
following obey files (always choose the RiscOS disc number that
corresponds to the *first* disc on the NetBSD device):
- wd0a (ADFS::4 drive, not disc, root file system)
- wd0e (ADFS::4 drive, not disc, /usr file system)
- wd1a (ADFS::5 drive, not disc, root file system)
- wd1e (ADFS::5 drive, not disc, /usr file system)

If you are not using an ADFS IDE device, you need to create such
an obey file yourself. We recommend that you copy one of the
above and change that. These files normally only contain a
unixfs_mount command. If you go to the command line (or a task
window), and you type *help unixfs_mount you will see that the
unixfs_mount command has a very incomprehensible syntax.

The unixfs_mount command normally only takes one argument. That
is composed of the following:
(discop_swibase + (disc << 3) + partition)

To mount the root partition of third Power-tec SCSI-2 disc the
following commands can be used in task window (press CTRL-F12) to
find the argument to unixfs_mount:
        *basic
        PRINT ~(&40980 + (6 << 3) + 0)
        QUIT

The PRINT command calculates the value to use and will in this
context give the value 409B0 which also is in hexadecimal. The
interesting things above are:
- &40980        The SWI base for SCSIFS_DiscOp.
- 6             The disc number in RISC OS.
- 0             The RiscBSD partition no. with a=0, b=1 etc.
- ~             Tell the PRINT command to show the result in hexadecimal.
- <<            Shifts the first number with the second number
                places left.
                In this case, it shifts 6 with 3 places to the left.
- &             Denotes that the number is in hexadecimal.
- ( and )       Used to group the sub-expressions.

When you have calculated the figure to give to unixfs_mount you
just change it in the copy of the file you made above and run it by
double-clicking on it.

When you have mounted the unixfs file system, you can open the
directory and copy the sets to it.
Don't forget to copy the file "checksums" too. As its name suggests, it
contains checksums to check if the files are OK.

When you are finished with the transfer, run the file
kill_unixfs to dismount the unixfs file system.



Appendix A - Device naming

The names of the devices in NetBSD are not at all like the ones
in RISC OS. We will here try to explain the naming scheme used
in NetBSD. This is pretty much the same in all UNIXes, but
there will be some differences. NetBSD is derived from BSD and
differs from the ones that are derived from System V. Most of
the dominant operating systems in the UNIX market today are
based on System V (Sun Solaris, SGI Irix, HP HP-UX 10.xx, Linux
etc.). Some of them are actually hybrids of both.

The file systems in UNIX use the slash character (/) as the
directory separator. The top (or bottom if you like) directory
is called the root and is denoted by a single slash (/). All
absolute filenames are addressed starting with the root, so the
temporary directory is called /tmp.

The devices in UNIX are addressed as special files in the
file system, and they all start with /dev, so e.g. the quadrature
mouse is called /dev/quadmouse.

Also some devices can be addressed in two different ways; as a
raw (character by character) or block device. This is especially
true with discs, and they therefore have two different names.
The raw device is called the same as the block device except
that it has an 'r' in front of the name. E.g. the first internal
hard drive is called /dev/wd0 as a block device, but /dev/rwd0
as a raw device. See also later.

For now, the only needed devices are the storage devices, so we
will hereby describe the naming convention used for these.
Please note that when you have different partitions on a device,
they will get the same number in NetBSD, but different letters,
whereas in RISC OS they will get different numbers. See the
examples at the end of this section.

The (block) device names are mostly composed of 4 characters:
1. The type
        - w     Winchester drives (i.e. standard ADFS drives)
        - s     SCSI drives
        - c     CD-ROM drives
        - r     RAM drives (obsolete in newer kernels)
        - m     Memory drives (only in newer kernels)
        - f     Floppy drives
2. A 'd' indicating a disc device
3. The number of the device of that type starting with 0.
        - For IDE drives, the master will be 0, and the slave 1.
        - For SCSI drives, the target ID will be used to
determine the number. They start on 0 and increase with
each device found. The drive with the lowest target ID will get
0, the second lowest target ID will get 1 etc.
Also, if you have different controllers, all devices on controller
0 (lowest expansion slot) will be added first.
        - The CD-ROM drives act the same way as SCSI drives.
        - The floppy drive is numbered as in RISC OS.
        - At present you can only have one RAM drive, so it is 0.
4. The name of the partition. There are eight of these (along with
   common allocations):
        - a     The root partition
        - b     The swap partition
        - c     The complete and whole disc ; all OS's and partitions
        - d     Part of the disc that is not used by NetBSD; normally RiscOS
        - e     The first additional partition.
                i.e. if you have only /usr, then this will be /usr
                if you have both /var and /usr this will be /var
        - f     The second additional partition.
                i.e. if you have /var and /usr, this will be /usr
        - g     The third ...
        - h     The fourth ...

If you only have one partition on the drive this can normally be
accessed with either partition a (root partition) or c (whole
disc). This has not been verified to work.

A couple of examples of how to map RISC OS names to NetBSD ones
(the partition names have been left out):
ADFS::0                         fd0
ADFS::1                         fd1
ADFS::4                         wd0
ADFS::5 (same drive as :4)      wd0
ADFS::5 (other drive than :4)   wd1
SCSI::4                         sd0
SCSI::5 (same drive as :4)      sd0
SCSI::5 (other drive than :4)   sd1

So, if you have one ADFS IDE drive, and want to install NetBSD
at the after ADFS::5, you should still use wd0. If on the other
hand, ADFS::5 is a second drive, then you will have to use wd1.


Appendix B - Acknowledgments

This document was based upon the document
"Installing RiscBSD 1.2-Release"
(C) 1996 The RiscBSD Documentation Project

That has the following acknowledgement:

This manual has been written from scratch based on version 1.2
of the installation manual that Mark Brinicombe wrote.

It was mainly written by Kjetil B. Thomassen
(kjetil@thomassen.priv.no) with contributions from:
Neil Hoggarth (neil.hoggarth@physiol.ox.ac.uk)
Markus Baeurle (emw4maba@gp.fht-esslingen.de)
Jasper Wallace (jasper@ivision.co.uk)
Mark Brinicombe (amb@physig.ph.kcl.ac.uk)
Scott Stevens (s.k.stevens@ic.ac.uk)
and a lot more people posting to the original RiscBSD mailing list.