Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[sanboot] Quick and dirty hack to make SAN boot protocols selectable
  • Loading branch information
Michael Brown committed Oct 13, 2008
1 parent d4e152e commit 54c024e
Show file tree
Hide file tree
Showing 9 changed files with 64 additions and 22 deletions.
3 changes: 3 additions & 0 deletions src/config/defaults/pcbios.h
Expand Up @@ -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 */
8 changes: 8 additions & 0 deletions src/config/general.h
Expand Up @@ -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
*
Expand Down
11 changes: 11 additions & 0 deletions src/core/config.c
Expand Up @@ -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
*
Expand Down
14 changes: 14 additions & 0 deletions src/include/gpxe/sanboot.h
@@ -0,0 +1,14 @@
#ifndef _GPXE_SANBOOT_H
#define _GPXE_SANBOOT_H

#include <gpxe/tables.h>

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 */
6 changes: 0 additions & 6 deletions src/include/usr/aoeboot.h

This file was deleted.

6 changes: 0 additions & 6 deletions src/include/usr/iscsiboot.h

This file was deleted.

9 changes: 7 additions & 2 deletions src/usr/aoeboot.c
Expand Up @@ -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
Expand All @@ -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;
Expand Down Expand Up @@ -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,
};
20 changes: 14 additions & 6 deletions src/usr/autoboot.c
Expand Up @@ -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
Expand All @@ -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
*
Expand Down Expand Up @@ -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;
Expand Down
9 changes: 7 additions & 2 deletions src/usr/iscsiboot.c
Expand Up @@ -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",
Expand All @@ -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;
Expand Down Expand Up @@ -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,
};

0 comments on commit 54c024e

Please sign in to comment.