2006-06-14 17:00:25 +00:00
|
|
|
#include <stdint.h>
|
|
|
|
#include <byteswap.h>
|
|
|
|
#include <vsprintf.h>
|
|
|
|
#include <gpxe/netdevice.h>
|
|
|
|
#include <gpxe/iscsi.h>
|
2006-08-27 23:54:20 +00:00
|
|
|
#include <gpxe/ibft.h>
|
2006-06-14 17:00:25 +00:00
|
|
|
#include <int13.h>
|
|
|
|
|
|
|
|
static struct iscsi_device test_iscsidev;
|
|
|
|
|
|
|
|
int test_iscsiboot ( const char *initiator_iqn,
|
2006-08-07 16:48:24 +00:00
|
|
|
struct sockaddr_tcpip *target,
|
2006-08-27 23:54:20 +00:00
|
|
|
const char *target_iqn,
|
2006-12-08 15:53:49 +00:00
|
|
|
unsigned int lun,
|
2006-11-28 00:29:02 +00:00
|
|
|
const char *username,
|
|
|
|
const char *password,
|
2006-11-29 00:27:10 +00:00
|
|
|
struct net_device *netdev,
|
|
|
|
unsigned int drivenum ) {
|
2006-06-14 17:00:25 +00:00
|
|
|
struct int13_drive drive;
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
memset ( &test_iscsidev, 0, sizeof ( test_iscsidev ) );
|
2006-08-07 16:48:24 +00:00
|
|
|
memcpy ( &test_iscsidev.iscsi.tcp.peer, target,
|
|
|
|
sizeof ( test_iscsidev.iscsi.tcp.peer ) );
|
2006-06-14 17:00:25 +00:00
|
|
|
test_iscsidev.iscsi.initiator = initiator_iqn;
|
|
|
|
test_iscsidev.iscsi.target = target_iqn;
|
2006-12-08 15:53:49 +00:00
|
|
|
test_iscsidev.iscsi.lun = lun;
|
2006-11-28 00:29:02 +00:00
|
|
|
test_iscsidev.iscsi.username = username;
|
|
|
|
test_iscsidev.iscsi.password = password;
|
2006-06-14 17:00:25 +00:00
|
|
|
|
|
|
|
printf ( "Initialising %s\n", target_iqn );
|
|
|
|
if ( ( rc = init_iscsidev ( &test_iscsidev ) ) != 0 ) {
|
|
|
|
printf ( "Could not reach %s\n", target_iqn );
|
|
|
|
return rc;
|
|
|
|
}
|
2006-08-27 23:54:20 +00:00
|
|
|
ibft_fill_data ( netdev, initiator_iqn, target, target_iqn );
|
2006-06-14 17:00:25 +00:00
|
|
|
memset ( &drive, 0, sizeof ( drive ) );
|
2006-11-29 00:27:10 +00:00
|
|
|
drive.drive = drivenum;
|
2006-06-14 17:00:25 +00:00
|
|
|
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;
|
|
|
|
}
|