11 #include <gpxe/list.h>
16 * @defgroup int13ops INT 13 operation codes
20 /** Reset disk system */
21 #define INT13_RESET 0x00
22 /** Get status of last operation */
23 #define INT13_GET_LAST_STATUS 0x01
25 #define INT13_READ_SECTORS 0x02
27 #define INT13_WRITE_SECTORS 0x03
28 /** Get drive parameters */
29 #define INT13_GET_PARAMETERS 0x08
31 #define INT13_GET_DISK_TYPE 0x15
32 /** Extensions installation check */
33 #define INT13_EXTENSION_CHECK 0x41
35 #define INT13_EXTENDED_READ 0x42
37 #define INT13_EXTENDED_WRITE 0x43
38 /** Get extended drive parameters */
39 #define INT13_GET_EXTENDED_PARAMETERS 0x48
44 * @defgroup int13status INT 13 status codes
48 /** Operation completed successfully */
49 #define INT13_STATUS_SUCCESS 0x00
50 /** Invalid function or parameter */
51 #define INT13_STATUS_INVALID 0x01
53 #define INT13_STATUS_READ_ERROR 0x04
55 #define INT13_STATUS_WRITE_ERROR 0xcc
59 /** Block size for non-extended INT 13 calls */
60 #define INT13_BLKSIZE 512
62 /** An INT 13 emulated drive */
64 /** List of all registered drives */
65 struct list_head list;
67 /** Underlying block device */
68 struct block_device *blockdev;
70 /** BIOS drive number (0x80-0xff) */
72 /** Number of cylinders
74 * The cylinder number field in an INT 13 call is ten bits
75 * wide, giving a maximum of 1024 cylinders. Conventionally,
76 * when the 7.8GB limit of a CHS address is exceeded, it is
77 * the number of cylinders that is increased beyond the
80 unsigned int cylinders;
83 * The head number field in an INT 13 call is eight bits wide,
84 * giving a maximum of 256 heads. However, apparently all
85 * versions of MS-DOS up to and including Win95 fail with 256
86 * heads, so the maximum encountered in practice is 255.
89 /** Number of sectors per track
91 * The sector number field in an INT 13 call is six bits wide,
92 * giving a maximum of 63 sectors, since sector numbering
93 * (unlike head and cylinder numbering) starts at 1, not 0.
95 unsigned int sectors_per_track;
97 /** Status of last operation */
101 /** An INT 13 disk address packet */
102 struct int13_disk_address {
103 /** Size of the packet, in bytes */
105 /** Reserved, must be zero */
110 struct segoff buffer;
111 /** Starting block number */
113 /** Data buffer (EDD-3.0 only) */
114 uint64_t buffer_phys;
117 /** INT 13 disk parameters */
118 struct int13_disk_parameters {
119 /** Size of this structure */
123 /** Number of cylinders */
125 /** Number of heads */
127 /** Number of sectors per track */
128 uint32_t sectors_per_track;
129 /** Total number of sectors on drive */
131 /** Bytes per sector */
132 uint16_t sector_size;
137 * @defgroup int13types INT 13 disk types
142 #define INT13_DISK_TYPE_NONE 0x00
143 /** Floppy without change-line support */
144 #define INT13_DISK_TYPE_FDD 0x01
145 /** Floppy with change-line support */
146 #define INT13_DISK_TYPE_FDD_CL 0x02
148 #define INT13_DISK_TYPE_HDD 0x03
153 * @defgroup int13flags INT 13 disk parameter flags
157 /** DMA boundary errors handled transparently */
158 #define INT13_FL_DMA_TRANSPARENT 0x01
159 /** CHS information is valid */
160 #define INT13_FL_CHS_VALID 0x02
161 /** Removable drive */
162 #define INT13_FL_REMOVABLE 0x04
163 /** Write with verify supported */
164 #define INT13_FL_VERIFIABLE 0x08
165 /** Has change-line supported (valid only for removable drives) */
166 #define INT13_FL_CHANGE_LINE 0x10
167 /** Drive can be locked (valid only for removable drives) */
168 #define INT13_FL_LOCKABLE 0x20
169 /** CHS is max possible, not current media (valid only for removable drives) */
170 #define INT13_FL_CHS_MAX 0x40
175 * @defgroup int13exts INT 13 extension flags
179 /** Extended disk access functions supported */
180 #define INT13_EXTENSION_LINEAR 0x01
181 /** Removable drive functions supported */
182 #define INT13_EXTENSION_REMOVABLE 0x02
183 /** EDD functions supported */
184 #define INT13_EXTENSION_EDD 0x04
189 * @defgroup int13vers INT 13 extension versions
193 /** INT13 extensions version 1.x */
194 #define INT13_EXTENSION_VER_1_X 0x01
195 /** INT13 extensions version 2.0 (EDD-1.0) */
196 #define INT13_EXTENSION_VER_2_0 0x20
197 /** INT13 extensions version 2.1 (EDD-1.1) */
198 #define INT13_EXTENSION_VER_2_1 0x21
199 /** INT13 extensions version 3.0 (EDD-3.0) */
200 #define INT13_EXTENSION_VER_3_0 0x30
204 extern void register_int13_drive ( struct int13_drive *drive );
205 extern void unregister_int13_drive ( struct int13_drive *drive );
206 extern int int13_boot ( unsigned int drive );