Explorar el Código

Attempt a PXE NBP boot as the TFTP test.

tags/v0.9.3
Michael Brown hace 18 años
padre
commit
c9e6c33bba
Se han modificado 2 ficheros con 21 adiciones y 19 borrados
  1. 3
    3
      src/tests/dhcptest.c
  2. 18
    16
      src/tests/tftptest.c

+ 3
- 3
src/tests/dhcptest.c Ver fichero

@@ -57,7 +57,7 @@ static int test_dhcp_hello ( char *helloname ) {
57 57
 	return 0;
58 58
 }
59 59
 
60
-static int test_dhcp_tftp ( char *tftpname ) {
60
+static int test_dhcp_tftp ( struct net_device *netdev, char *tftpname ) {
61 61
 	union {
62 62
 		struct sockaddr_in sin;
63 63
 		struct sockaddr_tcpip st;
@@ -69,7 +69,7 @@ static int test_dhcp_tftp ( char *tftpname ) {
69 69
 	find_global_dhcp_ipv4_option ( DHCP_EB_SIADDR,
70 70
 				       &target.sin.sin_addr );
71 71
 
72
-	return test_tftp ( &target.st, tftpname );
72
+	return test_tftp ( netdev, &target.st, tftpname );
73 73
 }
74 74
 
75 75
 static int test_dhcp_boot ( struct net_device *netdev, char *filename ) {
@@ -80,7 +80,7 @@ static int test_dhcp_boot ( struct net_device *netdev, char *filename ) {
80 80
 	} else if ( strncmp ( filename, "hello:", 6 ) == 0 ) {
81 81
 		return test_dhcp_hello ( &filename[6] );
82 82
 	} else {
83
-		return test_dhcp_tftp ( filename );
83
+		return test_dhcp_tftp ( netdev, filename );
84 84
 	}
85 85
 }
86 86
 

+ 18
- 16
src/tests/tftptest.c Ver fichero

@@ -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
 }

Loading…
Cancelar
Guardar