Browse Source

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

tags/v0.9.6
Michael Brown 15 years ago
parent
commit
54c024e0af

+ 3
- 0
src/config/defaults/pcbios.h View File

@@ -22,4 +22,7 @@
22 22
 #define IMAGE_BZIMAGE		/* Linux bzImage image support */
23 23
 #define IMAGE_COMBOOT		/* SYSLINUX COMBOOT image support */
24 24
 
25
+#define	SANBOOT_PROTO_ISCSI	/* iSCSI protocol */
26
+#define	SANBOOT_PROTO_AOE	/* AoE protocol */
27
+
25 28
 #endif /* CONFIG_DEFAULTS_PCBIOS_H */

+ 8
- 0
src/config/general.h View File

@@ -37,6 +37,14 @@
37 37
 #undef	DOWNLOAD_PROTO_SLAM	/* Scalable Local Area Multicast */
38 38
 #undef	DOWNLOAD_PROTO_FSP	/* FSP? */
39 39
 
40
+/*
41
+ * SAN boot protocols
42
+ *
43
+ */
44
+
45
+//#undef	SANBOOT_PROTO_ISCSI	/* iSCSI protocol */
46
+//#undef	SANBOOT_PROTO_AOE	/* AoE protocol */
47
+
40 48
 /*
41 49
  * Name resolution modules
42 50
  *

+ 11
- 0
src/core/config.c View File

@@ -94,6 +94,17 @@ REQUIRE_OBJECT ( tftm );
94 94
 REQUIRE_OBJECT ( slam );
95 95
 #endif
96 96
 
97
+/*
98
+ * Drag in all requested SAN boot protocols
99
+ *
100
+ */
101
+#ifdef SANBOOT_PROTO_ISCSI
102
+REQUIRE_OBJECT ( iscsiboot );
103
+#endif
104
+#ifdef SANBOOT_PROTO_AOE
105
+REQUIRE_OBJECT ( aoeboot );
106
+#endif
107
+
97 108
 /*
98 109
  * Drag in all requested resolvers
99 110
  *

+ 14
- 0
src/include/gpxe/sanboot.h View File

@@ -0,0 +1,14 @@
1
+#ifndef _GPXE_SANBOOT_H
2
+#define _GPXE_SANBOOT_H
3
+
4
+#include <gpxe/tables.h>
5
+
6
+struct sanboot_protocol {
7
+	const char *prefix;
8
+	int ( * boot ) ( const char *root_path );
9
+};
10
+
11
+#define __sanboot_protocol \
12
+	__table ( struct sanboot_protocol, sanboot_protocols, 01 )
13
+
14
+#endif /* _GPXE_SANBOOT_H */

+ 0
- 6
src/include/usr/aoeboot.h View File

@@ -1,6 +0,0 @@
1
-#ifndef _USR_AOEBOOT_H
2
-#define _USR_AOEBOOT_H
3
-
4
-extern int aoeboot ( const char *root_path );
5
-
6
-#endif /* _USR_AOEBOOT_H */

+ 0
- 6
src/include/usr/iscsiboot.h View File

@@ -1,6 +0,0 @@
1
-#ifndef _USR_ISCSIBOOT_H
2
-#define _USR_ISCSIBOOT_H
3
-
4
-extern int iscsiboot ( const char *root_path );
5
-
6
-#endif /* _USR_ISCSIBOOT_H */

+ 7
- 2
src/usr/aoeboot.c View File

@@ -6,9 +6,9 @@
6 6
 #include <gpxe/ata.h>
7 7
 #include <gpxe/netdevice.h>
8 8
 #include <gpxe/settings.h>
9
+#include <gpxe/sanboot.h>
9 10
 #include <gpxe/abft.h>
10 11
 #include <int13.h>
11
-#include <usr/aoeboot.h>
12 12
 
13 13
 /**
14 14
  * Guess boot network device
@@ -26,7 +26,7 @@ static struct net_device * guess_boot_netdev ( void ) {
26 26
 	return NULL;
27 27
 }
28 28
 
29
-int aoeboot ( const char *root_path ) {
29
+static int aoeboot ( const char *root_path ) {
30 30
 	struct ata_device ata;
31 31
 	struct int13_drive drive;
32 32
 	int rc;
@@ -71,3 +71,8 @@ int aoeboot ( const char *root_path ) {
71 71
  error_attach:
72 72
 	return rc;
73 73
 }
74
+
75
+struct sanboot_protocol aoe_sanboot_protocol __sanboot_protocol = {
76
+	.prefix = "aoe:",
77
+	.boot = aoeboot,
78
+};

+ 14
- 6
src/usr/autoboot.c View File

@@ -24,13 +24,12 @@
24 24
 #include <gpxe/settings.h>
25 25
 #include <gpxe/image.h>
26 26
 #include <gpxe/embedded.h>
27
+#include <gpxe/sanboot.h>
27 28
 #include <gpxe/uri.h>
28 29
 #include <usr/ifmgmt.h>
29 30
 #include <usr/route.h>
30 31
 #include <usr/dhcpmgmt.h>
31 32
 #include <usr/imgmgmt.h>
32
-#include <usr/iscsiboot.h>
33
-#include <usr/aoeboot.h>
34 33
 #include <usr/autoboot.h>
35 34
 
36 35
 /** @file
@@ -45,6 +44,12 @@
45 44
 /** Shutdown flags for exit */
46 45
 int shutdown_exit_flags = 0;
47 46
 
47
+/* SAN boot protocols */
48
+static struct sanboot_protocol sanboot_protocols[0] \
49
+	__table_start ( struct sanboot_protocol, sanboot_protocols );
50
+static struct sanboot_protocol sanboot_protocols_end[0] \
51
+	__table_end ( struct sanboot_protocol, sanboot_protocols );
52
+
48 53
 /**
49 54
  * Identify the boot network device
50 55
  *
@@ -141,12 +146,15 @@ static int boot_next_server_and_filename ( struct in_addr next_server,
141 146
  * @ret rc		Return status code
142 147
  */
143 148
 int boot_root_path ( const char *root_path ) {
149
+	struct sanboot_protocol *sanboot;
144 150
 
145 151
 	/* Quick hack */
146
-	if ( strncmp ( root_path, "iscsi:", 6 ) == 0 ) {
147
-		return iscsiboot ( root_path );
148
-	} else if ( strncmp ( root_path, "aoe:", 4 ) == 0 ) {
149
-		return aoeboot ( root_path );
152
+	for ( sanboot = sanboot_protocols ;
153
+	      sanboot < sanboot_protocols_end ; sanboot++ ) {
154
+		if ( strncmp ( root_path, sanboot->prefix,
155
+			       strlen ( sanboot->prefix ) ) == 0 ) {
156
+			return sanboot->boot ( root_path );
157
+		}
150 158
 	}
151 159
 
152 160
 	return -ENOTSUP;

+ 7
- 2
src/usr/iscsiboot.c View File

@@ -9,9 +9,9 @@
9 9
 #include <gpxe/netdevice.h>
10 10
 #include <gpxe/ibft.h>
11 11
 #include <gpxe/init.h>
12
+#include <gpxe/sanboot.h>
12 13
 #include <int13.h>
13 14
 #include <usr/autoboot.h>
14
-#include <usr/iscsiboot.h>
15 15
 
16 16
 struct setting keep_san_setting __setting = {
17 17
 	.name = "keep-san",
@@ -36,7 +36,7 @@ static struct net_device * guess_boot_netdev ( void ) {
36 36
 	return NULL;
37 37
 }
38 38
 
39
-int iscsiboot ( const char *root_path ) {
39
+static int iscsiboot ( const char *root_path ) {
40 40
 	struct scsi_device *scsi;
41 41
 	struct int13_drive *drive;
42 42
 	int keep_san;
@@ -100,3 +100,8 @@ int iscsiboot ( const char *root_path ) {
100 100
  err_alloc_scsi:
101 101
 	return rc;
102 102
 }
103
+
104
+struct sanboot_protocol iscsi_sanboot_protocol __sanboot_protocol = {
105
+	.prefix = "iscsi:",
106
+	.boot = iscsiboot,
107
+};

Loading…
Cancel
Save