7 #include <gpxe/netdevice.h>
11 #include <usr/aoeboot.h>
14 * Guess boot network device
16 * @ret netdev Boot network device
18 static struct net_device * guess_boot_netdev ( void ) {
19 struct net_device *boot_netdev;
21 /* Just use the first network device */
22 for_each_netdev ( boot_netdev ) {
29 int aoeboot ( const char *root_path ) {
30 struct ata_device ata;
31 struct int13_drive drive;
34 memset ( &ata, 0, sizeof ( ata ) );
35 memset ( &drive, 0, sizeof ( drive ) );
37 printf ( "AoE booting from %s\n", root_path );
39 /* FIXME: ugly, ugly hack */
40 struct net_device *netdev = guess_boot_netdev();
42 if ( ( rc = aoe_attach ( &ata, netdev, root_path ) ) != 0 ) {
43 printf ( "Could not attach AoE device: %s\n",
47 if ( ( rc = init_atadev ( &ata ) ) != 0 ) {
48 printf ( "Could not initialise AoE device: %s\n",
53 /* FIXME: ugly, ugly hack */
54 struct aoe_session *aoe =
55 container_of ( ata.backend, struct aoe_session, refcnt );
56 abft_fill_data ( aoe );
58 drive.drive = find_global_dhcp_num_option ( DHCP_EB_BIOS_DRIVE );
59 drive.blockdev = &ata.blockdev;
61 register_int13_drive ( &drive );
62 printf ( "Registered as BIOS drive %#02x\n", drive.drive );
63 printf ( "Booting from BIOS drive %#02x\n", drive.drive );
64 rc = int13_boot ( drive.drive );
65 printf ( "Boot failed\n" );
67 printf ( "Unregistering BIOS drive %#02x\n", drive.drive );
68 unregister_int13_drive ( &drive );