Bladeren bron

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

tags/v0.9.3
Michael Brown 18 jaren geleden
bovenliggende
commit
91ac92bc86
1 gewijzigde bestanden met toevoegingen van 14 en 1 verwijderingen
  1. 14
    1
      src/tests/tftptest.c

+ 14
- 1
src/tests/tftptest.c Bestand weergeven

@@ -6,17 +6,22 @@
6 6
 #include <gpxe/async.h>
7 7
 #include <gpxe/uaccess.h>
8 8
 #include <gpxe/buffer.h>
9
+#include <gpxe/elf.h>
10
+#include <bios.h>
9 11
 #include "pxe.h"
10 12
 
11 13
 int test_tftp ( struct net_device *netdev, struct sockaddr_tcpip *target,
12 14
 		const char *filename ) {
13 15
 	struct tftp_session tftp;
14 16
 	struct buffer buffer;
17
+	struct elf elf;
18
+	uint16_t fbms;
15 19
 	int rc;
16 20
 
17 21
 	memset ( &buffer, 0, sizeof ( buffer ) );
18 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 26
 	memset ( &tftp, 0, sizeof ( tftp ) );
22 27
 	udp_connect ( &tftp.udp, target );
@@ -27,6 +32,14 @@ int test_tftp ( struct net_device *netdev, struct sockaddr_tcpip *target,
27 32
 	if ( ( rc = async_wait ( tftp_get ( &tftp ) ) ) != 0 )
28 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 43
 	printf ( "Attempting PXE boot\n" );
31 44
 	pxe_netdev = netdev;
32 45
 	rc = pxe_boot();

Laden…
Annuleren
Opslaan