6 #include <gpxe/async.h>
7 #include <gpxe/uaccess.h>
10 static void test_tftp_callback ( struct tftp_session *tftp, unsigned int block,
11 void *data, size_t len ) {
12 unsigned long offset = ( ( block - 1 ) * tftp->blksize );
13 userptr_t pxe_buffer = real_to_user ( 0, 0x7c00 );
15 copy_to_user ( pxe_buffer, offset, data, len );
18 int test_tftp ( struct net_device *netdev, struct sockaddr_tcpip *target,
19 const char *filename ) {
20 struct tftp_session tftp;
23 memset ( &tftp, 0, sizeof ( tftp ) );
24 udp_connect ( &tftp.udp, target );
25 tftp.filename = filename;
26 tftp.callback = test_tftp_callback;
28 printf ( "Fetching \"%s\" via TFTP\n", filename );
29 if ( ( rc = async_wait ( tftp_get ( &tftp ) ) ) != 0 )
32 printf ( "Attempting PXE boot\n" );
35 printf ( "PXE NBP returned with status %04x\n", rc );