mirror of https://github.com/ipxe/ipxe.git
[pxe] Separate parent PXE API caller from UNDINET driver
Calling the parent PXE stack (the stack that loaded us, for undionly.kkpxe) can be useful for more than UNDI calls; for instance, it lets us get cached DHCP packets to avoid re-DHCP when working with embedded images. Signed-off-by: Marty Connor <mdc@etherboot.org>pull/1/head
parent
2d58a62330
commit
337e1ed4b4
|
@ -80,6 +80,7 @@ SRCDIRS += arch/i386/drivers
|
||||||
SRCDIRS += arch/i386/drivers/net
|
SRCDIRS += arch/i386/drivers/net
|
||||||
SRCDIRS += arch/i386/interface/pcbios
|
SRCDIRS += arch/i386/interface/pcbios
|
||||||
SRCDIRS += arch/i386/interface/pxe
|
SRCDIRS += arch/i386/interface/pxe
|
||||||
|
SRCDIRS += arch/i386/interface/pxeparent
|
||||||
SRCDIRS += arch/i386/interface/syslinux
|
SRCDIRS += arch/i386/interface/syslinux
|
||||||
SRCDIRS += arch/i386/hci/commands
|
SRCDIRS += arch/i386/hci/commands
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,7 @@ undiisr:
|
||||||
movw %ax, %ds
|
movw %ax, %ds
|
||||||
|
|
||||||
/* Check that we have an UNDI entry point */
|
/* Check that we have an UNDI entry point */
|
||||||
cmpw $0, undinet_entry_point
|
cmpw $0, pxeparent_entry_point
|
||||||
je chain
|
je chain
|
||||||
|
|
||||||
/* Issue UNDI API call */
|
/* Issue UNDI API call */
|
||||||
|
@ -42,7 +42,7 @@ undiisr:
|
||||||
pushw %es
|
pushw %es
|
||||||
pushw %di
|
pushw %di
|
||||||
pushw %bx
|
pushw %bx
|
||||||
lcall *undinet_entry_point
|
lcall *pxeparent_entry_point
|
||||||
cli /* Just in case */
|
cli /* Just in case */
|
||||||
addw $6, %sp
|
addw $6, %sp
|
||||||
cmpw $PXENV_UNDI_ISR_OUT_OURS, funcflag
|
cmpw $PXENV_UNDI_ISR_OUT_OURS, funcflag
|
||||||
|
|
|
@ -32,6 +32,7 @@ FILE_LICENCE ( GPL2_OR_LATER );
|
||||||
#include <gpxe/ethernet.h>
|
#include <gpxe/ethernet.h>
|
||||||
#include <undi.h>
|
#include <undi.h>
|
||||||
#include <undinet.h>
|
#include <undinet.h>
|
||||||
|
#include <pxeparent.h>
|
||||||
|
|
||||||
|
|
||||||
/** @file
|
/** @file
|
||||||
|
@ -62,178 +63,8 @@ struct undi_nic {
|
||||||
|
|
||||||
static void undinet_close ( struct net_device *netdev );
|
static void undinet_close ( struct net_device *netdev );
|
||||||
|
|
||||||
/*****************************************************************************
|
/** Address of UNDI entry point */
|
||||||
*
|
static SEGOFF16_t undinet_entry;
|
||||||
* UNDI API call
|
|
||||||
*
|
|
||||||
*****************************************************************************
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Name UNDI API call
|
|
||||||
*
|
|
||||||
* @v function API call number
|
|
||||||
* @ret name API call name
|
|
||||||
*/
|
|
||||||
static inline __attribute__ (( always_inline )) const char *
|
|
||||||
undinet_function_name ( unsigned int function ) {
|
|
||||||
switch ( function ) {
|
|
||||||
case PXENV_START_UNDI:
|
|
||||||
return "PXENV_START_UNDI";
|
|
||||||
case PXENV_STOP_UNDI:
|
|
||||||
return "PXENV_STOP_UNDI";
|
|
||||||
case PXENV_UNDI_STARTUP:
|
|
||||||
return "PXENV_UNDI_STARTUP";
|
|
||||||
case PXENV_UNDI_CLEANUP:
|
|
||||||
return "PXENV_UNDI_CLEANUP";
|
|
||||||
case PXENV_UNDI_INITIALIZE:
|
|
||||||
return "PXENV_UNDI_INITIALIZE";
|
|
||||||
case PXENV_UNDI_RESET_ADAPTER:
|
|
||||||
return "PXENV_UNDI_RESET_ADAPTER";
|
|
||||||
case PXENV_UNDI_SHUTDOWN:
|
|
||||||
return "PXENV_UNDI_SHUTDOWN";
|
|
||||||
case PXENV_UNDI_OPEN:
|
|
||||||
return "PXENV_UNDI_OPEN";
|
|
||||||
case PXENV_UNDI_CLOSE:
|
|
||||||
return "PXENV_UNDI_CLOSE";
|
|
||||||
case PXENV_UNDI_TRANSMIT:
|
|
||||||
return "PXENV_UNDI_TRANSMIT";
|
|
||||||
case PXENV_UNDI_SET_MCAST_ADDRESS:
|
|
||||||
return "PXENV_UNDI_SET_MCAST_ADDRESS";
|
|
||||||
case PXENV_UNDI_SET_STATION_ADDRESS:
|
|
||||||
return "PXENV_UNDI_SET_STATION_ADDRESS";
|
|
||||||
case PXENV_UNDI_SET_PACKET_FILTER:
|
|
||||||
return "PXENV_UNDI_SET_PACKET_FILTER";
|
|
||||||
case PXENV_UNDI_GET_INFORMATION:
|
|
||||||
return "PXENV_UNDI_GET_INFORMATION";
|
|
||||||
case PXENV_UNDI_GET_STATISTICS:
|
|
||||||
return "PXENV_UNDI_GET_STATISTICS";
|
|
||||||
case PXENV_UNDI_CLEAR_STATISTICS:
|
|
||||||
return "PXENV_UNDI_CLEAR_STATISTICS";
|
|
||||||
case PXENV_UNDI_INITIATE_DIAGS:
|
|
||||||
return "PXENV_UNDI_INITIATE_DIAGS";
|
|
||||||
case PXENV_UNDI_FORCE_INTERRUPT:
|
|
||||||
return "PXENV_UNDI_FORCE_INTERRUPT";
|
|
||||||
case PXENV_UNDI_GET_MCAST_ADDRESS:
|
|
||||||
return "PXENV_UNDI_GET_MCAST_ADDRESS";
|
|
||||||
case PXENV_UNDI_GET_NIC_TYPE:
|
|
||||||
return "PXENV_UNDI_GET_NIC_TYPE";
|
|
||||||
case PXENV_UNDI_GET_IFACE_INFO:
|
|
||||||
return "PXENV_UNDI_GET_IFACE_INFO";
|
|
||||||
/*
|
|
||||||
* Duplicate case value; this is a bug in the PXE specification.
|
|
||||||
*
|
|
||||||
* case PXENV_UNDI_GET_STATE:
|
|
||||||
* return "PXENV_UNDI_GET_STATE";
|
|
||||||
*/
|
|
||||||
case PXENV_UNDI_ISR:
|
|
||||||
return "PXENV_UNDI_ISR";
|
|
||||||
default:
|
|
||||||
return "UNKNOWN API CALL";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* UNDI parameter block
|
|
||||||
*
|
|
||||||
* Used as the paramter block for all UNDI API calls. Resides in base
|
|
||||||
* memory.
|
|
||||||
*/
|
|
||||||
static union u_PXENV_ANY __bss16 ( undinet_params );
|
|
||||||
#define undinet_params __use_data16 ( undinet_params )
|
|
||||||
|
|
||||||
/** UNDI entry point
|
|
||||||
*
|
|
||||||
* Used as the indirection vector for all UNDI API calls. Resides in
|
|
||||||
* base memory.
|
|
||||||
*/
|
|
||||||
SEGOFF16_t __bss16 ( undinet_entry_point );
|
|
||||||
#define undinet_entry_point __use_data16 ( undinet_entry_point )
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Issue UNDI API call
|
|
||||||
*
|
|
||||||
* @v undinic UNDI NIC
|
|
||||||
* @v function API call number
|
|
||||||
* @v params UNDI parameter block
|
|
||||||
* @v params_len Length of UNDI parameter block
|
|
||||||
* @ret rc Return status code
|
|
||||||
*/
|
|
||||||
static int undinet_call ( struct undi_nic *undinic, unsigned int function,
|
|
||||||
void *params, size_t params_len ) {
|
|
||||||
PXENV_EXIT_t exit;
|
|
||||||
int discard_b, discard_D;
|
|
||||||
int rc;
|
|
||||||
|
|
||||||
/* Copy parameter block and entry point */
|
|
||||||
assert ( params_len <= sizeof ( undinet_params ) );
|
|
||||||
memcpy ( &undinet_params, params, params_len );
|
|
||||||
|
|
||||||
/* Call real-mode entry point. This calling convention will
|
|
||||||
* work with both the !PXE and the PXENV+ entry points.
|
|
||||||
*/
|
|
||||||
__asm__ __volatile__ ( REAL_CODE ( "pushw %%es\n\t"
|
|
||||||
"pushw %%di\n\t"
|
|
||||||
"pushw %%bx\n\t"
|
|
||||||
"lcall *undinet_entry_point\n\t"
|
|
||||||
"addw $6, %%sp\n\t" )
|
|
||||||
: "=a" ( exit ), "=b" ( discard_b ),
|
|
||||||
"=D" ( discard_D )
|
|
||||||
: "b" ( function ),
|
|
||||||
"D" ( __from_data16 ( &undinet_params ) )
|
|
||||||
: "ecx", "edx", "esi", "ebp" );
|
|
||||||
|
|
||||||
/* UNDI API calls may rudely change the status of A20 and not
|
|
||||||
* bother to restore it afterwards. Intel is known to be
|
|
||||||
* guilty of this.
|
|
||||||
*
|
|
||||||
* Note that we will return to this point even if A20 gets
|
|
||||||
* screwed up by the UNDI driver, because Etherboot always
|
|
||||||
* resides in an even megabyte of RAM.
|
|
||||||
*/
|
|
||||||
gateA20_set();
|
|
||||||
|
|
||||||
/* Determine return status code based on PXENV_EXIT and
|
|
||||||
* PXENV_STATUS
|
|
||||||
*/
|
|
||||||
if ( exit == PXENV_EXIT_SUCCESS ) {
|
|
||||||
rc = 0;
|
|
||||||
} else {
|
|
||||||
rc = -undinet_params.Status;
|
|
||||||
/* Paranoia; don't return success for the combination
|
|
||||||
* of PXENV_EXIT_FAILURE but PXENV_STATUS_SUCCESS
|
|
||||||
*/
|
|
||||||
if ( rc == 0 )
|
|
||||||
rc = -EIO;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* If anything goes wrong, print as much debug information as
|
|
||||||
* it's possible to give.
|
|
||||||
*/
|
|
||||||
if ( rc != 0 ) {
|
|
||||||
SEGOFF16_t rm_params = {
|
|
||||||
.segment = rm_ds,
|
|
||||||
.offset = __from_data16 ( &undinet_params ),
|
|
||||||
};
|
|
||||||
|
|
||||||
DBGC ( undinic, "UNDINIC %p %s failed: %s\n", undinic,
|
|
||||||
undinet_function_name ( function ), strerror ( rc ) );
|
|
||||||
DBGC ( undinic, "UNDINIC %p parameters at %04x:%04x length "
|
|
||||||
"%#02zx, entry point at %04x:%04x\n", undinic,
|
|
||||||
rm_params.segment, rm_params.offset, params_len,
|
|
||||||
undinet_entry_point.segment,
|
|
||||||
undinet_entry_point.offset );
|
|
||||||
DBGC ( undinic, "UNDINIC %p parameters provided:\n", undinic );
|
|
||||||
DBGC_HDA ( undinic, rm_params, params, params_len );
|
|
||||||
DBGC ( undinic, "UNDINIC %p parameters returned:\n", undinic );
|
|
||||||
DBGC_HDA ( undinic, rm_params, &undinet_params, params_len );
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Copy parameter block back */
|
|
||||||
memcpy ( params, &undinet_params, params_len );
|
|
||||||
|
|
||||||
return rc;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*****************************************************************************
|
/*****************************************************************************
|
||||||
*
|
*
|
||||||
|
@ -336,7 +167,6 @@ static struct s_PXENV_UNDI_TBD __data16 ( undinet_tbd );
|
||||||
*/
|
*/
|
||||||
static int undinet_transmit ( struct net_device *netdev,
|
static int undinet_transmit ( struct net_device *netdev,
|
||||||
struct io_buffer *iobuf ) {
|
struct io_buffer *iobuf ) {
|
||||||
struct undi_nic *undinic = netdev->priv;
|
|
||||||
struct s_PXENV_UNDI_TRANSMIT undi_transmit;
|
struct s_PXENV_UNDI_TRANSMIT undi_transmit;
|
||||||
size_t len = iob_len ( iobuf );
|
size_t len = iob_len ( iobuf );
|
||||||
int rc;
|
int rc;
|
||||||
|
@ -369,9 +199,9 @@ static int undinet_transmit ( struct net_device *netdev,
|
||||||
undinet_tbd.Xmit.offset = __from_data16 ( basemem_packet );
|
undinet_tbd.Xmit.offset = __from_data16 ( basemem_packet );
|
||||||
|
|
||||||
/* Issue PXE API call */
|
/* Issue PXE API call */
|
||||||
if ( ( rc = undinet_call ( undinic, PXENV_UNDI_TRANSMIT,
|
if ( ( rc = pxeparent_call ( undinet_entry, PXENV_UNDI_TRANSMIT,
|
||||||
&undi_transmit,
|
&undi_transmit,
|
||||||
sizeof ( undi_transmit ) ) ) != 0 )
|
sizeof ( undi_transmit ) ) ) != 0 )
|
||||||
goto done;
|
goto done;
|
||||||
|
|
||||||
/* Free I/O buffer */
|
/* Free I/O buffer */
|
||||||
|
@ -441,8 +271,9 @@ static void undinet_poll ( struct net_device *netdev ) {
|
||||||
|
|
||||||
/* Run through the ISR loop */
|
/* Run through the ISR loop */
|
||||||
while ( 1 ) {
|
while ( 1 ) {
|
||||||
if ( ( rc = undinet_call ( undinic, PXENV_UNDI_ISR, &undi_isr,
|
if ( ( rc = pxeparent_call ( undinet_entry, PXENV_UNDI_ISR,
|
||||||
sizeof ( undi_isr ) ) ) != 0 )
|
&undi_isr,
|
||||||
|
sizeof ( undi_isr ) ) ) != 0 )
|
||||||
break;
|
break;
|
||||||
switch ( undi_isr.FuncFlag ) {
|
switch ( undi_isr.FuncFlag ) {
|
||||||
case PXENV_UNDI_ISR_OUT_TRANSMIT:
|
case PXENV_UNDI_ISR_OUT_TRANSMIT:
|
||||||
|
@ -538,8 +369,8 @@ static int undinet_open ( struct net_device *netdev ) {
|
||||||
*/
|
*/
|
||||||
memcpy ( undi_set_address.StationAddress, netdev->ll_addr,
|
memcpy ( undi_set_address.StationAddress, netdev->ll_addr,
|
||||||
sizeof ( undi_set_address.StationAddress ) );
|
sizeof ( undi_set_address.StationAddress ) );
|
||||||
undinet_call ( undinic, PXENV_UNDI_SET_STATION_ADDRESS,
|
pxeparent_call ( undinet_entry, PXENV_UNDI_SET_STATION_ADDRESS,
|
||||||
&undi_set_address, sizeof ( undi_set_address ) );
|
&undi_set_address, sizeof ( undi_set_address ) );
|
||||||
|
|
||||||
/* Open NIC. We ask for promiscuous operation, since it's the
|
/* Open NIC. We ask for promiscuous operation, since it's the
|
||||||
* only way to ask for all multicast addresses. On any
|
* only way to ask for all multicast addresses. On any
|
||||||
|
@ -548,8 +379,8 @@ static int undinet_open ( struct net_device *netdev ) {
|
||||||
*/
|
*/
|
||||||
memset ( &undi_open, 0, sizeof ( undi_open ) );
|
memset ( &undi_open, 0, sizeof ( undi_open ) );
|
||||||
undi_open.PktFilter = ( FLTR_DIRECTED | FLTR_BRDCST | FLTR_PRMSCS );
|
undi_open.PktFilter = ( FLTR_DIRECTED | FLTR_BRDCST | FLTR_PRMSCS );
|
||||||
if ( ( rc = undinet_call ( undinic, PXENV_UNDI_OPEN, &undi_open,
|
if ( ( rc = pxeparent_call ( undinet_entry, PXENV_UNDI_OPEN,
|
||||||
sizeof ( undi_open ) ) ) != 0 )
|
&undi_open, sizeof ( undi_open ) ) ) != 0 )
|
||||||
goto err;
|
goto err;
|
||||||
|
|
||||||
DBGC ( undinic, "UNDINIC %p opened\n", undinic );
|
DBGC ( undinic, "UNDINIC %p opened\n", undinic );
|
||||||
|
@ -574,8 +405,9 @@ static void undinet_close ( struct net_device *netdev ) {
|
||||||
/* Ensure ISR has exited cleanly */
|
/* Ensure ISR has exited cleanly */
|
||||||
while ( undinic->isr_processing ) {
|
while ( undinic->isr_processing ) {
|
||||||
undi_isr.FuncFlag = PXENV_UNDI_ISR_IN_GET_NEXT;
|
undi_isr.FuncFlag = PXENV_UNDI_ISR_IN_GET_NEXT;
|
||||||
if ( ( rc = undinet_call ( undinic, PXENV_UNDI_ISR, &undi_isr,
|
if ( ( rc = pxeparent_call ( undinet_entry, PXENV_UNDI_ISR,
|
||||||
sizeof ( undi_isr ) ) ) != 0 )
|
&undi_isr,
|
||||||
|
sizeof ( undi_isr ) ) ) != 0 )
|
||||||
break;
|
break;
|
||||||
switch ( undi_isr.FuncFlag ) {
|
switch ( undi_isr.FuncFlag ) {
|
||||||
case PXENV_UNDI_ISR_OUT_TRANSMIT:
|
case PXENV_UNDI_ISR_OUT_TRANSMIT:
|
||||||
|
@ -590,8 +422,8 @@ static void undinet_close ( struct net_device *netdev ) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Close NIC */
|
/* Close NIC */
|
||||||
undinet_call ( undinic, PXENV_UNDI_CLOSE, &undi_close,
|
pxeparent_call ( undinet_entry, PXENV_UNDI_CLOSE,
|
||||||
sizeof ( undi_close ) );
|
&undi_close, sizeof ( undi_close ) );
|
||||||
|
|
||||||
/* Disable interrupt and unhook ISR */
|
/* Disable interrupt and unhook ISR */
|
||||||
disable_irq ( undinic->irq );
|
disable_irq ( undinic->irq );
|
||||||
|
@ -651,7 +483,7 @@ int undinet_probe ( struct undi_device *undi ) {
|
||||||
undi_set_drvdata ( undi, netdev );
|
undi_set_drvdata ( undi, netdev );
|
||||||
netdev->dev = &undi->dev;
|
netdev->dev = &undi->dev;
|
||||||
memset ( undinic, 0, sizeof ( *undinic ) );
|
memset ( undinic, 0, sizeof ( *undinic ) );
|
||||||
undinet_entry_point = undi->entry;
|
undinet_entry = undi->entry;
|
||||||
DBGC ( undinic, "UNDINIC %p using UNDI %p\n", undinic, undi );
|
DBGC ( undinic, "UNDINIC %p using UNDI %p\n", undinic, undi );
|
||||||
|
|
||||||
/* Hook in UNDI stack */
|
/* Hook in UNDI stack */
|
||||||
|
@ -662,9 +494,9 @@ int undinet_probe ( struct undi_device *undi ) {
|
||||||
start_undi.DX = undi->isapnp_read_port;
|
start_undi.DX = undi->isapnp_read_port;
|
||||||
start_undi.ES = BIOS_SEG;
|
start_undi.ES = BIOS_SEG;
|
||||||
start_undi.DI = find_pnp_bios();
|
start_undi.DI = find_pnp_bios();
|
||||||
if ( ( rc = undinet_call ( undinic, PXENV_START_UNDI,
|
if ( ( rc = pxeparent_call ( undinet_entry, PXENV_START_UNDI,
|
||||||
&start_undi,
|
&start_undi,
|
||||||
sizeof ( start_undi ) ) ) != 0 )
|
sizeof ( start_undi ) ) ) != 0 )
|
||||||
goto err_start_undi;
|
goto err_start_undi;
|
||||||
}
|
}
|
||||||
undi->flags |= UNDI_FL_STARTED;
|
undi->flags |= UNDI_FL_STARTED;
|
||||||
|
@ -672,22 +504,23 @@ int undinet_probe ( struct undi_device *undi ) {
|
||||||
/* Bring up UNDI stack */
|
/* Bring up UNDI stack */
|
||||||
if ( ! ( undi->flags & UNDI_FL_INITIALIZED ) ) {
|
if ( ! ( undi->flags & UNDI_FL_INITIALIZED ) ) {
|
||||||
memset ( &undi_startup, 0, sizeof ( undi_startup ) );
|
memset ( &undi_startup, 0, sizeof ( undi_startup ) );
|
||||||
if ( ( rc = undinet_call ( undinic, PXENV_UNDI_STARTUP,
|
if ( ( rc = pxeparent_call ( undinet_entry, PXENV_UNDI_STARTUP,
|
||||||
&undi_startup,
|
&undi_startup,
|
||||||
sizeof ( undi_startup ) ) ) != 0 )
|
sizeof ( undi_startup ) ) ) != 0 )
|
||||||
goto err_undi_startup;
|
goto err_undi_startup;
|
||||||
memset ( &undi_initialize, 0, sizeof ( undi_initialize ) );
|
memset ( &undi_initialize, 0, sizeof ( undi_initialize ) );
|
||||||
if ( ( rc = undinet_call ( undinic, PXENV_UNDI_INITIALIZE,
|
if ( ( rc = pxeparent_call ( undinet_entry,
|
||||||
&undi_initialize,
|
PXENV_UNDI_INITIALIZE,
|
||||||
sizeof ( undi_initialize ))) != 0 )
|
&undi_initialize,
|
||||||
|
sizeof ( undi_initialize ))) != 0 )
|
||||||
goto err_undi_initialize;
|
goto err_undi_initialize;
|
||||||
}
|
}
|
||||||
undi->flags |= UNDI_FL_INITIALIZED;
|
undi->flags |= UNDI_FL_INITIALIZED;
|
||||||
|
|
||||||
/* Get device information */
|
/* Get device information */
|
||||||
memset ( &undi_info, 0, sizeof ( undi_info ) );
|
memset ( &undi_info, 0, sizeof ( undi_info ) );
|
||||||
if ( ( rc = undinet_call ( undinic, PXENV_UNDI_GET_INFORMATION,
|
if ( ( rc = pxeparent_call ( undinet_entry, PXENV_UNDI_GET_INFORMATION,
|
||||||
&undi_info, sizeof ( undi_info ) ) ) != 0 )
|
&undi_info, sizeof ( undi_info ) ) ) != 0 )
|
||||||
goto err_undi_get_information;
|
goto err_undi_get_information;
|
||||||
memcpy ( netdev->hw_addr, undi_info.PermNodeAddress, ETH_ALEN );
|
memcpy ( netdev->hw_addr, undi_info.PermNodeAddress, ETH_ALEN );
|
||||||
undinic->irq = undi_info.IntNumber;
|
undinic->irq = undi_info.IntNumber;
|
||||||
|
@ -701,9 +534,9 @@ int undinet_probe ( struct undi_device *undi ) {
|
||||||
|
|
||||||
/* Get interface information */
|
/* Get interface information */
|
||||||
memset ( &undi_iface, 0, sizeof ( undi_iface ) );
|
memset ( &undi_iface, 0, sizeof ( undi_iface ) );
|
||||||
if ( ( rc = undinet_call ( undinic, PXENV_UNDI_GET_IFACE_INFO,
|
if ( ( rc = pxeparent_call ( undinet_entry, PXENV_UNDI_GET_IFACE_INFO,
|
||||||
&undi_iface,
|
&undi_iface,
|
||||||
sizeof ( undi_iface ) ) ) != 0 )
|
sizeof ( undi_iface ) ) ) != 0 )
|
||||||
goto err_undi_get_iface_info;
|
goto err_undi_get_iface_info;
|
||||||
DBGC ( undinic, "UNDINIC %p has type %s, speed %d, flags %08x\n",
|
DBGC ( undinic, "UNDINIC %p has type %s, speed %d, flags %08x\n",
|
||||||
undinic, undi_iface.IfaceType, undi_iface.LinkSpeed,
|
undinic, undi_iface.IfaceType, undi_iface.LinkSpeed,
|
||||||
|
@ -732,17 +565,17 @@ int undinet_probe ( struct undi_device *undi ) {
|
||||||
err_undi_initialize:
|
err_undi_initialize:
|
||||||
/* Shut down UNDI stack */
|
/* Shut down UNDI stack */
|
||||||
memset ( &undi_shutdown, 0, sizeof ( undi_shutdown ) );
|
memset ( &undi_shutdown, 0, sizeof ( undi_shutdown ) );
|
||||||
undinet_call ( undinic, PXENV_UNDI_SHUTDOWN, &undi_shutdown,
|
pxeparent_call ( undinet_entry, PXENV_UNDI_SHUTDOWN, &undi_shutdown,
|
||||||
sizeof ( undi_shutdown ) );
|
sizeof ( undi_shutdown ) );
|
||||||
memset ( &undi_cleanup, 0, sizeof ( undi_cleanup ) );
|
memset ( &undi_cleanup, 0, sizeof ( undi_cleanup ) );
|
||||||
undinet_call ( undinic, PXENV_UNDI_CLEANUP, &undi_cleanup,
|
pxeparent_call ( undinet_entry, PXENV_UNDI_CLEANUP, &undi_cleanup,
|
||||||
sizeof ( undi_cleanup ) );
|
sizeof ( undi_cleanup ) );
|
||||||
undi->flags &= ~UNDI_FL_INITIALIZED;
|
undi->flags &= ~UNDI_FL_INITIALIZED;
|
||||||
err_undi_startup:
|
err_undi_startup:
|
||||||
/* Unhook UNDI stack */
|
/* Unhook UNDI stack */
|
||||||
memset ( &stop_undi, 0, sizeof ( stop_undi ) );
|
memset ( &stop_undi, 0, sizeof ( stop_undi ) );
|
||||||
undinet_call ( undinic, PXENV_STOP_UNDI, &stop_undi,
|
pxeparent_call ( undinet_entry, PXENV_STOP_UNDI, &stop_undi,
|
||||||
sizeof ( stop_undi ) );
|
sizeof ( stop_undi ) );
|
||||||
undi->flags &= ~UNDI_FL_STARTED;
|
undi->flags &= ~UNDI_FL_STARTED;
|
||||||
err_start_undi:
|
err_start_undi:
|
||||||
netdev_nullify ( netdev );
|
netdev_nullify ( netdev );
|
||||||
|
@ -773,22 +606,22 @@ void undinet_remove ( struct undi_device *undi ) {
|
||||||
|
|
||||||
/* Shut down UNDI stack */
|
/* Shut down UNDI stack */
|
||||||
memset ( &undi_shutdown, 0, sizeof ( undi_shutdown ) );
|
memset ( &undi_shutdown, 0, sizeof ( undi_shutdown ) );
|
||||||
undinet_call ( undinic, PXENV_UNDI_SHUTDOWN, &undi_shutdown,
|
pxeparent_call ( undinet_entry, PXENV_UNDI_SHUTDOWN,
|
||||||
sizeof ( undi_shutdown ) );
|
&undi_shutdown, sizeof ( undi_shutdown ) );
|
||||||
memset ( &undi_cleanup, 0, sizeof ( undi_cleanup ) );
|
memset ( &undi_cleanup, 0, sizeof ( undi_cleanup ) );
|
||||||
undinet_call ( undinic, PXENV_UNDI_CLEANUP, &undi_cleanup,
|
pxeparent_call ( undinet_entry, PXENV_UNDI_CLEANUP,
|
||||||
sizeof ( undi_cleanup ) );
|
&undi_cleanup, sizeof ( undi_cleanup ) );
|
||||||
undi->flags &= ~UNDI_FL_INITIALIZED;
|
undi->flags &= ~UNDI_FL_INITIALIZED;
|
||||||
|
|
||||||
/* Unhook UNDI stack */
|
/* Unhook UNDI stack */
|
||||||
memset ( &stop_undi, 0, sizeof ( stop_undi ) );
|
memset ( &stop_undi, 0, sizeof ( stop_undi ) );
|
||||||
undinet_call ( undinic, PXENV_STOP_UNDI, &stop_undi,
|
pxeparent_call ( undinet_entry, PXENV_STOP_UNDI, &stop_undi,
|
||||||
sizeof ( stop_undi ) );
|
sizeof ( stop_undi ) );
|
||||||
undi->flags &= ~UNDI_FL_STARTED;
|
undi->flags &= ~UNDI_FL_STARTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Clear entry point */
|
/* Clear entry point */
|
||||||
memset ( &undinet_entry_point, 0, sizeof ( undinet_entry_point ) );
|
memset ( &undinet_entry, 0, sizeof ( undinet_entry ) );
|
||||||
|
|
||||||
/* Free network device */
|
/* Free network device */
|
||||||
netdev_nullify ( netdev );
|
netdev_nullify ( netdev );
|
||||||
|
|
|
@ -14,6 +14,7 @@ FILE_LICENCE ( GPL2_OR_LATER );
|
||||||
#define ERRFILE_bios_smbios ( ERRFILE_ARCH | ERRFILE_CORE | 0x00030000 )
|
#define ERRFILE_bios_smbios ( ERRFILE_ARCH | ERRFILE_CORE | 0x00030000 )
|
||||||
#define ERRFILE_biosint ( ERRFILE_ARCH | ERRFILE_CORE | 0x00040000 )
|
#define ERRFILE_biosint ( ERRFILE_ARCH | ERRFILE_CORE | 0x00040000 )
|
||||||
#define ERRFILE_int13 ( ERRFILE_ARCH | ERRFILE_CORE | 0x00050000 )
|
#define ERRFILE_int13 ( ERRFILE_ARCH | ERRFILE_CORE | 0x00050000 )
|
||||||
|
#define ERRFILE_pxeparent ( ERRFILE_ARCH | ERRFILE_CORE | 0x00060000 )
|
||||||
|
|
||||||
#define ERRFILE_bootsector ( ERRFILE_ARCH | ERRFILE_IMAGE | 0x00000000 )
|
#define ERRFILE_bootsector ( ERRFILE_ARCH | ERRFILE_IMAGE | 0x00000000 )
|
||||||
#define ERRFILE_bzimage ( ERRFILE_ARCH | ERRFILE_IMAGE | 0x00010000 )
|
#define ERRFILE_bzimage ( ERRFILE_ARCH | ERRFILE_IMAGE | 0x00010000 )
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
#ifndef PXEPARENT_H
|
||||||
|
#define PXEPARENT_H
|
||||||
|
|
||||||
|
FILE_LICENCE ( GPL2_OR_LATER );
|
||||||
|
|
||||||
|
#include <pxe_types.h>
|
||||||
|
|
||||||
|
extern int pxeparent_call ( SEGOFF16_t entry, unsigned int function,
|
||||||
|
void *params, size_t params_len );
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,201 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2007 Michael Brown <mbrown@fensystems.co.uk>.
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License as
|
||||||
|
* published by the Free Software Foundation; either version 2 of the
|
||||||
|
* License, or any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but
|
||||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
FILE_LICENCE ( GPL2_OR_LATER );
|
||||||
|
|
||||||
|
#include <gpxe/dhcp.h>
|
||||||
|
#include <pxeparent.h>
|
||||||
|
#include <pxe_api.h>
|
||||||
|
#include <pxe_types.h>
|
||||||
|
#include <pxe.h>
|
||||||
|
|
||||||
|
/** @file
|
||||||
|
*
|
||||||
|
* Call interface to parent PXE stack
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Name PXE API call
|
||||||
|
*
|
||||||
|
* @v function API call number
|
||||||
|
* @ret name API call name
|
||||||
|
*/
|
||||||
|
static inline __attribute__ (( always_inline )) const char *
|
||||||
|
pxeparent_function_name ( unsigned int function ) {
|
||||||
|
switch ( function ) {
|
||||||
|
case PXENV_START_UNDI:
|
||||||
|
return "PXENV_START_UNDI";
|
||||||
|
case PXENV_STOP_UNDI:
|
||||||
|
return "PXENV_STOP_UNDI";
|
||||||
|
case PXENV_UNDI_STARTUP:
|
||||||
|
return "PXENV_UNDI_STARTUP";
|
||||||
|
case PXENV_UNDI_CLEANUP:
|
||||||
|
return "PXENV_UNDI_CLEANUP";
|
||||||
|
case PXENV_UNDI_INITIALIZE:
|
||||||
|
return "PXENV_UNDI_INITIALIZE";
|
||||||
|
case PXENV_UNDI_RESET_ADAPTER:
|
||||||
|
return "PXENV_UNDI_RESET_ADAPTER";
|
||||||
|
case PXENV_UNDI_SHUTDOWN:
|
||||||
|
return "PXENV_UNDI_SHUTDOWN";
|
||||||
|
case PXENV_UNDI_OPEN:
|
||||||
|
return "PXENV_UNDI_OPEN";
|
||||||
|
case PXENV_UNDI_CLOSE:
|
||||||
|
return "PXENV_UNDI_CLOSE";
|
||||||
|
case PXENV_UNDI_TRANSMIT:
|
||||||
|
return "PXENV_UNDI_TRANSMIT";
|
||||||
|
case PXENV_UNDI_SET_MCAST_ADDRESS:
|
||||||
|
return "PXENV_UNDI_SET_MCAST_ADDRESS";
|
||||||
|
case PXENV_UNDI_SET_STATION_ADDRESS:
|
||||||
|
return "PXENV_UNDI_SET_STATION_ADDRESS";
|
||||||
|
case PXENV_UNDI_SET_PACKET_FILTER:
|
||||||
|
return "PXENV_UNDI_SET_PACKET_FILTER";
|
||||||
|
case PXENV_UNDI_GET_INFORMATION:
|
||||||
|
return "PXENV_UNDI_GET_INFORMATION";
|
||||||
|
case PXENV_UNDI_GET_STATISTICS:
|
||||||
|
return "PXENV_UNDI_GET_STATISTICS";
|
||||||
|
case PXENV_UNDI_CLEAR_STATISTICS:
|
||||||
|
return "PXENV_UNDI_CLEAR_STATISTICS";
|
||||||
|
case PXENV_UNDI_INITIATE_DIAGS:
|
||||||
|
return "PXENV_UNDI_INITIATE_DIAGS";
|
||||||
|
case PXENV_UNDI_FORCE_INTERRUPT:
|
||||||
|
return "PXENV_UNDI_FORCE_INTERRUPT";
|
||||||
|
case PXENV_UNDI_GET_MCAST_ADDRESS:
|
||||||
|
return "PXENV_UNDI_GET_MCAST_ADDRESS";
|
||||||
|
case PXENV_UNDI_GET_NIC_TYPE:
|
||||||
|
return "PXENV_UNDI_GET_NIC_TYPE";
|
||||||
|
case PXENV_UNDI_GET_IFACE_INFO:
|
||||||
|
return "PXENV_UNDI_GET_IFACE_INFO";
|
||||||
|
/*
|
||||||
|
* Duplicate case value; this is a bug in the PXE specification.
|
||||||
|
*
|
||||||
|
* case PXENV_UNDI_GET_STATE:
|
||||||
|
* return "PXENV_UNDI_GET_STATE";
|
||||||
|
*/
|
||||||
|
case PXENV_UNDI_ISR:
|
||||||
|
return "PXENV_UNDI_ISR";
|
||||||
|
case PXENV_GET_CACHED_INFO:
|
||||||
|
return "PXENV_GET_CACHED_INFO";
|
||||||
|
default:
|
||||||
|
return "UNKNOWN API CALL";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PXE parent parameter block
|
||||||
|
*
|
||||||
|
* Used as the paramter block for all parent PXE API calls. Resides in base
|
||||||
|
* memory.
|
||||||
|
*/
|
||||||
|
static union u_PXENV_ANY __bss16 ( pxeparent_params );
|
||||||
|
#define pxeparent_params __use_data16 ( pxeparent_params )
|
||||||
|
|
||||||
|
/** PXE parent entry point
|
||||||
|
*
|
||||||
|
* Used as the indirection vector for all parent PXE API calls. Resides in
|
||||||
|
* base memory.
|
||||||
|
*/
|
||||||
|
SEGOFF16_t __bss16 ( pxeparent_entry_point );
|
||||||
|
#define pxeparent_entry_point __use_data16 ( pxeparent_entry_point )
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Issue parent PXE API call
|
||||||
|
*
|
||||||
|
* @v entry Parent PXE stack entry point
|
||||||
|
* @v function API call number
|
||||||
|
* @v params PXE parameter block
|
||||||
|
* @v params_len Length of PXE parameter block
|
||||||
|
* @ret rc Return status code
|
||||||
|
*/
|
||||||
|
int pxeparent_call ( SEGOFF16_t entry, unsigned int function,
|
||||||
|
void *params, size_t params_len ) {
|
||||||
|
PXENV_EXIT_t exit;
|
||||||
|
int discard_b, discard_D;
|
||||||
|
int rc;
|
||||||
|
|
||||||
|
/* Copy parameter block and entry point */
|
||||||
|
assert ( params_len <= sizeof ( pxeparent_params ) );
|
||||||
|
memcpy ( &pxeparent_params, params, params_len );
|
||||||
|
memcpy ( &pxeparent_entry_point, &entry, sizeof ( entry ) );
|
||||||
|
|
||||||
|
/* Call real-mode entry point. This calling convention will
|
||||||
|
* work with both the !PXE and the PXENV+ entry points.
|
||||||
|
*/
|
||||||
|
__asm__ __volatile__ ( REAL_CODE ( "pushw %%es\n\t"
|
||||||
|
"pushw %%di\n\t"
|
||||||
|
"pushw %%bx\n\t"
|
||||||
|
"lcall *pxeparent_entry_point\n\t"
|
||||||
|
"addw $6, %%sp\n\t" )
|
||||||
|
: "=a" ( exit ), "=b" ( discard_b ),
|
||||||
|
"=D" ( discard_D )
|
||||||
|
: "b" ( function ),
|
||||||
|
"D" ( __from_data16 ( &pxeparent_params ) )
|
||||||
|
: "ecx", "edx", "esi", "ebp" );
|
||||||
|
|
||||||
|
/* PXE API calls may rudely change the status of A20 and not
|
||||||
|
* bother to restore it afterwards. Intel is known to be
|
||||||
|
* guilty of this.
|
||||||
|
*
|
||||||
|
* Note that we will return to this point even if A20 gets
|
||||||
|
* screwed up by the parent PXE stack, because Etherboot always
|
||||||
|
* resides in an even megabyte of RAM.
|
||||||
|
*/
|
||||||
|
gateA20_set();
|
||||||
|
|
||||||
|
/* Determine return status code based on PXENV_EXIT and
|
||||||
|
* PXENV_STATUS
|
||||||
|
*/
|
||||||
|
if ( exit == PXENV_EXIT_SUCCESS ) {
|
||||||
|
rc = 0;
|
||||||
|
} else {
|
||||||
|
rc = -pxeparent_params.Status;
|
||||||
|
/* Paranoia; don't return success for the combination
|
||||||
|
* of PXENV_EXIT_FAILURE but PXENV_STATUS_SUCCESS
|
||||||
|
*/
|
||||||
|
if ( rc == 0 )
|
||||||
|
rc = -EIO;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* If anything goes wrong, print as much debug information as
|
||||||
|
* it's possible to give.
|
||||||
|
*/
|
||||||
|
if ( rc != 0 ) {
|
||||||
|
SEGOFF16_t rm_params = {
|
||||||
|
.segment = rm_ds,
|
||||||
|
.offset = __from_data16 ( &pxeparent_params ),
|
||||||
|
};
|
||||||
|
|
||||||
|
DBG ( "PXEPARENT %s failed: %s\n",
|
||||||
|
pxeparent_function_name ( function ), strerror ( rc ) );
|
||||||
|
DBG ( "PXEPARENT parameters at %04x:%04x length "
|
||||||
|
"%#02zx, entry point at %04x:%04x\n",
|
||||||
|
rm_params.segment, rm_params.offset, params_len,
|
||||||
|
pxeparent_entry_point.segment,
|
||||||
|
pxeparent_entry_point.offset );
|
||||||
|
DBG ( "PXEPARENT parameters provided:\n" );
|
||||||
|
DBG_HDA ( rm_params, params, params_len );
|
||||||
|
DBG ( "PXEPARENT parameters returned:\n" );
|
||||||
|
DBG_HDA ( rm_params, &pxeparent_params, params_len );
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Copy parameter block back */
|
||||||
|
memcpy ( params, &pxeparent_params, params_len );
|
||||||
|
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue