#include <stdint.h>
#include <gpxe/list.h>
#include <realmode.h>
Go to the source code of this file.
Data Structures | |
| struct | int13_drive |
| An INT 13 emulated drive. More... | |
| struct | int13_disk_address |
| An INT 13 disk address packet. More... | |
| struct | int13_disk_parameters |
| INT 13 disk parameters. More... | |
| struct | int13_cdrom_specification |
| Bootable CD-ROM specification packet. More... | |
| struct | partition_chs |
| A C/H/S address within a partition table entry. More... | |
| struct | partition_table_entry |
| A partition table entry within the MBR. More... | |
| struct | master_boot_record |
| A Master Boot Record. More... | |
Defines | |
| #define | INT13_RESET 0x00 |
| Reset disk system. | |
| #define | INT13_GET_LAST_STATUS 0x01 |
| Get status of last operation. | |
| #define | INT13_READ_SECTORS 0x02 |
| Read sectors. | |
| #define | INT13_WRITE_SECTORS 0x03 |
| Write sectors. | |
| #define | INT13_GET_PARAMETERS 0x08 |
| Get drive parameters. | |
| #define | INT13_GET_DISK_TYPE 0x15 |
| Get disk type. | |
| #define | INT13_EXTENSION_CHECK 0x41 |
| Extensions installation check. | |
| #define | INT13_EXTENDED_READ 0x42 |
| Extended read. | |
| #define | INT13_EXTENDED_WRITE 0x43 |
| Extended write. | |
| #define | INT13_GET_EXTENDED_PARAMETERS 0x48 |
| Get extended drive parameters. | |
| #define | INT13_CDROM_STATUS_TERMINATE 0x4b |
| Get CD-ROM status / terminate emulation. | |
| #define | INT13_STATUS_SUCCESS 0x00 |
| Operation completed successfully. | |
| #define | INT13_STATUS_INVALID 0x01 |
| Invalid function or parameter. | |
| #define | INT13_STATUS_READ_ERROR 0x04 |
| Read error. | |
| #define | INT13_STATUS_WRITE_ERROR 0xcc |
| Write error. | |
| #define | INT13_BLKSIZE 512 |
| Block size for non-extended INT 13 calls. | |
| #define | INT13_DISK_TYPE_NONE 0x00 |
| No such drive. | |
| #define | INT13_DISK_TYPE_FDD 0x01 |
| Floppy without change-line support. | |
| #define | INT13_DISK_TYPE_FDD_CL 0x02 |
| Floppy with change-line support. | |
| #define | INT13_DISK_TYPE_HDD 0x03 |
| Hard disk. | |
| #define | INT13_FL_DMA_TRANSPARENT 0x01 |
| DMA boundary errors handled transparently. | |
| #define | INT13_FL_CHS_VALID 0x02 |
| CHS information is valid. | |
| #define | INT13_FL_REMOVABLE 0x04 |
| Removable drive. | |
| #define | INT13_FL_VERIFIABLE 0x08 |
| Write with verify supported. | |
| #define | INT13_FL_CHANGE_LINE 0x10 |
| Has change-line supported (valid only for removable drives). | |
| #define | INT13_FL_LOCKABLE 0x20 |
| Drive can be locked (valid only for removable drives). | |
| #define | INT13_FL_CHS_MAX 0x40 |
| CHS is max possible, not current media (valid only for removable drives). | |
| #define | INT13_EXTENSION_LINEAR 0x01 |
| Extended disk access functions supported. | |
| #define | INT13_EXTENSION_REMOVABLE 0x02 |
| Removable drive functions supported. | |
| #define | INT13_EXTENSION_EDD 0x04 |
| EDD functions supported. | |
| #define | INT13_EXTENSION_VER_1_X 0x01 |
| INT13 extensions version 1.x. | |
| #define | INT13_EXTENSION_VER_2_0 0x20 |
| INT13 extensions version 2.0 (EDD-1.0). | |
| #define | INT13_EXTENSION_VER_2_1 0x21 |
| INT13 extensions version 2.1 (EDD-1.1). | |
| #define | INT13_EXTENSION_VER_3_0 0x30 |
| INT13 extensions version 3.0 (EDD-3.0). | |
| #define | PART_HEAD(chs) ( (chs).head ) |
| #define | PART_SECTOR(chs) ( (chs).cyl_sector & 0x3f ) |
| #define | PART_CYLINDER(chs) ( (chs).cyl | ( ( (chs).cyl_sector & 0xc0 ) << 2 ) ) |
Functions | |
| FILE_LICENCE (GPL2_OR_LATER) | |
| void | register_int13_drive (struct int13_drive *drive) |
| Register INT 13 emulated drive. | |
| void | unregister_int13_drive (struct int13_drive *drive) |
| Unregister INT 13 emulated drive. | |
| int | int13_boot (unsigned int drive) |
| Attempt to boot from an INT 13 drive. | |
Variables | |
| struct int13_disk_address | packed |
| An INT 13 disk address packet. | |
Definition in file int13.h.
| #define INT13_BLKSIZE 512 |
Block size for non-extended INT 13 calls.
Definition at line 65 of file int13.h.
Referenced by guess_int13_geometry(), and int13_rw_sectors().
| #define PART_HEAD | ( | chs | ) | ( (chs).head ) |
| #define PART_SECTOR | ( | chs | ) | ( (chs).cyl_sector & 0x3f ) |
| #define PART_CYLINDER | ( | chs | ) | ( (chs).cyl | ( ( (chs).cyl_sector & 0xc0 ) << 2 ) ) |
| FILE_LICENCE | ( | GPL2_OR_LATER | ) |
| void register_int13_drive | ( | struct int13_drive * | drive | ) |
Register INT 13 emulated drive.
| drive | Emulated drive |
The underlying block device must be valid. A drive number and geometry will be assigned if left blank.
Definition at line 594 of file int13.c.
References BDA_NUM_DRIVES, BDA_SEG, int13_drive::cylinders, DBG, int13_drive::drive, get_real, guess_int13_geometry(), int13_drive::heads, hook_int13(), int13_set_num_drives(), int13_drive::list, list_add, list_empty(), int13_drive::natural_drive, num_drives, and int13_drive::sectors_per_track.
Referenced by aoeboot(), eltorito_exec(), ib_srpboot(), and iscsiboot().
00594 { 00595 uint8_t num_drives; 00596 00597 /* Give drive a default geometry if none specified */ 00598 guess_int13_geometry ( drive ); 00599 00600 /* Assign natural drive number */ 00601 get_real ( num_drives, BDA_SEG, BDA_NUM_DRIVES ); 00602 drive->natural_drive = ( num_drives | 0x80 ); 00603 00604 /* Assign drive number */ 00605 if ( ( drive->drive & 0xff ) == 0xff ) { 00606 /* Drive number == -1 => use natural drive number */ 00607 drive->drive = drive->natural_drive; 00608 } else { 00609 /* Use specified drive number (+0x80 if necessary) */ 00610 drive->drive |= 0x80; 00611 } 00612 00613 DBG ( "Registered INT13 drive %02x (naturally %02x) with C/H/S " 00614 "geometry %d/%d/%d\n", drive->drive, drive->natural_drive, 00615 drive->cylinders, drive->heads, drive->sectors_per_track ); 00616 00617 /* Hook INT 13 vector if not already hooked */ 00618 if ( list_empty ( &drives ) ) 00619 hook_int13(); 00620 00621 /* Add to list of emulated drives */ 00622 list_add ( &drive->list, &drives ); 00623 00624 /* Update BIOS drive count */ 00625 int13_set_num_drives(); 00626 }
| void unregister_int13_drive | ( | struct int13_drive * | drive | ) |
Unregister INT 13 emulated drive.
| drive | Emulated drive |
Definition at line 637 of file int13.c.
References DBG, int13_drive::drive, int13_drive::list, list_del, list_empty(), and unhook_int13().
Referenced by aoeboot(), eltorito_exec(), ib_srpboot(), and iscsiboot().
00637 { 00638 /* Remove from list of emulated drives */ 00639 list_del ( &drive->list ); 00640 00641 /* Should adjust BIOS drive count, but it's difficult to do so 00642 * reliably. 00643 */ 00644 00645 DBG ( "Unregistered INT13 drive %02x\n", drive->drive ); 00646 00647 /* Unhook INT 13 vector if no more drives */ 00648 if ( list_empty ( &drives ) ) 00649 unhook_int13(); 00650 }
| int int13_boot | ( | unsigned int | drive | ) |
Attempt to boot from an INT 13 drive.
| drive | Drive number |
| rc | Return status code |
Note that this function can never return success, by definition.
Definition at line 665 of file int13.c.
References __asm__(), be16_to_cpu, call_bootsector(), cpu_to_be16, DBG, ECANCELED, EIO, ENOEXEC, get_memmap(), REAL_CODE, and strerror().
Referenced by aoeboot(), ib_srpboot(), and iscsiboot().
00665 { 00666 struct memory_map memmap; 00667 int status, signature; 00668 int discard_c, discard_d; 00669 int rc; 00670 00671 DBG ( "Booting from INT 13 drive %02x\n", drive ); 00672 00673 /* Use INT 13 to read the boot sector */ 00674 __asm__ __volatile__ ( REAL_CODE ( "pushw %%es\n\t" 00675 "pushw $0\n\t" 00676 "popw %%es\n\t" 00677 "stc\n\t" 00678 "sti\n\t" 00679 "int $0x13\n\t" 00680 "sti\n\t" /* BIOS bugs */ 00681 "jc 1f\n\t" 00682 "xorl %%eax, %%eax\n\t" 00683 "\n1:\n\t" 00684 "movzwl %%es:0x7dfe, %%ebx\n\t" 00685 "popw %%es\n\t" ) 00686 : "=a" ( status ), "=b" ( signature ), 00687 "=c" ( discard_c ), "=d" ( discard_d ) 00688 : "a" ( 0x0201 ), "b" ( 0x7c00 ), 00689 "c" ( 1 ), "d" ( drive ) ); 00690 if ( status ) 00691 return -EIO; 00692 00693 /* Check signature is correct */ 00694 if ( signature != be16_to_cpu ( 0x55aa ) ) { 00695 DBG ( "Invalid disk signature %#04x (should be 0x55aa)\n", 00696 cpu_to_be16 ( signature ) ); 00697 return -ENOEXEC; 00698 } 00699 00700 /* Dump out memory map prior to boot, if memmap debugging is 00701 * enabled. Not required for program flow, but we have so 00702 * many problems that turn out to be memory-map related that 00703 * it's worth doing. 00704 */ 00705 get_memmap ( &memmap ); 00706 00707 /* Jump to boot sector */ 00708 if ( ( rc = call_bootsector ( 0x0, 0x7c00, drive ) ) != 0 ) { 00709 DBG ( "INT 13 drive %02x boot returned: %s\n", 00710 drive, strerror ( rc ) ); 00711 return rc; 00712 } 00713 00714 return -ECANCELED; /* -EIMPOSSIBLE */ 00715 }
| struct master_boot_record packed |
An INT 13 disk address packet.
A Master Boot Record.
A partition table entry within the MBR.
A C/H/S address within a partition table entry.
Bootable CD-ROM specification packet.
INT 13 disk parameters.
1.5.7.1