out8.comp
1 component out8; 2 pin out unsigned out_ "Output value; only low 8 bits are used"; 3 param r unsigned ioaddr; 4 5 function _; 6 7 option count_function; 8 option extra_setup; 9 option extra_cleanup; 10 option constructable no; 11 12 license "GPL"; 13 ;; 14 #include <asm/io.h> 15 16 #define MAX 8 17 int io[MAX] = {0,}; 18 RTAPI_MP_ARRAY_INT(io, MAX, "I/O addresses of out8 boards"); 19 20 int get_count(void) { 21 int i = 0; 22 for(i=0; i<MAX && io[i]; i++) { /* Nothing */ } 23 return i; 24 } 25 26 EXTRA_SETUP() { 27 if(!rtapi_request_region(io[extra_arg], 1, "out8")) { 28 // set this I/O port to 0 so that EXTRA_CLEANUP does not release the IO 29 // ports that were never requested. 30 io[extra_arg] = 0; 31 return -EBUSY; 32 } 33 ioaddr = io[extra_arg]; 34 return 0; 35 } 36 37 EXTRA_CLEANUP() { 38 int i; 39 for(i=0; i < MAX && io[i]; i++) { 40 rtapi_release_region(io[i], 1); 41 } 42 } 43 44 FUNCTION(_) { outb(out_, ioaddr); }