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.

aoeboot.c 1.7KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. #include <stdint.h>
  2. #include <stdlib.h>
  3. #include <stdio.h>
  4. #include <errno.h>
  5. #include <console.h>
  6. #include <gpxe/netdevice.h>
  7. #include <gpxe/aoe.h>
  8. #include <int13.h>
  9. static struct aoe_device test_aoedev = {
  10. .aoe = {
  11. .major = 0,
  12. .minor = 0,
  13. },
  14. };
  15. static int aoe_parse ( const char *aoename, struct aoe_session *aoe ) {
  16. char *ptr = ( ( char * ) aoename );
  17. if ( *ptr++ != 'e' )
  18. return -EINVAL;
  19. aoe->major = strtoul ( ptr, &ptr, 10 );
  20. if ( *ptr++ != '.' )
  21. return -EINVAL;
  22. aoe->minor = strtoul ( ptr, &ptr, 10 );
  23. if ( *ptr )
  24. return -EINVAL;
  25. return 0;
  26. }
  27. int test_aoeboot ( struct net_device *netdev, const char *aoename,
  28. unsigned int drivenum ) {
  29. struct int13_drive drive;
  30. int rc;
  31. printf ( "Attempting to boot from AoE device %s via %s\n",
  32. aoename, netdev->name );
  33. if ( ( rc = aoe_parse ( aoename, &test_aoedev.aoe ) ) != 0 ) {
  34. printf ( "Invalid AoE device name \"%s\"\n", aoename );
  35. return rc;
  36. }
  37. printf ( "Initialising AoE device e%d.%d\n",
  38. test_aoedev.aoe.major, test_aoedev.aoe.minor );
  39. test_aoedev.aoe.netdev = netdev;
  40. if ( ( rc = init_aoedev ( &test_aoedev ) ) != 0 ) {
  41. printf ( "Could not reach AoE device e%d.%d\n",
  42. test_aoedev.aoe.major, test_aoedev.aoe.minor );
  43. return rc;
  44. }
  45. memset ( &drive, 0, sizeof ( drive ) );
  46. drive.drive = drivenum;
  47. drive.blockdev = &test_aoedev.ata.blockdev;
  48. register_int13_drive ( &drive );
  49. printf ( "Registered AoE device e%d.%d as BIOS drive %#02x\n",
  50. test_aoedev.aoe.major, test_aoedev.aoe.minor, drive.drive );
  51. printf ( "Booting from BIOS drive %#02x\n", drive.drive );
  52. rc = int13_boot ( drive.drive );
  53. printf ( "Boot failed\n" );
  54. printf ( "Unregistering BIOS drive %#02x\n", drive.drive );
  55. unregister_int13_drive ( &drive );
  56. return rc;
  57. }