diff options
| author | Michael Brown | 2006-08-09 05:00:11 +0200 |
|---|---|---|
| committer | Michael Brown | 2006-08-09 05:00:11 +0200 |
| commit | c9e6c33bba13477fc73ecbded61558e1d2d38793 (patch) | |
| tree | 11d0c2baa633214ce97c878591e90b331cd7d085 /src/tests/tftptest.c | |
| parent | Implement enough of PXENV_GET_CACHED_INFO to support pxelinux. (diff) | |
| download | ipxe-c9e6c33bba13477fc73ecbded61558e1d2d38793.tar.gz ipxe-c9e6c33bba13477fc73ecbded61558e1d2d38793.tar.xz ipxe-c9e6c33bba13477fc73ecbded61558e1d2d38793.zip | |
Attempt a PXE NBP boot as the TFTP test.
Diffstat (limited to 'src/tests/tftptest.c')
| -rw-r--r-- | src/tests/tftptest.c | 34 |
1 files changed, 18 insertions, 16 deletions
diff --git a/src/tests/tftptest.c b/src/tests/tftptest.c index ba4c5d0f8..e09ef585f 100644 --- a/src/tests/tftptest.c +++ b/src/tests/tftptest.c @@ -4,32 +4,34 @@ #include <gpxe/udp.h> #include <gpxe/tftp.h> #include <gpxe/async.h> +#include <gpxe/uaccess.h> +#include "pxe.h" -static void test_tftp_callback ( struct tftp_session *tftp __unused, - unsigned int block __unused, +static void test_tftp_callback ( struct tftp_session *tftp, unsigned int block, void *data, size_t len ) { - unsigned int i; - char c; + unsigned long offset = ( ( block - 1 ) * tftp->blksize ); + userptr_t pxe_buffer = real_to_user ( 0, 0x7c00 ); - for ( i = 0 ; i < len ; i++ ) { - c = * ( ( char * ) data + i ); - if ( c == '\r' ) { - /* Print nothing */ - } else if ( ( c == '\n' ) || ( c >= 32 ) || ( c <= 126 ) ) { - putchar ( c ); - } else { - putchar ( '.' ); - } - } + copy_to_user ( pxe_buffer, offset, data, len ); } -int test_tftp ( struct sockaddr_tcpip *target, const char *filename ) { +int test_tftp ( struct net_device *netdev, struct sockaddr_tcpip *target, + const char *filename ) { struct tftp_session tftp; + int rc; memset ( &tftp, 0, sizeof ( tftp ) ); udp_connect ( &tftp.udp, target ); tftp.filename = filename; tftp.callback = test_tftp_callback; - return async_wait ( tftp_get ( &tftp ) ); + printf ( "Fetching \"%s\" via TFTP\n", filename ); + if ( ( rc = async_wait ( tftp_get ( &tftp ) ) ) != 0 ) + return rc; + + printf ( "Attempting PXE boot\n" ); + pxe_netdev = netdev; + rc = pxe_boot(); + printf ( "PXE NBP returned with status %04x\n", rc ); + return 0; } |
