1 /*
2 ** File: devio.c Jun. 11, 2005
3 **
4 ** Author: Giovanni Falzoni <gfalzoni@inwind.it>
5 **
6 ** This file contains the routines for reading/writing
7 ** from/to the device registers.
8 */
9
10 #include <minix/drivers.h>
11 #include <minix/netdriver.h>
12 #include "dp.h"
13
14 #if (USE_IOPL == 0)
15
warning(const char * type,int err)16 static void warning(const char *type, int err)
17 {
18
19 printf("Warning: eth#0 sys_%s failed (%d)\n", type, err);
20 }
21
22 /*
23 ** Name: inb
24 ** Function: Reads a byte from specified i/o port.
25 */
inb(unsigned short port)26 unsigned int inb(unsigned short port)
27 {
28 u32_t value;
29 int rc;
30
31 if ((rc = sys_inb(port, &value)) != OK) warning("inb", rc);
32 return value;
33 }
34
35 /*
36 ** Name: inw
37 ** Function: Reads a word from specified i/o port.
38 */
inw(unsigned short port)39 unsigned int inw(unsigned short port)
40 {
41 u32_t value;
42 int rc;
43
44 if ((rc = sys_inw(port, &value)) != OK) warning("inw", rc);
45 return value;
46 }
47
48 /*
49 ** Name: insb
50 ** Function: Reads a sequence of bytes from an i/o port.
51 */
insb(unsigned short int port,void * buffer,int count)52 void insb(unsigned short int port, void *buffer, int count)
53 {
54 int rc;
55
56 if ((rc = sys_insb(port, SELF, buffer, count)) != OK)
57 warning("insb", rc);
58 }
59
60 /*
61 ** Name: insw
62 ** Function: Reads a sequence of words from an i/o port.
63 */
insw(unsigned short int port,void * buffer,int count)64 void insw(unsigned short int port, void *buffer, int count)
65 {
66 int rc;
67
68 if ((rc = sys_insw(port, SELF, buffer, count)) != OK)
69 warning("insw", rc);
70 }
71
72 /*
73 ** Name: outb
74 ** Function: Writes a byte to specified i/o port.
75 */
outb(unsigned short port,unsigned long value)76 void outb(unsigned short port, unsigned long value)
77 {
78 int rc;
79
80 if ((rc = sys_outb(port, value)) != OK) warning("outb", rc);
81 }
82
83 /*
84 ** Name: outw
85 ** Function: Writes a word to specified i/o port.
86 */
outw(unsigned short port,unsigned long value)87 void outw(unsigned short port, unsigned long value)
88 {
89 int rc;
90
91 if ((rc = sys_outw(port, value)) != OK) warning("outw", rc);
92 }
93
94 /*
95 ** Name: outsb
96 ** Function: Writes a sequence of bytes to an i/o port.
97 */
outsb(unsigned short port,void * buffer,int count)98 void outsb(unsigned short port, void *buffer, int count)
99 {
100 int rc;
101
102 if ((rc = sys_outsb(port, SELF, buffer, count)) != OK)
103 warning("outsb", rc);
104 }
105
106 #else
107 #error To be implemented
108 #endif /* USE_IOPL */
109 /** devio.c **/
110