The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/i386at/boot/

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

Name Size Last modified (GMT) Description
Back Parent directory 2008-12-15 18:00:04
File Makeconf 0 bytes 1992-04-09 18:48:10
File Makefile 2133 bytes 1993-09-01 21:14:32
File Makefile.bnr 2238 bytes 1993-06-02 16:38:13
File README 8664 bytes 1992-04-09 18:48:12
File asm.s 4843 bytes 1993-06-02 15:10:27
File bios.s 6640 bytes 1993-06-02 15:10:32
C file boot.c 6455 bytes 1993-09-01 21:14:33
C file boot.h 1974 bytes 1993-09-01 21:14:34
File boot.sed 39 bytes 1992-04-09 18:48:16
File boot2.s 1472 bytes 1992-04-09 18:48:17
C file disk.c 6806 bytes 1993-09-01 21:14:34
C file io.c 3961 bytes 1992-04-09 18:48:19
File rmaouthdr 179 bytes 1992-04-09 18:48:21
File start.s 5604 bytes 1993-09-01 21:14:35
C file sys.c 4866 bytes 1993-09-01 21:14:35
C file table.c 4054 bytes 1993-06-02 15:10:37

    1 /*
    2  * Mach Operating System
    3  * Copyright (c) 1992, 1991 Carnegie Mellon University
    4  * All Rights Reserved.
    5  * 
    6  * Permission to use, copy, modify and distribute this software and its
    7  * documentation is hereby granted, provided that both the copyright
    8  * notice and this permission notice appear in all copies of the
    9  * software, derivative works or modified versions, and any portions
   10  * thereof, and that both notices appear in supporting documentation.
   11  * 
   12  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
   13  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
   14  * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
   15  * 
   16  * Carnegie Mellon requests users of this software to return to
   17  * 
   18  *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
   19  *  School of Computer Science
   20  *  Carnegie Mellon University
   21  *  Pittsburgh PA 15213-3890
   22  * 
   23  * any improvements or extensions that they make and grant Carnegie Mellon
   24  * the rights to redistribute these changes.
   25  */
   26 
   27 /*
   28  * HISTORY
   29  * $Log:        README,v $
   30  * Revision 2.2  92/04/04  11:33:55  rpd
   31  *      From 2.5
   32  *      [92/03/30            mg32]
   33  * 
   34  */
   35 
   36                 AT386 Protected Mode Bootstrap Loader
   37                 =====================================
   38 
   39 1. Overview of Startup
   40    -------------------
   41 
   42         After the system is rebooted, the BIOS bootstrap routine reads Sector
   43         1, Track 0 into memory at location 0000:7C00H.  If location 0000:7DFEH
   44         (last two bytes of that sector) contains the value AA55H, the BIOS
   45         bootstrap routine will transfer control to 0000:7C00H.  Otherwise, the
   46         boot code in that sector is bad and the boot routine stops.
   47         
   48         For DOS compatibility reason, one extra stage of boot is required if
   49         the boot device is a hard disk.  The first sector of the hard disk will
   50         contain the MOS-DOS boot code and a boot record partition table.
   51         When this sector is loaded into 0000:7C00H, it will relocate itself
   52         to somewhere else and then load the first sector of the active
   53         partition into 0000:7C00H.  Both UNIX and DOS use the command "fdisk"
   54         to install this first sector into the hard disk and to manipulate
   55         the hard disk partitions.
   56 
   57         
   58 
   59 2. The First Stage Bootstrap Loader
   60    --------------------------------
   61 
   62         After startup, the first stage boot is loaded at 0000:7C00H.  This
   63         first stage boot will load itself and the second stage boot into
   64         memory at location 0000:1000H.  For floppy disks, the first cylinder
   65         is reserved as the boot cylinder, and the boot code (first and second)
   66         will be loaded from there.  Currently, only double sided, high density
   67         (15 sectors per track) floppies are supported.  For hard disks, the
   68         first 29 sectors of the active partition is reserved for boot code
   69         which will be loaded by the first stage boot.  All the disk types
   70         recognized by BIOS are supported by this bootstrap loader. 
   71 
   72 
   73 
   74 3. The Second Stage Bootstrap Loader
   75    --------------------------------
   76 
   77         After the boot code is loaded, the control is passed to the second
   78         stage bootstrap loader "boot2()".  In order to be able to load the
   79         big kernel image (bigger than 512K or 640K, depends on the memory
   80         configuration), the second stage boot loader will run on the protected
   81         mode.  This bootstarp loader does not have any stand alone device
   82         drivers, all the I/O's are through the BIOS calls.  Since the first
   83         stage boot code will no longer be used at this moment, the memory
   84         location of the first stage boot code (0000:1000H to 0000:1200H) will
   85         be used as an internal buffer for BIOS calls.  Immediately after this 
   86         internal buffer is the GDT table for the second stage boot loader. 
   87         Since this boot loader needs to switch back and forth between protected
   88         and real mode in order to use BIOS calls, the limit of the boot code
   89         and boot data segments must not be greater than 64K.
   90         
   91         The boot loader loads the kernel image at memory location above 1 MB
   92         to skip the memory hole between 521K/640K and 1MB.  After the kernel
   93         is loaded, the boot loader stores the information in the stack and
   94         then passes control to kernel.  Currently, the three information passed
   95         fromm the boot loader to the kernel are type of the boot device, size
   96         of the base memory and size of the extended memory.
   97 
   98 
   99 4. The UNIX Startup
  100    ----------------
  101 
  102         Since the boot loader loads the kernel image at memory location above
  103         1MB, the kernel has to start as protected mode.  In addition, the
  104         link editor description file (vuifile) has to indicate that
  105         the text and data segments start above 1MB.  Also, the boot loader
  106         passes the infomation to the kernel through the stack.
  107 
  108 
  109 5. Disk Layout and Bad Block Handling
  110    ---------------------------------
  111         
  112     The System V/386 Release 3.2 (AT) disk layout will be used as the disk
  113     layout for the MACH System on the AT platform.
  114 
  115     This disk layout is as follows:
  116 
  117         * Reserve the first sector of cylinder 0 for the DOS boot record which
  118           contains the master boot code (446 bytes) and the partition table.
  119           (Refer to DOS Technical Reference Manual page 9-6 to 9-10).
  120 
  121         * Reserve the first 29 sectors of the UNIX partition for the first
  122           and the second stage bootstrap.
  123 
  124         * Reserve the 30th sector of the UNIX partition for the pdinfo and
  125           the vtoc tables.
  126 
  127         * Reserve the 31st to the 34th sectors of the UNIX partition for the
  128           bad track and the bad block mapping tables.
  129 
  130         * Reserve up to 253 consecutive tracks when required, beginning with
  131           the 35th sector of the UNIX partition, for alternate tracks.
  132 
  133         * Reserve up to 253 consecutive blocks, beginning with the first
  134           sector after the alternate tracks area, for alternate blocks.
  135 
  136          SEC
  137           1
  138         ----------------------------------------------------
  139         | X |                                              | CYL 0, TRK 0
  140         ----------------  ..........    --------------------
  141         |                 ..........                       |
  142         ----------------  ..........    --------------------
  143         |                 ..........                       |
  144    ===============================================================
  145     ^   |               BOOTSTRAP                          | CYL N, TRK M
  146     |   ----------------------------------------------------
  147     |   |                              |30 |31 |32 |33 |34 |
  148         ----------------------------------------------------  ---
  149     U   |                 ..........                       |   ^
  150     N   ----------------  ..........   ---------------------   |
  151     I   |                 ..........                       | Alternate Tracks
  152     X   ----------------  ..........   ---------------------   |
  153         |                 ..........                       |   V
  154     P   ----------------------------------------------------  --- 
  155     A   |                 ..........                       |   ^
  156     R   ----------------  ..........   ---------------------   |
  157     T   |                 ..........                       | Alternate Blocks
  158     I   ----------------  ..........   --------------------    |
  159     T   |                 ..........                       |   V
  160     I   ----------------------------------------------------  ---
  161     O   |  Unix root partition starts from here            |
  162     N   ----------------                   -----------------
  163         |                                                  |
  164         ----------------------------------------------------
  165         |                                                  |
  166         ----------------------------------------------------
  167         |                                                  |
  168     |   ---------------------------------------------------
  169     |   |                                                  |
  170     |   ----------------------------------------------------
  171     V   |                                                  |
  172    ===============================================================
  173         |                   ........                       |
  174         ---------------     ........          --------------
  175         |                   ........                       |
  176         ----------------------------------------------------
  177 
  178 
  179         The bad block handling mechanism is as follows:
  180 
  181         * Use the alternate track in the alternate tracks area if the
  182           track containing the target sector is bad.
  183 
  184         * Use the alternate block in the alternate blocks area if the
  185           target sector is bad.
  186 
  187 
  188 
  189 
  190 6. How to make:
  191    -----------
  192 
  193         Since the kernel image is loaded above 1 MB, the kernel must start
  194         as protected mode.  This means that this bootstrap loader will work
  195         only when the corresponding changes on the kernel startup code are done.
  196 
  197         The make command to generate this bootstrap loader is:
  198 
  199         make -f boot.mk fdboot      (floppy boot loader)
  200         make -f boot.mk hdboot      (wini boot loader)

[ source navigation ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.