diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/linux/crc-itu-t.h | 28 | ||||
-rw-r--r-- | include/linux/firewire-cdev.h | 229 | ||||
-rw-r--r-- | include/linux/firewire-constants.h | 67 |
3 files changed, 324 insertions, 0 deletions
diff --git a/include/linux/crc-itu-t.h b/include/linux/crc-itu-t.h new file mode 100644 index 000000000000..84920f3cc83e --- /dev/null +++ b/include/linux/crc-itu-t.h | |||
@@ -0,0 +1,28 @@ | |||
1 | /* | ||
2 | * crc-itu-t.h - CRC ITU-T V.41 routine | ||
3 | * | ||
4 | * Implements the standard CRC ITU-T V.41: | ||
5 | * Width 16 | ||
6 | * Poly 0x0x1021 (x^16 + x^12 + x^15 + 1) | ||
7 | * Init 0 | ||
8 | * | ||
9 | * This source code is licensed under the GNU General Public License, | ||
10 | * Version 2. See the file COPYING for more details. | ||
11 | */ | ||
12 | |||
13 | #ifndef CRC_ITU_T_H | ||
14 | #define CRC_ITU_T_H | ||
15 | |||
16 | #include <linux/types.h> | ||
17 | |||
18 | extern u16 const crc_itu_t_table[256]; | ||
19 | |||
20 | extern u16 crc_itu_t(u16 crc, const u8 *buffer, size_t len); | ||
21 | |||
22 | static inline u16 crc_itu_t_byte(u16 crc, const u8 data) | ||
23 | { | ||
24 | return (crc << 8) ^ crc_itu_t_table[((crc >> 8) ^ data) & 0xff]; | ||
25 | } | ||
26 | |||
27 | #endif /* CRC_ITU_T_H */ | ||
28 | |||
diff --git a/include/linux/firewire-cdev.h b/include/linux/firewire-cdev.h new file mode 100644 index 000000000000..d4455eb2ae35 --- /dev/null +++ b/include/linux/firewire-cdev.h | |||
@@ -0,0 +1,229 @@ | |||
1 | /* | ||
2 | * Char device interface. | ||
3 | * | ||
4 | * Copyright (C) 2005-2006 Kristian Hoegsberg <krh@bitplanet.net> | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify | ||
7 | * it under the terms of the GNU General Public License as published by | ||
8 | * the Free Software Foundation; either version 2 of the License, or | ||
9 | * (at your option) any later version. | ||
10 | * | ||
11 | * This program is distributed in the hope that it will be useful, | ||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
14 | * GNU General Public License for more details. | ||
15 | * | ||
16 | * You should have received a copy of the GNU General Public License | ||
17 | * along with this program; if not, write to the Free Software Foundation, | ||
18 | * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||
19 | */ | ||
20 | |||
21 | #ifndef _LINUX_FIREWIRE_CDEV_H | ||
22 | #define _LINUX_FIREWIRE_CDEV_H | ||
23 | |||
24 | #include <linux/ioctl.h> | ||
25 | #include <linux/types.h> | ||
26 | #include <linux/firewire-constants.h> | ||
27 | |||
28 | #define FW_CDEV_EVENT_BUS_RESET 0x00 | ||
29 | #define FW_CDEV_EVENT_RESPONSE 0x01 | ||
30 | #define FW_CDEV_EVENT_REQUEST 0x02 | ||
31 | #define FW_CDEV_EVENT_ISO_INTERRUPT 0x03 | ||
32 | |||
33 | /* The 'closure' fields are for user space to use. Data passed in the | ||
34 | * 'closure' field for a request will be returned in the corresponding | ||
35 | * event. It's a 64-bit type so that it's a fixed size type big | ||
36 | * enough to hold a pointer on all platforms. */ | ||
37 | |||
38 | struct fw_cdev_event_common { | ||
39 | __u64 closure; | ||
40 | __u32 type; | ||
41 | }; | ||
42 | |||
43 | struct fw_cdev_event_bus_reset { | ||
44 | __u64 closure; | ||
45 | __u32 type; | ||
46 | __u32 node_id; | ||
47 | __u32 local_node_id; | ||
48 | __u32 bm_node_id; | ||
49 | __u32 irm_node_id; | ||
50 | __u32 root_node_id; | ||
51 | __u32 generation; | ||
52 | }; | ||
53 | |||
54 | struct fw_cdev_event_response { | ||
55 | __u64 closure; | ||
56 | __u32 type; | ||
57 | __u32 rcode; | ||
58 | __u32 length; | ||
59 | __u32 data[0]; | ||
60 | }; | ||
61 | |||
62 | struct fw_cdev_event_request { | ||
63 | __u64 closure; | ||
64 | __u32 type; | ||
65 | __u32 tcode; | ||
66 | __u64 offset; | ||
67 | __u32 handle; | ||
68 | __u32 length; | ||
69 | __u32 data[0]; | ||
70 | }; | ||
71 | |||
72 | struct fw_cdev_event_iso_interrupt { | ||
73 | __u64 closure; | ||
74 | __u32 type; | ||
75 | __u32 cycle; | ||
76 | __u32 header_length; /* Length in bytes of following headers. */ | ||
77 | __u32 header[0]; | ||
78 | }; | ||
79 | |||
80 | union fw_cdev_event { | ||
81 | struct fw_cdev_event_common common; | ||
82 | struct fw_cdev_event_bus_reset bus_reset; | ||
83 | struct fw_cdev_event_response response; | ||
84 | struct fw_cdev_event_request request; | ||
85 | struct fw_cdev_event_iso_interrupt iso_interrupt; | ||
86 | }; | ||
87 | |||
88 | #define FW_CDEV_IOC_GET_INFO _IOWR('#', 0x00, struct fw_cdev_get_info) | ||
89 | #define FW_CDEV_IOC_SEND_REQUEST _IOW('#', 0x01, struct fw_cdev_send_request) | ||
90 | #define FW_CDEV_IOC_ALLOCATE _IOWR('#', 0x02, struct fw_cdev_allocate) | ||
91 | #define FW_CDEV_IOC_DEALLOCATE _IOW('#', 0x03, struct fw_cdev_deallocate) | ||
92 | #define FW_CDEV_IOC_SEND_RESPONSE _IOW('#', 0x04, struct fw_cdev_send_response) | ||
93 | #define FW_CDEV_IOC_INITIATE_BUS_RESET _IOW('#', 0x05, struct fw_cdev_initiate_bus_reset) | ||
94 | #define FW_CDEV_IOC_ADD_DESCRIPTOR _IOWR('#', 0x06, struct fw_cdev_add_descriptor) | ||
95 | #define FW_CDEV_IOC_REMOVE_DESCRIPTOR _IOW('#', 0x07, struct fw_cdev_remove_descriptor) | ||
96 | |||
97 | #define FW_CDEV_IOC_CREATE_ISO_CONTEXT _IOWR('#', 0x08, struct fw_cdev_create_iso_context) | ||
98 | #define FW_CDEV_IOC_QUEUE_ISO _IOWR('#', 0x09, struct fw_cdev_queue_iso) | ||
99 | #define FW_CDEV_IOC_START_ISO _IOW('#', 0x0a, struct fw_cdev_start_iso) | ||
100 | #define FW_CDEV_IOC_STOP_ISO _IOW('#', 0x0b, struct fw_cdev_stop_iso) | ||
101 | |||
102 | /* FW_CDEV_VERSION History | ||
103 | * | ||
104 | * 1 Feb 18, 2007: Initial version. | ||
105 | */ | ||
106 | #define FW_CDEV_VERSION 1 | ||
107 | |||
108 | struct fw_cdev_get_info { | ||
109 | /* The version field is just a running serial number. We | ||
110 | * never break backwards compatibility. Userspace passes in | ||
111 | * the version it expects and the kernel passes back the | ||
112 | * highest version it can provide. Even if the structs in | ||
113 | * this interface are extended in a later version, the kernel | ||
114 | * will not copy back more data than what was present in the | ||
115 | * interface version userspace expects. */ | ||
116 | __u32 version; | ||
117 | |||
118 | /* If non-zero, at most rom_length bytes of config rom will be | ||
119 | * copied into that user space address. In either case, | ||
120 | * rom_length is updated with the actual length of the config | ||
121 | * rom. */ | ||
122 | __u32 rom_length; | ||
123 | __u64 rom; | ||
124 | |||
125 | /* If non-zero, a fw_cdev_event_bus_reset struct will be | ||
126 | * copied here with the current state of the bus. This does | ||
127 | * not cause a bus reset to happen. The value of closure in | ||
128 | * this and sub-sequent bus reset events is set to | ||
129 | * bus_reset_closure. */ | ||
130 | __u64 bus_reset; | ||
131 | __u64 bus_reset_closure; | ||
132 | |||
133 | /* The index of the card this devices belongs to. */ | ||
134 | __u32 card; | ||
135 | }; | ||
136 | |||
137 | struct fw_cdev_send_request { | ||
138 | __u32 tcode; | ||
139 | __u32 length; | ||
140 | __u64 offset; | ||
141 | __u64 closure; | ||
142 | __u64 data; | ||
143 | __u32 generation; | ||
144 | }; | ||
145 | |||
146 | struct fw_cdev_send_response { | ||
147 | __u32 rcode; | ||
148 | __u32 length; | ||
149 | __u64 data; | ||
150 | __u32 handle; | ||
151 | }; | ||
152 | |||
153 | struct fw_cdev_allocate { | ||
154 | __u64 offset; | ||
155 | __u64 closure; | ||
156 | __u32 length; | ||
157 | __u32 handle; | ||
158 | }; | ||
159 | |||
160 | struct fw_cdev_deallocate { | ||
161 | __u32 handle; | ||
162 | }; | ||
163 | |||
164 | #define FW_CDEV_LONG_RESET 0 | ||
165 | #define FW_CDEV_SHORT_RESET 1 | ||
166 | |||
167 | struct fw_cdev_initiate_bus_reset { | ||
168 | __u32 type; | ||
169 | }; | ||
170 | |||
171 | struct fw_cdev_add_descriptor { | ||
172 | __u32 immediate; | ||
173 | __u32 key; | ||
174 | __u64 data; | ||
175 | __u32 length; | ||
176 | __u32 handle; | ||
177 | }; | ||
178 | |||
179 | struct fw_cdev_remove_descriptor { | ||
180 | __u32 handle; | ||
181 | }; | ||
182 | |||
183 | #define FW_CDEV_ISO_CONTEXT_TRANSMIT 0 | ||
184 | #define FW_CDEV_ISO_CONTEXT_RECEIVE 1 | ||
185 | |||
186 | #define FW_CDEV_ISO_CONTEXT_MATCH_TAG0 1 | ||
187 | #define FW_CDEV_ISO_CONTEXT_MATCH_TAG1 2 | ||
188 | #define FW_CDEV_ISO_CONTEXT_MATCH_TAG2 4 | ||
189 | #define FW_CDEV_ISO_CONTEXT_MATCH_TAG3 8 | ||
190 | #define FW_CDEV_ISO_CONTEXT_MATCH_ALL_TAGS 15 | ||
191 | |||
192 | struct fw_cdev_create_iso_context { | ||
193 | __u32 type; | ||
194 | __u32 header_size; | ||
195 | __u32 channel; | ||
196 | __u32 speed; | ||
197 | __u64 closure; | ||
198 | __u32 handle; | ||
199 | }; | ||
200 | |||
201 | struct fw_cdev_iso_packet { | ||
202 | __u16 payload_length; /* Length of indirect payload. */ | ||
203 | __u32 interrupt : 1; /* Generate interrupt on this packet */ | ||
204 | __u32 skip : 1; /* Set to not send packet at all. */ | ||
205 | __u32 tag : 2; | ||
206 | __u32 sy : 4; | ||
207 | __u32 header_length : 8; /* Length of immediate header. */ | ||
208 | __u32 header[0]; | ||
209 | }; | ||
210 | |||
211 | struct fw_cdev_queue_iso { | ||
212 | __u64 packets; | ||
213 | __u64 data; | ||
214 | __u32 size; | ||
215 | __u32 handle; | ||
216 | }; | ||
217 | |||
218 | struct fw_cdev_start_iso { | ||
219 | __s32 cycle; | ||
220 | __u32 sync; | ||
221 | __u32 tags; | ||
222 | __u32 handle; | ||
223 | }; | ||
224 | |||
225 | struct fw_cdev_stop_iso { | ||
226 | __u32 handle; | ||
227 | }; | ||
228 | |||
229 | #endif /* _LINUX_FIREWIRE_CDEV_H */ | ||
diff --git a/include/linux/firewire-constants.h b/include/linux/firewire-constants.h new file mode 100644 index 000000000000..b316770a43fd --- /dev/null +++ b/include/linux/firewire-constants.h | |||
@@ -0,0 +1,67 @@ | |||
1 | #ifndef _LINUX_FIREWIRE_CONSTANTS_H | ||
2 | #define _LINUX_FIREWIRE_CONSTANTS_H | ||
3 | |||
4 | #define TCODE_WRITE_QUADLET_REQUEST 0x0 | ||
5 | #define TCODE_WRITE_BLOCK_REQUEST 0x1 | ||
6 | #define TCODE_WRITE_RESPONSE 0x2 | ||
7 | #define TCODE_READ_QUADLET_REQUEST 0x4 | ||
8 | #define TCODE_READ_BLOCK_REQUEST 0x5 | ||
9 | #define TCODE_READ_QUADLET_RESPONSE 0x6 | ||
10 | #define TCODE_READ_BLOCK_RESPONSE 0x7 | ||
11 | #define TCODE_CYCLE_START 0x8 | ||
12 | #define TCODE_LOCK_REQUEST 0x9 | ||
13 | #define TCODE_STREAM_DATA 0xa | ||
14 | #define TCODE_LOCK_RESPONSE 0xb | ||
15 | |||
16 | #define EXTCODE_MASK_SWAP 0x1 | ||
17 | #define EXTCODE_COMPARE_SWAP 0x2 | ||
18 | #define EXTCODE_FETCH_ADD 0x3 | ||
19 | #define EXTCODE_LITTLE_ADD 0x4 | ||
20 | #define EXTCODE_BOUNDED_ADD 0x5 | ||
21 | #define EXTCODE_WRAP_ADD 0x6 | ||
22 | #define EXTCODE_VENDOR_DEPENDENT 0x7 | ||
23 | |||
24 | /* Juju specific tcodes */ | ||
25 | #define TCODE_LOCK_MASK_SWAP (0x10 | EXTCODE_MASK_SWAP) | ||
26 | #define TCODE_LOCK_COMPARE_SWAP (0x10 | EXTCODE_COMPARE_SWAP) | ||
27 | #define TCODE_LOCK_FETCH_ADD (0x10 | EXTCODE_FETCH_ADD) | ||
28 | #define TCODE_LOCK_LITTLE_ADD (0x10 | EXTCODE_LITTLE_ADD) | ||
29 | #define TCODE_LOCK_BOUNDED_ADD (0x10 | EXTCODE_BOUNDED_ADD) | ||
30 | #define TCODE_LOCK_WRAP_ADD (0x10 | EXTCODE_WRAP_ADD) | ||
31 | #define TCODE_LOCK_VENDOR_DEPENDENT (0x10 | EXTCODE_VENDOR_DEPENDENT) | ||
32 | |||
33 | #define RCODE_COMPLETE 0x0 | ||
34 | #define RCODE_CONFLICT_ERROR 0x4 | ||
35 | #define RCODE_DATA_ERROR 0x5 | ||
36 | #define RCODE_TYPE_ERROR 0x6 | ||
37 | #define RCODE_ADDRESS_ERROR 0x7 | ||
38 | |||
39 | /* Juju specific rcodes */ | ||
40 | #define RCODE_SEND_ERROR 0x10 | ||
41 | #define RCODE_CANCELLED 0x11 | ||
42 | #define RCODE_BUSY 0x12 | ||
43 | #define RCODE_GENERATION 0x13 | ||
44 | #define RCODE_NO_ACK 0x14 | ||
45 | |||
46 | #define SCODE_100 0x0 | ||
47 | #define SCODE_200 0x1 | ||
48 | #define SCODE_400 0x2 | ||
49 | #define SCODE_800 0x3 | ||
50 | #define SCODE_1600 0x4 | ||
51 | #define SCODE_3200 0x5 | ||
52 | #define SCODE_BETA 0x3 | ||
53 | |||
54 | #define ACK_COMPLETE 0x1 | ||
55 | #define ACK_PENDING 0x2 | ||
56 | #define ACK_BUSY_X 0x4 | ||
57 | #define ACK_BUSY_A 0x5 | ||
58 | #define ACK_BUSY_B 0x6 | ||
59 | #define ACK_DATA_ERROR 0xd | ||
60 | #define ACK_TYPE_ERROR 0xe | ||
61 | |||
62 | #define RETRY_1 0x00 | ||
63 | #define RETRY_X 0x01 | ||
64 | #define RETRY_A 0x02 | ||
65 | #define RETRY_B 0x03 | ||
66 | |||
67 | #endif /* _LINUX_FIREWIRE_CONSTANTS_H */ | ||