2005-06-29 12:16:46 +02:00
|
|
|
/*
|
|
|
|
** File: devio.c Jun. 11, 2005
|
|
|
|
**
|
|
|
|
** Author: Giovanni Falzoni <gfalzoni@inwind.it>
|
|
|
|
**
|
|
|
|
** This file contains the routines for readind/writing
|
|
|
|
** from/to the device registers.
|
|
|
|
*/
|
|
|
|
|
2010-03-22 22:25:22 +01:00
|
|
|
#include <minix/drivers.h>
|
2005-06-29 12:16:46 +02:00
|
|
|
#include <net/gen/ether.h>
|
|
|
|
#include <net/gen/eth_io.h>
|
|
|
|
#include "dp.h"
|
|
|
|
|
2005-08-03 13:53:36 +02:00
|
|
|
#if (USE_IOPL == 0)
|
2005-06-29 12:16:46 +02:00
|
|
|
|
|
|
|
static void warning(const char *type, int err)
|
|
|
|
{
|
|
|
|
|
|
|
|
printf("Warning: eth#0 sys_%s failed (%d)\n", type, err);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
** Name: unsigned int inb(unsigned short int port);
|
|
|
|
** Function: Reads a byte from specified i/o port.
|
|
|
|
*/
|
2012-03-25 20:25:53 +02:00
|
|
|
unsigned int inb(unsigned short port)
|
2005-06-29 12:16:46 +02:00
|
|
|
{
|
2012-03-05 00:11:41 +01:00
|
|
|
u32_t value;
|
2005-06-29 12:16:46 +02:00
|
|
|
int rc;
|
|
|
|
|
|
|
|
if ((rc = sys_inb(port, &value)) != OK) warning("inb", rc);
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
** Name: unsigned int inw(unsigned short int port);
|
|
|
|
** Function: Reads a word from specified i/o port.
|
|
|
|
*/
|
2012-03-25 20:25:53 +02:00
|
|
|
unsigned int inw(unsigned short port)
|
2005-06-29 12:16:46 +02:00
|
|
|
{
|
2012-03-05 00:11:41 +01:00
|
|
|
u32_t value;
|
2005-06-29 12:16:46 +02:00
|
|
|
int rc;
|
|
|
|
|
|
|
|
if ((rc = sys_inw(port, &value)) != OK) warning("inw", rc);
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
** Name: unsigned int insb(unsigned short int port, int proc_nr, void *buffer, int count);
|
|
|
|
** Function: Reads a sequence of bytes from specified i/o port to user space buffer.
|
|
|
|
*/
|
2012-03-25 20:25:53 +02:00
|
|
|
void insb(unsigned short int port, endpoint_t proc_nr,
|
2010-03-30 16:07:15 +02:00
|
|
|
void *buffer, int count)
|
2005-06-29 12:16:46 +02:00
|
|
|
{
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
if ((rc = sys_insb(port, proc_nr, buffer, count)) != OK)
|
|
|
|
warning("insb", rc);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
** Name: void outb(unsigned short int port, unsigned long value);
|
|
|
|
** Function: Writes a byte to specified i/o port.
|
|
|
|
*/
|
2012-03-25 20:25:53 +02:00
|
|
|
void outb(unsigned short port, unsigned long value)
|
2005-06-29 12:16:46 +02:00
|
|
|
{
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
if ((rc = sys_outb(port, value)) != OK) warning("outb", rc);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
** Name: void outw(unsigned short int port, unsigned long value);
|
|
|
|
** Function: Writes a word to specified i/o port.
|
|
|
|
*/
|
2012-03-25 20:25:53 +02:00
|
|
|
void outw(unsigned short port, unsigned long value)
|
2005-06-29 12:16:46 +02:00
|
|
|
{
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
if ((rc = sys_outw(port, value)) != OK) warning("outw", rc);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
** Name: void outsb(unsigned short int port, int proc_nr, void *buffer, int count);
|
|
|
|
** Function: Writes a sequence of bytes from user space to specified i/o port.
|
|
|
|
*/
|
2012-03-25 20:25:53 +02:00
|
|
|
void outsb(unsigned short port, endpoint_t proc_nr, void *buffer, int count)
|
2005-06-29 12:16:46 +02:00
|
|
|
{
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
if ((rc = sys_outsb(port, proc_nr, buffer, count)) != OK)
|
|
|
|
warning("outsb", rc);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
#else
|
|
|
|
#error To be implemented
|
|
|
|
#endif /* USE_IOPL */
|
|
|
|
/** devio.c **/
|