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