mirror of https://github.com/ipxe/ipxe.git
Try image as ELF file first. (Don't yet actually try to execute it).
parent
3460860bef
commit
91ac92bc86
|
@ -6,17 +6,22 @@
|
||||||
#include <gpxe/async.h>
|
#include <gpxe/async.h>
|
||||||
#include <gpxe/uaccess.h>
|
#include <gpxe/uaccess.h>
|
||||||
#include <gpxe/buffer.h>
|
#include <gpxe/buffer.h>
|
||||||
|
#include <gpxe/elf.h>
|
||||||
|
#include <bios.h>
|
||||||
#include "pxe.h"
|
#include "pxe.h"
|
||||||
|
|
||||||
int test_tftp ( struct net_device *netdev, struct sockaddr_tcpip *target,
|
int test_tftp ( struct net_device *netdev, struct sockaddr_tcpip *target,
|
||||||
const char *filename ) {
|
const char *filename ) {
|
||||||
struct tftp_session tftp;
|
struct tftp_session tftp;
|
||||||
struct buffer buffer;
|
struct buffer buffer;
|
||||||
|
struct elf elf;
|
||||||
|
uint16_t fbms;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
memset ( &buffer, 0, sizeof ( buffer ) );
|
memset ( &buffer, 0, sizeof ( buffer ) );
|
||||||
buffer.addr = real_to_user ( 0, 0x7c00 );
|
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 ) );
|
memset ( &tftp, 0, sizeof ( tftp ) );
|
||||||
udp_connect ( &tftp.udp, target );
|
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 )
|
if ( ( rc = async_wait ( tftp_get ( &tftp ) ) ) != 0 )
|
||||||
return rc;
|
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" );
|
printf ( "Attempting PXE boot\n" );
|
||||||
pxe_netdev = netdev;
|
pxe_netdev = netdev;
|
||||||
rc = pxe_boot();
|
rc = pxe_boot();
|
||||||
|
|
Loading…
Reference in New Issue