iPXE
int13.h
Go to the documentation of this file.
1#ifndef INT13_H
2#define INT13_H
4/** @file
5 *
6 * INT 13 emulation
7 *
8 */
10FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
12#include <stdint.h>
13#include <ipxe/list.h>
14#include <ipxe/edd.h>
15#include <realmode.h>
16
17/**
18 * @defgroup int13ops INT 13 operation codes
19 * @{
20 */
22/** Reset disk system */
23#define INT13_RESET 0x00
24/** Get status of last operation */
25#define INT13_GET_LAST_STATUS 0x01
26/** Read sectors */
27#define INT13_READ_SECTORS 0x02
28/** Write sectors */
29#define INT13_WRITE_SECTORS 0x03
30/** Get drive parameters */
31#define INT13_GET_PARAMETERS 0x08
32/** Get disk type */
33#define INT13_GET_DISK_TYPE 0x15
34/** Extensions installation check */
35#define INT13_EXTENSION_CHECK 0x41
36/** Extended read */
37#define INT13_EXTENDED_READ 0x42
38/** Extended write */
39#define INT13_EXTENDED_WRITE 0x43
40/** Verify sectors */
41#define INT13_EXTENDED_VERIFY 0x44
42/** Extended seek */
43#define INT13_EXTENDED_SEEK 0x47
44/** Get extended drive parameters */
45#define INT13_GET_EXTENDED_PARAMETERS 0x48
46/** Get CD-ROM status / terminate emulation */
47#define INT13_CDROM_STATUS_TERMINATE 0x4b
48/** Read CD-ROM boot catalog */
49#define INT13_CDROM_READ_BOOT_CATALOG 0x4d
50
51/** @} */
52
53/**
54 * @defgroup int13status INT 13 status codes
55 * @{
56 */
57
58/** Operation completed successfully */
59#define INT13_STATUS_SUCCESS 0x00
60/** Invalid function or parameter */
61#define INT13_STATUS_INVALID 0x01
62/** Read error */
63#define INT13_STATUS_READ_ERROR 0x04
64/** Reset failed */
65#define INT13_STATUS_RESET_FAILED 0x05
66/** Write error */
67#define INT13_STATUS_WRITE_ERROR 0xcc
68
69/** @} */
70
71/** Block size for non-extended INT 13 calls */
72#define INT13_BLKSIZE 512
73
74/** @defgroup int13fddtype INT 13 floppy disk drive types
75 * @{
76 */
77
78/** 360K */
79#define INT13_FDD_TYPE_360K 0x01
80/** 1.2M */
81#define INT13_FDD_TYPE_1M2 0x02
82/** 720K */
83#define INT13_FDD_TYPE_720K 0x03
84/** 1.44M */
85#define INT13_FDD_TYPE_1M44 0x04
86
87/** An INT 13 disk address packet */
89 /** Size of the packet, in bytes */
91 /** Reserved */
93 /** Block count */
95 /** Reserved */
97 /** Data buffer */
98 struct segoff buffer;
99 /** Starting block number */
101 /** Data buffer (EDD 3.0+ only) */
103 /** Block count (EDD 4.0+ only) */
105 /** Reserved */
107} __attribute__ (( packed ));
108
109/** INT 13 disk parameters */
111 /** Size of this structure */
113 /** Flags */
115 /** Number of cylinders */
117 /** Number of heads */
119 /** Number of sectors per track */
121 /** Total number of sectors on drive */
123 /** Bytes per sector */
125 /** Device parameter table extension */
126 struct segoff dpte;
127 /** Device path information */
129} __attribute__ (( packed ));
130
131/**
132 * @defgroup int13types INT 13 disk types
133 * @{
134 */
135
136/** No such drive */
137#define INT13_DISK_TYPE_NONE 0x00
138/** Floppy without change-line support */
139#define INT13_DISK_TYPE_FDD 0x01
140/** Floppy with change-line support */
141#define INT13_DISK_TYPE_FDD_CL 0x02
142/** Hard disk */
143#define INT13_DISK_TYPE_HDD 0x03
144
145/** @} */
146
147/**
148 * @defgroup int13flags INT 13 disk parameter flags
149 * @{
150 */
151
152/** DMA boundary errors handled transparently */
153#define INT13_FL_DMA_TRANSPARENT 0x01
154/** CHS information is valid */
155#define INT13_FL_CHS_VALID 0x02
156/** Removable drive */
157#define INT13_FL_REMOVABLE 0x04
158/** Write with verify supported */
159#define INT13_FL_VERIFIABLE 0x08
160/** Has change-line supported (valid only for removable drives) */
161#define INT13_FL_CHANGE_LINE 0x10
162/** Drive can be locked (valid only for removable drives) */
163#define INT13_FL_LOCKABLE 0x20
164/** CHS is max possible, not current media (valid only for removable drives) */
165#define INT13_FL_CHS_MAX 0x40
166
167/** @} */
168
169/**
170 * @defgroup int13exts INT 13 extension flags
171 * @{
172 */
173
174/** Extended disk access functions supported */
175#define INT13_EXTENSION_LINEAR 0x01
176/** Removable drive functions supported */
177#define INT13_EXTENSION_REMOVABLE 0x02
178/** EDD functions supported */
179#define INT13_EXTENSION_EDD 0x04
180/** 64-bit extensions are present */
181#define INT13_EXTENSION_64BIT 0x08
182
183/** @} */
184
185/**
186 * @defgroup int13vers INT 13 extension versions
187 * @{
188 */
189
190/** INT13 extensions version 1.x */
191#define INT13_EXTENSION_VER_1_X 0x01
192/** INT13 extensions version 2.0 (EDD-1.0) */
193#define INT13_EXTENSION_VER_2_0 0x20
194/** INT13 extensions version 2.1 (EDD-1.1) */
195#define INT13_EXTENSION_VER_2_1 0x21
196/** INT13 extensions version 3.0 (EDD-3.0) */
197#define INT13_EXTENSION_VER_3_0 0x30
198
199/** @} */
200
201/** Maximum number of sectors for which CHS geometry is allowed to be valid
202 *
203 * This number is taken from the EDD specification.
204 */
205#define INT13_MAX_CHS_SECTORS 15482880
206
207/** Bootable CD-ROM specification packet */
209 /** Size of packet in bytes */
211 /** Boot media type */
213 /** Drive number */
215 /** CD-ROM controller number */
217 /** LBA of disk image to emulate */
219 /** Device specification */
221 /** Segment of 3K buffer for caching CD-ROM reads */
223 /** Load segment for initial boot image */
225 /** Number of 512-byte sectors to load */
227 /** Low 8 bits of cylinder number */
229 /** Sector number, plus high 2 bits of cylinder number */
231 /** Head number */
233} __attribute__ (( packed ));
234
235/** Bootable CD-ROM boot catalog command packet */
237 /** Size of packet in bytes */
239 /** Number of sectors of boot catalog to read */
241 /** Buffer for boot catalog */
243 /** First sector in boot catalog to transfer */
245} __attribute__ (( packed ));
246
247/** A C/H/S address within a partition table entry */
249 /** Head number */
251 /** Sector number, plus high 2 bits of cylinder number */
253 /** Low 8 bits of cylinder number */
255} __attribute__ (( packed ));
256
257#define PART_HEAD(chs) ( (chs).head )
258#define PART_SECTOR(chs) ( (chs).cyl_sector & 0x3f )
259#define PART_CYLINDER(chs) ( (chs).cyl | ( ( (chs).cyl_sector & 0xc0 ) << 2 ) )
260
261/** A partition table entry within the MBR */
263 /** Bootable flag */
265 /** C/H/S start address */
267 /** System indicator (partition type) */
269 /** C/H/S end address */
271 /** Linear start address */
273 /** Linear length */
275} __attribute__ (( packed ));
276
277/** A Master Boot Record */
279 /** Code area */
281 /** Disk signature */
283 /** Padding */
285 /** Partition table */
287 /** 0x55aa MBR signature */
289} __attribute__ (( packed ));
290
291/** MBR magic signature */
292#define INT13_MBR_MAGIC 0xaa55
293
294/** A floppy disk geometry */
296 /** Number of tracks */
298 /** Number of heads and sectors per track */
301
302/** Define a floppy disk geometry */
303#define INT13_FDD_GEOMETRY( cylinders, heads, sectors ) \
304 { \
305 .tracks = (cylinders), \
306 .heads_spt = ( ( (heads) << 6 ) | (sectors) ), \
307 }
308
309/** Get floppy disk number of cylinders */
310#define INT13_FDD_CYLINDERS( geometry ) ( (geometry)->tracks )
311
312/** Get floppy disk number of heads */
313#define INT13_FDD_HEADS( geometry ) ( (geometry)->heads_spt >> 6 )
314
315/** Get floppy disk number of sectors per track */
316#define INT13_FDD_SECTORS( geometry ) ( (geometry)->heads_spt & 0x3f )
317
318/** A floppy drive parameter table */
332
333#endif /* INT13_H */
unsigned short uint16_t
Definition stdint.h:11
unsigned int uint32_t
Definition stdint.h:12
unsigned long long uint64_t
Definition stdint.h:13
unsigned char uint8_t
Definition stdint.h:10
Enhanced Disk Drive specification.
uint8_t cyl
Low 8 bits of cylinder number.
Definition int13.h:228
uint8_t bufsize
Size of the packet, in bytes.
Definition int13.h:90
uint8_t drive
Drive number.
Definition int13.h:214
uint64_t lba
Starting block number.
Definition int13.h:100
uint8_t pad[2]
Padding.
Definition int13.h:284
uint32_t signature
Disk signature.
Definition int13.h:282
uint64_t sectors
Total number of sectors on drive.
Definition int13.h:122
uint8_t format_gap_length
Definition int13.h:327
uint16_t start
First sector in boot catalog to transfer.
Definition int13.h:244
uint8_t cyl
Low 8 bits of cylinder number.
Definition int13.h:254
uint8_t controller
CD-ROM controller number.
Definition int13.h:216
uint8_t data_length
Definition int13.h:326
uint32_t start
Linear start address.
Definition int13.h:272
uint8_t motor_start_time
Definition int13.h:330
uint32_t lba
LBA of disk image to emulate.
Definition int13.h:218
uint8_t format_filler
Definition int13.h:328
uint8_t bootable
Bootable flag.
Definition int13.h:264
uint16_t flags
Flags.
Definition int13.h:114
uint8_t bytes_per_sector
Definition int13.h:323
uint8_t gap_length
Definition int13.h:325
uint16_t bufsize
Size of this structure.
Definition int13.h:112
uint8_t motor_off_delay
Definition int13.h:322
uint16_t sector_size
Bytes per sector.
Definition int13.h:124
uint32_t sectors_per_track
Number of sectors per track.
Definition int13.h:120
uint8_t size
Size of packet in bytes.
Definition int13.h:238
uint8_t cyl_sector
Sector number, plus high 2 bits of cylinder number.
Definition int13.h:230
uint8_t head_settle_time
Definition int13.h:329
uint8_t heads_spt
Number of heads and sectors per track.
Definition int13.h:299
struct partition_chs chs_end
C/H/S end address.
Definition int13.h:270
uint32_t reserved_c
Reserved.
Definition int13.h:106
uint32_t length
Linear length.
Definition int13.h:274
uint64_t buffer_phys
Data buffer (EDD 3.0+ only)
Definition int13.h:102
uint8_t size
Size of packet in bytes.
Definition int13.h:210
uint8_t count
Number of sectors of boot catalog to read.
Definition int13.h:240
uint8_t type
System indicator (partition type)
Definition int13.h:268
struct partition_chs chs_start
C/H/S start address.
Definition int13.h:266
uint32_t buffer
Buffer for boot catalog.
Definition int13.h:242
uint8_t step_rate__head_unload
Definition int13.h:320
struct int13_fdd_geometry __attribute__
uint32_t long_count
Block count (EDD 4.0+ only)
Definition int13.h:104
uint8_t head
Head number.
Definition int13.h:250
uint8_t tracks
Number of tracks.
Definition int13.h:297
uint8_t head_load__ndma
Definition int13.h:321
uint8_t code[440]
Code area.
Definition int13.h:280
uint8_t head
Head number.
Definition int13.h:232
uint8_t sectors_per_track
Definition int13.h:324
struct edd_device_path_information dpi
Device path information.
Definition int13.h:128
uint8_t cyl_sector
Sector number, plus high 2 bits of cylinder number.
Definition int13.h:252
uint16_t cache_segment
Segment of 3K buffer for caching CD-ROM reads.
Definition int13.h:222
uint8_t reserved_b
Reserved.
Definition int13.h:96
struct segoff buffer
Data buffer.
Definition int13.h:98
uint8_t reserved_a
Reserved.
Definition int13.h:92
uint8_t media_type
Boot media type.
Definition int13.h:212
uint16_t load_segment
Load segment for initial boot image.
Definition int13.h:224
struct segoff dpte
Device parameter table extension.
Definition int13.h:126
uint32_t heads
Number of heads.
Definition int13.h:118
uint32_t cylinders
Number of cylinders.
Definition int13.h:116
uint16_t magic
0x55aa MBR signature
Definition int13.h:288
struct partition_table_entry partitions[4]
Partition table.
Definition int13.h:286
uint8_t count
Block count.
Definition int13.h:94
uint16_t device
Device specification.
Definition int13.h:220
uint16_t load_sectors
Number of 512-byte sectors to load.
Definition int13.h:226
#define FILE_LICENCE(_licence)
Declare a particular licence as applying to a file.
Definition compiler.h:896
Linked lists.
EDD device path information.
Definition edd.h:163
Bootable CD-ROM boot catalog command packet.
Definition int13.h:236
Bootable CD-ROM specification packet.
Definition int13.h:208
An INT 13 disk address packet.
Definition int13.h:88
INT 13 disk parameters.
Definition int13.h:110
A floppy disk geometry.
Definition int13.h:295
A floppy drive parameter table.
Definition int13.h:319
A Master Boot Record.
Definition int13.h:278
A C/H/S address within a partition table entry.
Definition int13.h:248
A partition table entry within the MBR.
Definition int13.h:262