NetBSD/sys/arch/i386/boot
mycroft bb563c9eec Do I/O through iobuf rather than address 0, where applicable. Avoid an extra
copy in devread().
1995-01-18 16:22:35 +00:00
..
Makefile Some general cleanup, and add support for serial terminals, `#ifdef SERIAL'. 1995-01-16 02:50:32 +00:00
README.386BSD new RCS ID format. 1994-10-27 04:14:23 +00:00
README.MACH new RCS ID format. 1994-10-27 04:14:23 +00:00
asm.S new RCS ID format. 1994-10-27 04:14:23 +00:00
asm.h new RCS ID format. 1994-10-27 04:14:23 +00:00
bios.S Minor rearrangement. 1995-01-18 15:09:55 +00:00
boot.c Minor change. 1995-01-18 15:42:30 +00:00
boot.h new RCS ID format. 1994-10-27 04:14:23 +00:00
boot.sed after 0.2.2 "stable" patches applied 1993-03-21 18:04:42 +00:00
boot2.S new RCS ID format. 1994-10-27 04:14:23 +00:00
disk.c Do I/O through iobuf rather than address 0, where applicable. Avoid an extra 1995-01-18 16:22:35 +00:00
io.c 24 more bytes... 1995-01-18 03:13:37 +00:00
rmaouthdr new RCS ID format. 1994-10-27 04:14:23 +00:00
start.S Some general cleanup, and add support for serial terminals, `#ifdef SERIAL'. 1995-01-16 02:50:32 +00:00
sys.c Implement symbolic links (plus a minor fix for %x printing) 1995-01-09 22:13:10 +00:00
table.c new RCS ID format. 1994-10-27 04:14:23 +00:00
version.c Some general cleanup, and add support for serial terminals, `#ifdef SERIAL'. 1995-01-16 02:50:32 +00:00

README.MACH

/*	$NetBSD: README.MACH,v 1.5 1994/10/27 04:14:28 cgd Exp $	*/

/*
 * Ported to boot 386BSD by Julian Elischer, September 1992
 *
 * Mach Operating System
 * Copyright (c) 1992, 1991 Carnegie Mellon University
 * All Rights Reserved.
 * 
 * Permission to use, copy, modify and distribute this software and its
 * documentation is hereby granted, provided that both the copyright
 * notice and this permission notice appear in all copies of the
 * software, derivative works or modified versions, and any portions
 * thereof, and that both notices appear in supporting documentation.
 * 
 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
 * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
 * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
 * 
 * Carnegie Mellon requests users of this software to return to
 * 
 *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
 *  School of Computer Science
 *  Carnegie Mellon University
 *  Pittsburgh PA 15213-3890
 * 
 * any improvements or extensions that they make and grant Carnegie Mellon
 * the rights to redistribute these changes.
 */

********NOTE: This is not all relevant to the 386BSD version**********

		AT386 Protected Mode Bootstrap Loader
		=====================================

1. Overview of Startup
   -------------------

	After the system is rebooted, the BIOS bootstrap routine reads Sector
	1, Track 0 into memory at location 0000:7C00H.  If location 0000:7DFEH
	(last two bytes of that sector) contains the value AA55H, the BIOS
	bootstrap routine will transfer control to 0000:7C00H.  Otherwise, the
	boot code in that sector is bad and the boot routine stops.
	
	For DOS compatibility reason, one extra stage of boot is required if
	the boot device is a hard disk.  The first sector of the hard disk will
	contain the MOS-DOS boot code and a boot record partition table.
	When this sector is loaded into 0000:7C00H, it will relocate itself
	to somewhere else and then load the first sector of the active
	partition into 0000:7C00H.  Both UNIX and DOS use the command "fdisk"
	to install this first sector into the hard disk and to manipulate
	the hard disk partitions.

	

2. The First Stage Bootstrap Loader
   --------------------------------

	After startup, the first stage boot is loaded at 0000:7C00H.  This
	first stage boot will load itself and the second stage boot into
	memory at location 0000:1000H.  For floppy disks, the first cylinder
	is reserved as the boot cylinder, and the boot code (first and second)
	will be loaded from there.  Currently, only double sided, high density
	(15 sectors per track) floppies are supported.  For hard disks, the
	first 29 sectors of the active partition is reserved for boot code
	which will be loaded by the first stage boot.  All the disk types
	recognized by BIOS are supported by this bootstrap loader. 



3. The Second Stage Bootstrap Loader
   --------------------------------

	After the boot code is loaded, the control is passed to the second
	stage bootstrap loader "boot2()".  In order to be able to load the
	big kernel image (bigger than 512K or 640K, depends on the memory
	configuration), the second stage boot loader will run on the protected
	mode.  This bootstarp loader does not have any stand alone device
	drivers, all the I/O's are through the BIOS calls.  Since the first
	stage boot code will no longer be used at this moment, the memory
	location of the first stage boot code (0000:1000H to 0000:1200H) will
	be used as an internal buffer for BIOS calls.  Immediately after this 
[For NetBSD, we have a different buffer which can hold an entire floppy
track.]
	internal buffer is the GDT table for the second stage boot loader. 
	Since this boot loader needs to switch back and forth between protected
	and real mode in order to use BIOS calls, the limit of the boot code
	and boot data segments must not be greater than 64K.
	
	The boot loader loads the kernel image at memory location above 1 MB
	to skip the memory hole between 521K/640K and 1MB.  After the kernel
	is loaded, the boot loader stores the information in the stack and
	then passes control to kernel.  Currently, the three information passed
	fromm the boot loader to the kernel are type of the boot device, size
	of the base memory and size of the extended memory.

[NetBSD receives: howto, bootdev, esym.]

[NetBSD is loaded where-ever the "MByte" bits of the load address specify;
normally the load address is F8100000, so it loads at 1MB.]


4. The UNIX Startup
   ----------------

	Since the boot loader loads the kernel image at memory location above
	1MB, the kernel has to start as protected mode.  In addition, the
	link editor description file (vuifile) has to indicate that
	the text and data segments start above 1MB.  Also, the boot loader
	passes the infomation to the kernel through the stack.

[MOST of what is mentionned below is NOT relevant to NetBSD.]

5. Disk Layout and Bad Block Handling
   ---------------------------------
	
    The System V/386 Release 3.2 (AT) disk layout will be used as the disk
    layout for the MACH System on the AT platform.

    This disk layout is as follows:

	* Reserve the first sector of cylinder 0 for the DOS boot record which
	  contains the master boot code (446 bytes) and the partition table.
	  (Refer to DOS Technical Reference Manual page 9-6 to 9-10).

	* Reserve the first 29 sectors of the UNIX partition for the first
	  and the second stage bootstrap.

	* Reserve the 30th sector of the UNIX partition for the pdinfo and
	  the vtoc tables.

	* Reserve the 31st to the 34th sectors of the UNIX partition for the
	  bad track and the bad block mapping tables.

	* Reserve up to 253 consecutive tracks when required, beginning with
	  the 35th sector of the UNIX partition, for alternate tracks.

	* Reserve up to 253 consecutive blocks, beginning with the first
	  sector after the alternate tracks area, for alternate blocks.

	 SEC
	  1
	----------------------------------------------------
	| X |                                              | CYL 0, TRK 0
	----------------  ..........    --------------------
	|                 ..........                       |
	----------------  ..........    --------------------
	|                 ..........                       |
   ===============================================================
    ^   |               BOOTSTRAP                          | CYL N, TRK M
    |   ----------------------------------------------------
    |   |                              |30 |31 |32 |33 |34 |
	----------------------------------------------------  ---
    U   |                 ..........                       |   ^
    N   ----------------  ..........   ---------------------   |
    I   |                 ..........                       | Alternate Tracks
    X   ----------------  ..........   ---------------------   |
        |                 ..........                       |   V
    P   ----------------------------------------------------  --- 
    A   |                 ..........                       |   ^
    R   ----------------  ..........   ---------------------   |
    T   |                 ..........                       | Alternate Blocks
    I   ----------------  ..........   --------------------    |
    T   |                 ..........                       |   V
    I   ----------------------------------------------------  ---
    O   |  Unix root partition starts from here            |
    N   ----------------                   -----------------
  	|                                                  |
        ----------------------------------------------------
        |                                                  |
	----------------------------------------------------
	|                                                  |
    |   ---------------------------------------------------
    |   |                                                  |
    |   ----------------------------------------------------
    V   |                                                  |
   ===============================================================
  	|                   ........                       |
	---------------     ........          --------------
	|                   ........                       |
	----------------------------------------------------


	The bad block handling mechanism is as follows:

	* Use the alternate track in the alternate tracks area if the
	  track containing the target sector is bad.

	* Use the alternate block in the alternate blocks area if the
	  target sector is bad.




6. How to make:
   -----------

	Since the kernel image is loaded above 1 MB, the kernel must start
	as protected mode.  This means that this bootstrap loader will work
	only when the corresponding changes on the kernel startup code are done.

	The make command to generate this bootstrap loader is:

	make -f boot.mk fdboot      (floppy boot loader)
	make -f boot.mk hdboot      (wini boot loader)
[To make NetBSD bootblocks "make install" (warning: they will be installed
in /usr/mdec.. make backups).]