Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

aoeboot.c 1.7KB

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