Преглед изворни кода

[int13] Allow drive to be hooked using the natural drive number

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>
tags/v1.20.1
Michael Brown пре 8 година
родитељ
комит
ab5b3abbba
3 измењених фајлова са 13 додато и 7 уклоњено
  1. 6
    2
      src/arch/x86/interface/pcbios/int13.c
  2. 1
    1
      src/include/ipxe/sanboot.h
  3. 6
    4
      src/usr/autoboot.c

+ 6
- 2
src/arch/x86/interface/pcbios/int13.c Прегледај датотеку

@@ -1588,7 +1588,7 @@ static void int13_free ( struct refcnt *refcnt ) {
1588 1588
  *
1589 1589
  * @v uri		URI
1590 1590
  * @v drive		Drive number
1591
- * @ret rc		Return status code
1591
+ * @ret drive		Drive number, or negative error
1592 1592
  *
1593 1593
  * Registers the drive with the INT 13 emulation subsystem, and hooks
1594 1594
  * the INT 13 interrupt vector (if not already hooked).
@@ -1603,6 +1603,10 @@ static int int13_hook ( struct uri *uri, unsigned int drive ) {
1603 1603
 	int13_sync_num_drives();
1604 1604
 	natural_drive = ( ( drive & 0x80 ) ? ( num_drives | 0x80 ) : num_fdds );
1605 1605
 
1606
+	/* Use natural drive number if directed to do so */
1607
+	if ( ( drive & 0x7f ) == 0x7f )
1608
+		drive = natural_drive;
1609
+
1606 1610
 	/* Check that drive number is not in use */
1607 1611
 	list_for_each_entry ( int13, &int13s, list ) {
1608 1612
 		if ( int13->drive == drive ) {
@@ -1661,7 +1665,7 @@ static int int13_hook ( struct uri *uri, unsigned int drive ) {
1661 1665
 	int13_sync_num_drives();
1662 1666
 
1663 1667
 	free ( scratch );
1664
-	return 0;
1668
+	return drive;
1665 1669
 
1666 1670
  err_guess_geometry:
1667 1671
  err_parse_iso9660:

+ 1
- 1
src/include/ipxe/sanboot.h Прегледај датотеку

@@ -70,7 +70,7 @@ unsigned int san_default_drive ( void );
70 70
  *
71 71
  * @v uri		URI
72 72
  * @v drive		Drive number
73
- * @ret rc		Return status code
73
+ * @ret drive		Drive number, or negative error
74 74
  */
75 75
 int san_hook ( struct uri *uri, unsigned int drive );
76 76
 

+ 6
- 4
src/usr/autoboot.c Прегледај датотеку

@@ -127,7 +127,9 @@ int uriboot ( struct uri *filename, struct uri *root_path, int drive,
127 127
 
128 128
 	/* Hook SAN device, if applicable */
129 129
 	if ( root_path ) {
130
-		if ( ( rc = san_hook ( root_path, drive ) ) != 0 ) {
130
+		drive = san_hook ( root_path, drive );
131
+		if ( drive < 0 ) {
132
+			rc = drive;
131 133
 			printf ( "Could not open SAN device: %s\n",
132 134
 				 strerror ( rc ) );
133 135
 			goto err_san_hook;
@@ -136,7 +138,7 @@ int uriboot ( struct uri *filename, struct uri *root_path, int drive,
136 138
 	}
137 139
 
138 140
 	/* Describe SAN device, if applicable */
139
-	if ( ( drive >= 0 ) && ! ( flags & URIBOOT_NO_SAN_DESCRIBE ) ) {
141
+	if ( ! ( flags & URIBOOT_NO_SAN_DESCRIBE ) ) {
140 142
 		if ( ( rc = san_describe ( drive ) ) != 0 ) {
141 143
 			printf ( "Could not describe SAN device %#02x: %s\n",
142 144
 				 drive, strerror ( rc ) );
@@ -170,7 +172,7 @@ int uriboot ( struct uri *filename, struct uri *root_path, int drive,
170 172
 	}
171 173
 
172 174
 	/* Attempt SAN boot if applicable */
173
-	if ( ( drive >= 0 ) && ! ( flags & URIBOOT_NO_SAN_BOOT ) ) {
175
+	if ( ! ( flags & URIBOOT_NO_SAN_BOOT ) ) {
174 176
 		if ( fetch_intz_setting ( NULL, &skip_san_boot_setting) == 0 ) {
175 177
 			printf ( "Booting from SAN device %#02x\n", drive );
176 178
 			rc = san_boot ( drive );
@@ -188,7 +190,7 @@ int uriboot ( struct uri *filename, struct uri *root_path, int drive,
188 190
  err_download:
189 191
  err_san_describe:
190 192
 	/* Unhook SAN device, if applicable */
191
-	if ( ( drive >= 0 ) && ! ( flags & URIBOOT_NO_SAN_UNHOOK ) ) {
193
+	if ( ! ( flags & URIBOOT_NO_SAN_UNHOOK ) ) {
192 194
 		if ( fetch_intz_setting ( NULL, &keep_san_setting ) == 0 ) {
193 195
 			san_unhook ( drive );
194 196
 			printf ( "Unregistered SAN device %#02x\n", drive );

Loading…
Откажи
Сачувај