]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[block] Centralise "san-drive" setting
authorMichael Brown <mcb30@ipxe.org>
Mon, 6 Mar 2017 12:25:20 +0000 (12:25 +0000)
committerMichael Brown <mcb30@ipxe.org>
Tue, 7 Mar 2017 13:40:35 +0000 (13:40 +0000)
The concept of the SAN drive number is meaningful only in a BIOS
environment, where it represents the INT13 drive number (0x80 for the
first hard disk).  We retain this concept in a UEFI environment to
allow for a simple way for iPXE commands to refer to SAN drives.

Centralise the concept of the default drive number, since it is shared
between all supported environments.

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

index 3e03e8c5db62e622417ba67ee046e1cc2d5215ad..283e5be7da2ccf97392bd1965d7bbe7dd7f7922e 100644 (file)
@@ -44,8 +44,6 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
 #include <ipxe/pci.h>
 #include <ipxe/iso9660.h>
 #include <ipxe/eltorito.h>
-#include <ipxe/dhcp.h>
-#include <ipxe/settings.h>
 #include <realmode.h>
 #include <bios.h>
 #include <biosint.h>
@@ -1992,32 +1990,6 @@ static int int13_describe ( unsigned int drive ) {
        return 0;
 }
 
-/** The "san-drive" setting */
-const struct setting san_drive_setting __setting ( SETTING_SANBOOT_EXTRA,
-                                                  san-drive ) = {
-       .name = "san-drive",
-       .description = "SAN drive number",
-       .tag = DHCP_EB_SAN_DRIVE,
-       .type = &setting_type_uint8,
-};
-
-/**
- * Get default SAN drive number
- *
- * @ret drive          Default drive number
- */
-static unsigned int int13_default_drive ( void ) {
-       unsigned long drive;
-
-       /* Use "san-drive" setting, if specified */
-       if ( fetch_uint_setting ( NULL, &san_drive_setting, &drive ) >= 0 )
-               return drive;
-
-       /* Otherwise, default to booting from first hard disk */
-       return 0x80;
-}
-
-PROVIDE_SANBOOT ( pcbios, san_default_drive, int13_default_drive );
 PROVIDE_SANBOOT ( pcbios, san_hook, int13_hook );
 PROVIDE_SANBOOT ( pcbios, san_unhook, int13_unhook );
 PROVIDE_SANBOOT ( pcbios, san_boot, int13_boot );
index 2f7522c6ccf4f6658c80e70a6f124cb5a5926e8c..31a8a56b0d5f594b86f50f2f24cc33c75f6883bf 100644 (file)
@@ -43,7 +43,6 @@ static int null_san_describe ( unsigned int drive __unused ) {
        return -EOPNOTSUPP;
 }
 
-PROVIDE_SANBOOT_INLINE ( null, san_default_drive );
 PROVIDE_SANBOOT ( null, san_hook, null_san_hook );
 PROVIDE_SANBOOT ( null, san_unhook, null_san_unhook );
 PROVIDE_SANBOOT ( null, san_boot, null_san_boot );
index da1b68b5f83d3fb06a2bf295b9e25db51edd7e9a..42a30839251a2d28e205ffbbb6c51a7829119e47 100644 (file)
@@ -39,8 +39,20 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
 #include <ipxe/timer.h>
 #include <ipxe/process.h>
 #include <ipxe/iso9660.h>
+#include <ipxe/dhcp.h>
+#include <ipxe/settings.h>
 #include <ipxe/sanboot.h>
 
+/**
+ * Default SAN drive number
+ *
+ * The drive number is a meaningful concept only in a BIOS
+ * environment, where it represents the INT13 drive number (0x80 for
+ * the first hard disk).  We retain it in other environments to allow
+ * for a simple way for iPXE commands to refer to SAN drives.
+ */
+#define SAN_DEFAULT_DRIVE 0x80
+
 /**
  * Timeout for block device commands (in ticks)
  *
@@ -541,6 +553,7 @@ int register_sandev ( struct san_device *sandev ) {
 
        /* Add to list of SAN devices */
        list_add_tail ( &sandev->list, &san_devices );
+       DBGC ( sandev, "SAN %#02x registered\n", sandev->drive );
 
        return 0;
 }
@@ -560,4 +573,30 @@ void unregister_sandev ( struct san_device *sandev ) {
 
        /* Remove from list of SAN devices */
        list_del ( &sandev->list );
+       DBGC ( sandev, "SAN %#02x unregistered\n", sandev->drive );
+}
+
+/** The "san-drive" setting */
+const struct setting san_drive_setting __setting ( SETTING_SANBOOT_EXTRA,
+                                                  san-drive ) = {
+       .name = "san-drive",
+       .description = "SAN drive number",
+       .tag = DHCP_EB_SAN_DRIVE,
+       .type = &setting_type_uint8,
+};
+
+/**
+ * Get default SAN drive number
+ *
+ * @ret drive          Default drive number
+ */
+unsigned int san_default_drive ( void ) {
+       unsigned long drive;
+
+       /* Use "san-drive" setting, if specified */
+       if ( fetch_uint_setting ( NULL, &san_drive_setting, &drive ) >= 0 )
+               return drive;
+
+       /* Otherwise, default to booting from first hard disk */
+       return SAN_DEFAULT_DRIVE;
 }
index ea28230bff9411aea2a1ed6eb670d87539922a3d..f8cf7fc1344d6ec371a5dbffe88e6dd3501ee8e2 100644 (file)
@@ -15,13 +15,4 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
 #define SANBOOT_PREFIX_efi __efi_
 #endif
 
-static inline __always_inline unsigned int
-SANBOOT_INLINE ( efi, san_default_drive ) ( void ) {
-       /* Drive numbers don't exist as a concept under EFI.  We
-        * arbitarily choose to use drive 0x80 to minimise differences
-        * with a standard BIOS.
-        */
-       return 0x80;
-}
-
 #endif /* _IPXE_EFI_BLOCK_H */
index 58f03339f9555e3c955a41ddde67c765aea77134..b0e36b8b09efb94e2e500e525a81cbc593fcd872 100644 (file)
@@ -15,9 +15,4 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
 #define SANBOOT_PREFIX_null __null_
 #endif
 
-static inline __always_inline unsigned int
-SANBOOT_INLINE ( null, san_default_drive ) ( void ) {
-       return 0;
-}
-
 #endif /* _IPXE_NULL_SANBOOT_H */
index 420d4dbed52afeccbf6017231ecd85be1b9b02aa..3e7ed1c80abc4203812c310a46ff4ca07ad4e53c 100644 (file)
@@ -95,13 +95,6 @@ struct san_device {
 /* Include all architecture-dependent sanboot API headers */
 #include <bits/sanboot.h>
 
-/**
- * Get default SAN drive number
- *
- * @ret drive          Default drive number
- */
-unsigned int san_default_drive ( void );
-
 /**
  * Hook SAN device
  *
@@ -212,5 +205,6 @@ extern int sandev_rw ( struct san_device *sandev, uint64_t lba,
 extern struct san_device * alloc_sandev ( struct uri *uri, size_t priv_size );
 extern int register_sandev ( struct san_device *sandev );
 extern void unregister_sandev ( struct san_device *sandev );
+extern unsigned int san_default_drive ( void );
 
 #endif /* _IPXE_SANBOOT_H */
index ab23094317bae6fade6ba63b348f39f6c1136773..ee26b37d8ce3c050c0c022c3e121dc5371156d6d 100644 (file)
@@ -1055,7 +1055,6 @@ static int efi_block_boot ( unsigned int drive ) {
        return rc;
 }
 
-PROVIDE_SANBOOT_INLINE ( efi, san_default_drive );
 PROVIDE_SANBOOT ( efi, san_hook, efi_block_hook );
 PROVIDE_SANBOOT ( efi, san_unhook, efi_block_unhook );
 PROVIDE_SANBOOT ( efi, san_describe, efi_block_describe );