Browse Source

[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 years ago
parent
commit
ab5b3abbba
3 changed files with 13 additions and 7 deletions
  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 View File

1588
  *
1588
  *
1589
  * @v uri		URI
1589
  * @v uri		URI
1590
  * @v drive		Drive number
1590
  * @v drive		Drive number
1591
- * @ret rc		Return status code
1591
+ * @ret drive		Drive number, or negative error
1592
  *
1592
  *
1593
  * Registers the drive with the INT 13 emulation subsystem, and hooks
1593
  * Registers the drive with the INT 13 emulation subsystem, and hooks
1594
  * the INT 13 interrupt vector (if not already hooked).
1594
  * the INT 13 interrupt vector (if not already hooked).
1603
 	int13_sync_num_drives();
1603
 	int13_sync_num_drives();
1604
 	natural_drive = ( ( drive & 0x80 ) ? ( num_drives | 0x80 ) : num_fdds );
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
 	/* Check that drive number is not in use */
1610
 	/* Check that drive number is not in use */
1607
 	list_for_each_entry ( int13, &int13s, list ) {
1611
 	list_for_each_entry ( int13, &int13s, list ) {
1608
 		if ( int13->drive == drive ) {
1612
 		if ( int13->drive == drive ) {
1661
 	int13_sync_num_drives();
1665
 	int13_sync_num_drives();
1662
 
1666
 
1663
 	free ( scratch );
1667
 	free ( scratch );
1664
-	return 0;
1668
+	return drive;
1665
 
1669
 
1666
  err_guess_geometry:
1670
  err_guess_geometry:
1667
  err_parse_iso9660:
1671
  err_parse_iso9660:

+ 1
- 1
src/include/ipxe/sanboot.h View File

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

+ 6
- 4
src/usr/autoboot.c View File

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

Loading…
Cancel
Save