From 91ac92bc863d0e0b17c321e19944fbffd52807c1 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Thu, 11 Jan 2007 15:27:06 +0000 Subject: [PATCH] Try image as ELF file first. (Don't yet actually try to execute it). --- src/tests/tftptest.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/tests/tftptest.c b/src/tests/tftptest.c index 2e558a35..57f51502 100644 --- a/src/tests/tftptest.c +++ b/src/tests/tftptest.c @@ -6,17 +6,22 @@ #include #include #include +#include +#include #include "pxe.h" int test_tftp ( struct net_device *netdev, struct sockaddr_tcpip *target, const char *filename ) { struct tftp_session tftp; struct buffer buffer; + struct elf elf; + uint16_t fbms; int rc; memset ( &buffer, 0, sizeof ( buffer ) ); buffer.addr = real_to_user ( 0, 0x7c00 ); - buffer.len = ( 512 * 1024 - 0x7c00 ); + get_real ( fbms, BDA_SEG, BDA_FBMS ); + buffer.len = ( fbms * 1024 - 0x7c00 ); memset ( &tftp, 0, sizeof ( tftp ) ); udp_connect ( &tftp.udp, target ); @@ -27,6 +32,14 @@ int test_tftp ( struct net_device *netdev, struct sockaddr_tcpip *target, if ( ( rc = async_wait ( tftp_get ( &tftp ) ) ) != 0 ) return rc; + elf.image = buffer.addr; + elf.len = buffer.len; + if ( ( rc = elf_load ( &elf ) ) == 0 ) { + printf ( "Got valid ELF image: execaddr at %lx\n", + elf.entry ); + return 0; + } + printf ( "Attempting PXE boot\n" ); pxe_netdev = netdev; rc = pxe_boot();