diff options
author | Hans J. Koch <hjk@linutronix.de> | 2008-12-05 20:23:13 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2009-01-06 13:44:44 -0500 |
commit | e70c412ee45332db2636a8f5a35a0685efb0e4aa (patch) | |
tree | 98340f89baa09af04f67f4be5184363c54f2ef2f /include/linux/uio_driver.h | |
parent | e543ae896626a54c0c05e3c434312d6d033d450c (diff) |
UIO: Pass information about ioports to userspace (V2)
Devices sometimes have memory where all or parts of it can not be mapped to
userspace. But it might still be possible to access this memory from
userspace by other means. An example are PCI cards that advertise not only
mappable memory but also ioport ranges. On x86 architectures, these can be
accessed with ioperm, iopl, inb, outb, and friends. Mike Frysinger (CCed)
reported a similar problem on Blackfin arch where it doesn't seem to be easy
to mmap non-cached memory but it can still be accessed from userspace.
This patch allows kernel drivers to pass information about such ports to
userspace. Similar to the existing mem[] array, it adds a port[] array to
struct uio_info. Each port range is described by start, size, and porttype.
If a driver fills in at least one such port range, the UIO core will simply
pass this information to userspace by creating a new directory "portio"
underneath /sys/class/uio/uioN/. Similar to the "mem" directory, it will
contain a subdirectory (portX) for each port range given.
Note that UIO simply passes this information to userspace, it performs no
action whatsoever with this data. It's userspace's responsibility to obtain
access to these ports and to solve arch dependent issues. The "porttype"
attribute tells userspace what kind of port it is dealing with.
This mechanism could also be used to give userspace information about GPIOs
related to a device. You frequently find such hardware in embedded devices,
so I added a UIO_PORT_GPIO definition. I'm not really sure if this is a good
idea since there are other solutions to this problem, but it won't hurt much
anyway.
Signed-off-by: Hans J. Koch <hjk@linutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'include/linux/uio_driver.h')
-rw-r--r-- | include/linux/uio_driver.h | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/include/linux/uio_driver.h b/include/linux/uio_driver.h index cdf338d94b7f..20be327bfbb4 100644 --- a/include/linux/uio_driver.h +++ b/include/linux/uio_driver.h | |||
@@ -38,6 +38,24 @@ struct uio_mem { | |||
38 | 38 | ||
39 | #define MAX_UIO_MAPS 5 | 39 | #define MAX_UIO_MAPS 5 |
40 | 40 | ||
41 | struct uio_portio; | ||
42 | |||
43 | /** | ||
44 | * struct uio_port - description of a UIO port region | ||
45 | * @start: start of port region | ||
46 | * @size: size of port region | ||
47 | * @porttype: type of port (see UIO_PORT_* below) | ||
48 | * @portio: for use by the UIO core only. | ||
49 | */ | ||
50 | struct uio_port { | ||
51 | unsigned long start; | ||
52 | unsigned long size; | ||
53 | int porttype; | ||
54 | struct uio_portio *portio; | ||
55 | }; | ||
56 | |||
57 | #define MAX_UIO_PORT_REGIONS 5 | ||
58 | |||
41 | struct uio_device; | 59 | struct uio_device; |
42 | 60 | ||
43 | /** | 61 | /** |
@@ -46,6 +64,7 @@ struct uio_device; | |||
46 | * @name: device name | 64 | * @name: device name |
47 | * @version: device driver version | 65 | * @version: device driver version |
48 | * @mem: list of mappable memory regions, size==0 for end of list | 66 | * @mem: list of mappable memory regions, size==0 for end of list |
67 | * @port: list of port regions, size==0 for end of list | ||
49 | * @irq: interrupt number or UIO_IRQ_CUSTOM | 68 | * @irq: interrupt number or UIO_IRQ_CUSTOM |
50 | * @irq_flags: flags for request_irq() | 69 | * @irq_flags: flags for request_irq() |
51 | * @priv: optional private data | 70 | * @priv: optional private data |
@@ -60,6 +79,7 @@ struct uio_info { | |||
60 | char *name; | 79 | char *name; |
61 | char *version; | 80 | char *version; |
62 | struct uio_mem mem[MAX_UIO_MAPS]; | 81 | struct uio_mem mem[MAX_UIO_MAPS]; |
82 | struct uio_port port[MAX_UIO_PORT_REGIONS]; | ||
63 | long irq; | 83 | long irq; |
64 | unsigned long irq_flags; | 84 | unsigned long irq_flags; |
65 | void *priv; | 85 | void *priv; |
@@ -92,4 +112,10 @@ extern void uio_event_notify(struct uio_info *info); | |||
92 | #define UIO_MEM_LOGICAL 2 | 112 | #define UIO_MEM_LOGICAL 2 |
93 | #define UIO_MEM_VIRTUAL 3 | 113 | #define UIO_MEM_VIRTUAL 3 |
94 | 114 | ||
115 | /* defines for uio_port->porttype */ | ||
116 | #define UIO_PORT_NONE 0 | ||
117 | #define UIO_PORT_X86 1 | ||
118 | #define UIO_PORT_GPIO 2 | ||
119 | #define UIO_PORT_OTHER 3 | ||
120 | |||
95 | #endif /* _LINUX_UIO_DRIVER_H_ */ | 121 | #endif /* _LINUX_UIO_DRIVER_H_ */ |