
This is a driver-breaking update to the netdriver library, which is used by all network drivers. The aim of this change is to make the library more compatible with NetBSD, and in particular with various features that are expected to be supported by the NetBSD userland. The main changes made by this patch are the following: - each network driver now has a NetBSD-style short device name; - drivers are not expected to receive packets right after startup; - extended support for receipt modes, including multicast lists; - support for multiple parallel send, receive requests; - embedding of I/O vectors in send and receive requests; - support for capabilities, including checksum offloading; - support for reporting link status updates to the TCP/IP stack; - support for setting and retrieving media status; - support for changing the hardware (MAC) address; - support for NetBSD interface flags IFF_DEBUG, IFF_LINK[0-2]; - support for NetBSD error statistics; - support for regular time-based ("tick") callbacks. IMPORTANT: this patch applies a minimal update to the existing drivers in order to make them work at all with the new netdriver library. It however does *not* change all drivers to make use of the new features. In fact, strictly speaking, all drivers are now violating requirements imposed by the new library in one way or another, most notably by enabling packet receipt when starting the driver. Changing all the drivers to be compliant, and to support the newly added options, is left to future patches. The existing drivers should currently *not* be taken as examples of how to implement a new network driver! With that said, a few drivers have already been changed to make use of some of the new features: fxp, e1000, rtl8139, and rtl8169 now report link and media status, and the last three of those now support setting the hardware MAC address on the fly. In addition, dp8390 has been changed to default to PCI autoconfiguration if no configuration is specified through environment variables. Change-Id: I4b3ea9c0b9bc25d5b0609c6ff256fb0db71cdc42
110 lines
2.0 KiB
C
110 lines
2.0 KiB
C
/*
|
|
** File: devio.c Jun. 11, 2005
|
|
**
|
|
** Author: Giovanni Falzoni <gfalzoni@inwind.it>
|
|
**
|
|
** This file contains the routines for reading/writing
|
|
** from/to the device registers.
|
|
*/
|
|
|
|
#include <minix/drivers.h>
|
|
#include <minix/netdriver.h>
|
|
#include "dp.h"
|
|
|
|
#if (USE_IOPL == 0)
|
|
|
|
static void warning(const char *type, int err)
|
|
{
|
|
|
|
printf("Warning: eth#0 sys_%s failed (%d)\n", type, err);
|
|
}
|
|
|
|
/*
|
|
** Name: inb
|
|
** Function: Reads a byte from specified i/o port.
|
|
*/
|
|
unsigned int inb(unsigned short port)
|
|
{
|
|
u32_t value;
|
|
int rc;
|
|
|
|
if ((rc = sys_inb(port, &value)) != OK) warning("inb", rc);
|
|
return value;
|
|
}
|
|
|
|
/*
|
|
** Name: inw
|
|
** Function: Reads a word from specified i/o port.
|
|
*/
|
|
unsigned int inw(unsigned short port)
|
|
{
|
|
u32_t value;
|
|
int rc;
|
|
|
|
if ((rc = sys_inw(port, &value)) != OK) warning("inw", rc);
|
|
return value;
|
|
}
|
|
|
|
/*
|
|
** Name: insb
|
|
** Function: Reads a sequence of bytes from an i/o port.
|
|
*/
|
|
void insb(unsigned short int port, void *buffer, int count)
|
|
{
|
|
int rc;
|
|
|
|
if ((rc = sys_insb(port, SELF, buffer, count)) != OK)
|
|
warning("insb", rc);
|
|
}
|
|
|
|
/*
|
|
** Name: insw
|
|
** Function: Reads a sequence of words from an i/o port.
|
|
*/
|
|
void insw(unsigned short int port, void *buffer, int count)
|
|
{
|
|
int rc;
|
|
|
|
if ((rc = sys_insw(port, SELF, buffer, count)) != OK)
|
|
warning("insw", rc);
|
|
}
|
|
|
|
/*
|
|
** Name: outb
|
|
** Function: Writes a byte to specified i/o port.
|
|
*/
|
|
void outb(unsigned short port, unsigned long value)
|
|
{
|
|
int rc;
|
|
|
|
if ((rc = sys_outb(port, value)) != OK) warning("outb", rc);
|
|
}
|
|
|
|
/*
|
|
** Name: outw
|
|
** Function: Writes a word to specified i/o port.
|
|
*/
|
|
void outw(unsigned short port, unsigned long value)
|
|
{
|
|
int rc;
|
|
|
|
if ((rc = sys_outw(port, value)) != OK) warning("outw", rc);
|
|
}
|
|
|
|
/*
|
|
** Name: outsb
|
|
** Function: Writes a sequence of bytes to an i/o port.
|
|
*/
|
|
void outsb(unsigned short port, void *buffer, int count)
|
|
{
|
|
int rc;
|
|
|
|
if ((rc = sys_outsb(port, SELF, buffer, count)) != OK)
|
|
warning("outsb", rc);
|
|
}
|
|
|
|
#else
|
|
#error To be implemented
|
|
#endif /* USE_IOPL */
|
|
/** devio.c **/
|