diff options
| author | Stefan Richter <stefanr@s5r6.in-berlin.de> | 2011-07-14 15:08:39 -0400 |
|---|---|---|
| committer | Stefan Richter <stefanr@s5r6.in-berlin.de> | 2011-07-16 01:24:32 -0400 |
| commit | f6a7cd0212c359f7b55414aeee364ee7cac363cc (patch) | |
| tree | f7d75b8040c69f21b8b1ffcbbde762c5636cac37 | |
| parent | 93b37905f70083d6143f5f4dba0a45cc64379a62 (diff) | |
firewire: cdev: ABI documentation enhancements
Add overview documentation in Documentation/ABI/stable/firewire-cdev.
Improve the inline reference documentation in firewire-cdev.h:
- Add /* available since kernel... */ comments to event numbers
consistent with the comments on ioctl numbers.
- Shorten some documentation on an event and an ioctl that are
less interesting to current programming because there are newer
preferable variants.
- Spell Configuration ROM (name of an IEEE 1212 register) in
upper case.
- Move the dummy FW_CDEV_VERSION out of the reader's field of
vision. We should remove it from the header next year or so.
Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
| -rw-r--r-- | Documentation/ABI/stable/firewire-cdev | 103 | ||||
| -rw-r--r-- | include/linux/firewire-cdev.h | 75 |
2 files changed, 137 insertions, 41 deletions
diff --git a/Documentation/ABI/stable/firewire-cdev b/Documentation/ABI/stable/firewire-cdev new file mode 100644 index 000000000000..16d030827368 --- /dev/null +++ b/Documentation/ABI/stable/firewire-cdev | |||
| @@ -0,0 +1,103 @@ | |||
| 1 | What: /dev/fw[0-9]+ | ||
| 2 | Date: May 2007 | ||
| 3 | KernelVersion: 2.6.22 | ||
| 4 | Contact: linux1394-devel@lists.sourceforge.net | ||
| 5 | Description: | ||
| 6 | The character device files /dev/fw* are the interface between | ||
| 7 | firewire-core and IEEE 1394 device drivers implemented in | ||
| 8 | userspace. The ioctl(2)- and read(2)-based ABI is defined and | ||
| 9 | documented in <linux/firewire-cdev.h>. | ||
| 10 | |||
| 11 | This ABI offers most of the features which firewire-core also | ||
| 12 | exposes to kernelspace IEEE 1394 drivers. | ||
| 13 | |||
| 14 | Each /dev/fw* is associated with one IEEE 1394 node, which can | ||
| 15 | be remote or local nodes. Operations on a /dev/fw* file have | ||
| 16 | different scope: | ||
| 17 | - The 1394 node which is associated with the file: | ||
| 18 | - Asynchronous request transmission | ||
| 19 | - Get the Configuration ROM | ||
| 20 | - Query node ID | ||
| 21 | - Query maximum speed of the path between this node | ||
| 22 | and local node | ||
| 23 | - The 1394 bus (i.e. "card") to which the node is attached to: | ||
| 24 | - Isochronous stream transmission and reception | ||
| 25 | - Asynchronous stream transmission and reception | ||
| 26 | - Asynchronous broadcast request transmission | ||
| 27 | - PHY packet transmission and reception | ||
| 28 | - Allocate, reallocate, deallocate isochronous | ||
| 29 | resources (channels, bandwidth) at the bus's IRM | ||
| 30 | - Query node IDs of local node, root node, IRM, bus | ||
| 31 | manager | ||
| 32 | - Query cycle time | ||
| 33 | - Bus reset initiation, bus reset event reception | ||
| 34 | - All 1394 buses: | ||
| 35 | - Allocation of IEEE 1212 address ranges on the local | ||
| 36 | link layers, reception of inbound requests to such | ||
| 37 | an address range, asynchronous response transmission | ||
| 38 | to inbound requests | ||
| 39 | - Addition of descriptors or directories to the local | ||
| 40 | nodes' Configuration ROM | ||
| 41 | |||
| 42 | Due to the different scope of operations and in order to let | ||
| 43 | userland implement different access permission models, some | ||
| 44 | operations are restricted to /dev/fw* files that are associated | ||
| 45 | with a local node: | ||
| 46 | - Addition of descriptors or directories to the local | ||
| 47 | nodes' Configuration ROM | ||
| 48 | - PHY packet transmission and reception | ||
| 49 | |||
| 50 | A /dev/fw* file remains associated with one particular node | ||
| 51 | during its entire life time. Bus topology changes, and hence | ||
| 52 | node ID changes, are tracked by firewire-core. ABI users do not | ||
| 53 | need to be aware of topology. | ||
| 54 | |||
| 55 | The following file operations are supported: | ||
| 56 | |||
| 57 | open(2) | ||
| 58 | Currently the only useful flags are O_RDWR. | ||
| 59 | |||
| 60 | ioctl(2) | ||
| 61 | Initiate various actions. Some take immediate effect, others | ||
| 62 | are performed asynchronously while or after the ioctl returns. | ||
| 63 | See the inline documentation in <linux/firewire-cdev.h> for | ||
| 64 | descriptions of all ioctls. | ||
| 65 | |||
| 66 | poll(2), select(2), epoll_wait(2) etc. | ||
| 67 | Watch for events to become available to be read. | ||
| 68 | |||
| 69 | read(2) | ||
| 70 | Receive various events. There are solicited events like | ||
| 71 | outbound asynchronous transaction completion or isochronous | ||
| 72 | buffer completion, and unsolicited events such as bus resets, | ||
| 73 | request reception, or PHY packet reception. Always use a read | ||
| 74 | buffer which is large enough to receive the largest event that | ||
| 75 | could ever arrive. See <linux/firewire-cdev.h> for descriptions | ||
| 76 | of all event types and for which ioctls affect reception of | ||
| 77 | events. | ||
| 78 | |||
| 79 | mmap(2) | ||
| 80 | Allocate a DMA buffer for isochronous reception or transmission | ||
| 81 | and map it into the process address space. The arguments should | ||
| 82 | be used as follows: addr = NULL, length = the desired buffer | ||
| 83 | size, i.e. number of packets times size of largest packet, | ||
| 84 | prot = at least PROT_READ for reception and at least PROT_WRITE | ||
| 85 | for transmission, flags = MAP_SHARED, fd = the handle to the | ||
| 86 | /dev/fw*, offset = 0. | ||
| 87 | |||
| 88 | Isochronous reception works in packet-per-buffer fashion except | ||
| 89 | for multichannel reception which works in buffer-fill mode. | ||
| 90 | |||
| 91 | munmap(2) | ||
| 92 | Unmap the isochronous I/O buffer from the process address space. | ||
| 93 | |||
| 94 | close(2) | ||
| 95 | Besides stopping and freeing I/O contexts that were associated | ||
| 96 | with the file descriptor, back out any changes to the local | ||
| 97 | nodes' Configuration ROM. Deallocate isochronous channels and | ||
| 98 | bandwidth at the IRM that were marked for kernel-assisted | ||
| 99 | re- and deallocation. | ||
| 100 | |||
| 101 | Users: libraw1394 | ||
| 102 | libdc1394 | ||
| 103 | tools like jujuutils, fwhack, ... | ||
diff --git a/include/linux/firewire-cdev.h b/include/linux/firewire-cdev.h index 55814aa33be2..357dbfc2829e 100644 --- a/include/linux/firewire-cdev.h +++ b/include/linux/firewire-cdev.h | |||
| @@ -30,10 +30,13 @@ | |||
| 30 | #include <linux/types.h> | 30 | #include <linux/types.h> |
| 31 | #include <linux/firewire-constants.h> | 31 | #include <linux/firewire-constants.h> |
| 32 | 32 | ||
| 33 | /* available since kernel version 2.6.22 */ | ||
| 33 | #define FW_CDEV_EVENT_BUS_RESET 0x00 | 34 | #define FW_CDEV_EVENT_BUS_RESET 0x00 |
| 34 | #define FW_CDEV_EVENT_RESPONSE 0x01 | 35 | #define FW_CDEV_EVENT_RESPONSE 0x01 |
| 35 | #define FW_CDEV_EVENT_REQUEST 0x02 | 36 | #define FW_CDEV_EVENT_REQUEST 0x02 |
| 36 | #define FW_CDEV_EVENT_ISO_INTERRUPT 0x03 | 37 | #define FW_CDEV_EVENT_ISO_INTERRUPT 0x03 |
| 38 | |||
| 39 | /* available since kernel version 2.6.30 */ | ||
| 37 | #define FW_CDEV_EVENT_ISO_RESOURCE_ALLOCATED 0x04 | 40 | #define FW_CDEV_EVENT_ISO_RESOURCE_ALLOCATED 0x04 |
| 38 | #define FW_CDEV_EVENT_ISO_RESOURCE_DEALLOCATED 0x05 | 41 | #define FW_CDEV_EVENT_ISO_RESOURCE_DEALLOCATED 0x05 |
| 39 | 42 | ||
| @@ -120,24 +123,11 @@ struct fw_cdev_event_response { | |||
| 120 | 123 | ||
| 121 | /** | 124 | /** |
| 122 | * struct fw_cdev_event_request - Old version of &fw_cdev_event_request2 | 125 | * struct fw_cdev_event_request - Old version of &fw_cdev_event_request2 |
| 123 | * @closure: See &fw_cdev_event_common; set by %FW_CDEV_IOC_ALLOCATE ioctl | ||
| 124 | * @type: See &fw_cdev_event_common; always %FW_CDEV_EVENT_REQUEST | 126 | * @type: See &fw_cdev_event_common; always %FW_CDEV_EVENT_REQUEST |
| 125 | * @tcode: See &fw_cdev_event_request2 | ||
| 126 | * @offset: See &fw_cdev_event_request2 | ||
| 127 | * @handle: See &fw_cdev_event_request2 | ||
| 128 | * @length: See &fw_cdev_event_request2 | ||
| 129 | * @data: See &fw_cdev_event_request2 | ||
| 130 | * | 127 | * |
| 131 | * This event is sent instead of &fw_cdev_event_request2 if the kernel or | 128 | * This event is sent instead of &fw_cdev_event_request2 if the kernel or |
| 132 | * the client implements ABI version <= 3. | 129 | * the client implements ABI version <= 3. &fw_cdev_event_request lacks |
| 133 | * | 130 | * essential information; use &fw_cdev_event_request2 instead. |
| 134 | * Unlike &fw_cdev_event_request2, the sender identity cannot be established, | ||
| 135 | * broadcast write requests cannot be distinguished from unicast writes, and | ||
| 136 | * @tcode of lock requests is %TCODE_LOCK_REQUEST. | ||
| 137 | * | ||
| 138 | * Requests to the FCP_REQUEST or FCP_RESPONSE register are responded to as | ||
| 139 | * with &fw_cdev_event_request2, except in kernel 2.6.32 and older which send | ||
| 140 | * the response packet of the client's %FW_CDEV_IOC_SEND_RESPONSE ioctl. | ||
| 141 | */ | 131 | */ |
| 142 | struct fw_cdev_event_request { | 132 | struct fw_cdev_event_request { |
| 143 | __u64 closure; | 133 | __u64 closure; |
| @@ -452,30 +442,29 @@ union fw_cdev_event { | |||
| 452 | * %FW_CDEV_ISO_CONTEXT_RECEIVE_MULTICHANNEL, and | 442 | * %FW_CDEV_ISO_CONTEXT_RECEIVE_MULTICHANNEL, and |
| 453 | * %FW_CDEV_IOC_SET_ISO_CHANNELS | 443 | * %FW_CDEV_IOC_SET_ISO_CHANNELS |
| 454 | */ | 444 | */ |
| 455 | #define FW_CDEV_VERSION 3 /* Meaningless; don't use this macro. */ | ||
| 456 | 445 | ||
| 457 | /** | 446 | /** |
| 458 | * struct fw_cdev_get_info - General purpose information ioctl | 447 | * struct fw_cdev_get_info - General purpose information ioctl |
| 459 | * @version: The version field is just a running serial number. Both an | 448 | * @version: The version field is just a running serial number. Both an |
| 460 | * input parameter (ABI version implemented by the client) and | 449 | * input parameter (ABI version implemented by the client) and |
| 461 | * output parameter (ABI version implemented by the kernel). | 450 | * output parameter (ABI version implemented by the kernel). |
| 462 | * A client must not fill in an %FW_CDEV_VERSION defined from an | 451 | * A client shall fill in the ABI @version for which the client |
| 463 | * included kernel header file but the actual version for which | 452 | * was implemented. This is necessary for forward compatibility. |
| 464 | * the client was implemented. This is necessary for forward | 453 | * @rom_length: If @rom is non-zero, up to @rom_length bytes of Configuration |
| 465 | * compatibility. We never break backwards compatibility, but | ||
| 466 | * may add more structs, events, and ioctls in later revisions. | ||
| 467 | * @rom_length: If @rom is non-zero, at most rom_length bytes of configuration | ||
| 468 | * ROM will be copied into that user space address. In either | 454 | * ROM will be copied into that user space address. In either |
| 469 | * case, @rom_length is updated with the actual length of the | 455 | * case, @rom_length is updated with the actual length of the |
| 470 | * configuration ROM. | 456 | * Configuration ROM. |
| 471 | * @rom: If non-zero, address of a buffer to be filled by a copy of the | 457 | * @rom: If non-zero, address of a buffer to be filled by a copy of the |
| 472 | * device's configuration ROM | 458 | * device's Configuration ROM |
| 473 | * @bus_reset: If non-zero, address of a buffer to be filled by a | 459 | * @bus_reset: If non-zero, address of a buffer to be filled by a |
| 474 | * &struct fw_cdev_event_bus_reset with the current state | 460 | * &struct fw_cdev_event_bus_reset with the current state |
| 475 | * of the bus. This does not cause a bus reset to happen. | 461 | * of the bus. This does not cause a bus reset to happen. |
| 476 | * @bus_reset_closure: Value of &closure in this and subsequent bus reset events | 462 | * @bus_reset_closure: Value of &closure in this and subsequent bus reset events |
| 477 | * @card: The index of the card this device belongs to | 463 | * @card: The index of the card this device belongs to |
| 478 | * | 464 | * |
| 465 | * The %FW_CDEV_IOC_GET_INFO ioctl is usually the very first one which a client | ||
| 466 | * performs right after it opened a /dev/fw* file. | ||
| 467 | * | ||
| 479 | * As a side effect, reception of %FW_CDEV_EVENT_BUS_RESET events to be read(2) | 468 | * As a side effect, reception of %FW_CDEV_EVENT_BUS_RESET events to be read(2) |
| 480 | * is started by this ioctl. | 469 | * is started by this ioctl. |
| 481 | */ | 470 | */ |
| @@ -615,7 +604,7 @@ struct fw_cdev_initiate_bus_reset { | |||
| 615 | * @handle: Handle to the descriptor, written by the kernel | 604 | * @handle: Handle to the descriptor, written by the kernel |
| 616 | * | 605 | * |
| 617 | * Add a descriptor block and optionally a preceding immediate key to the local | 606 | * Add a descriptor block and optionally a preceding immediate key to the local |
| 618 | * node's configuration ROM. | 607 | * node's Configuration ROM. |
| 619 | * | 608 | * |
| 620 | * The @key field specifies the upper 8 bits of the descriptor root directory | 609 | * The @key field specifies the upper 8 bits of the descriptor root directory |
| 621 | * pointer and the @data and @length fields specify the contents. The @key | 610 | * pointer and the @data and @length fields specify the contents. The @key |
| @@ -630,9 +619,9 @@ struct fw_cdev_initiate_bus_reset { | |||
| 630 | * If successful, the kernel adds the descriptor and writes back a @handle to | 619 | * If successful, the kernel adds the descriptor and writes back a @handle to |
| 631 | * the kernel-side object to be used for later removal of the descriptor block | 620 | * the kernel-side object to be used for later removal of the descriptor block |
| 632 | * and immediate key. The kernel will also generate a bus reset to signal the | 621 | * and immediate key. The kernel will also generate a bus reset to signal the |
| 633 | * change of the configuration ROM to other nodes. | 622 | * change of the Configuration ROM to other nodes. |
| 634 | * | 623 | * |
| 635 | * This ioctl affects the configuration ROMs of all local nodes. | 624 | * This ioctl affects the Configuration ROMs of all local nodes. |
| 636 | * The ioctl only succeeds on device files which represent a local node. | 625 | * The ioctl only succeeds on device files which represent a local node. |
| 637 | */ | 626 | */ |
| 638 | struct fw_cdev_add_descriptor { | 627 | struct fw_cdev_add_descriptor { |
| @@ -644,13 +633,13 @@ struct fw_cdev_add_descriptor { | |||
| 644 | }; | 633 | }; |
| 645 | 634 | ||
| 646 | /** | 635 | /** |
| 647 | * struct fw_cdev_remove_descriptor - Remove contents from the configuration ROM | 636 | * struct fw_cdev_remove_descriptor - Remove contents from the Configuration ROM |
| 648 | * @handle: Handle to the descriptor, as returned by the kernel when the | 637 | * @handle: Handle to the descriptor, as returned by the kernel when the |
| 649 | * descriptor was added | 638 | * descriptor was added |
| 650 | * | 639 | * |
| 651 | * Remove a descriptor block and accompanying immediate key from the local | 640 | * Remove a descriptor block and accompanying immediate key from the local |
| 652 | * nodes' configuration ROMs. The kernel will also generate a bus reset to | 641 | * nodes' Configuration ROMs. The kernel will also generate a bus reset to |
| 653 | * signal the change of the configuration ROM to other nodes. | 642 | * signal the change of the Configuration ROM to other nodes. |
| 654 | */ | 643 | */ |
| 655 | struct fw_cdev_remove_descriptor { | 644 | struct fw_cdev_remove_descriptor { |
| 656 | __u32 handle; | 645 | __u32 handle; |
| @@ -866,13 +855,8 @@ struct fw_cdev_stop_iso { | |||
| 866 | * @local_time: system time, in microseconds since the Epoch | 855 | * @local_time: system time, in microseconds since the Epoch |
| 867 | * @cycle_timer: Cycle Time register contents | 856 | * @cycle_timer: Cycle Time register contents |
| 868 | * | 857 | * |
| 869 | * The %FW_CDEV_IOC_GET_CYCLE_TIMER ioctl reads the isochronous cycle timer | 858 | * Same as %FW_CDEV_IOC_GET_CYCLE_TIMER2, but fixed to use %CLOCK_REALTIME |
| 870 | * and also the system clock (%CLOCK_REALTIME). This allows to express the | 859 | * and only with microseconds resolution. |
| 871 | * receive time of an isochronous packet as a system time. | ||
| 872 | * | ||
| 873 | * @cycle_timer consists of 7 bits cycleSeconds, 13 bits cycleCount, and | ||
| 874 | * 12 bits cycleOffset, in host byte order. Cf. the Cycle Time register | ||
| 875 | * per IEEE 1394 or Isochronous Cycle Timer register per OHCI-1394. | ||
| 876 | * | 860 | * |
| 877 | * In version 1 and 2 of the ABI, this ioctl returned unreliable (non- | 861 | * In version 1 and 2 of the ABI, this ioctl returned unreliable (non- |
| 878 | * monotonic) @cycle_timer values on certain controllers. | 862 | * monotonic) @cycle_timer values on certain controllers. |
| @@ -889,10 +873,17 @@ struct fw_cdev_get_cycle_timer { | |||
| 889 | * @clk_id: input parameter, clock from which to get the system time | 873 | * @clk_id: input parameter, clock from which to get the system time |
| 890 | * @cycle_timer: Cycle Time register contents | 874 | * @cycle_timer: Cycle Time register contents |
| 891 | * | 875 | * |
| 892 | * The %FW_CDEV_IOC_GET_CYCLE_TIMER2 works like | 876 | * The %FW_CDEV_IOC_GET_CYCLE_TIMER2 ioctl reads the isochronous cycle timer |
| 893 | * %FW_CDEV_IOC_GET_CYCLE_TIMER but lets you choose a clock like with POSIX' | 877 | * and also the system clock. This allows to correlate reception time of |
| 894 | * clock_gettime function. Supported @clk_id values are POSIX' %CLOCK_REALTIME | 878 | * isochronous packets with system time. |
| 895 | * and %CLOCK_MONOTONIC and Linux' %CLOCK_MONOTONIC_RAW. | 879 | * |
| 880 | * @clk_id lets you choose a clock like with POSIX' clock_gettime function. | ||
| 881 | * Supported @clk_id values are POSIX' %CLOCK_REALTIME and %CLOCK_MONOTONIC | ||
| 882 | * and Linux' %CLOCK_MONOTONIC_RAW. | ||
| 883 | * | ||
| 884 | * @cycle_timer consists of 7 bits cycleSeconds, 13 bits cycleCount, and | ||
| 885 | * 12 bits cycleOffset, in host byte order. Cf. the Cycle Time register | ||
| 886 | * per IEEE 1394 or Isochronous Cycle Timer register per OHCI-1394. | ||
| 896 | */ | 887 | */ |
| 897 | struct fw_cdev_get_cycle_timer2 { | 888 | struct fw_cdev_get_cycle_timer2 { |
| 898 | __s64 tv_sec; | 889 | __s64 tv_sec; |
| @@ -1014,4 +1005,6 @@ struct fw_cdev_receive_phy_packets { | |||
| 1014 | __u64 closure; | 1005 | __u64 closure; |
| 1015 | }; | 1006 | }; |
| 1016 | 1007 | ||
| 1008 | #define FW_CDEV_VERSION 3 /* Meaningless legacy macro; don't use it. */ | ||
| 1009 | |||
| 1017 | #endif /* _LINUX_FIREWIRE_CDEV_H */ | 1010 | #endif /* _LINUX_FIREWIRE_CDEV_H */ |
