Repository navigation
Expand file tree
/
Copy pathdevio.c
More file actions
131 lines (110 loc) · 2.98 KB
/
Copy pathdevio.c
File metadata and controls
131 lines (110 loc) · 2.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
/*
** 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.
**
** $Id$
*/
#include "drivers.h"
#include <net/gen/ether.h>
#include <net/gen/eth_io.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);
return;
}
/*
** Name: unsigned int inb(unsigned short int port);
** Function: Reads a byte from specified i/o port.
*/
PUBLIC unsigned int inb(unsigned short port)
{
unsigned int value;
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.
*/
PUBLIC unsigned int inw(unsigned short port)
{
unsigned int value;
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.
*/
PUBLIC void insb(unsigned short int port, int proc_nr, void *buffer, int count)
{
int rc;
if ((rc = sys_insb(port, proc_nr, buffer, count)) != OK)
warning("insb", rc);
return;
}
/*
** Name: unsigned int insw(unsigned short int port, int proc_nr, void *buffer, int count);
** Function: Reads a sequence of words from specified i/o port to user space buffer.
*/
PUBLIC void insw(unsigned short int port, int proc_nr, void *buffer, int count)
{
int rc;
if ((rc = sys_insw(port, proc_nr, buffer, count)) != OK)
warning("insw", rc);
return;
}
/*
** Name: void outb(unsigned short int port, unsigned long value);
** Function: Writes a byte to specified i/o port.
*/
PUBLIC void outb(unsigned short port, unsigned long value)
{
int rc;
if ((rc = sys_outb(port, value)) != OK) warning("outb", rc);
}
/*
** Name: void outw(unsigned short int port, unsigned long value);
** Function: Writes a word to specified i/o port.
*/
PUBLIC void outw(unsigned short port, unsigned long value)
{
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.
*/
PUBLIC void outsb(unsigned short port, int proc_nr, void *buffer, int count)
{
int rc;
if ((rc = sys_outsb(port, proc_nr, buffer, count)) != OK)
warning("outsb", rc);
return;
}
/*
** Name: void outsw(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.
*/
PUBLIC void outsw(unsigned short port, int proc_nr, void *buffer, int count)
{
int rc;
if ((rc = sys_outsw(port, proc_nr, buffer, count)) != OK)
warning("outsw", rc);
return;
}
#else
#error To be implemented
#endif /* USE_IOPL */
/** devio.c **/