/**************************************************************************
Bochs Pseudo NIC driver for Etherboot
***************************************************************************/
/*
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2, or (at
* your option) any later version.
*
* See pnic_api.h for an explanation of the Bochs Pseudo NIC.
*/
/* to get some global routines like printf */
#include "etherboot.h"
/* to get the interface to the body of the program */
#include "nic.h"
/* to get the PCI support functions, if this is a PCI NIC */
#include "pci.h"
/* PNIC API */
#include "pnic_api.h"
/* Private data structure */
typedef struct {
/* Function prototypes */
/* NIC specific static variables go here */
/*
* Utility functions: issue a PNIC command, retrieve result. Use
* pnic_command_quiet if you don't want failure codes to be
* automatically printed. Returns the PNIC status code.
*
* Set output_length to NULL only if you expect to receive exactly
* output_max_length bytes, otherwise it'll complain that you didn't
* get enough data (on the assumption that if you not interested in
* discovering the output length then you're expecting a fixed amount
* of data).
*/
uint16_t *output_length ) {
int i;
/* Write input length */
/* Write input data */
for ( i = 0; i < input_length; i++ ) {
}
}
/* Write command */
/* Retrieve status */
/* Retrieve output length */
if ( output_length == NULL ) {
if ( _output_length != output_max_length ) {
printf ( "pnic_command %#hx: wrong data length "
"returned (expected %d, got %d)\n", command,
}
} else {
}
if ( _output_length > output_max_length ) {
printf ( "pnic_command %#hx: output buffer too small "
"(have %d, need %d)\n", command,
}
/* Retrieve output data */
for ( i = 0; i < _output_length; i++ ) {
((char*)output)[i] =
}
}
return status;
}
uint16_t *output_length ) {
printf ( "PNIC command %#hx (len %#hx) failed with status %#hx\n",
return status;
}
/* Check API version matches that of NIC */
if ( api_version != PNIC_API_VERSION ) {
printf ( "Warning: API version mismatch! "
"(NIC's is %d.%d, ours is %d.%d)\n",
}
if ( api_version < PNIC_API_VERSION ) {
printf ( "*** You may need to update your copy of Bochs ***\n" );
}
return ( api_version == PNIC_API_VERSION );
}
/**************************************************************************
POLL - Wait for a frame
***************************************************************************/
{
/* Check receive queue length to see if there's anything to
* get. Necessary since once we've called PNIC_CMD_RECV we
* have to read out the packet, otherwise it's lost forever.
*/
!= PNIC_STATUS_OK ) return ( 0 );
if ( qlen == 0 ) return ( 0 );
/* There is a packet ready. Return 1 if we're only checking. */
if ( ! retrieve ) return ( 1 );
/* Retrieve the packet */
!= PNIC_STATUS_OK ) return ( 0 );
return ( 1 );
}
/**************************************************************************
TRANSMIT - Transmit a frame
***************************************************************************/
static void pnic_transmit(
const char *dest, /* Destination */
unsigned int type, /* Type */
unsigned int size, /* size */
const char *data) /* Packet */
{
printf ( "pnic_transmit: packet too large\n" );
return;
}
/* Assemble packet */
}
/**************************************************************************
DISABLE - Turn off ethernet interface
***************************************************************************/
{
}
/**************************************************************************
IRQ - Handle card interrupt status
***************************************************************************/
{
switch ( action ) {
case DISABLE :
case ENABLE :
break;
case FORCE :
break;
}
}
/**************************************************************************
PROBE - Look for an adapter, this routine's visible to the outside
***************************************************************************/
{
printf(" - ");
/* Clear private data structure and chain it in */
/* Mask the bit that says "this is an io addr" */
/* Not sure what this does, but the rtl8139 driver does it */
if ( status != PNIC_STATUS_OK ) {
printf ( "PNIC failed installation check, code %#hx\n",
status );
return 0;
}
printf ( "Detected Bochs Pseudo NIC MAC %! (API v%d.%d) at %#hx\n",
/* point to NIC specific routines */
return 1;
}
/* genrules.pl doesn't let us use macros for PCI IDs...*/
};
.type = NIC_DRIVER,
.name = "PNIC",
.probe = pnic_probe,
.class = 0,
};