9LOAD(8)                                                 9LOAD(8)

     NAME
          9load, ld, 9pxeload - 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 a 386 or amd64 kernel,
          but it cannot be run from DOS; use ld to bootstrap (by
          starting 9load) if DOS is running.  9load is run automati-
          cally by the boot procedures described below; it cannot be
          run directly by hand.  9pxeload is a version of 9load that
          can be booted using the PXE download (BOOTP/DHCP followed by
          TFTP) found in any reasonable ethernet card's BIOS.  9load
          will not use BIOS device drivers.  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 disk or floppy, the BIOS loads the first
          sector of the medium at location 0x7C00.  In the case of a
          disk, it is the master boot record (MBR).  In the case of a
          floppy, this is the PBS.  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

     Page 1                       Plan 9            (printed 12/21/24)

     9LOAD(8)                                                 9LOAD(8)

          considerations.  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.

          Thus the default sequence when booting from disk 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.
          Its 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 virtual address 0x80010000 (64K)
          and loads the bootfile at the entry address specified by the
          header, usually virtual 0xF0100020 for 386 kernels.  After
          loading, control is passed to the entry location.

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

        Bootfile
          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 (see Kernel
          loading below).  If the plan9.ini file contains multiple
          bootfile= entries, 9load will present a numerical menu of
          the choices; type the corresponding 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

          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.

     Page 2                       Plan 9            (printed 12/21/24)

     9LOAD(8)                                                 9LOAD(8)

          sdCn    Normal 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 con-
                  tain a small FAT file system for configuration.  By
                  convention, this partition is called 9fat.  There is
                  no default partition or pathname.

          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 normal disks, a partition may be
                  given, but only dos is recognized: fd0!dos!file.

          bios0   (Not in 9pxeload.) 9load loads from a FAT file sys-
                  tem on the first LBA device in the BIOS's list of
                  devices to try to boot from, using the BIOS INT 13
                  calls also used by pbslba. It does not understand
                  any form of partition table; see the EXAMPLES in
                  prep(8) for how to format such a device.  This has
                  been mostly useful for booting from USB devices so
                  far.

          sdB0    (Not in 9pxeload.) A special case of sdCn that uses
                  bios0 to read from a FAT file system.  Partitions
                  are understood.

        Kernel loading
          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.

          9pxeload differs slightly in operation from 9load. It is
          initially loaded by the PXE BIOS at physical address 0x7C00.
          Only devices which can be automatically configured, e.g.
          most PCI ethernet adapters, will be recognised.  If the file
          /cfg/pxe/ether can be located via a DHCP server, where ether
          is the lower-case MAC address of a recognised ethernet
          adapter, the contents are obtained and used as a plan9.ini.

          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

     Page 3                       Plan 9            (printed 12/21/24)

     9LOAD(8)                                                 9LOAD(8)

          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.

        Other facilities and caveats
          9load parses the master boot record and Plan 9 partition
          tables (see prep(8)), leaving partitioning information
          appended to the in-memory contents of plan9.ini for the
          bootfile. This is used by sd(3) to initialize partitions so
          that fossil(4) or kfs(4) file systems can be mounted as the
          root file system.  A more extensive partitioning is typi-
          cally 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.

          9pxeload differs slightly in operation from 9load. It is

     Page 4                       Plan 9            (printed 12/21/24)

     9LOAD(8)                                                 9LOAD(8)

          initially loaded by the PXE BIOS at physical address 0x7C00.
          Only devices which can be automatically configured, e.g.
          most PCI ethernet adapters, will be recognised.  If the file
          /cfg/pxe/XXXXXXXXXXXX can be located via a DHCP server,
          where XXXXXXXXXXXX is the MAC address of a recognised ether-
          net adapter, the contents are obtained and used as a
          plan9.ini.

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

          /386      most of these binaries reside here
          /cfg/pxe  directory of plan9.ini files on your TFTP server

     SOURCE
          /sys/src/boot/pc

     SEE ALSO
          booting(8), dhcpd(8), 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.

          The way 9pxeload obtains the information normally found in a
          disc plan9.ini file, and thereby the kernel to load and
          boot, is not ideal and may change in the future.

     Page 5                       Plan 9            (printed 12/21/24)