Merge remote branch 'hpa/master'
[profile/ivi/syslinux.git] / doc / memdisk.txt
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 To use it, type on the Syslinux command line:
13
14 memdisk initrd=diskimg.img
15
16 ... where diskimg.img is the disk image you want to boot from.
17
18 [Obviously, the memdisk binary as well as your disk image file need to
19 be present in the boot image directory.]
20
21 ... or add to your syslinux.cfg/pxelinux.cfg/isolinux.cfg something like:
22
23 label dos
24     kernel memdisk
25     append initrd=dosboot.img
26
27 Note the following:
28
29 a) The disk image can be uncompressed or compressed with gzip or zip.
30
31 b) If the disk image is less than 4,194,304 bytes (4096K, 4 MB) it is
32    assumed to be a floppy image and MEMDISK will try to guess its
33    geometry based on the size of the file.  MEMDISK recognizes all the
34    standard floppy sizes as well as common extended formats:
35
36      163,840 bytes  (160K) c=40 h=1 s=8         5.25" SSSD
37      184,320 bytes  (180K) c=40 h=1 s=9         5.25" SSSD
38      327,680 bytes  (320K) c=40 h=2 s=8         5.25" DSDD
39      368,640 bytes  (360K) c=40 h=2 s=9         5.25" DSDD
40      655,360 bytes  (640K) c=80 h=2 s=8         3.5"  DSDD
41      737,280 bytes  (720K) c=80 h=2 s=9         3.5"  DSDD
42    1,222,800 bytes (1200K) c=80 h=2 s=15        5.25" DSHD
43    1,474,560 bytes (1440K) c=80 h=2 s=18        3.5"  DSHD
44    1,638,400 bytes (1600K) c=80 h=2 s=20        3.5"  DSHD (extended)
45    1,720,320 bytes (1680K) c=80 h=2 s=21        3.5"  DSHD (extended)
46    1,763,328 bytes (1722K) c=82 h=2 s=21        3.5"  DSHD (extended)
47    1,784,832 bytes (1743K) c=83 h=2 s=21        3.5"  DSHD (extended)
48    1,802,240 bytes (1760K) c=80 h=2 s=22        3.5"  DSHD (extended)
49    1,884,160 bytes (1840K) c=80 h=2 s=23        3.5"  DSHD (extended)
50    1,966,080 bytes (1920K) c=80 h=2 s=24        3.5"  DSHD (extended)
51    2,949,120 bytes (2880K) c=80 h=2 s=36        3.5"  DSED
52    3,194,880 bytes (3120K) c=80 h=2 s=39        3.5"  DSED (extended)
53    3,276,800 bytes (3200K) c=80 h=2 s=40        3.5"  DSED (extended)
54    3,604,480 bytes (3520K) c=80 h=2 s=44        3.5"  DSED (extended)
55    3,932,160 bytes (3840K) c=80 h=2 s=48        3.5"  DSED (extended)
56
57    A small perl script is included in the MEMDISK directory which can
58    determine the geometry that MEMDISK would select for other sizes;
59    in general MEMDISK will correctly detect most physical extended
60    formats used, with 80 cylinders or slightly more.
61
62    If the image is 4 MB or larger, it is assumed to be a hard disk
63    image, and should typically have an MBR and a partition table.  It
64    may optionally have a DOSEMU geometry header; in which case the
65    header is used to determine the C/H/S geometry of the disk.
66    Otherwise, the geometry is determined by examining the partition
67    table, so the entire image should be partitioned for proper
68    operation (it may be divided between multiple partitions, however.)
69
70    You can also specify the geometry manually with the following command
71    line options:
72
73    c=#          Specify number of cylinders (max 1024[*])
74    h=#          Specify number of heads (max 256[*])
75    s=#          Specify number of sectors (max 63)
76    floppy[=#]   The image is a floppy image[**]
77    harddisk[=#] The image is a hard disk image[**]
78    iso          The image is an El Torito ISO9660 image (drive 0xE0)
79
80    # represents a decimal number.
81
82     [*] MS-DOS only allows max 255 heads, and only allows 255 cylinders
83         on floppy disks.
84
85    [**] Normally MEMDISK emulates the first floppy or hard disk.  This
86         can be overridden by specifying an index, e.g. floppy=1 will
87         simulate fd1 (B:). This may not work on all operating systems
88         or BIOSes.
89
90 c) The disk is normally writable (although, of course, there is
91    nothing backing it up, so it only lasts until reset.)  If you want,
92    you can mimic a write-protected disk by specifying the command line
93    option:
94
95    ro           Disk is readonly
96
97 d) MEMDISK normally uses the BIOS "INT 15h mover" API to access high
98    memory.  This is well-behaved with extended memory managers which load
99    later.  Unfortunately it appears that the "DOS boot disk" from
100    WinME/XP *deliberately* crash the system when this API is invoked.
101    The following command-line options tells MEMDISK to enter protected
102    mode directly, whenever possible:
103
104    raw          Use raw access to protected mode memory.
105
106    bigraw       Use raw access to protected mode memory, and leave the
107                 CPU in "big real" mode afterwards.
108
109    int          Use plain INT 15h access to protected memory.  This assumes
110                 that anything which hooks INT 15h knows what it is doing.
111
112    safeint      Use INT 15h access to protected memory, but invoke
113                 INT 15h the way it was *before* MEMDISK was loaded.
114                 This is the default since version 3.73.
115
116 e) MEMDISK by default supports EDD/EBIOS on hard disks, but not on
117    floppy disks.  This can be controlled with the options:
118
119    edd          Enable EDD/EBIOS
120    noedd        Disable EDD/EBIOS
121
122 f) The following option can be used to pause to view the messages:
123
124    pause        Wait for a keypress right before booting
125
126 g) The following option can be used to set the real-mode stack size.
127    The default is 512 bytes, but if there is a failure it might be
128    interesting to set it to something larger:
129
130    stack=size   Set the stack to "size" bytes
131
132
133 Some interesting things to note:
134
135 If you're using MEMDISK to boot DOS from a CD-ROM (using ISOLINUX),
136 you might find the generic El Torito CD-ROM driver by Gary Tong and
137 Bart Lagerweij useful:
138
139         http://www.nu2.nu/eltorito/
140
141
142 Similarly, if you're booting DOS over the network using PXELINUX, you
143 can use the "keeppxe" option and use the generic PXE (UNDI) NDIS
144 network driver, which is part of the PROBOOT.EXE distribution from
145 Intel:
146
147         http://www.intel.com/support/network/adapter/1000/software.htm
148
149
150 Additional technical information:
151
152 Starting with version 2.08, MEMDISK now supports an installation check
153 API.  This works as follows:
154
155         EAX = 454D08xxh ("ME") (08h = parameter query)
156         ECX = 444Dxxxxh ("MD")
157         EDX = 5349xxnnh ("IS") (nn = drive #)
158         EBX = 3F4Bxxxxh ("K?")
159         INT 13h
160
161 If drive nn is a MEMDISK, the registers will contain:
162
163         EAX = 4D21xxxxh ("!M")
164         ECX = 4D45xxxxh ("EM")
165         EDX = 4944xxxxh ("DI")
166         EBX = 4B53xxxxh ("SK")
167
168         ES:DI -> MEMDISK info structures
169
170 The low parts of EAX/ECX/EDX/EBX have the normal return values for INT
171 13h, AH=08h, i.e. information of the disk geometry etc.
172
173 See Ralf Brown's interrupt list,
174 http://www.cs.cmu.edu/afs/cs.cmu.edu/user/ralf/pub/WWW/files.html or
175 http://www.ctyme.com/rbrown.htm, for a detailed description.
176
177 The MEMDISK info structure currently contains:
178
179         [ES:DI]         word    Total size of structure (currently 30 bytes)
180         [ES:DI+2]       byte    MEMDISK minor version
181         [ES:DI+3]       byte    MEMDISK major version
182         [ES:DI+4]       dword   Pointer to MEMDISK data in high memory
183         [ES:DI+8]       dword   Size of MEMDISK data in 512-byte sectors
184         [ES:DI+12]      16:16   Far pointer to command line
185         [ES:DI+16]      16:16   Old INT 13h pointer
186         [ES:DI+20]      16:16   Old INT 15h pointer
187         [ES:DI+24]      word    Amount of DOS memory before MEMDISK loaded
188         [ES:DI+26]      byte    Boot loader ID
189         [ES:DI+27]      byte    Currently unused
190         [ES:DI+28]      word    If nonzero, offset (vs ES) to installed DPT
191                                 This pointer+16 contains the original INT 1Eh
192
193 Sizes of this structure:
194
195 3.71+           30 bytes        Added DPT pointer
196 3.00-3.70       27 bytes        Added boot loader ID
197 pre-3.00        26 bytes
198
199 In addition, the following fields are available at [ES:0]:
200
201         [ES:0]          word    Offset of INT 13h routine (segment == ES)
202         [ES:2]          word    Offset of INT 15h routine (segment == ES)
203
204 The program mdiskchk.c in the sample directory is an example on how
205 this API can be used.
206
207 The following code can be used to "disable" MEMDISK.  Note that it
208 does not free the handler in DOS memory, and that running this from
209 DOS will probably crash your machine (DOS doesn't like drives suddenly
210 disappearing from underneath.)  This is also not necessarily the best
211 method for this.
212
213         mov eax, 454D0800h
214         mov ecx, 444D0000h
215         mov edx, 53490000h
216         mov dl,drive_number
217         mov ebx, 3F4B0000h
218         int 13h
219
220         shr eax, 16
221         cmp ax, 4D21h
222         jne not_memdisk
223         shr ecx, 16
224         cmp cx, 4D45h
225         jne not_memdisk
226         shr edx, 16
227         cmp dx, 4944h
228         jne not_memdisk
229         shr ebx, 16
230         cmp bx, 4B53h
231         jne not_memdisk
232
233         cli
234         mov bx,[es:0]           ; INT 13h handler offset
235         mov eax,[es:di+16]      ; Old INT 13h handler
236         mov byte [es:bx], 0EAh  ; FAR JMP
237         mov [es:bx+1], eax
238
239         mov bx,[es:2]           ; INT 15h handler offset
240         mov eax,[es:di+20]      ; Old INT 15h handler
241         mov byte [es:bx], 0EAh  ; FAR JMP
242         mov [es:bx+1], eax
243         sti