dloader

Write a boot loader to a disk on an x86 system

Syntax:

dloader

dloader [-v] [-d drive_number] [-F|H] [device loader]...

Runs on:

QNX Neutrino

Targets:

x86

Options:

-d drive_number
Set the BIOS drive number for booting the second-stage loader (*pc2). This lets you set up the loader to boot when the drive is configured as either a primary or secondary drive. Common values for drive_number are 80 for the first hard drive, and 81 for the second one.
If you don't specify this option or any of the other override options (-F, -H), a heuristic based on disk size and removability determines whether the drive is for a fixed or removable disk. The order of precedence used to determine the drive number to be patched into the loader code is:
  1. -d
  2. -F
  3. -H
  4. heuristic
-F
Use the removable-disk loader (originally for floppies, hence the “F”).
-H
Use the hard-disk loader.
-v
Be verbose.
device
The device name of the raw or partition disk mountpoint.
loader
The loader name. An option of this type must follow each device option.

Description:

The dloader utility writes boot loaders to disks on x86 systems (32- or 64-bit architecture). You can run the utility without any options to make it list the loaders shipped with the platform. These loaders support both 32- and 64- bit architectures and are found in a specific path within the processor family subdirectory in the QNX target files on the host. For SDP 7.0, this path is target/qnx7/x86/boot/sys within the SDP installation directory.

If you run dloader with options, you must include at least one device loader option pair. Specifying multiple pairs lets you write stage 1 and stage 2 loaders to disk using a single dloader invocation.

The utility starts by looking for each loader you specified. If the loader name contains a / (slash), dloader assumes it's a complete pathname and looks for that path. If the name doesn't contain a slash, dloader looks in target/qnx7/x86/boot/sys, which is the standard path for loaders (for both 32- and 64-bit architectures).

The loader naming framework provides a way of specifying our shipped QNX loaders and your own custom loaders. The framework consists of a loader name and a syntax for specifying optional variants.

Currently, the QNX Neutrino RTOS supports the following two forms for loader names:
prefixpc1*
This is the standard first-stage (partition) loader on a PC. This loader has to fit in less than one block (block 0—the first block—of the physical disk); the BIOS itself will have jumped to this block content when the hardware board was first powered on. The first-stage loader's job is basic; it just identifies a bootable OS partition, reads one block from the start of that partition into memory, then jumps into (begins executing) it.
perfixpc2*
This is the standard second-stage (OS-specific) loader on a PC. This loader's job is more complicated because it needs to understand the particular filesystem format and boot the OS. For this reason, there are more variants for this loader type, often based on the filesystem (e.g., QNX4 vs. Power-Safe or QNX6). Depending on the variation, this loader can be a single or multiple blocks but its first block is always written to the first block of the OS partition.
Note that each bootable OS must provide a corresponding second-stage loader.

More details about these two loader types and what exactly they do during system startup are given in the x86 disk boot IPLs section of Building Embedded Systems. Because the two loaders get written to different physical locations, you have to be careful to match the drive name given in the device option (e.g., /dev/hd0 or /dev/hd0t179) with the loader code that you are writing to that device.

The device names for our shipped loaders are prefixed with ipl-disk. So if you run dloader without any options (or look in target/qnx7/x86/boot/sys/), you will see the following loaders:
  • ipl-diskpc1
  • ipl-diskpc1-nomsg
  • ipl-diskpc2
  • ipl-diskpc2-fsq6

If you wish to write and use your own loaders, you must include this ipl-disk naming prefix but you can provide your own unique variant names. If the loader is in the standard path given above, you don't have to specify the ipl-disk prefix on the command line because dloader adds it for you. But if your loader is in a different directory, you have to specify the exact path, including the prefix.

Assuming you specified a device and loader correctly, dloader opens the device in the specified path and, if you selected the verbose option, displays the device's disk and partition information. The specified loader data are then put together and written to the disk.

Note: The removable disk (-F) option forces dloader to treat a fixed device (e.g., a hard disk) as if it were a removable device, and the hard disk (-H) option does the opposite.

Examples:

Display a list of available disk loaders:
dloader
Write a PC partition loader to a hard disk:
dloader /dev/hd0 pc1
Write a custom partition loader to the second hard disk:
dloader -d 81 /dev/hd1 /home/joe/ipl-diskpc1-tst
Write a QNX-specific second-stage PC loader to a Power-Safe partition:
dloader /dev/hd0t179 pc2
Write a QNX loader to a “removable” disk:
dloader -F /dev/dsk1 pc2

Exit status:

0
The loader was written to the disk.
Any other value
An error occurred. In these cases, dloader sends a description of the error to stderr.