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 10 #include <minix/drivers.h> 11 #include <net/gen/ether.h> 12 #include <net/gen/eth_io.h> 13 #include "dp.h" 14 15 #if (USE_IOPL == 0) 16 17 static void warning(const char *type, int err) 18 { 19 20 printf("Warning: eth#0 sys_%s failed (%d)\n", type, err); 21 return; 22 } 23 24 /* 25 ** Name: unsigned int inb(unsigned short int port); 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: unsigned int inw(unsigned short int port); 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: unsigned int insb(unsigned short int port, int proc_nr, void *buffer, int count); 52 ** Function: Reads a sequence of bytes from specified i/o port to user space buffer. 53 */ 54 void insb(unsigned short int port, endpoint_t proc_nr, 55 void *buffer, int count) 56 { 57 int rc; 58 59 if ((rc = sys_insb(port, proc_nr, buffer, count)) != OK) 60 warning("insb", rc); 61 return; 62 } 63 64 65 /* 66 ** Name: void outb(unsigned short int port, unsigned long value); 67 ** Function: Writes a byte to specified i/o port. 68 */ 69 void outb(unsigned short port, unsigned long value) 70 { 71 int rc; 72 73 if ((rc = sys_outb(port, value)) != OK) warning("outb", rc); 74 return; 75 } 76 77 /* 78 ** Name: void outw(unsigned short int port, unsigned long value); 79 ** Function: Writes a word to specified i/o port. 80 */ 81 void outw(unsigned short port, unsigned long value) 82 { 83 int rc; 84 85 if ((rc = sys_outw(port, value)) != OK) warning("outw", rc); 86 return; 87 } 88 89 /* 90 ** Name: void outsb(unsigned short int port, int proc_nr, void *buffer, int count); 91 ** Function: Writes a sequence of bytes from user space to specified i/o port. 92 */ 93 void outsb(unsigned short port, endpoint_t proc_nr, void *buffer, int count) 94 { 95 int rc; 96 97 if ((rc = sys_outsb(port, proc_nr, buffer, count)) != OK) 98 warning("outsb", rc); 99 return; 100 } 101 102 #else 103 #error To be implemented 104 #endif /* USE_IOPL */ 105 /** devio.c **/ 106