Warnings purge of drivers (continued)
[gpxe.git] / src / tests / aoeboot.c
blob17fda2c66c2ae3f4119c34881e3dbe655364f238
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>
10 static struct aoe_device test_aoedev = {
11 .aoe = {
12 .major = 0,
13 .minor = 0,
17 static int aoe_parse ( const char *aoename, struct aoe_session *aoe ) {
18 char *ptr = ( ( char * ) aoename );
20 if ( *ptr++ != 'e' )
21 return -EINVAL;
23 aoe->major = strtoul ( ptr, &ptr, 10 );
24 if ( *ptr++ != '.' )
25 return -EINVAL;
27 aoe->minor = strtoul ( ptr, &ptr, 10 );
28 if ( *ptr )
29 return -EINVAL;
31 return 0;
34 int test_aoeboot ( struct net_device *netdev, const char *aoename,
35 unsigned int drivenum ) {
36 struct int13_drive drive;
37 int rc;
39 printf ( "Attempting to boot from AoE device %s via %s\n",
40 aoename, netdev->name );
42 if ( ( rc = aoe_parse ( aoename, &test_aoedev.aoe ) ) != 0 ) {
43 printf ( "Invalid AoE device name \"%s\"\n", aoename );
44 return rc;
47 printf ( "Initialising AoE device e%d.%d\n",
48 test_aoedev.aoe.major, test_aoedev.aoe.minor );
49 test_aoedev.aoe.netdev = netdev;
50 if ( ( rc = init_aoedev ( &test_aoedev ) ) != 0 ) {
51 printf ( "Could not reach AoE device e%d.%d\n",
52 test_aoedev.aoe.major, test_aoedev.aoe.minor );
53 return rc;
56 memset ( &drive, 0, sizeof ( drive ) );
57 drive.drive = drivenum;
58 drive.blockdev = &test_aoedev.ata.blockdev;
59 register_int13_drive ( &drive );
60 printf ( "Registered AoE device e%d.%d as BIOS drive %#02x\n",
61 test_aoedev.aoe.major, test_aoedev.aoe.minor, 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 );
70 return rc;