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_EXTENDED_READ 0x42
33 #define INT13_EXTENDED_WRITE 0x43
34 /** Get extended drive parameters */
35 #define INT13_GET_EXTENDED_PARAMETERS 0x48
40 * @defgroup int13status INT 13 status codes
44 /** Operation completed successfully */
45 #define INT13_STATUS_SUCCESS 0x00
46 /** Invalid function or parameter */
47 #define INT13_STATUS_INVALID 0x01
49 #define INT13_STATUS_READ_ERROR 0x04
51 #define INT13_STATUS_WRITE_ERROR 0xcc
55 /** Block size for non-extended INT 13 calls */
56 #define INT13_BLKSIZE 512
58 /** An INT 13 emulated drive */
60 /** List of all registered drives */
61 struct list_head list;
63 /** Underlying block device */
64 struct block_device *blockdev;
66 /** BIOS drive number (0x80-0xff) */
68 /** Number of cylinders
70 * The cylinder number field in an INT 13 call is ten bits
71 * wide, giving a maximum of 1024 cylinders. Conventionally,
72 * when the 7.8GB limit of a CHS address is exceeded, it is
73 * the number of cylinders that is increased beyond the
76 unsigned int cylinders;
79 * The head number field in an INT 13 call is eight bits wide,
80 * giving a maximum of 256 heads. However, apparently all
81 * versions of MS-DOS up to and including Win95 fail with 256
82 * heads, so the maximum encountered in practice is 255.
85 /** Number of sectors per track
87 * The sector number field in an INT 13 call is six bits wide,
88 * giving a maximum of 63 sectors, since sector numbering
89 * (unlike head and cylinder numbering) starts at 1, not 0.
91 unsigned int sectors_per_track;
93 /** Status of last operation */
97 /** An INT 13 disk address packet */
98 struct int13_disk_address {
99 /** Size of the packet, in bytes */
101 /** Reserved, must be zero */
106 struct segoff buffer;
107 /** Starting block number */
109 /** Data buffer (EDD-3.0 only) */
110 uint64_t buffer_phys;
113 /** INT 13 disk parameters */
114 struct int13_disk_parameters {
115 /** Size of this structure */
119 /** Number of cylinders */
121 /** Number of heads */
123 /** Number of sectors per track */
124 uint32_t sectors_per_track;
125 /** Total number of sectors on drive */
127 /** Bytes per sector */
128 uint16_t sector_size;
133 * @defgroup int13flags INT 13 disk parameter flags
137 /** DMA boundary errors handled transparently */
138 #define INT13_FL_DMA_TRANSPARENT 0x01
139 /** CHS information is valid */
140 #define INT13_FL_CHS_VALID 0x02
141 /** Removable drive */
142 #define INT13_FL_REMOVABLE 0x04
143 /** Write with verify supported */
144 #define INT13_FL_VERIFIABLE 0x08
145 /** Has change-line supported (valid only for removable drives) */
146 #define INT13_FL_CHANGE_LINE 0x10
147 /** Drive can be locked (valid only for removable drives) */
148 #define INT13_FL_LOCKABLE 0x20
149 /** CHS is max possible, not current media (valid only for removable drives) */
150 #define INT13_FL_CHS_MAX 0x40
154 extern void register_int13_drive ( struct int13_drive *drive );
155 extern void unregister_int13_drive ( struct int13_drive *drive );