[sanboot] Quick and dirty hack to make SAN boot protocols selectable

This commit is contained in:
Michael Brown
2008-10-13 10:05:23 +01:00
parent d4e152e766
commit 54c024e0af
9 changed files with 64 additions and 22 deletions

View File

@@ -6,9 +6,9 @@
#include <gpxe/ata.h>
#include <gpxe/netdevice.h>
#include <gpxe/settings.h>
#include <gpxe/sanboot.h>
#include <gpxe/abft.h>
#include <int13.h>
#include <usr/aoeboot.h>
/**
* 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,
};

View File

@@ -24,13 +24,12 @@
#include <gpxe/settings.h>
#include <gpxe/image.h>
#include <gpxe/embedded.h>
#include <gpxe/sanboot.h>
#include <gpxe/uri.h>
#include <usr/ifmgmt.h>
#include <usr/route.h>
#include <usr/dhcpmgmt.h>
#include <usr/imgmgmt.h>
#include <usr/iscsiboot.h>
#include <usr/aoeboot.h>
#include <usr/autoboot.h>
/** @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;

View File

@@ -9,9 +9,9 @@
#include <gpxe/netdevice.h>
#include <gpxe/ibft.h>
#include <gpxe/init.h>
#include <gpxe/sanboot.h>
#include <int13.h>
#include <usr/autoboot.h>
#include <usr/iscsiboot.h>
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,
};