7 #include <gpxe/netdevice.h>
11 #include <usr/aoeboot.h>
14 * AoE boot information block
16 * Must be placed at 40:f0.
18 * This structure needs to be replaced by an ACPI table or similar.
20 struct aoe_boot_info {
23 /** Client MAC address */
24 uint8_t client[ETH_ALEN];
25 /** Server MAC address */
26 uint8_t server[ETH_ALEN];
31 } __attribute__ (( packed ));
34 * Guess boot network device
36 * @ret netdev Boot network device
38 static struct net_device * guess_boot_netdev ( void ) {
39 struct net_device *boot_netdev;
41 /* Just use the first network device */
42 for_each_netdev ( boot_netdev ) {
49 int aoeboot ( const char *root_path ) {
50 struct ata_device ata;
51 struct int13_drive drive;
54 memset ( &ata, 0, sizeof ( ata ) );
55 memset ( &drive, 0, sizeof ( drive ) );
57 printf ( "AoE booting from %s\n", root_path );
59 /* FIXME: ugly, ugly hack */
60 struct net_device *netdev = guess_boot_netdev();
62 if ( ( rc = aoe_attach ( &ata, netdev, root_path ) ) != 0 ) {
63 printf ( "Could not attach AoE device: %s\n",
67 if ( ( rc = init_atadev ( &ata ) ) != 0 ) {
68 printf ( "Could not initialise AoE device: %s\n",
73 /* FIXME: ugly, ugly hack */
74 struct aoe_session *aoe =
75 container_of ( ata.backend, struct aoe_session, refcnt );
76 struct aoe_boot_info boot_info;
78 memcpy ( boot_info.client, netdev->ll_addr,
79 sizeof ( boot_info.client ) );
80 memcpy ( boot_info.server, aoe->target,
81 sizeof ( boot_info.server ) );
82 boot_info.shelf = htons ( aoe->major );
83 boot_info.slot = aoe->minor;
84 copy_to_real ( 0x40, 0xf0, &boot_info, sizeof ( boot_info ) );
86 abft_fill_data ( aoe );
88 drive.drive = find_global_dhcp_num_option ( DHCP_EB_BIOS_DRIVE );
89 drive.blockdev = &ata.blockdev;
91 register_int13_drive ( &drive );
92 printf ( "Registered as BIOS drive %#02x\n", drive.drive );
93 printf ( "Booting from BIOS drive %#02x\n", drive.drive );
94 rc = int13_boot ( drive.drive );
95 printf ( "Boot failed\n" );
97 printf ( "Unregistering BIOS drive %#02x\n", drive.drive );
98 unregister_int13_drive ( &drive );