6 #include <gpxe/iscsi.h>
7 #include <gpxe/netdevice.h>
9 #include <gpxe/sanboot.h>
12 FILE_LICENCE ( GPL2_OR_LATER
);
14 static int iscsiboot ( const char *root_path
) {
15 struct scsi_device
*scsi
;
16 struct int13_drive
*drive
;
19 scsi
= zalloc ( sizeof ( *scsi
) );
24 drive
= zalloc ( sizeof ( *drive
) );
30 if ( ( rc
= iscsi_attach ( scsi
, root_path
) ) != 0 ) {
31 printf ( "Could not attach iSCSI device: %s\n",
35 if ( ( rc
= init_scsidev ( scsi
) ) != 0 ) {
36 printf ( "Could not initialise iSCSI device: %s\n",
41 drive
->blockdev
= &scsi
->blockdev
;
43 /* FIXME: ugly, ugly hack */
44 struct net_device
*netdev
= last_opened_netdev();
45 struct iscsi_session
*iscsi
=
46 container_of ( scsi
->backend
, struct iscsi_session
, refcnt
);
47 ibft_fill_data ( netdev
, iscsi
);
49 register_int13_drive ( drive
);
50 printf ( "Registered as BIOS drive %#02x\n", drive
->drive
);
51 printf ( "Booting from BIOS drive %#02x\n", drive
->drive
);
52 rc
= int13_boot ( drive
->drive
);
53 printf ( "Boot failed\n" );
55 /* Leave drive registered, if instructed to do so */
59 printf ( "Unregistering BIOS drive %#02x\n", drive
->drive
);
60 unregister_int13_drive ( drive
);
63 iscsi_detach ( scsi
);
72 struct sanboot_protocol iscsi_sanboot_protocol __sanboot_protocol
= {