You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

iscsiboot.c 1.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #include <stdint.h>
  2. #include <string.h>
  3. #include <stdio.h>
  4. #include <gpxe/iscsi.h>
  5. #include <gpxe/dhcp.h>
  6. #include <int13.h>
  7. #include <usr/iscsiboot.h>
  8. int iscsiboot ( const char *root_path ) {
  9. struct scsi_device scsi;
  10. struct int13_drive drive;
  11. int rc;
  12. memset ( &scsi, 0, sizeof ( scsi ) );
  13. memset ( &drive, 0, sizeof ( drive ) );
  14. printf ( "iSCSI booting from %s\n", root_path );
  15. if ( ( rc = iscsi_attach ( &scsi, root_path ) ) != 0 ) {
  16. printf ( "Could not attach iSCSI device: %s\n",
  17. strerror ( rc ) );
  18. goto error_attach;
  19. }
  20. if ( ( rc = init_scsidev ( &scsi ) ) != 0 ) {
  21. printf ( "Could not initialise iSCSI device: %s\n",
  22. strerror ( rc ) );
  23. goto error_init;
  24. }
  25. drive.drive = find_global_dhcp_num_option ( DHCP_EB_BIOS_DRIVE );
  26. drive.blockdev = &scsi.blockdev;
  27. register_int13_drive ( &drive );
  28. printf ( "Registered as BIOS drive %#02x\n", drive.drive );
  29. printf ( "Booting from BIOS drive %#02x\n", drive.drive );
  30. rc = int13_boot ( drive.drive );
  31. printf ( "Boot failed\n" );
  32. printf ( "Unregistering BIOS drive %#02x\n", drive.drive );
  33. unregister_int13_drive ( &drive );
  34. error_init:
  35. iscsi_detach ( &scsi );
  36. error_attach:
  37. return rc;
  38. }