|
@@ -4,32 +4,34 @@
|
4
|
4
|
#include <gpxe/udp.h>
|
5
|
5
|
#include <gpxe/tftp.h>
|
6
|
6
|
#include <gpxe/async.h>
|
|
7
|
+#include <gpxe/uaccess.h>
|
|
8
|
+#include "pxe.h"
|
7
|
9
|
|
8
|
|
-static void test_tftp_callback ( struct tftp_session *tftp __unused,
|
9
|
|
- unsigned int block __unused,
|
|
10
|
+static void test_tftp_callback ( struct tftp_session *tftp, unsigned int block,
|
10
|
11
|
void *data, size_t len ) {
|
11
|
|
- unsigned int i;
|
12
|
|
- char c;
|
|
12
|
+ unsigned long offset = ( ( block - 1 ) * tftp->blksize );
|
|
13
|
+ userptr_t pxe_buffer = real_to_user ( 0, 0x7c00 );
|
13
|
14
|
|
14
|
|
- for ( i = 0 ; i < len ; i++ ) {
|
15
|
|
- c = * ( ( char * ) data + i );
|
16
|
|
- if ( c == '\r' ) {
|
17
|
|
- /* Print nothing */
|
18
|
|
- } else if ( ( c == '\n' ) || ( c >= 32 ) || ( c <= 126 ) ) {
|
19
|
|
- putchar ( c );
|
20
|
|
- } else {
|
21
|
|
- putchar ( '.' );
|
22
|
|
- }
|
23
|
|
- }
|
|
15
|
+ copy_to_user ( pxe_buffer, offset, data, len );
|
24
|
16
|
}
|
25
|
17
|
|
26
|
|
-int test_tftp ( struct sockaddr_tcpip *target, const char *filename ) {
|
|
18
|
+int test_tftp ( struct net_device *netdev, struct sockaddr_tcpip *target,
|
|
19
|
+ const char *filename ) {
|
27
|
20
|
struct tftp_session tftp;
|
|
21
|
+ int rc;
|
28
|
22
|
|
29
|
23
|
memset ( &tftp, 0, sizeof ( tftp ) );
|
30
|
24
|
udp_connect ( &tftp.udp, target );
|
31
|
25
|
tftp.filename = filename;
|
32
|
26
|
tftp.callback = test_tftp_callback;
|
33
|
27
|
|
34
|
|
- return async_wait ( tftp_get ( &tftp ) );
|
|
28
|
+ printf ( "Fetching \"%s\" via TFTP\n", filename );
|
|
29
|
+ if ( ( rc = async_wait ( tftp_get ( &tftp ) ) ) != 0 )
|
|
30
|
+ return rc;
|
|
31
|
+
|
|
32
|
+ printf ( "Attempting PXE boot\n" );
|
|
33
|
+ pxe_netdev = netdev;
|
|
34
|
+ rc = pxe_boot();
|
|
35
|
+ printf ( "PXE NBP returned with status %04x\n", rc );
|
|
36
|
+ return 0;
|
35
|
37
|
}
|