6 #include <gpxe/async.h>
7 #include <gpxe/uaccess.h>
8 #include <gpxe/buffer.h>
9 #include <gpxe/image.h>
14 int test_tftp ( struct net_device *netdev, struct sockaddr_tcpip *target,
15 const char *filename ) {
16 struct tftp_session tftp;
23 ebuffer_alloc ( &buffer, 0 );
25 memset ( &buffer, 0, sizeof ( buffer ) );
26 buffer.addr = real_to_user ( 0, 0x7c00 );
27 get_real ( fbms, BDA_SEG, BDA_FBMS );
28 buffer.len = ( fbms * 1024 - 0x7c00 );
31 memset ( &tftp, 0, sizeof ( tftp ) );
32 udp_connect ( &tftp.udp, target );
33 tftp.filename = filename;
34 tftp.buffer = &buffer;
36 printf ( "Fetching \"%s\" via TFTP\n", filename );
37 if ( ( rc = async_wait ( tftp_get ( &tftp ) ) ) != 0 )
40 memset ( &image, 0, sizeof ( image ) );
41 image.data = buffer.addr;
42 image.len = buffer.len;
43 if ( ( rc = multiboot_load ( &image ) ) == 0 ) {
44 printf ( "Got valid multiboot image: execaddr at %lx\n",
47 image_exec ( &image );
52 printf ( "Attempting PXE boot\n" );
55 printf ( "PXE NBP returned with status %04x\n", rc );