您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

ib_srpboot.c 1.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. #include <stdint.h>
  2. #include <string.h>
  3. #include <stdlib.h>
  4. #include <stdio.h>
  5. #include <errno.h>
  6. #include <gpxe/sanboot.h>
  7. #include <int13.h>
  8. #include <gpxe/srp.h>
  9. #include <gpxe/sbft.h>
  10. FILE_LICENCE ( GPL2_OR_LATER );
  11. static int ib_srpboot ( const char *root_path ) {
  12. struct scsi_device *scsi;
  13. struct int13_drive *drive;
  14. int rc;
  15. scsi = zalloc ( sizeof ( *scsi ) );
  16. if ( ! scsi ) {
  17. rc = -ENOMEM;
  18. goto err_alloc_scsi;
  19. }
  20. drive = zalloc ( sizeof ( *drive ) );
  21. if ( ! drive ) {
  22. rc = -ENOMEM;
  23. goto err_alloc_drive;
  24. }
  25. if ( ( rc = srp_attach ( scsi, root_path ) ) != 0 ) {
  26. printf ( "Could not attach IB_SRP device: %s\n",
  27. strerror ( rc ) );
  28. goto err_attach;
  29. }
  30. if ( ( rc = init_scsidev ( scsi ) ) != 0 ) {
  31. printf ( "Could not initialise IB_SRP device: %s\n",
  32. strerror ( rc ) );
  33. goto err_init;
  34. }
  35. drive->blockdev = &scsi->blockdev;
  36. /* FIXME: ugly, ugly hack */
  37. struct srp_device *srp =
  38. container_of ( scsi->backend, struct srp_device, refcnt );
  39. sbft_fill_data ( srp );
  40. register_int13_drive ( drive );
  41. printf ( "Registered as BIOS drive %#02x\n", drive->drive );
  42. printf ( "Booting from BIOS drive %#02x\n", drive->drive );
  43. rc = int13_boot ( drive->drive );
  44. printf ( "Boot failed\n" );
  45. printf ( "Unregistering BIOS drive %#02x\n", drive->drive );
  46. unregister_int13_drive ( drive );
  47. err_init:
  48. srp_detach ( scsi );
  49. err_attach:
  50. free ( drive );
  51. err_alloc_drive:
  52. free ( scsi );
  53. err_alloc_scsi:
  54. return rc;
  55. }
  56. struct sanboot_protocol ib_srp_sanboot_protocol __sanboot_protocol = {
  57. .prefix = "ib_srp:",
  58. .boot = ib_srpboot,
  59. };