/* * portio.h --- Linux port I/O device driver. * * Author: William Lavender * * Purpose: This module allows access to a restricted range of * I/O ports from user mode programs. The range of ports * allowed is set at the time the module is loaded by the * insmod command. * *----------------------------------------------------------------------- * * Copyright 1999 Illinois Institute of Technology * * See the file "LICENSE" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * */ #ifndef __PORTIO_H__ #define __PORTIO_H__ #define PORTIO_MAJOR 60 #define PORTIO_DEVICE "/dev/portio" #define PORTIO_MIN_ADDRESS 0x100 #define PORTIO_MAX_ADDRESS 0x3ff #define PORTIO_NUM_PORTS ( 1 + PORTIO_MAX_ADDRESS - PORTIO_MIN_ADDRESS ) typedef struct { __u16 address; union { __u8 byte; __u16 word; } arg; } portio_message; typedef struct { int map[PORTIO_NUM_PORTS]; } portio_permission_map; /* Ioctl commands */ #define PORTIO_OUTB_CMD 1 #define PORTIO_OUTW_CMD 2 #define PORTIO_INB_CMD 3 #define PORTIO_INW_CMD 4 #define PORTIO_GETMAP_CMD 5 #define PORTIO_DEBUG_CMD 6 #define PORTIO_IOCTL 'p' #define PORTIO_OUTB_IOCTL _IOW(PORTIO_IOCTL, PORTIO_OUTB_CMD, portio_message) #define PORTIO_OUTW_IOCTL _IOW(PORTIO_IOCTL, PORTIO_OUTW_CMD, portio_message) #define PORTIO_INB_IOCTL _IOWR(PORTIO_IOCTL, PORTIO_INB_CMD, portio_message) #define PORTIO_INW_IOCTL _IOWR(PORTIO_IOCTL, PORTIO_INW_CMD, portio_message) #define PORTIO_GETMAP_IOCTL \ _IOR(PORTIO_IOCTL, PORTIO_GETMAP_CMD, portio_permission_map) #define PORTIO_DEBUG_IOCTL _IOW(PORTIO_IOCTL, PORTIO_DEBUG_CMD, int) /* Functions for use in user mode programs. */ extern int portio_outb( int fd, __u8 value, __u16 address ); extern int portio_outw( int fd, __u16 value, __u16 address ); extern int portio_inb( int fd, __u8 *value, __u16 address ); extern int portio_inw( int fd, __u16 *value, __u16 address ); extern int portio_getmap( int fd, portio_permission_map *map ); #endif /* __PORTIO_H__ */