Ready to start testing

This commit is contained in:
Michael Brown
2007-07-08 22:01:49 +01:00
parent edd1b173a7
commit b94420a52b
6 changed files with 127 additions and 161 deletions

View File

@@ -1,48 +1,36 @@
#include <stdint.h>
#include <string.h>
#include <stdio.h>
#include <byteswap.h>
#include <gpxe/netdevice.h>
#include <gpxe/iscsi.h>
#include <gpxe/ibft.h>
#include <gpxe/tcpip.h>
#include <gpxe/dhcp.h>
#include <int13.h>
static struct iscsi_device test_iscsidev;
int test_iscsiboot ( const char *initiator_iqn,
struct sockaddr_tcpip *target,
const char *target_iqn,
unsigned int lun,
const char *username,
const char *password,
struct net_device *netdev,
unsigned int drivenum ) {
int iscsiboot ( const char *root_path ) {
struct scsi_device scsi;
struct int13_drive drive;
int rc;
memset ( &test_iscsidev, 0, sizeof ( test_iscsidev ) );
memcpy ( &test_iscsidev.iscsi.target, target,
sizeof ( test_iscsidev.iscsi.target ) );
test_iscsidev.iscsi.initiator_iqn = initiator_iqn;
test_iscsidev.iscsi.target_iqn = target_iqn;
test_iscsidev.iscsi.lun = lun;
test_iscsidev.iscsi.username = username;
test_iscsidev.iscsi.password = password;
printf ( "Initialising %s\n", target_iqn );
if ( ( rc = init_iscsidev ( &test_iscsidev ) ) != 0 ) {
printf ( "Could not reach %s: %s\n", target_iqn,
strerror ( rc ) );
return rc;
}
ibft_fill_data ( netdev, &test_iscsidev.iscsi );
memset ( &scsi, 0, sizeof ( scsi ) );
memset ( &drive, 0, sizeof ( drive ) );
drive.drive = drivenum;
drive.blockdev = &test_iscsidev.scsi.blockdev;
printf ( "iSCSI booting from %s\n", root_path );
if ( ( rc = iscsi_attach ( &scsi, root_path ) ) != 0 ) {
printf ( "Could not attach iSCSI device: %s\n",
strerror ( rc ) );
goto error_attach;
}
if ( ( rc = init_scsidev ( &scsi ) ) != 0 ) {
printf ( "Could not initialise iSCSI device: %s\n",
strerror ( rc ) );
goto error_init;
}
drive.drive = find_global_dhcp_num_option ( DHCP_EB_BIOS_DRIVE );
drive.blockdev = &scsi.blockdev;
register_int13_drive ( &drive );
printf ( "Registered %s as BIOS drive %#02x\n",
target_iqn, drive.drive );
printf ( "Registered as BIOS drive %#02x\n", drive.drive );
printf ( "Booting from BIOS drive %#02x\n", drive.drive );
rc = int13_boot ( drive.drive );
printf ( "Boot failed\n" );
@@ -50,7 +38,8 @@ int test_iscsiboot ( const char *initiator_iqn,
printf ( "Unregistering BIOS drive %#02x\n", drive.drive );
unregister_int13_drive ( &drive );
fini_iscsidev ( &test_iscsidev );
error_init:
iscsi_detach ( &scsi );
error_attach:
return rc;
}