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