1 | [This documentation is rather crufty at the moment.] |
---|
2 | |
---|
3 | MEMDISK is meant to allow booting legacy operating systems via PXE, |
---|
4 | and as a workaround for BIOSes where ISOLINUX image support doesn't |
---|
5 | work. |
---|
6 | |
---|
7 | MEMDISK simulates a disk by claiming a chunk of high memory for the |
---|
8 | disk and a (very small - 2K typical) chunk of low (DOS) memory for the |
---|
9 | driver itself, then hooking the INT 13h (disk driver) and INT 15h |
---|
10 | (memory query) BIOS interrupts. |
---|
11 | |
---|
12 | MEMDISK allows for an OS to detect the MEMDISK instance. (See the |
---|
13 | "Additional technical information" section below.) |
---|
14 | |
---|
15 | To use it, type on the Syslinux command line: |
---|
16 | |
---|
17 | memdisk initrd=diskimg.img |
---|
18 | |
---|
19 | ... where diskimg.img is the disk image you want to boot from. |
---|
20 | |
---|
21 | [Obviously, the memdisk binary as well as your disk image file need to |
---|
22 | be present in the boot image directory.] |
---|
23 | |
---|
24 | ... or add to your syslinux.cfg/pxelinux.cfg/isolinux.cfg something like: |
---|
25 | |
---|
26 | label dos |
---|
27 | kernel memdisk |
---|
28 | append initrd=dosboot.img |
---|
29 | |
---|
30 | Note the following: |
---|
31 | |
---|
32 | a) The disk image can be uncompressed or compressed with gzip or zip. |
---|
33 | |
---|
34 | b) If the disk image is less than 4,194,304 bytes (4096K, 4 MB) it is |
---|
35 | assumed to be a floppy image and MEMDISK will try to guess its |
---|
36 | geometry based on the size of the file. MEMDISK recognizes all the |
---|
37 | standard floppy sizes as well as common extended formats: |
---|
38 | |
---|
39 | 163,840 bytes (160K) c=40 h=1 s=8 5.25" SSSD |
---|
40 | 184,320 bytes (180K) c=40 h=1 s=9 5.25" SSSD |
---|
41 | 327,680 bytes (320K) c=40 h=2 s=8 5.25" DSDD |
---|
42 | 368,640 bytes (360K) c=40 h=2 s=9 5.25" DSDD |
---|
43 | 655,360 bytes (640K) c=80 h=2 s=8 3.5" DSDD |
---|
44 | 737,280 bytes (720K) c=80 h=2 s=9 3.5" DSDD |
---|
45 | 1,222,800 bytes (1200K) c=80 h=2 s=15 5.25" DSHD |
---|
46 | 1,474,560 bytes (1440K) c=80 h=2 s=18 3.5" DSHD |
---|
47 | 1,638,400 bytes (1600K) c=80 h=2 s=20 3.5" DSHD (extended) |
---|
48 | 1,720,320 bytes (1680K) c=80 h=2 s=21 3.5" DSHD (extended) |
---|
49 | 1,763,328 bytes (1722K) c=82 h=2 s=21 3.5" DSHD (extended) |
---|
50 | 1,784,832 bytes (1743K) c=83 h=2 s=21 3.5" DSHD (extended) |
---|
51 | 1,802,240 bytes (1760K) c=80 h=2 s=22 3.5" DSHD (extended) |
---|
52 | 1,884,160 bytes (1840K) c=80 h=2 s=23 3.5" DSHD (extended) |
---|
53 | 1,966,080 bytes (1920K) c=80 h=2 s=24 3.5" DSHD (extended) |
---|
54 | 2,949,120 bytes (2880K) c=80 h=2 s=36 3.5" DSED |
---|
55 | 3,194,880 bytes (3120K) c=80 h=2 s=39 3.5" DSED (extended) |
---|
56 | 3,276,800 bytes (3200K) c=80 h=2 s=40 3.5" DSED (extended) |
---|
57 | 3,604,480 bytes (3520K) c=80 h=2 s=44 3.5" DSED (extended) |
---|
58 | 3,932,160 bytes (3840K) c=80 h=2 s=48 3.5" DSED (extended) |
---|
59 | |
---|
60 | A small perl script is included in the MEMDISK directory which can |
---|
61 | determine the geometry that MEMDISK would select for other sizes; |
---|
62 | in general MEMDISK will correctly detect most physical extended |
---|
63 | formats used, with 80 cylinders or slightly more. |
---|
64 | |
---|
65 | If the image is 4 MB or larger, it is assumed to be a hard disk |
---|
66 | image, and should typically have an MBR and a partition table. It |
---|
67 | may optionally have a DOSEMU geometry header; in which case the |
---|
68 | header is used to determine the C/H/S geometry of the disk. |
---|
69 | Otherwise, the geometry is determined by examining the partition |
---|
70 | table, so the entire image should be partitioned for proper |
---|
71 | operation (it may be divided between multiple partitions, however.) |
---|
72 | |
---|
73 | You can also specify the geometry manually with the following command |
---|
74 | line options: |
---|
75 | |
---|
76 | c=# Specify number of cylinders (max 1024[*]) |
---|
77 | h=# Specify number of heads (max 256[*]) |
---|
78 | s=# Specify number of sectors (max 63) |
---|
79 | floppy[=#] The image is a floppy image[**] |
---|
80 | harddisk[=#] The image is a hard disk image[**] |
---|
81 | iso The image is an El Torito ISO9660 image (drive 0xE0) |
---|
82 | |
---|
83 | # represents a decimal number. |
---|
84 | |
---|
85 | [*] MS-DOS only allows max 255 heads, and only allows 255 cylinders |
---|
86 | on floppy disks. |
---|
87 | |
---|
88 | [**] Normally MEMDISK emulates the first floppy or hard disk. This |
---|
89 | can be overridden by specifying an index, e.g. floppy=1 will |
---|
90 | simulate fd1 (B:). This may not work on all operating systems |
---|
91 | or BIOSes. |
---|
92 | |
---|
93 | c) The disk is normally writable (although, of course, there is |
---|
94 | nothing backing it up, so it only lasts until reset.) If you want, |
---|
95 | you can mimic a write-protected disk by specifying the command line |
---|
96 | option: |
---|
97 | |
---|
98 | ro Disk is readonly |
---|
99 | |
---|
100 | d) MEMDISK normally uses the BIOS "INT 15h mover" API to access high |
---|
101 | memory. This is well-behaved with extended memory managers which load |
---|
102 | later. Unfortunately it appears that the "DOS boot disk" from |
---|
103 | WinME/XP *deliberately* crash the system when this API is invoked. |
---|
104 | The following command-line options tells MEMDISK to enter protected |
---|
105 | mode directly, whenever possible: |
---|
106 | |
---|
107 | raw Use raw access to protected mode memory. |
---|
108 | |
---|
109 | bigraw Use raw access to protected mode memory, and leave the |
---|
110 | CPU in "big real" mode afterwards. |
---|
111 | |
---|
112 | int Use plain INT 15h access to protected memory. This assumes |
---|
113 | that anything which hooks INT 15h knows what it is doing. |
---|
114 | |
---|
115 | safeint Use INT 15h access to protected memory, but invoke |
---|
116 | INT 15h the way it was *before* MEMDISK was loaded. |
---|
117 | This is the default since version 3.73. |
---|
118 | |
---|
119 | e) MEMDISK by default supports EDD/EBIOS on hard disks, but not on |
---|
120 | floppy disks. This can be controlled with the options: |
---|
121 | |
---|
122 | edd Enable EDD/EBIOS |
---|
123 | noedd Disable EDD/EBIOS |
---|
124 | |
---|
125 | f) The following option can be used to pause to view the messages: |
---|
126 | |
---|
127 | pause Wait for a keypress right before booting |
---|
128 | |
---|
129 | g) The following option can be used to set the real-mode stack size. |
---|
130 | The default is 512 bytes, but if there is a failure it might be |
---|
131 | interesting to set it to something larger: |
---|
132 | |
---|
133 | stack=size Set the stack to "size" bytes |
---|
134 | |
---|
135 | h) Some systems without a floppy drive have been known to have |
---|
136 | problems with floppy images. To avoid that those problems, first |
---|
137 | of all make sure you don't have a floppy drive configured on the |
---|
138 | BIOS screen. If there is no option to configure that, or that |
---|
139 | doesn't work, you can use the option: |
---|
140 | |
---|
141 | nopass Hide all real drives of the same type (floppy or hard disk) |
---|
142 | nopassany Hide all real drives (floppy and hard disk) |
---|
143 | |
---|
144 | i) The following standard Linux option will mark memory as reserved. |
---|
145 | Please note that the Syslinux core already loads MEMDISK and its |
---|
146 | initrd below this point: |
---|
147 | |
---|
148 | mem=size Mark available memory above this point as Reserved. |
---|
149 | |
---|
150 | |
---|
151 | Some interesting things to note: |
---|
152 | |
---|
153 | If you're using MEMDISK to boot DOS from a CD-ROM (using ISOLINUX), |
---|
154 | you might find the generic El Torito CD-ROM driver by Gary Tong and |
---|
155 | Bart Lagerweij useful. It is now included with the Syslinux |
---|
156 | distribution, in the dosutil directory. See the file |
---|
157 | dosutil/eltorito.txt for more information. |
---|
158 | |
---|
159 | Similarly, if you're booting DOS over the network using PXELINUX, you |
---|
160 | can use the "keeppxe" option and use the generic PXE (UNDI) NDIS |
---|
161 | network driver, which is part of the PROBOOT.EXE distribution from |
---|
162 | Intel: |
---|
163 | |
---|
164 | http://www.intel.com/support/network/adapter/1000/software.htm |
---|
165 | |
---|
166 | |
---|
167 | Additional technical information: |
---|
168 | |
---|
169 | Starting with version 2.08, MEMDISK now supports an installation check |
---|
170 | API. This works as follows: |
---|
171 | |
---|
172 | EAX = 454D08xxh ("ME") (08h = parameter query) |
---|
173 | ECX = 444Dxxxxh ("MD") |
---|
174 | EDX = 5349xxnnh ("IS") (nn = drive #) |
---|
175 | EBX = 3F4Bxxxxh ("K?") |
---|
176 | INT 13h |
---|
177 | |
---|
178 | If drive nn is a MEMDISK, the registers will contain: |
---|
179 | |
---|
180 | EAX = 4D21xxxxh ("!M") |
---|
181 | ECX = 4D45xxxxh ("EM") |
---|
182 | EDX = 4944xxxxh ("DI") |
---|
183 | EBX = 4B53xxxxh ("SK") |
---|
184 | |
---|
185 | ES:DI -> MEMDISK info structures |
---|
186 | |
---|
187 | The low parts of EAX/ECX/EDX/EBX have the normal return values for INT |
---|
188 | 13h, AH=08h, i.e. information of the disk geometry etc. |
---|
189 | |
---|
190 | See Ralf Brown's interrupt list, |
---|
191 | http://www.cs.cmu.edu/afs/cs.cmu.edu/user/ralf/pub/WWW/files.html or |
---|
192 | http://www.ctyme.com/rbrown.htm, for a detailed description. |
---|
193 | |
---|
194 | The MEMDISK info structure currently contains: |
---|
195 | |
---|
196 | [ES:DI] word Total size of structure (currently 30 bytes) |
---|
197 | [ES:DI+2] byte MEMDISK minor version |
---|
198 | [ES:DI+3] byte MEMDISK major version |
---|
199 | [ES:DI+4] dword Pointer to MEMDISK data in high memory |
---|
200 | [ES:DI+8] dword Size of MEMDISK data in sectors |
---|
201 | [ES:DI+12] 16:16 Far pointer to command line |
---|
202 | [ES:DI+16] 16:16 Old INT 13h pointer |
---|
203 | [ES:DI+20] 16:16 Old INT 15h pointer |
---|
204 | [ES:DI+24] word Amount of DOS memory before MEMDISK loaded |
---|
205 | [ES:DI+26] byte Boot loader ID |
---|
206 | [ES:DI+27] byte Sector size as a power of 2 |
---|
207 | (If zero, assume 512-byte sectors) |
---|
208 | [ES:DI+28] word If nonzero, offset (vs ES) to installed DPT |
---|
209 | This pointer+16 contains the original INT 1Eh |
---|
210 | |
---|
211 | Sizes of this structure: |
---|
212 | |
---|
213 | 3.71+ 30 bytes Added DPT pointer |
---|
214 | 3.00-3.70 27 bytes Added boot loader ID |
---|
215 | pre-3.00 26 bytes |
---|
216 | |
---|
217 | In addition, the following fields are available at [ES:0]: |
---|
218 | |
---|
219 | [ES:0] word Offset of INT 13h routine (segment == ES) |
---|
220 | [ES:2] word Offset of INT 15h routine (segment == ES) |
---|
221 | |
---|
222 | The program mdiskchk.c in the sample directory is an example on how |
---|
223 | this API can be used. |
---|
224 | |
---|
225 | The following code can be used to "disable" MEMDISK. Note that it |
---|
226 | does not free the handler in DOS memory, and that running this from |
---|
227 | DOS will probably crash your machine (DOS doesn't like drives suddenly |
---|
228 | disappearing from underneath.) This is also not necessarily the best |
---|
229 | method for this. |
---|
230 | |
---|
231 | mov eax, 454D0800h |
---|
232 | mov ecx, 444D0000h |
---|
233 | mov edx, 53490000h |
---|
234 | mov dl,drive_number |
---|
235 | mov ebx, 3F4B0000h |
---|
236 | int 13h |
---|
237 | |
---|
238 | shr eax, 16 |
---|
239 | cmp ax, 4D21h |
---|
240 | jne not_memdisk |
---|
241 | shr ecx, 16 |
---|
242 | cmp cx, 4D45h |
---|
243 | jne not_memdisk |
---|
244 | shr edx, 16 |
---|
245 | cmp dx, 4944h |
---|
246 | jne not_memdisk |
---|
247 | shr ebx, 16 |
---|
248 | cmp bx, 4B53h |
---|
249 | jne not_memdisk |
---|
250 | |
---|
251 | cli |
---|
252 | mov bx,[es:0] ; INT 13h handler offset |
---|
253 | mov eax,[es:di+16] ; Old INT 13h handler |
---|
254 | mov byte [es:bx], 0EAh ; FAR JMP |
---|
255 | mov [es:bx+1], eax |
---|
256 | |
---|
257 | mov bx,[es:2] ; INT 15h handler offset |
---|
258 | mov eax,[es:di+20] ; Old INT 15h handler |
---|
259 | mov byte [es:bx], 0EAh ; FAR JMP |
---|
260 | mov [es:bx+1], eax |
---|
261 | sti |
---|
262 | |
---|
263 | MEMDISK supports the Win9x "safe hook" structure for OS detection. |
---|
264 | (See "Safe Master Boot Record INT 13h Hook Routines," available at |
---|
265 | http://www.osronline.com/ddkx/w98ddk/storage_5l6g.htm as of |
---|
266 | December 7th, 2009.) An OS driver can take a look at the INTerrupt table |
---|
267 | and try to walk along the chain of those hooks that implement the "safe hook" |
---|
268 | structure. For each hook discovered, a vendor can be identified and the OS |
---|
269 | driver can take appropriate action. The OS driver can mark the "flags" field |
---|
270 | of the "safe hook" to indicate that the driver has reviewed it already. This |
---|
271 | prevents accidental re-detection, for example. |
---|
272 | |
---|
273 | MEMDISK adds one additional extension field to the "safe hook" structure, a |
---|
274 | pointer to a special MEMDISK structure called the "mBFT." The mBFT is the |
---|
275 | "MEMDISK Boot Firmware Table" (akin to the iSCSI iBFT and the AoE aBFT). An |
---|
276 | OS driver looking at MEMDISK's "safe hook" should know that this field will |
---|
277 | be present based on the fact that MEMDISK is the vendor identifier. |
---|
278 | |
---|
279 | The mBFT is little more than an ACPI table to prefix MEMDISK's traditional |
---|
280 | MEMDISK info structure (the "MDI"). The ACPI table's details are: |
---|
281 | |
---|
282 | OEM ID. . . .: MEMDSK |
---|
283 | OEM Table ID : Syslinux |
---|
284 | |
---|
285 | There is a 1-byte checksum field which covers the length of the mBFT all |
---|
286 | the way through to the end of the MEMDISK info structure. |
---|
287 | |
---|
288 | There is also a physical pointer to the "safe hook" structure associated |
---|
289 | with the MEMDISK instance. An OS driver might use the following logic: |
---|
290 | |
---|
291 | 1. Walk INT 13h "safe hook" chain as far as possible, marking hooks as |
---|
292 | having been reviewed. For MEMDISK hooks, the driver then follows the |
---|
293 | pointer to the mBFT and gathers the RAM disk details from the included |
---|
294 | MDI. |
---|
295 | 2. The OS driver scans low memory for valid mBFTs. MEMDISK instances that |
---|
296 | have been "disconnected" from the INT 13h "safe hook" chain can be thus |
---|
297 | discovered. Looking at their associated "safe hook" structure will |
---|
298 | reveal if they were indeed reviewed by the previous stage. |
---|