7 #include <gpxe/netdevice.h>
10 #include <usr/aoeboot.h>
13 * AoE boot information block
15 * Must be placed at 40:f0.
17 * This structure needs to be replaced by an ACPI table or similar.
19 struct aoe_boot_info {
22 /** Client MAC address */
23 uint8_t client[ETH_ALEN];
24 /** Server MAC address */
25 uint8_t server[ETH_ALEN];
30 } __attribute__ (( packed ));
33 * Guess boot network device
35 * @ret netdev Boot network device
37 static struct net_device * guess_boot_netdev ( void ) {
38 struct net_device *boot_netdev;
40 /* Just use the first network device */
41 for_each_netdev ( boot_netdev ) {
48 int aoeboot ( const char *root_path ) {
49 struct ata_device ata;
50 struct int13_drive drive;
53 memset ( &ata, 0, sizeof ( ata ) );
54 memset ( &drive, 0, sizeof ( drive ) );
56 printf ( "AoE booting from %s\n", root_path );
58 /* FIXME: ugly, ugly hack */
59 struct net_device *netdev = guess_boot_netdev();
61 if ( ( rc = aoe_attach ( &ata, netdev, root_path ) ) != 0 ) {
62 printf ( "Could not attach AoE device: %s\n",
66 if ( ( rc = init_atadev ( &ata ) ) != 0 ) {
67 printf ( "Could not initialise AoE device: %s\n",
72 /* FIXME: ugly, ugly hack */
73 struct aoe_session *aoe =
74 container_of ( ata.backend, struct aoe_session, refcnt );
75 struct aoe_boot_info boot_info;
77 memcpy ( boot_info.client, netdev->ll_addr,
78 sizeof ( boot_info.client ) );
79 memcpy ( boot_info.server, aoe->target,
80 sizeof ( boot_info.server ) );
81 boot_info.shelf = htons ( aoe->major );
82 boot_info.slot = aoe->minor;
83 copy_to_real ( 0x40, 0xf0, &boot_info, sizeof ( boot_info ) );
85 drive.drive = find_global_dhcp_num_option ( DHCP_EB_BIOS_DRIVE );
86 drive.blockdev = &ata.blockdev;
88 register_int13_drive ( &drive );
89 printf ( "Registered as BIOS drive %#02x\n", drive.drive );
90 printf ( "Booting from BIOS drive %#02x\n", drive.drive );
91 rc = int13_boot ( drive.drive );
92 printf ( "Boot failed\n" );
94 printf ( "Unregistering BIOS drive %#02x\n", drive.drive );
95 unregister_int13_drive ( &drive );