1 #ifndef _IO_H 2 #define _IO_H 3 4 #include <sys/types.h> 5 #include <minix/syslib.h> 6 #include "trident.h" 7 8 /* I/O function */ 9 static u8_t my_inb(u32_t port) { 10 u32_t value; 11 int r; 12 #ifdef DMA_BASE_IOMAP 13 value = *(volatile u8_t *)(port); 14 #else 15 if ((r = sys_inb(port, &value)) != OK) 16 printf("SDR: sys_inb failed: %d\n", r); 17 #endif 18 return (u8_t)value; 19 } 20 #define sdr_in8(port, offset) (my_inb((port) + (offset))) 21 22 static u16_t my_inw(u32_t port) { 23 u32_t value; 24 int r; 25 #ifdef DMA_BASE_IOMAP 26 value = *(volatile u16_t *)(port); 27 #else 28 if ((r = sys_inw(port, &value)) != OK) 29 printf("SDR: sys_inw failed: %d\n", r); 30 #endif 31 return (u16_t)value; 32 } 33 #define sdr_in16(port, offset) (my_inw((port) + (offset))) 34 35 static u32_t my_inl(u32_t port) { 36 u32_t value; 37 int r; 38 #ifdef DMA_BASE_IOMAP 39 value = *(volatile u32_t *)(port); 40 #else 41 if ((r = sys_inl(port, &value)) != OK) 42 printf("SDR: sys_inl failed: %d\n", r); 43 #endif 44 return value; 45 } 46 #define sdr_in32(port, offset) (my_inl((port) + (offset))) 47 48 static void my_outb(u32_t port, u32_t value) { 49 int r; 50 #ifdef DMA_BASE_IOMAP 51 *(volatile u8_t *)(port) = value; 52 #else 53 if ((r = sys_outb(port, (u8_t)value)) != OK) 54 printf("SDR: sys_outb failed: %d\n", r); 55 #endif 56 } 57 #define sdr_out8(port, offset, value) \ 58 (my_outb(((port) + (offset)), (value))) 59 60 static void my_outw(u32_t port, u32_t value) { 61 int r; 62 #ifdef DMA_BASE_IOMAP 63 *(volatile u16_t *)(port) = value; 64 #else 65 if ((r = sys_outw(port, (u16_t)value)) != OK) 66 printf("SDR: sys_outw failed: %d\n", r); 67 #endif 68 } 69 #define sdr_out16(port, offset, value) \ 70 (my_outw(((port) + (offset)), (value))) 71 72 static void my_outl(u32_t port, u32_t value) { 73 int r; 74 #ifdef DMA_BASE_IOMAP 75 *(volatile u32_t *)(port) = value; 76 #else 77 if ((r = sys_outl(port, value)) != OK) 78 printf("SDR: sys_outl failed: %d\n", r); 79 #endif 80 } 81 #define sdr_out32(port, offset, value) \ 82 (my_outl(((port) + (offset)), (value))) 83 84 #endif 85