summaryrefslogtreecommitdiff
path: root/minix/drivers/net/dpeth/devio.c
blob: 14e701723f9bf6897733ee092236055b87090355 (plain)
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
/*
**  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  **/