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
30 /** Extensions installation check */
31 #define INT13_EXTENSION_CHECK 0x41
33 #define INT13_EXTENDED_READ 0x42
35 #define INT13_EXTENDED_WRITE 0x43
36 /** Get extended drive parameters */
37 #define INT13_GET_EXTENDED_PARAMETERS 0x48
42 * @defgroup int13status INT 13 status codes
46 /** Operation completed successfully */
47 #define INT13_STATUS_SUCCESS 0x00
48 /** Invalid function or parameter */
49 #define INT13_STATUS_INVALID 0x01
51 #define INT13_STATUS_READ_ERROR 0x04
53 #define INT13_STATUS_WRITE_ERROR 0xcc
57 /** Block size for non-extended INT 13 calls */
58 #define INT13_BLKSIZE 512
60 /** An INT 13 emulated drive */
62 /** List of all registered drives */
63 struct list_head list;
65 /** Underlying block device */
66 struct block_device *blockdev;
68 /** BIOS drive number (0x80-0xff) */
70 /** Number of cylinders
72 * The cylinder number field in an INT 13 call is ten bits
73 * wide, giving a maximum of 1024 cylinders. Conventionally,
74 * when the 7.8GB limit of a CHS address is exceeded, it is
75 * the number of cylinders that is increased beyond the
78 unsigned int cylinders;
81 * The head number field in an INT 13 call is eight bits wide,
82 * giving a maximum of 256 heads. However, apparently all
83 * versions of MS-DOS up to and including Win95 fail with 256
84 * heads, so the maximum encountered in practice is 255.
87 /** Number of sectors per track
89 * The sector number field in an INT 13 call is six bits wide,
90 * giving a maximum of 63 sectors, since sector numbering
91 * (unlike head and cylinder numbering) starts at 1, not 0.
93 unsigned int sectors_per_track;
95 /** Status of last operation */
99 /** An INT 13 disk address packet */
100 struct int13_disk_address {
101 /** Size of the packet, in bytes */
103 /** Reserved, must be zero */
108 struct segoff buffer;
109 /** Starting block number */
111 /** Data buffer (EDD-3.0 only) */
112 uint64_t buffer_phys;
115 /** INT 13 disk parameters */
116 struct int13_disk_parameters {
117 /** Size of this structure */
121 /** Number of cylinders */
123 /** Number of heads */
125 /** Number of sectors per track */
126 uint32_t sectors_per_track;
127 /** Total number of sectors on drive */
129 /** Bytes per sector */
130 uint16_t sector_size;
135 * @defgroup int13flags INT 13 disk parameter flags
139 /** DMA boundary errors handled transparently */
140 #define INT13_FL_DMA_TRANSPARENT 0x01
141 /** CHS information is valid */
142 #define INT13_FL_CHS_VALID 0x02
143 /** Removable drive */
144 #define INT13_FL_REMOVABLE 0x04
145 /** Write with verify supported */
146 #define INT13_FL_VERIFIABLE 0x08
147 /** Has change-line supported (valid only for removable drives) */
148 #define INT13_FL_CHANGE_LINE 0x10
149 /** Drive can be locked (valid only for removable drives) */
150 #define INT13_FL_LOCKABLE 0x20
151 /** CHS is max possible, not current media (valid only for removable drives) */
152 #define INT13_FL_CHS_MAX 0x40
157 * @defgroup int13exts INT 13 extension flags
161 /** Extended disk access functions supported */
162 #define INT13_EXTENSION_LINEAR 0x01
163 /** Removable drive functions supported */
164 #define INT13_EXTENSION_REMOVABLE 0x02
165 /** EDD functions supported */
166 #define INT13_EXTENSION_EDD 0x04
171 * @defgroup int13vers INT 13 extension versions
175 /** INT13 extensions version 1.x */
176 #define INT13_EXTENSION_VER_1_X 0x01
177 /** INT13 extensions version 2.0 (EDD-1.0) */
178 #define INT13_EXTENSION_VER_2_0 0x20
179 /** INT13 extensions version 2.1 (EDD-1.1) */
180 #define INT13_EXTENSION_VER_2_1 0x21
181 /** INT13 extensions version 3.0 (EDD-3.0) */
182 #define INT13_EXTENSION_VER_3_0 0x30
186 extern void register_int13_drive ( struct int13_drive *drive );
187 extern void unregister_int13_drive ( struct int13_drive *drive );
188 extern int int13_boot ( unsigned int drive );