diff --git a/src/config/defaults/pcbios.h b/src/config/defaults/pcbios.h index 80faef13..e1360f53 100644 --- a/src/config/defaults/pcbios.h +++ b/src/config/defaults/pcbios.h @@ -22,4 +22,7 @@ #define IMAGE_BZIMAGE /* Linux bzImage image support */ #define IMAGE_COMBOOT /* SYSLINUX COMBOOT image support */ +#define SANBOOT_PROTO_ISCSI /* iSCSI protocol */ +#define SANBOOT_PROTO_AOE /* AoE protocol */ + #endif /* CONFIG_DEFAULTS_PCBIOS_H */ diff --git a/src/config/general.h b/src/config/general.h index bf1afd76..d18c9cca 100644 --- a/src/config/general.h +++ b/src/config/general.h @@ -37,6 +37,14 @@ #undef DOWNLOAD_PROTO_SLAM /* Scalable Local Area Multicast */ #undef DOWNLOAD_PROTO_FSP /* FSP? */ +/* + * SAN boot protocols + * + */ + +//#undef SANBOOT_PROTO_ISCSI /* iSCSI protocol */ +//#undef SANBOOT_PROTO_AOE /* AoE protocol */ + /* * Name resolution modules * diff --git a/src/core/config.c b/src/core/config.c index 0ed837d7..ee16b9c1 100644 --- a/src/core/config.c +++ b/src/core/config.c @@ -94,6 +94,17 @@ REQUIRE_OBJECT ( tftm ); REQUIRE_OBJECT ( slam ); #endif +/* + * Drag in all requested SAN boot protocols + * + */ +#ifdef SANBOOT_PROTO_ISCSI +REQUIRE_OBJECT ( iscsiboot ); +#endif +#ifdef SANBOOT_PROTO_AOE +REQUIRE_OBJECT ( aoeboot ); +#endif + /* * Drag in all requested resolvers * diff --git a/src/include/gpxe/sanboot.h b/src/include/gpxe/sanboot.h new file mode 100644 index 00000000..ea26a356 --- /dev/null +++ b/src/include/gpxe/sanboot.h @@ -0,0 +1,14 @@ +#ifndef _GPXE_SANBOOT_H +#define _GPXE_SANBOOT_H + +#include + +struct sanboot_protocol { + const char *prefix; + int ( * boot ) ( const char *root_path ); +}; + +#define __sanboot_protocol \ + __table ( struct sanboot_protocol, sanboot_protocols, 01 ) + +#endif /* _GPXE_SANBOOT_H */ diff --git a/src/include/usr/aoeboot.h b/src/include/usr/aoeboot.h deleted file mode 100644 index 0421ebcc..00000000 --- a/src/include/usr/aoeboot.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef _USR_AOEBOOT_H -#define _USR_AOEBOOT_H - -extern int aoeboot ( const char *root_path ); - -#endif /* _USR_AOEBOOT_H */ diff --git a/src/include/usr/iscsiboot.h b/src/include/usr/iscsiboot.h deleted file mode 100644 index b17951d5..00000000 --- a/src/include/usr/iscsiboot.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef _USR_ISCSIBOOT_H -#define _USR_ISCSIBOOT_H - -extern int iscsiboot ( const char *root_path ); - -#endif /* _USR_ISCSIBOOT_H */ diff --git a/src/usr/aoeboot.c b/src/usr/aoeboot.c index f0e481bd..08d21c4e 100644 --- a/src/usr/aoeboot.c +++ b/src/usr/aoeboot.c @@ -6,9 +6,9 @@ #include #include #include +#include #include #include -#include /** * Guess boot network device @@ -26,7 +26,7 @@ static struct net_device * guess_boot_netdev ( void ) { return NULL; } -int aoeboot ( const char *root_path ) { +static int aoeboot ( const char *root_path ) { struct ata_device ata; struct int13_drive drive; int rc; @@ -71,3 +71,8 @@ int aoeboot ( const char *root_path ) { error_attach: return rc; } + +struct sanboot_protocol aoe_sanboot_protocol __sanboot_protocol = { + .prefix = "aoe:", + .boot = aoeboot, +}; diff --git a/src/usr/autoboot.c b/src/usr/autoboot.c index 326292b4..f5f7f7d1 100644 --- a/src/usr/autoboot.c +++ b/src/usr/autoboot.c @@ -24,13 +24,12 @@ #include #include #include +#include #include #include #include #include #include -#include -#include #include /** @file @@ -45,6 +44,12 @@ /** Shutdown flags for exit */ int shutdown_exit_flags = 0; +/* SAN boot protocols */ +static struct sanboot_protocol sanboot_protocols[0] \ + __table_start ( struct sanboot_protocol, sanboot_protocols ); +static struct sanboot_protocol sanboot_protocols_end[0] \ + __table_end ( struct sanboot_protocol, sanboot_protocols ); + /** * Identify the boot network device * @@ -141,12 +146,15 @@ static int boot_next_server_and_filename ( struct in_addr next_server, * @ret rc Return status code */ int boot_root_path ( const char *root_path ) { + struct sanboot_protocol *sanboot; /* Quick hack */ - if ( strncmp ( root_path, "iscsi:", 6 ) == 0 ) { - return iscsiboot ( root_path ); - } else if ( strncmp ( root_path, "aoe:", 4 ) == 0 ) { - return aoeboot ( root_path ); + for ( sanboot = sanboot_protocols ; + sanboot < sanboot_protocols_end ; sanboot++ ) { + if ( strncmp ( root_path, sanboot->prefix, + strlen ( sanboot->prefix ) ) == 0 ) { + return sanboot->boot ( root_path ); + } } return -ENOTSUP; diff --git a/src/usr/iscsiboot.c b/src/usr/iscsiboot.c index 84d77c45..e0098fd2 100644 --- a/src/usr/iscsiboot.c +++ b/src/usr/iscsiboot.c @@ -9,9 +9,9 @@ #include #include #include +#include #include #include -#include struct setting keep_san_setting __setting = { .name = "keep-san", @@ -36,7 +36,7 @@ static struct net_device * guess_boot_netdev ( void ) { return NULL; } -int iscsiboot ( const char *root_path ) { +static int iscsiboot ( const char *root_path ) { struct scsi_device *scsi; struct int13_drive *drive; int keep_san; @@ -100,3 +100,8 @@ int iscsiboot ( const char *root_path ) { err_alloc_scsi: return rc; } + +struct sanboot_protocol iscsi_sanboot_protocol __sanboot_protocol = { + .prefix = "iscsi:", + .boot = iscsiboot, +};