]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[int13] Allow drive to be hooked using the natural drive number
authorMichael Brown <mcb30@ipxe.org>
Sun, 20 Mar 2016 09:16:13 +0000 (09:16 +0000)
committerMichael Brown <mcb30@ipxe.org>
Tue, 22 Mar 2016 09:55:09 +0000 (09:55 +0000)
Interpret the maximum drive number (0xff for hard disks, 0x7f for
floppy disks) as meaning "use natural drive number".

Signed-off-by: Michael Brown <mcb30@ipxe.org>
src/arch/x86/interface/pcbios/int13.c
src/include/ipxe/sanboot.h
src/usr/autoboot.c

index 38880e4f0b985589ae5e62b2c141d5ca3d61adc4..3b3f87306876d97eb01f332514c515c8baa3e6bc 100644 (file)
@@ -1588,7 +1588,7 @@ static void int13_free ( struct refcnt *refcnt ) {
  *
  * @v uri              URI
  * @v drive            Drive number
- * @ret rc             Return status code
+ * @ret drive          Drive number, or negative error
  *
  * Registers the drive with the INT 13 emulation subsystem, and hooks
  * the INT 13 interrupt vector (if not already hooked).
@@ -1603,6 +1603,10 @@ static int int13_hook ( struct uri *uri, unsigned int drive ) {
        int13_sync_num_drives();
        natural_drive = ( ( drive & 0x80 ) ? ( num_drives | 0x80 ) : num_fdds );
 
+       /* Use natural drive number if directed to do so */
+       if ( ( drive & 0x7f ) == 0x7f )
+               drive = natural_drive;
+
        /* Check that drive number is not in use */
        list_for_each_entry ( int13, &int13s, list ) {
                if ( int13->drive == drive ) {
@@ -1661,7 +1665,7 @@ static int int13_hook ( struct uri *uri, unsigned int drive ) {
        int13_sync_num_drives();
 
        free ( scratch );
-       return 0;
+       return drive;
 
  err_guess_geometry:
  err_parse_iso9660:
index 57025f2c62460f4d822d15df6007b4fe4c0f0e05..041e18935c0708060125197b02fb69ae1c57551f 100644 (file)
@@ -70,7 +70,7 @@ unsigned int san_default_drive ( void );
  *
  * @v uri              URI
  * @v drive            Drive number
- * @ret rc             Return status code
+ * @ret drive          Drive number, or negative error
  */
 int san_hook ( struct uri *uri, unsigned int drive );
 
index e93b0150de4ce22872bed87a13b0ec7cb132f108..57bf96ef28ce7c85585dba000e3e17ac5435c263 100644 (file)
@@ -127,7 +127,9 @@ int uriboot ( struct uri *filename, struct uri *root_path, int drive,
 
        /* Hook SAN device, if applicable */
        if ( root_path ) {
-               if ( ( rc = san_hook ( root_path, drive ) ) != 0 ) {
+               drive = san_hook ( root_path, drive );
+               if ( drive < 0 ) {
+                       rc = drive;
                        printf ( "Could not open SAN device: %s\n",
                                 strerror ( rc ) );
                        goto err_san_hook;
@@ -136,7 +138,7 @@ int uriboot ( struct uri *filename, struct uri *root_path, int drive,
        }
 
        /* Describe SAN device, if applicable */
-       if ( ( drive >= 0 ) && ! ( flags & URIBOOT_NO_SAN_DESCRIBE ) ) {
+       if ( ! ( flags & URIBOOT_NO_SAN_DESCRIBE ) ) {
                if ( ( rc = san_describe ( drive ) ) != 0 ) {
                        printf ( "Could not describe SAN device %#02x: %s\n",
                                 drive, strerror ( rc ) );
@@ -170,7 +172,7 @@ int uriboot ( struct uri *filename, struct uri *root_path, int drive,
        }
 
        /* Attempt SAN boot if applicable */
-       if ( ( drive >= 0 ) && ! ( flags & URIBOOT_NO_SAN_BOOT ) ) {
+       if ( ! ( flags & URIBOOT_NO_SAN_BOOT ) ) {
                if ( fetch_intz_setting ( NULL, &skip_san_boot_setting) == 0 ) {
                        printf ( "Booting from SAN device %#02x\n", drive );
                        rc = san_boot ( drive );
@@ -188,7 +190,7 @@ int uriboot ( struct uri *filename, struct uri *root_path, int drive,
  err_download:
  err_san_describe:
        /* Unhook SAN device, if applicable */
-       if ( ( drive >= 0 ) && ! ( flags & URIBOOT_NO_SAN_UNHOOK ) ) {
+       if ( ! ( flags & URIBOOT_NO_SAN_UNHOOK ) ) {
                if ( fetch_intz_setting ( NULL, &keep_san_setting ) == 0 ) {
                        san_unhook ( drive );
                        printf ( "Unregistered SAN device %#02x\n", drive );