1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183
|
extipl::Develop.txt
April 30, 1999
takamiti@tsden.org
extipl@tsden.org
http://www.tsden.org/takamiti/extipl/
(translation into English by Ryutaroh Matsumoto <ryutaroh@tsden.org>)
==============================================================================
1. Who This Document Is For
This document is provided for skilled programmers want to modify
existing IPLs or write their own IPL. It cannot be used easily by
everyone. Please use it at your own risk. Expected readers of this
document are those who easily read the source code of Extended-IPL.
If you make a better IPL using this package, please email to extipl@tsden.org.
1.1. Usage
You can make your own IPL with following procedure. The current directory
is assumed to be extipl/sample.
(0) Get "nasm" from http://www.web-sites.co.uk/nasm/ and install it.
(1) Write you own IPL code and save it as myipl.asm.
(2) Adding the following line to Makefile:
myipl.bin : myipl.asm
and do "make myipl.bin".
Then you will get myipl.bin. This is the binary image of your IPL.
(3) Examine carefully correctness of myipl.bin, otherwise critical results
may happen. You can get file "_BootSec" by following command.
extipl -d install myipl.bin
"_BootSec" is an image which extipl tries to replace MBR with.
You can examine the correctness with "_BootSec" in more realistic setting.
(4) Following command write your IPL to MBR of hard disk.
extipl install myipl.bin
If your IPL behaves as if it was loaded from hard disk when it is loaded
from floppy disk, you can write your IPL to floppy disk by following
command and verify correctness without changing hard disk MBR.
extipl fdtest myipl.bin
When installation of your IPL, extipl discards 447th and later bytes
of myipl.bin. Note that the length of space allowed for IPL is 446 bytes
in MBR.
2. How to compile extipl
We verified that extipl can be compiled under Linux 2.0.36, FreeBSD
2.2.8R, and 3.1R.
2.1 FreeBSD
Enter the subdirectory "src" and type "make". If make fails, try Gnu make
or modify the Makefile appropriately.
2.2 Linux
Enter the subdirectory "src" and type "make".
3. About Example
We provide an example that can do both LBA (logical block addressing)
access and traditional CHS (cylinder/head/sector) adressing access.
It consists of
lba_xipl.asm, lbafdsim.asm, and lba_main.asm.
Since an IPL must be smaller than 447 bytes, we omit the function
as follows. the example cannot change the bootable partition. The
password function of DR-DOS cannot be used because of the large size
of the IPL. The error processing is not strict.
It is easy to make the example LBA access only. If so, we can put more
function into the IPL, but a problem arise when it is used for non-LBA
harddisk.
4 Technical information
4.1 Memory map
In booting procedure of IBM PC/AT compatibles, BIOS load MBR to address
0x07c00 and execute it. Extended-IPL relocates itself to 0x0600 and starts
its job. After relocation, memory map becomes as follows.
| |
^ ^
|----------------------|
| |
| 512 bytes | <- Extended-IPL loads first 512 bytes of
| | booting partition here. Extended-IPL also
| | loaded here.
0x07C00 +======================+ <- upper bound of Extended-IPL stack
| | (SP register is set to 0x07c000)
^ ^
|------------------55AA| <- partition validity indicator 0xAA55
0x007BE |______64_bytes________| <- partition table
| |
| 446 bytes | <- code and data of Extended-IPL
| |
0x00600 +======================+
| |
^ ^
| |
| | <- interrupt vector and system reserved region
| |
0x00000 +----------------------+
/////////////////////////////////////////////////////////////////////////
4.2 What Extended-IPL is doing
After Extended-IPL relocate itself to 0x0600 do the following step.
(1) See if shift key is pressed while floppy drive motor is turned on.
If shift key is pressed, go to (3).
(2) Search partition marked active. If it is found and has partition validity
indicator 0xaa55, go to (4.5). If active partition does not have 0xaa55,
makes beep sound.
(3) Display partition table and "Boot#h:d.p", which indicates that the
partition `p' in the depth `d' in the harddisk `h' is selected.
(4) Wait for keyboard input. Check pressed key in following steps.
(4.1) If key is "0", "1", "2", "3" or "4", update and display selected
partition number and return to (4).
(4.2) If key is neither <Enter> nor <End>, make beep sound
and return to (4).
(4.3) If the selected number is "0", load first 512 bytes of next HD to
0x07c000 and copy partition table to 0x07be and go to (3).
(4.4) If the selected partition is an empty partition, make beep sound and
return to (4).
(4.5) If the selected partition is an extended partition, load first
512 bytes of the extended partition 0x07c000, copy the partition
table to 0x07be, increase the depth, and redisplay the prompt,
and go to (3).
(4.6) Load first 512 bytes of selected partition to 0x7c00.
(a) If key is <Enter> or it comes from (2), check 0xaa55 and go to (5).
(b) If key is <End>, check 0xaa55, mark selected partition
bootable only if the selected partition is a primary
partition in the first HD, and go to (5).
(5) Execute OS specific loader in first 512 bytes in selected partition by
jump to 0x7c00. Each register has following content.
ax, bx, cx, dh, di, bp: undefined.
dl = BIOS drive number of OS specific loader (0x80, 0x81, ...)
ds = data segment of Extended-IPL
si = relative address of selected partition information. Let n be
the selected partition number, value of si is
si = 0x07be + 16 * (n - 1)
OS specific loader can get its partition information from address
indicated by ds:si. Extended-IPL set bootable flag in partition
information at address ds:si.
(note: In IBM technical information, only value of ds:si is specified.)
4.3 How Extended-IPL boots OS on non-1st hard disk
In this section we explain how Extended-IPL passes the drive number to
OS specific loader.
A partition table is equivalent to the following structure.
typedef unsigned char byte;
typedef struct {
byte head;
byte sector;
byte cyl;
} hd_addr;
typedef struct {
byte bootind; <<--- active flag
hd_addr start;
byte systemind;
hd_addr end;
unsigned long start_sector;
unsigned long nr_sectors;
} partition;
If partition.bootind is 0x80, its partition is marked bootable. If it is
0x00, its partition is marked not bootable. If HD unit number is n,
Extended-IPL sets partition.bootind to 0x80 + n, then execute OS specific
loader. Thus OS specific loader can know which HD unit it resides as
the value partition.bootind & 0x7f.
|