Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

aoeboot.c 1.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. #include <stdint.h>
  2. #include <string.h>
  3. #include <stdio.h>
  4. #include <byteswap.h>
  5. #include <gpxe/aoe.h>
  6. #include <gpxe/ata.h>
  7. #include <gpxe/netdevice.h>
  8. #include <gpxe/settings.h>
  9. #include <gpxe/sanboot.h>
  10. #include <gpxe/abft.h>
  11. #include <int13.h>
  12. FILE_LICENCE ( GPL2_OR_LATER );
  13. static int aoeboot ( const char *root_path ) {
  14. struct ata_device ata;
  15. struct int13_drive drive;
  16. int rc;
  17. memset ( &ata, 0, sizeof ( ata ) );
  18. memset ( &drive, 0, sizeof ( drive ) );
  19. printf ( "AoE booting from %s\n", root_path );
  20. /* FIXME: ugly, ugly hack */
  21. struct net_device *netdev = last_opened_netdev();
  22. if ( ( rc = aoe_attach ( &ata, netdev, root_path ) ) != 0 ) {
  23. printf ( "Could not attach AoE device: %s\n",
  24. strerror ( rc ) );
  25. goto error_attach;
  26. }
  27. if ( ( rc = init_atadev ( &ata ) ) != 0 ) {
  28. printf ( "Could not initialise AoE device: %s\n",
  29. strerror ( rc ) );
  30. goto error_init;
  31. }
  32. /* FIXME: ugly, ugly hack */
  33. struct aoe_session *aoe =
  34. container_of ( ata.backend, struct aoe_session, refcnt );
  35. abft_fill_data ( aoe );
  36. drive.blockdev = &ata.blockdev;
  37. register_int13_drive ( &drive );
  38. printf ( "Registered as BIOS drive %#02x\n", drive.drive );
  39. printf ( "Booting from BIOS drive %#02x\n", drive.drive );
  40. rc = int13_boot ( drive.drive );
  41. printf ( "Boot failed\n" );
  42. printf ( "Unregistering BIOS drive %#02x\n", drive.drive );
  43. unregister_int13_drive ( &drive );
  44. error_init:
  45. aoe_detach ( &ata );
  46. error_attach:
  47. return rc;
  48. }
  49. struct sanboot_protocol aoe_sanboot_protocol __sanboot_protocol = {
  50. .prefix = "aoe:",
  51. .boot = aoeboot,
  52. };