2006-08-09 00:09:29 +00:00
|
|
|
#include <stdint.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <console.h>
|
|
|
|
#include <gpxe/udp.h>
|
|
|
|
#include <gpxe/tftp.h>
|
|
|
|
#include <gpxe/async.h>
|
2006-08-09 03:00:11 +00:00
|
|
|
#include <gpxe/uaccess.h>
|
|
|
|
#include "pxe.h"
|
2006-08-09 00:09:29 +00:00
|
|
|
|
2006-08-09 03:00:11 +00:00
|
|
|
static void test_tftp_callback ( struct tftp_session *tftp, unsigned int block,
|
2006-08-09 00:09:29 +00:00
|
|
|
void *data, size_t len ) {
|
2006-08-09 03:00:11 +00:00
|
|
|
unsigned long offset = ( ( block - 1 ) * tftp->blksize );
|
|
|
|
userptr_t pxe_buffer = real_to_user ( 0, 0x7c00 );
|
2006-08-09 00:09:29 +00:00
|
|
|
|
2006-08-09 03:00:11 +00:00
|
|
|
copy_to_user ( pxe_buffer, offset, data, len );
|
2006-08-09 00:09:29 +00:00
|
|
|
}
|
|
|
|
|
2006-08-09 03:00:11 +00:00
|
|
|
int test_tftp ( struct net_device *netdev, struct sockaddr_tcpip *target,
|
|
|
|
const char *filename ) {
|
2006-08-09 00:09:29 +00:00
|
|
|
struct tftp_session tftp;
|
2006-08-09 03:00:11 +00:00
|
|
|
int rc;
|
2006-08-09 00:09:29 +00:00
|
|
|
|
|
|
|
memset ( &tftp, 0, sizeof ( tftp ) );
|
|
|
|
udp_connect ( &tftp.udp, target );
|
|
|
|
tftp.filename = filename;
|
|
|
|
tftp.callback = test_tftp_callback;
|
|
|
|
|
2006-08-09 03:00:11 +00:00
|
|
|
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;
|
2006-08-09 00:09:29 +00:00
|
|
|
}
|