9LOAD(8)                                                 9LOAD(8)

     NAME
          9load, ld - PC bootstrap program

     SYNOPSIS
          (Under MS-DOS)
          [ drive :][ path ]ld [ 9load ]

     DESCRIPTION
          9load and ld are programs that reside in a FAT file system
          and bootstrap Plan 9.  9load loads the kernel, but it cannot
          be run from DOS; use ld to bootstrap (by starting 9load) if
          DOS is running.  9load is run automatically by the boot pro-
          cedures described below; it cannot be run directly by hand.
          There are three bootstrap sequences:

          -    BIOS, MBR, disk partition PBS, 9load, kernel

          -    BIOS, floppy PBS, 9load, kernel

          -    BIOS, MBR, DOS, ld, 9load, kernel.

          Details follow.

          9load is a bootstrap program that loads and starts a pro-
          gram, typically the kernel, on a PC.  It is run by the PC
          partition boot sector program (PBS), which usually resides
          in the first sector of the active partition.  A copy of the
          Plan 9 PBS is kept in /386/pbs, but due to the ``cylinder-
          head-sector'' (CHS) addressing mode of old BIOSes, it can
          only operate up to 8.5GB into the disk.  Plan 9 partitions
          further into the disk can only be booted using /386/pbslba,
          and then only if the machine's BIOS supports linear block
          addressing (LBA) mode for disk transfers.

          When booting from floppy or hard disk, the BIOS loads the
          first sector of the medium at location 0x7C00.  In the case
          of a floppy, this is the PBS.  In the case of a hard disk it
          it the master boot record (MBR).  The MBR copies itself to
          address 0x600, finds the active partition and loads its PBS
          at address 0x7C00.  A copy of the Plan 9 MBR is kept in
          /386/mbr; some commercial MBRs cannot read sectors past 2GB.
          The Plan 9 MBR can read sectors up to 8.5GB into the disk,
          and further if the BIOS supports LBA.  The single file
          /386/mbr detects whether the BIOS supports LBA and acts
          appropriately, defaulting to CHS mode when LBA is not pre-
          sent.  The PBSs cannot do this due to code size considera-
          tions.  The Plan 9 MBR is suitable for booting non-Plan 9
          operating systems, and (modulo the large disk constraints
          just described) non-Plan 9 MBRs are suitable for booting
          Plan 9.

     Page 1                       Plan 9            (printed 11/22/24)

     9LOAD(8)                                                 9LOAD(8)

          Thus the default sequence is: BIOS, MBR, PBS, 9load, kernel.

          Because it contains many device drivers for different disks
          and networks, 9load is larger than 64K and cannot be run as
          a DOS ``.com'' executable.  A stripped-down version that
          knows about disks but not networks, called ld (really
          ld.com), fits in 64K and can be used under DOS to load and
          start a program (default 9load) from the FAT16 partition.
          It's command line argument is of the same format as the
          bootfile specifiers described below.  This profusion of
          loaders is unfortunate, but at least ld and 9load are com-
          piled from the same source.

          9load begins execution at address 0x80010000 (64K) and loads
          the bootfile at the entry address specified by the header,
          usually 0x80100020.  After loading, control is passed to the
          entry location.

          In summary, Plan 9 can be booted on a PC two different ways:
          either by booting MS-DOS and using ld to start 9load in the
          appropriate directory, or by booting directly from a Plan 9
          boot floppy or disk partition prepared using format to
          install the appropriate files and bootstrap sectors (see
          prep(8)).

          The bootfile, which may be compressed with gzip(1), can be
          specified to 9load as a bootfile= entry in plan9.ini, or if
          booting from the ethernet, by a BOOTP server.  If the
          plan9.ini file contains multiple bootfile= entries, 9load
          will present a numerical menu of the choices; type the cor-
          responding number to select an entry.

          The format of the bootfile name is device!file or
          device!partition!file.  If !file is omitted, the default for
          the particular device is used.  Supported devices are

          fdn     An MS-DOS floppy disk.  N specifies the floppy
                  drive, either 0 or 1.  The bootfile is the contents
                  of the MS-DOS file. There is no default file.  For
                  compatibility with hard disks, a partition may be
                  given, but only dos is recognized: fd0!dos!file.
          ethern  Ethernet.  N specifies the Ethernet device number.
                  If a partition is specified, it is taken to be the
                  name of a host machine from which to load the ker-
                  nel.  file is determined by the /lib/ndb (see
                  ndb(6)) entry for this PC.
          sdCn    Non-floppy disk.  The device name format is
                  described in sd(3). A partition must be given and
                  must name a partition containing a FAT file system.
                  The name dos refers to the first DOS partition on a
                  given device.  It is common for Plan 9 partitions to
                  contain a small FAT file system for configuration.

     Page 2                       Plan 9            (printed 11/22/24)

     9LOAD(8)                                                 9LOAD(8)

                  By convention, this partition is called 9fat.  There
                  is no default partition or pathname.

          When 9load starts running at physical address 0x10000, it
          switches to 32-bit mode.  It then double maps the first 16Mb
          of physical memory to virtual addresses 0 and 0x80000000.
          Physical memory from 0x300000 upwards is used as data space.
          Next, in order to find configuration information, 9load
          searches all units on devices fd and sdCn, in that order,
          for a file called plan9\plan9.ini or plan9.ini (see
          plan9.ini(8)) on a partition named dos or 9fat.  If one is
          found, searching stops and the file is read into memory at
          physical address 0x1200 where it can be found later by any
          loaded bootfile. Some options in plan9.ini are used by
          9load:

          console
          baud             Specifies the console device and baud rate
                           if not a display.
          ethern           Ethernet interfaces. These can be used to
                           load the bootfile over a network.  Probing
                           for Ethernet interfaces is too prone to
                           error.
          bootfile=bootfile
                           Specifies the bootfile. This option is
                           overridden by a command-line argument.
          bootfile=auto    Default.
          bootfile=local   Like auto, but do not attempt to load over
                           the network.
          bootfile=manual  After determining which devices are avail-
                           able for loading from, enter prompt mode.

          When the search for plan9.ini is done, 9load proceeds to
          determine which bootfile to load.  If there was no bootfile
          option, 9load chooses a default from the following priori-
          tized device list:
               fd sd ether
          9load then attempts to load the bootfile unless the
          bootfile=manual option was given, in which case prompt mode
          is entered immediately.  If the default device is fd, 9load
          will prompt the user for input before proceeding with the
          default bootfile load after 5 seconds; this prompt is omit-
          ted if a command-line argument or bootfile option was given.

          9load prints the list of available devices and enters prompt
          mode on encountering any error or if directed to do so by a
          bootfile=manual option.  In prompt mode, the user is
          required to type a bootfile in response to the `Boot from:'
          prompt.

          9load parses the master boot record and Plan 9 partition
          tables (see prep(8)), leaving partitioning information

     Page 3                       Plan 9            (printed 11/22/24)

     9LOAD(8)                                                 9LOAD(8)

          appended to the in-memory contents of plan9.ini for the
          bootfile. This is used by sd(3) to initialize partitions so
          that kfs(4) file systems can be mounted as the root file
          system.  A more extensive partitioning is typically done by
          fdisk and prep as part of termrc or cpurc (see cpurc(8)).

          A control-P character typed at any time on the console
          causes 9load to perform a hardware reset (Ctrl-Alt-Del can
          also be used on a PC keyboard).

          When loaded from a PBS (rather than from ld.com), 9load must
          be contiguously allocated on the disk.  See dossrv(4) for
          information on ensuring this.

     FILES
          [drive:] [ path ]9load
          [drive:] [ path ]ld
          FAT filesystem:\plan9\plan9.ini
          FAT filesystem:\plan9.ini

     SOURCE
          /sys/src/boot/pc

     SEE ALSO
          plan9.ini(8), prep(8)

     BUGS
          Much of the work done by 9load is duplicated by the loaded
          kernel.

          If ld detects an installed MS-DOS Extended Memory Manager,
          it attempts to de-install it, but the technique used may not
          always work.  It is safer not to install the Extended Memory
          Manager before running ld.

     Page 4                       Plan 9            (printed 11/22/24)