Browse Source

Try image as ELF file first. (Don't yet actually try to execute it).

tags/v0.9.3
Michael Brown 18 years ago
parent
commit
91ac92bc86
1 changed files with 14 additions and 1 deletions
  1. 14
    1
      src/tests/tftptest.c

+ 14
- 1
src/tests/tftptest.c View File

6
 #include <gpxe/async.h>
6
 #include <gpxe/async.h>
7
 #include <gpxe/uaccess.h>
7
 #include <gpxe/uaccess.h>
8
 #include <gpxe/buffer.h>
8
 #include <gpxe/buffer.h>
9
+#include <gpxe/elf.h>
10
+#include <bios.h>
9
 #include "pxe.h"
11
 #include "pxe.h"
10
 
12
 
11
 int test_tftp ( struct net_device *netdev, struct sockaddr_tcpip *target,
13
 int test_tftp ( struct net_device *netdev, struct sockaddr_tcpip *target,
12
 		const char *filename ) {
14
 		const char *filename ) {
13
 	struct tftp_session tftp;
15
 	struct tftp_session tftp;
14
 	struct buffer buffer;
16
 	struct buffer buffer;
17
+	struct elf elf;
18
+	uint16_t fbms;
15
 	int rc;
19
 	int rc;
16
 
20
 
17
 	memset ( &buffer, 0, sizeof ( buffer ) );
21
 	memset ( &buffer, 0, sizeof ( buffer ) );
18
 	buffer.addr = real_to_user ( 0, 0x7c00 );
22
 	buffer.addr = real_to_user ( 0, 0x7c00 );
19
-	buffer.len = ( 512 * 1024 - 0x7c00 );
23
+	get_real ( fbms, BDA_SEG, BDA_FBMS );
24
+	buffer.len = ( fbms * 1024 - 0x7c00 );
20
 
25
 
21
 	memset ( &tftp, 0, sizeof ( tftp ) );
26
 	memset ( &tftp, 0, sizeof ( tftp ) );
22
 	udp_connect ( &tftp.udp, target );
27
 	udp_connect ( &tftp.udp, target );
27
 	if ( ( rc = async_wait ( tftp_get ( &tftp ) ) ) != 0 )
32
 	if ( ( rc = async_wait ( tftp_get ( &tftp ) ) ) != 0 )
28
 		return rc;
33
 		return rc;
29
 
34
 
35
+	elf.image = buffer.addr;
36
+	elf.len = buffer.len;
37
+	if ( ( rc = elf_load ( &elf ) ) == 0 ) {
38
+		printf ( "Got valid ELF image: execaddr at %lx\n",
39
+			 elf.entry );
40
+		return 0;
41
+	}
42
+
30
 	printf ( "Attempting PXE boot\n" );
43
 	printf ( "Attempting PXE boot\n" );
31
 	pxe_netdev = netdev;
44
 	pxe_netdev = netdev;
32
 	rc = pxe_boot();
45
 	rc = pxe_boot();

Loading…
Cancel
Save