diff options
author | Michael Brown | 2017-03-06 13:25:20 +0100 |
---|---|---|
committer | Michael Brown | 2017-03-07 14:40:35 +0100 |
commit | e7ee2eda4badef6ee361f089768064ae737169ed (patch) | |
tree | 8e74668d89bc04e707143f0045ea7e67401a1f9a /src/core | |
parent | [block] Centralise SAN device abstraction (diff) | |
download | ipxe-e7ee2eda4badef6ee361f089768064ae737169ed.tar.gz ipxe-e7ee2eda4badef6ee361f089768064ae737169ed.tar.xz ipxe-e7ee2eda4badef6ee361f089768064ae737169ed.zip |
[block] Centralise "san-drive" setting
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>
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/null_sanboot.c | 1 | ||||
-rw-r--r-- | src/core/sanboot.c | 39 |
2 files changed, 39 insertions, 1 deletions
diff --git a/src/core/null_sanboot.c b/src/core/null_sanboot.c index 2f7522c6..31a8a56b 100644 --- a/src/core/null_sanboot.c +++ b/src/core/null_sanboot.c @@ -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 ); diff --git a/src/core/sanboot.c b/src/core/sanboot.c index da1b68b5..42a30839 100644 --- a/src/core/sanboot.c +++ b/src/core/sanboot.c @@ -39,9 +39,21 @@ 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) * * Underlying devices should ideally never become totally stuck. @@ -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; } |