Skip to content

Commit

Permalink
Merge branch 'master' of http://git.ipxe.org/ipxe
Browse files Browse the repository at this point in the history
  • Loading branch information
Jarrod Johnson committed Dec 15, 2011
2 parents c28c686 + 9a93db3 commit e7a19f2
Show file tree
Hide file tree
Showing 18 changed files with 752 additions and 600 deletions.
1 change: 1 addition & 0 deletions src/arch/i386/Makefile.pcbios
Expand Up @@ -19,6 +19,7 @@ MEDIA += mrom
MEDIA += pxe
MEDIA += kpxe
MEDIA += kkpxe
MEDIA += kkkpxe
MEDIA += lkrn
MEDIA += dsk
MEDIA += nbi
Expand Down
38 changes: 30 additions & 8 deletions src/arch/i386/drivers/net/undinet.c
Expand Up @@ -19,6 +19,7 @@
FILE_LICENCE ( GPL2_OR_LATER );

#include <string.h>
#include <unistd.h>
#include <pxe.h>
#include <realmode.h>
#include <pic8259.h>
Expand All @@ -34,7 +35,6 @@ FILE_LICENCE ( GPL2_OR_LATER );
#include <undinet.h>
#include <pxeparent.h>


/** @file
*
* UNDI network device driver
Expand Down Expand Up @@ -63,6 +63,12 @@ struct undi_nic {

/** @} */

/** Maximum number of times to retry PXENV_UNDI_INITIALIZE */
#define UNDI_INITIALIZE_RETRY_MAX 10

/** Delay between retries of PXENV_UNDI_INITIALIZE */
#define UNDI_INITIALIZE_RETRY_DELAY_MS 200

static void undinet_close ( struct net_device *netdev );

/** Address of UNDI entry point */
Expand Down Expand Up @@ -482,12 +488,13 @@ int undinet_probe ( struct undi_device *undi ) {
struct undi_nic *undinic;
struct s_PXENV_START_UNDI start_undi;
struct s_PXENV_UNDI_STARTUP undi_startup;
struct s_PXENV_UNDI_INITIALIZE undi_initialize;
struct s_PXENV_UNDI_INITIALIZE undi_init;
struct s_PXENV_UNDI_GET_INFORMATION undi_info;
struct s_PXENV_UNDI_GET_IFACE_INFO undi_iface;
struct s_PXENV_UNDI_SHUTDOWN undi_shutdown;
struct s_PXENV_UNDI_CLEANUP undi_cleanup;
struct s_PXENV_STOP_UNDI stop_undi;
unsigned int retry;
int rc;

/* Allocate net device */
Expand Down Expand Up @@ -524,12 +531,27 @@ int undinet_probe ( struct undi_device *undi ) {
&undi_startup,
sizeof ( undi_startup ) ) ) != 0 )
goto err_undi_startup;
memset ( &undi_initialize, 0, sizeof ( undi_initialize ) );
if ( ( rc = pxeparent_call ( undinet_entry,
PXENV_UNDI_INITIALIZE,
&undi_initialize,
sizeof ( undi_initialize ))) != 0 )
goto err_undi_initialize;
/* On some PXE stacks, PXENV_UNDI_INITIALIZE may fail
* due to a transient condition (e.g. media test
* failing because the link has only just come out of
* reset). We may therefore need to retry this call
* several times.
*/
for ( retry = 0 ; ; ) {
memset ( &undi_init, 0, sizeof ( undi_init ) );
if ( ( rc = pxeparent_call ( undinet_entry,
PXENV_UNDI_INITIALIZE,
&undi_init,
sizeof ( undi_init ))) ==0)
break;
if ( ++retry > UNDI_INITIALIZE_RETRY_MAX )
goto err_undi_initialize;
DBGC ( undinic, "UNDINIC %p retrying "
"PXENV_UNDI_INITIALIZE (retry %d)\n",
undinic, retry );
/* Delay to allow link to settle if necessary */
mdelay ( UNDI_INITIALIZE_RETRY_DELAY_MS );
}
}
undi->flags |= UNDI_FL_INITIALIZED;

Expand Down
49 changes: 47 additions & 2 deletions src/arch/i386/include/pxe.h
Expand Up @@ -6,8 +6,12 @@ FILE_LICENCE ( GPL2_OR_LATER );
#include "pxe_types.h"
#include "pxe_api.h"
#include <ipxe/device.h>
#include <ipxe/tables.h>

/* Parameter block for pxenv_unknown() */
/** PXE API invalid function code */
#define PXENV_UNKNOWN 0xffff

/** Parameter block for pxenv_unknown() */
struct s_PXENV_UNKNOWN {
PXENV_STATUS_t Status; /**< PXE status code */
} __attribute__ (( packed ));
Expand Down Expand Up @@ -72,6 +76,45 @@ union u_PXENV_ANY {

typedef union u_PXENV_ANY PXENV_ANY_t;

/** A PXE API call */
struct pxe_api_call {
/** Entry point
*
* @v params PXE API call parameters
* @ret exit PXE API call exit code
*/
PXENV_EXIT_t ( * entry ) ( union u_PXENV_ANY *params );
/** Length of parameters */
uint16_t params_len;
/** Opcode */
uint16_t opcode;
};

/** PXE API call table */
#define PXE_API_CALLS __table ( struct pxe_api_call, "pxe_api_calls" )

/** Declare a PXE API call */
#define __pxe_api_call __table_entry ( PXE_API_CALLS, 01 )

/**
* Define a PXE API call
*
* @v _opcode Opcode
* @v _entry Entry point
* @v _params_type Type of parameter structure
* @ret call PXE API call
*/
#define PXE_API_CALL( _opcode, _entry, _params_type ) { \
.entry = ( ( ( ( PXENV_EXIT_t ( * ) ( _params_type *params ) ) NULL ) \
== ( ( typeof ( _entry ) * ) NULL ) ) \
? ( ( PXENV_EXIT_t ( * ) \
( union u_PXENV_ANY *params ) ) _entry ) \
: ( ( PXENV_EXIT_t ( * ) \
( union u_PXENV_ANY *params ) ) _entry ) ), \
.params_len = sizeof ( _params_type ), \
.opcode = _opcode, \
}

/** An UNDI expansion ROM header */
struct undi_rom_header {
/** Signature
Expand Down Expand Up @@ -144,9 +187,11 @@ struct pcir_header {
#define PCIR_SIGNATURE \
( ( 'P' << 0 ) + ( 'C' << 8 ) + ( 'I' << 16 ) + ( 'R' << 24 ) )


extern struct net_device *pxe_netdev;

extern void pxe_set_netdev ( struct net_device *netdev );
extern PXENV_EXIT_t pxenv_tftp_read_file ( struct s_PXENV_TFTP_READ_FILE
*tftp_read_file );
extern PXENV_EXIT_t undi_loader ( struct s_UNDI_LOADER *undi_loader );

#endif /* PXE_H */

0 comments on commit e7a19f2

Please sign in to comment.