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;
22 memset ( &buffer, 0, sizeof ( buffer ) );
23 buffer.addr = real_to_user ( 0, 0x7c00 );
24 get_real ( fbms, BDA_SEG, BDA_FBMS );
25 buffer.len = ( fbms * 1024 - 0x7c00 );
27 memset ( &tftp, 0, sizeof ( tftp ) );
28 udp_connect ( &tftp.udp, target );
29 tftp.filename = filename;
30 tftp.buffer = &buffer;
32 printf ( "Fetching \"%s\" via TFTP\n", filename );
33 if ( ( rc = async_wait ( tftp_get ( &tftp ) ) ) != 0 )
36 image.data = buffer.addr;
37 image.len = buffer.len;
38 if ( ( rc = elf_load ( &image ) ) == 0 ) {
39 printf ( "Got valid ELF image: execaddr at %lx\n",
44 printf ( "Attempting PXE boot\n" );
47 printf ( "PXE NBP returned with status %04x\n", rc );