Lines Matching +full:memory +full:- +full:mapping
5 :Author: Hans-Jürgen Koch Linux developer, Linutronix
6 :Date: 2006-12-11
12 ------------
18 -------
22 access to the memory space of the device. The logic of controlling the
39 - The device has memory that can be mapped. The device can be
40 controlled completely by writing to this memory.
42 - The device usually generates interrupts.
44 - The device does not fit into one of the standard kernel subsystems.
47 ---------------
54 --------
64 - only one small kernel module to write and maintain.
66 - develop the main part of your driver in user space, with all the
69 - bugs in your driver won't crash the kernel.
71 - updates of your driver can take place without recompiling the kernel.
74 -------------
97 determine the cause of the interrupt, but it cannot re-enable
98 interrupts. Another cornercase is chips where re-enabling interrupts is
99 a read-modify-write operation to a combined IRQ status/acknowledge
107 to write a 32-bit value that is usually either 0 or 1 to disable or
110 ``-ENOSYS``.
113 own interrupt handler. It will automatically be called by the built-in
130 - ``name``: The name of your device. It is recommended to use the name
133 - ``version``: A version string defined by your driver. This allows the
137 - ``event``: The total number of interrupts handled by the driver since
145 Each UIO device can make one or more memory regions available for memory
146 mapping. This is necessary because some industrial I/O cards require
147 access to more than one PCI memory region in a driver.
149 Each mapping has its own directory in sysfs, the first mapping appears
152 appear if the size of the mapping is not 0.
154 Each ``mapX/`` directory contains four read-only files that show
155 attributes of the memory:
157 - ``name``: A string identifier for this mapping. This is optional, the
159 userspace to find the correct mapping.
161 - ``addr``: The address of memory that can be mapped.
163 - ``size``: The size, in bytes, of the memory pointed to by addr.
165 - ``offset``: The offset, in bytes, that has to be added to the pointer
166 returned by :c:func:`mmap()` to get to the actual device memory.
167 This is important if the device's memory is not page aligned.
173 memory of mapping N, you have to use N times the page size as your
178 Sometimes there is hardware with memory-like regions that can not be
186 ``/sys/class/uio/uioX/maps/`` like the normal memory described above.
197 Each ``portX/`` directory contains four read-only files that show name,
200 - ``name``: A string identifier for this port region. The string is
204 - ``start``: The first port of this region.
206 - ``size``: The number of ports in this region.
208 - ``porttype``: A string describing the type of port.
217 ---------------
222 - ``const char *name``: Required. The name of your driver as it will
225 - ``const char *version``: Required. This string appears in
228 - ``struct uio_mem mem[ MAX_UIO_MAPS ]``: Required if you have memory
229 that can be mapped with :c:func:`mmap()`. For each mapping you
233 - ``struct uio_port port[ MAX_UIO_PORTS_REGIONS ]``: Required if you
238 - ``long irq``: Required. If your hardware generates an interrupt, it's
245 - ``unsigned long irq_flags``: Required if you've set ``irq`` to a
249 - ``int (*mmap)(struct uio_info *info, struct vm_area_struct *vma)``:
252 :c:func:`mmap()` will be called instead of the built-in one.
254 - ``int (*open)(struct uio_info *info, struct inode *inode)``:
258 - ``int (*release)(struct uio_info *info, struct inode *inode)``:
262 - ``int (*irqcontrol)(struct uio_info *info, s32 irq_on)``:
268 Usually, your device will have one or more memory regions that can be
273 - ``const char *name``: Optional. Set this to help identify the memory
276 - ``int memtype``: Required if the mapping is used. Set this to
277 ``UIO_MEM_PHYS`` if you have physical memory on your card to be
278 mapped. Use ``UIO_MEM_LOGICAL`` for logical memory (e.g. allocated
280 ``UIO_MEM_VIRTUAL`` for virtual memory.
282 - ``phys_addr_t addr``: Required if the mapping is used. Fill in the
283 address of your memory block. This address is the one that appears in
286 - ``resource_size_t size``: Fill in the size of the memory block that
287 ``addr`` points to. If ``size`` is zero, the mapping is considered
291 - ``void *internal_addr``: If you have to access this memory region
299 used by the UIO framework to set up sysfs files for this mapping. Simply
309 - ``char *porttype``: Required. Set this to one of the predefined
313 - ``unsigned long start``: Required if the port region is used. Fill in
316 - ``unsigned long size``: Fill in the number of ports in this region.
325 ---------------------------
340 hardware at each interrupt and buffer it in a piece of kernel memory
360 -----------------------------------
370 addresses and sizes of your memory mappings. This information is passed
383 ------------------------------------------
411 When used in a device-tree enabled system, the driver needs to be
416 ``"linux,uio-name"`` may be specified in the DT node.
419 ------------------------------------------
421 In addition to statically allocated memory ranges, they may also be a
423 particular, being able to access memory made available through the
424 dma-mapping API, may be particularly useful. The ``uio_dmem_genirq``
438 - ``struct uio_info uioinfo``: The same structure used as the
441 - ``unsigned int *dynamic_region_sizes``: Pointer to list of sizes of
442 dynamic memory regions to be mapped into user space.
444 - ``unsigned int num_dynamic_regions``: Number of elements in
449 that the total number of static and dynamic memory regions cannot exceed
452 The dynamic memory regions will be allocated when the UIO device file,
453 ``/dev/uioX`` is opened. Similar to static memory resources, the memory
455 ``/sys/class/uio/uioX/maps/mapY/*``. The dynamic memory regions will be
469 -----------------------------------------
476 You should also make sure that the memory mapping you need exists and
491 mmap() device memory
492 --------------------
494 After you made sure you've got the right device with the memory mappings
496 device's memory to userspace.
499 meaning for UIO devices: It is used to select which mapping of your
500 device you want to map. To map the memory of mapping N, you have to use
505 N starts from zero, so if you've got only one memory range to map, set
506 ``offset = 0``. A drawback of this technique is that memory is always
510 ----------------------
512 After you successfully mapped your devices memory, you can access it
518 ``/dev/uioX`` is a read-only file. A :c:func:`read()` will always
535 driver, removing the need to write a hardware-specific kernel module.
538 --------------------------------------
552 echo -n 0000:00:19.0 > /sys/bus/pci/drivers/e1000e/unbind
553 echo -n 0000:00:19.0 > /sys/bus/pci/drivers/uio_pci_generic/bind
558 ls -l /sys/bus/pci/devices/0000:00:19.0/driver
562 .../0000:00:19.0/driver -> ../../../bus/pci/drivers/uio_pci_generic
572 ------------------------------------
587 ------------------------------------------------
590 wraps it, to talk to the device and to re-enable interrupts by writing
594 ----------------------------------
646 /* Re-enable interrupts. */
664 Generic Hyper-V UIO driver
668 supports devices on the Hyper-V VMBus similar to uio_pci_generic on
672 --------------------------------------
680 echo "f8615163-df3e-46c5-913f-f2d2f965ed0e" > /sys/bus/vmbus/drivers/uio_hv_generic/new_id
688 echo -n ed963694-e847-4b2a-85af-bc9cfc11d6f3 > /sys/bus/vmbus/drivers/hv_netvsc/unbind
689 echo -n ed963694-e847-4b2a-85af-bc9cfc11d6f3 > /sys/bus/vmbus/drivers/uio_hv_generic/bind
694 ls -l /sys/bus/vmbus/devices/ed963694-e847-4b2a-85af-bc9cfc11d6f3/driver
698 .../ed963694-e847-4b2a-85af-bc9cfc11d6f3/driver -> ../../../bus/vmbus/drivers/uio_hv_generic
701 -----------------------------------
709 and any reads of the interrupt file descriptor will return -EIO. Similar
720 device driver will create a sysfs binary file for the per-channel ring buffer.
723 /sys/bus/vmbus/devices/3811fe4d-0fa0-4b62-981a-74fc1084c757/channels/21/ring
728 - `OSADL homepage. <http://www.osadl.org>`_
730 - `Linutronix homepage. <http://www.linutronix.de>`_