Merge commit 'origin/gptmbr'
[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 one of the following sizes, it's assumed to be a
32    floppy image:
33
34      368,640 bytes -  360K floppy
35      737,280 bytes -  720K floppy
36    1,222,800 bytes - 1200K floppy
37    1,474,560 bytes - 1440K floppy
38    1,720,320 bytes - 1680K floppy (common extended format)
39    1,763,328 bytes - 1722K floppy (common extended format)
40    2,949,120 bytes - 2880K floppy
41    3,932,160 bytes - 3840K floppy (extended format)
42
43    For any other size, the image is assumed to be a hard disk image,
44    and should typically have an MBR and a partition table.  It may
45    optionally have a DOSEMU geometry header; in which case the header
46    is used to determine the C/H/S geometry of the disk.  Otherwise,
47    the geometry is determined by examining the partition table, so the
48    entire image should be partitioned for proper operation (it may be
49    divided between multiple partitions, however.)
50
51    You can also specify the geometry manually with the following command
52    line options:
53
54    c=#          Specify number of cylinders (max 1024[*])
55    h=#          Specify number of heads (max 256[*])
56    s=#          Specify number of sectors (max 63)
57    floppy[=#]   The image is a floppy image[**]
58    harddisk[=#] The image is a hard disk image[**]
59
60    # represents a decimal number.
61
62     [*] MS-DOS only allows max 255 heads, and only allows 255 cylinders
63         on floppy disks.
64
65    [**] Normally MEMDISK emulates the first floppy or hard disk.  This
66         can be overridden by specifying an index, e.g. floppy=1 will
67         simulate fd1 (B:). This may not work on all operating systems
68         or BIOSes.
69
70 c) The disk is normally writable (although, of course, there is
71    nothing backing it up, so it only lasts until reset.)  If you want,
72    you can mimic a write-protected disk by specifying the command line
73    option:
74
75    ro           Disk is readonly
76
77 d) MEMDISK normally uses the BIOS "INT 15h mover" API to access high
78    memory.  This is well-behaved with extended memory managers which load
79    later.  Unfortunately it appears that the "DOS boot disk" from
80    WinME/XP *deliberately* crash the system when this API is invoked.
81    The following command-line options tells MEMDISK to enter protected
82    mode directly, whenever possible:
83
84    raw          Use raw access to protected mode memory.
85
86    bigraw       Use raw access to protected mode memory, and leave the
87                 CPU in "big real" mode afterwards.
88
89    safeint      Use INT 15h access to protected memory, but invoke
90                 INT 15h the way it was *before* MEMDISK was loaded.
91
92 e) MEMDISK by default supports EDD/EBIOS on hard disks, but not on
93    floppy disks.  This can be controlled with the options:
94
95    edd          Enable EDD/EBIOS
96    noedd        Disable EDD/EBIOS
97
98
99 Some interesting things to note:
100
101 If you're using MEMDISK to boot DOS from a CD-ROM (using ISOLINUX),
102 you might find the generic El Torito CD-ROM driver by Gary Tong and
103 Bart Lagerweij useful:
104
105         http://www.nu2.nu/eltorito/
106
107
108 Similarly, if you're booting DOS over the network using PXELINUX, you
109 can use the "keeppxe" option and use the generic PXE (UNDI) NDIS
110 network driver, which is part of the PROBOOT.EXE distribution from
111 Intel:
112
113         http://www.intel.com/support/network/adapter/1000/software.htm
114
115
116 Additional technical information:
117
118 Starting with version 2.08, MEMDISK now supports an installation check
119 API.  This works as follows:
120
121         EAX = 454D08xxh ("ME") (08h = parameter query)
122         ECX = 444Dxxxxh ("MD")
123         EDX = 5349xxnnh ("IS") (nn = drive #)
124         EBX = 3F4Bxxxxh ("K?")
125         INT 13h
126
127 If drive nn is a MEMDISK, the registers will contain:
128
129         EAX = 4D21xxxxh ("!M")
130         ECX = 4D45xxxxh ("EM")
131         EDX = 4944xxxxh ("DI")
132         EBX = 4B53xxxxh ("SK")
133
134         ES:DI -> MEMDISK info structures
135
136 The low parts of EAX/ECX/EDX/EBX have the normal return values for INT
137 13h, AH=08h, i.e. information of the disk geometry etc.
138
139 See Ralf Brown's interrupt list,
140 http://www.cs.cmu.edu/afs/cs.cmu.edu/user/ralf/pub/WWW/files.html or
141 http://www.ctyme.com/rbrown.htm, for a detailed description.
142
143 The MEMDISK info structure currently contains:
144
145         [ES:DI]         word    Total size of structure (currently 28 bytes)
146         [ES:DI+2]       byte    MEMDISK minor version
147         [ES:DI+3]       byte    MEMDISK major version
148         [ES:DI+4]       dword   Pointer to MEMDISK data in high memory
149         [ES:DI+8]       dword   Size of MEMDISK data in 512-byte sectors
150         [ES:DI+12]      16:16   Far pointer to command line
151         [ES:DI+16]      16:16   Old INT 13h pointer
152         [ES:DI+20]      16:16   Old INT 15h pointer
153         [ES:DI+24]      word    Amount of DOS memory before MEMDISK loaded
154         [ES:DI+26]      byte    Boot loader ID
155
156 MEMDISK 3.00 and higher has the size of this structure as 27; earlier
157 versions had size 26 and did not include the boot loader ID.
158
159 In addition, the following fields are available at [ES:0]:
160
161         [ES:0]          word    Offset of INT 13h routine (segment == ES)
162         [ES:2]          word    Offset of INT 15h routine (segment == ES)
163
164 The program mdiskchk.c in the sample directory is an example on how
165 this API can be used.
166
167 The following code can be used to "disable" MEMDISK.  Note that it
168 does not free the handler in DOS memory, and that running this from
169 DOS will probably crash your machine (DOS doesn't like drives
170 suddenly disappearing from underneath):
171
172         mov eax, 454D0800h
173         mov ecx, 444D0000h
174         mov edx, 53490000h
175         mov dl,drive_number
176         mov ebx, 3F4B0000h
177         int 13h
178
179         shr eax, 16
180         cmp ax, 4D21h
181         jne not_memdisk
182         shr ecx, 16
183         cmp cx, 4D45h
184         jne not_memdisk
185         shr edx, 16
186         cmp dx, 4944h
187         jne not_memdisk
188         shr ebx, 16
189         cmp bx, 4B53h
190         jne not_memdisk
191
192         cli
193         mov bx,[es:0]           ; INT 13h handler offset
194         mov eax,[es:di+16]      ; Old INT 13h handler
195         mov byte [es:bx], 0EAh  ; FAR JMP
196         mov [es:bx+1], eax
197
198         mov bx,[es:2]           ; INT 15h handler offset
199         mov eax,[es:di+20]      ; Old INT 15h handler
200         mov byte [es:bx], 0EAh  ; FAR JMP
201         mov [es:bx+1], eax
202         sti