4 #include <gpxe/iscsi.h>
5 #include <gpxe/settings.h>
6 #include <gpxe/netdevice.h>
9 #include <usr/iscsiboot.h>
12 * Guess boot network device
14 * @ret netdev Boot network device
16 static struct net_device
* guess_boot_netdev ( void ) {
17 struct net_device
*boot_netdev
;
19 /* Just use the first network device */
20 for_each_netdev ( boot_netdev
) {
27 int iscsiboot ( const char *root_path
) {
28 struct scsi_device scsi
;
29 struct int13_drive drive
;
32 memset ( &scsi
, 0, sizeof ( scsi
) );
33 memset ( &drive
, 0, sizeof ( drive
) );
35 printf ( "iSCSI booting from %s\n", root_path
);
37 if ( ( rc
= iscsi_attach ( &scsi
, root_path
) ) != 0 ) {
38 printf ( "Could not attach iSCSI device: %s\n",
42 if ( ( rc
= init_scsidev ( &scsi
) ) != 0 ) {
43 printf ( "Could not initialise iSCSI device: %s\n",
48 drive
.blockdev
= &scsi
.blockdev
;
50 /* FIXME: ugly, ugly hack */
51 struct net_device
*netdev
= guess_boot_netdev();
52 struct iscsi_session
*iscsi
=
53 container_of ( scsi
.backend
, struct iscsi_session
, refcnt
);
54 ibft_fill_data ( netdev
, iscsi
);
56 register_int13_drive ( &drive
);
57 printf ( "Registered as BIOS drive %#02x\n", drive
.drive
);
58 printf ( "Booting from BIOS drive %#02x\n", drive
.drive
);
59 rc
= int13_boot ( drive
.drive
);
60 printf ( "Boot failed\n" );
62 printf ( "Unregistering BIOS drive %#02x\n", drive
.drive
);
63 unregister_int13_drive ( &drive
);
66 iscsi_detach ( &scsi
);