Skip to content

Commit

Permalink
[int13] Add support for emulating floppy disk drives
Browse files Browse the repository at this point in the history
Tested-by: Robin Smidsrød <robin@smidsrod.no>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
  • Loading branch information
mcb30 committed Mar 30, 2012
1 parent cf0953a commit 4dbb193
Show file tree
Hide file tree
Showing 3 changed files with 297 additions and 56 deletions.
1 change: 1 addition & 0 deletions src/arch/i386/include/bios.h
Expand Up @@ -4,6 +4,7 @@
FILE_LICENCE ( GPL2_OR_LATER );

#define BDA_SEG 0x0040
#define BDA_EQUIPMENT_WORD 0x0010
#define BDA_FBMS 0x0013
#define BDA_NUM_DRIVES 0x0075

Expand Down
52 changes: 52 additions & 0 deletions src/arch/i386/include/int13.h
Expand Up @@ -71,6 +71,19 @@ FILE_LICENCE ( GPL2_OR_LATER );
/** Block size for non-extended INT 13 calls */
#define INT13_BLKSIZE 512

/** @defgroup int13fddtype INT 13 floppy disk drive types
* @{
*/

/** 360K */
#define INT13_FDD_TYPE_360K 0x01
/** 1.2M */
#define INT13_FDD_TYPE_1M2 0x02
/** 720K */
#define INT13_FDD_TYPE_720K 0x03
/** 1.44M */
#define INT13_FDD_TYPE_1M44 0x04

/** An INT 13 disk address packet */
struct int13_disk_address {
/** Size of the packet, in bytes */
Expand Down Expand Up @@ -394,4 +407,43 @@ enum eltorito_media_type {
ELTORITO_NO_EMULATION = 0,
};

/** A floppy disk geometry */
struct int13_fdd_geometry {
/** Number of tracks */
uint8_t tracks;
/** Number of heads and sectors per track */
uint8_t heads_spt;
};

/** Define a floppy disk geometry */
#define INT13_FDD_GEOMETRY( cylinders, heads, sectors ) \
{ \
.tracks = (cylinders), \
.heads_spt = ( ( (heads) << 6 ) | (sectors) ), \
}

/** Get floppy disk number of cylinders */
#define INT13_FDD_CYLINDERS( geometry ) ( (geometry)->tracks )

/** Get floppy disk number of heads */
#define INT13_FDD_HEADS( geometry ) ( (geometry)->heads_spt >> 6 )

/** Get floppy disk number of sectors per track */
#define INT13_FDD_SECTORS( geometry ) ( (geometry)->heads_spt & 0x3f )

/** A floppy drive parameter table */
struct int13_fdd_parameters {
uint8_t step_rate__head_unload;
uint8_t head_load__ndma;
uint8_t motor_off_delay;
uint8_t bytes_per_sector;
uint8_t sectors_per_track;
uint8_t gap_length;
uint8_t data_length;
uint8_t format_gap_length;
uint8_t format_filler;
uint8_t head_settle_time;
uint8_t motor_start_time;
} __attribute__ (( packed ));

#endif /* INT13_H */

0 comments on commit 4dbb193

Please sign in to comment.