[PATCH 2/2] support netbooting on JS21 GA3 and older firmwares
Scott Moser
ssmoser at us.ibm.com
Sat Oct 6 01:07:26 EST 2007
In order to support older firmware on setups where dhcp server has
'next-server' set (so, dhcp server != tftp server), attempt to determine
if this is a new firmware that supports full ftp. If it is, then fill in
the siaddr and ciaddr from the previous bootp request.
The solution here just looks for the presense of /packages/cas in the OF.
In all the systems that I have access to (power6, js22, js21,
power5/squadron) this file exists on systems that have "true tftp"
support.
I realize this is by no means the best solution, but it does create a
yaboot capable of network booting on all hardware that I have access
to. This includes power5 and power6 systems, and JS20, JS21 and a
JS22 blades. I'm posting it here mostly in hopes that it will both
a.) give people a solution that have the same problem as myself, and
b.) start a discussion on a better solution.
diff --git a/second/fs_of.c b/second/fs_of.c
index a9404f6..d0b2e5b 100644
--- a/second/fs_of.c
+++ b/second/fs_of.c
@@ -60,6 +60,8 @@ static int of_net_open(struct boot_file_t* file, const char* dev_name,
static int of_net_read(struct boot_file_t* file, unsigned int size, void* buffer);
static int of_net_seek(struct boot_file_t* file, unsigned int newpos);
+static int of_supports_real_tftp(void);
+static int of_net_use_tftp = -1;
struct fs_t of_filesystem =
{
@@ -131,6 +133,30 @@ of_open(struct boot_file_t* file, const char* dev_name,
return FILE_ERR_OK;
}
+/*
+ * older firmwares were really not capable of doing a tftp load. Ie, the
+ * 'boot' command line: <device>:<siaddr>,<file>,<ciaddr> requires that
+ * <siaddr> to be running a bootp server, not simply a tftp server. The
+ * above syntax works with new firmwares.
+ *
+ * This function should return 1 if the running firmware fully supports
+ * tftp and 0 if not.
+ */
+static int of_supports_real_tftp() {
+ prom_handle h;
+ if(of_net_use_tftp>=0) return(of_net_use_tftp);
+
+ h=prom_open("/packages/cas");
+ if(h) {
+ prom_close(h);
+ of_net_use_tftp=1;
+ } else {
+ of_net_use_tftp=0;
+ }
+ return(of_net_use_tftp);
+}
+
+
static int
of_net_open(struct boot_file_t* file, const char* dev_name,
struct partition_t* part, const char* file_name)
@@ -143,24 +169,28 @@ of_net_open(struct boot_file_t* file, const char* dev_name,
DEBUG_ENTER;
DEBUG_OPEN;
- packet = prom_get_netinfo();
strncpy(buffer, dev_name, 768);
if (file_name && strlen(file_name)) {
- strcat(buffer, prom_get_siaddr(packet));
+ if(of_supports_real_tftp()){
+ packet = prom_get_netinfo();
+ strcat(buffer, prom_get_siaddr(packet));
+ }
strcat(buffer, ",");
filename = strdup(file_name);
for (p = filename; *p; p++)
if (*p == '/')
*p = '\\';
strcat(buffer, filename);
- strcat(buffer, ",");
- strcat(buffer, prom_get_yiaddr(packet));
- strcat(buffer, ",");
- /* Hack required since giaddr not returned on some systems
- and required to boot on those systems. This should work
- for the client and server on the same subnet. */
- strcat(buffer, prom_get_siaddr(packet));
+ if(of_supports_real_tftp()) {
+ strcat(buffer, ",");
+ strcat(buffer, prom_get_yiaddr(packet));
+ strcat(buffer, ",");
+ /* Hack required since giaddr not returned on some systems
+ and required to boot on those systems. This should work
+ for the client and server on the same subnet. */
+ strcat(buffer, prom_get_siaddr(packet));
+ }
free(filename);
}
More information about the Yaboot-devel
mailing list