summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Brown2006-06-14 19:00:25 +0200
committerMichael Brown2006-06-14 19:00:25 +0200
commitcce2e47ff4c63012810e1a3ff6f21286622631a5 (patch)
tree1aea9283e94c979ae1f3ef10360850b97984d884
parentGeneralise three-wire interface to generic SPI interface. (diff)
downloadipxe-cce2e47ff4c63012810e1a3ff6f21286622631a5.tar.gz
ipxe-cce2e47ff4c63012810e1a3ff6f21286622631a5.tar.xz
ipxe-cce2e47ff4c63012810e1a3ff6f21286622631a5.zip
Added iSCSI boot test code
-rw-r--r--src/include/gpxe/iscsi.h3
-rw-r--r--src/tests/iscsiboot.c41
2 files changed, 44 insertions, 0 deletions
diff --git a/src/include/gpxe/iscsi.h b/src/include/gpxe/iscsi.h
index c1161de95..4d0da132d 100644
--- a/src/include/gpxe/iscsi.h
+++ b/src/include/gpxe/iscsi.h
@@ -11,6 +11,9 @@
#include <gpxe/tcp.h>
#include <gpxe/scsi.h>
+/** Default iSCSI port */
+#define ISCSI_PORT 3260
+
/**
* iSCSI segment lengths
*
diff --git a/src/tests/iscsiboot.c b/src/tests/iscsiboot.c
new file mode 100644
index 000000000..ef1c4a1a4
--- /dev/null
+++ b/src/tests/iscsiboot.c
@@ -0,0 +1,41 @@
+#include <stdint.h>
+#include <byteswap.h>
+#include <vsprintf.h>
+#include <gpxe/netdevice.h>
+#include <gpxe/iscsi.h>
+#include <int13.h>
+
+static struct iscsi_device test_iscsidev;
+
+int test_iscsiboot ( const char *initiator_iqn,
+ struct in_addr target,
+ const char *target_iqn ) {
+ struct int13_drive drive;
+ int rc;
+
+ memset ( &test_iscsidev, 0, sizeof ( test_iscsidev ) );
+ test_iscsidev.iscsi.tcp.sin.sin_addr = target;
+ test_iscsidev.iscsi.tcp.sin.sin_port = htons ( ISCSI_PORT );
+ test_iscsidev.iscsi.initiator = initiator_iqn;
+ test_iscsidev.iscsi.target = target_iqn;
+
+ printf ( "Initialising %s\n", target_iqn );
+ if ( ( rc = init_iscsidev ( &test_iscsidev ) ) != 0 ) {
+ printf ( "Could not reach %s\n", target_iqn );
+ return rc;
+ }
+
+ memset ( &drive, 0, sizeof ( drive ) );
+ drive.blockdev = &test_iscsidev.scsi.blockdev;
+ register_int13_drive ( &drive );
+ printf ( "Registered %s as BIOS drive %#02x\n",
+ target_iqn, drive.drive );
+ printf ( "Booting from BIOS drive %#02x\n", drive.drive );
+ rc = int13_boot ( drive.drive );
+ printf ( "Boot failed\n" );
+
+ printf ( "Unregistering BIOS drive %#02x\n", drive.drive );
+ unregister_int13_drive ( &drive );
+
+ return rc;
+}