xref: /minix3/minix/drivers/net/dpeth/devio.c (revision f7df02e7476731c31f12548e38bcadbaf0233f6a)
1433d6423SLionel Sambuc /*
2433d6423SLionel Sambuc **  File:	devio.c		Jun. 11, 2005
3433d6423SLionel Sambuc **
4433d6423SLionel Sambuc **  Author:	Giovanni Falzoni <gfalzoni@inwind.it>
5433d6423SLionel Sambuc **
6*91c4db25SDavid van Moolenbroek **  This file contains the routines for reading/writing
7433d6423SLionel Sambuc **  from/to the device registers.
8433d6423SLionel Sambuc */
9433d6423SLionel Sambuc 
10433d6423SLionel Sambuc #include <minix/drivers.h>
11*91c4db25SDavid van Moolenbroek #include <minix/netdriver.h>
12433d6423SLionel Sambuc #include "dp.h"
13433d6423SLionel Sambuc 
14433d6423SLionel Sambuc #if (USE_IOPL == 0)
15433d6423SLionel Sambuc 
warning(const char * type,int err)16433d6423SLionel Sambuc static void warning(const char *type, int err)
17433d6423SLionel Sambuc {
18433d6423SLionel Sambuc 
19433d6423SLionel Sambuc   printf("Warning: eth#0 sys_%s failed (%d)\n", type, err);
20433d6423SLionel Sambuc }
21433d6423SLionel Sambuc 
22433d6423SLionel Sambuc /*
23*91c4db25SDavid van Moolenbroek **  Name:	inb
24433d6423SLionel Sambuc **  Function:	Reads a byte from specified i/o port.
25433d6423SLionel Sambuc */
inb(unsigned short port)26433d6423SLionel Sambuc unsigned int inb(unsigned short port)
27433d6423SLionel Sambuc {
28433d6423SLionel Sambuc   u32_t value;
29433d6423SLionel Sambuc   int rc;
30433d6423SLionel Sambuc 
31433d6423SLionel Sambuc   if ((rc = sys_inb(port, &value)) != OK) warning("inb", rc);
32433d6423SLionel Sambuc   return value;
33433d6423SLionel Sambuc }
34433d6423SLionel Sambuc 
35433d6423SLionel Sambuc /*
36*91c4db25SDavid van Moolenbroek **  Name:	inw
37433d6423SLionel Sambuc **  Function:	Reads a word from specified i/o port.
38433d6423SLionel Sambuc */
inw(unsigned short port)39433d6423SLionel Sambuc unsigned int inw(unsigned short port)
40433d6423SLionel Sambuc {
41433d6423SLionel Sambuc   u32_t value;
42433d6423SLionel Sambuc   int rc;
43433d6423SLionel Sambuc 
44433d6423SLionel Sambuc   if ((rc = sys_inw(port, &value)) != OK) warning("inw", rc);
45433d6423SLionel Sambuc   return value;
46433d6423SLionel Sambuc }
47433d6423SLionel Sambuc 
48433d6423SLionel Sambuc /*
49*91c4db25SDavid van Moolenbroek **  Name:	insb
50*91c4db25SDavid van Moolenbroek **  Function:	Reads a sequence of bytes from an i/o port.
51433d6423SLionel Sambuc */
insb(unsigned short int port,void * buffer,int count)52*91c4db25SDavid van Moolenbroek void insb(unsigned short int port, void *buffer, int count)
53433d6423SLionel Sambuc {
54433d6423SLionel Sambuc   int rc;
55433d6423SLionel Sambuc 
56*91c4db25SDavid van Moolenbroek   if ((rc = sys_insb(port, SELF, buffer, count)) != OK)
57433d6423SLionel Sambuc 	warning("insb", rc);
58433d6423SLionel Sambuc }
59433d6423SLionel Sambuc 
60*91c4db25SDavid van Moolenbroek /*
61*91c4db25SDavid van Moolenbroek **  Name:	insw
62*91c4db25SDavid van Moolenbroek **  Function:	Reads a sequence of words from an i/o port.
63*91c4db25SDavid van Moolenbroek */
insw(unsigned short int port,void * buffer,int count)64*91c4db25SDavid van Moolenbroek void insw(unsigned short int port, void *buffer, int count)
65*91c4db25SDavid van Moolenbroek {
66*91c4db25SDavid van Moolenbroek   int rc;
67*91c4db25SDavid van Moolenbroek 
68*91c4db25SDavid van Moolenbroek   if ((rc = sys_insw(port, SELF, buffer, count)) != OK)
69*91c4db25SDavid van Moolenbroek 	warning("insw", rc);
70*91c4db25SDavid van Moolenbroek }
71433d6423SLionel Sambuc 
72433d6423SLionel Sambuc /*
73*91c4db25SDavid van Moolenbroek **  Name:	outb
74433d6423SLionel Sambuc **  Function:	Writes a byte to specified i/o port.
75433d6423SLionel Sambuc */
outb(unsigned short port,unsigned long value)76433d6423SLionel Sambuc void outb(unsigned short port, unsigned long value)
77433d6423SLionel Sambuc {
78433d6423SLionel Sambuc   int rc;
79433d6423SLionel Sambuc 
80433d6423SLionel Sambuc   if ((rc = sys_outb(port, value)) != OK) warning("outb", rc);
81433d6423SLionel Sambuc }
82433d6423SLionel Sambuc 
83433d6423SLionel Sambuc /*
84*91c4db25SDavid van Moolenbroek **  Name:	outw
85433d6423SLionel Sambuc **  Function:	Writes a word to specified i/o port.
86433d6423SLionel Sambuc */
outw(unsigned short port,unsigned long value)87433d6423SLionel Sambuc void outw(unsigned short port, unsigned long value)
88433d6423SLionel Sambuc {
89433d6423SLionel Sambuc   int rc;
90433d6423SLionel Sambuc 
91433d6423SLionel Sambuc   if ((rc = sys_outw(port, value)) != OK) warning("outw", rc);
92433d6423SLionel Sambuc }
93433d6423SLionel Sambuc 
94433d6423SLionel Sambuc /*
95*91c4db25SDavid van Moolenbroek **  Name:	outsb
96*91c4db25SDavid van Moolenbroek **  Function:	Writes a sequence of bytes to an i/o port.
97433d6423SLionel Sambuc */
outsb(unsigned short port,void * buffer,int count)98*91c4db25SDavid van Moolenbroek void outsb(unsigned short port, void *buffer, int count)
99433d6423SLionel Sambuc {
100433d6423SLionel Sambuc   int rc;
101433d6423SLionel Sambuc 
102*91c4db25SDavid van Moolenbroek   if ((rc = sys_outsb(port, SELF, buffer, count)) != OK)
103433d6423SLionel Sambuc 	warning("outsb", rc);
104433d6423SLionel Sambuc }
105433d6423SLionel Sambuc 
106433d6423SLionel Sambuc #else
107433d6423SLionel Sambuc #error To be implemented
108433d6423SLionel Sambuc #endif				/* USE_IOPL */
109433d6423SLionel Sambuc /**  devio.c  **/
110