fw-transaction.c 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730
  1. /* -*- c-basic-offset: 8 -*-
  2. *
  3. * fw-transaction.c - core IEEE1394 transaction logic
  4. *
  5. * Copyright (C) 2004-2006 Kristian Hoegsberg <krh@bitplanet.net>
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 2 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software Foundation,
  19. * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  20. */
  21. #include <linux/kernel.h>
  22. #include <linux/module.h>
  23. #include <linux/init.h>
  24. #include <linux/interrupt.h>
  25. #include <linux/pci.h>
  26. #include <linux/delay.h>
  27. #include <linux/poll.h>
  28. #include <linux/list.h>
  29. #include <linux/kthread.h>
  30. #include <asm/uaccess.h>
  31. #include <asm/semaphore.h>
  32. #include "fw-transaction.h"
  33. #include "fw-topology.h"
  34. #define header_pri(pri) ((pri) << 0)
  35. #define header_tcode(tcode) ((tcode) << 4)
  36. #define header_retry(retry) ((retry) << 8)
  37. #define header_tlabel(tlabel) ((tlabel) << 10)
  38. #define header_destination(destination) ((destination) << 16)
  39. #define header_source(source) ((source) << 16)
  40. #define header_rcode(rcode) ((rcode) << 12)
  41. #define header_offset_high(offset_high) ((offset_high) << 0)
  42. #define header_data_length(length) ((length) << 16)
  43. #define header_extended_tcode(tcode) ((tcode) << 0)
  44. #define header_get_tcode(q) (((q) >> 4) & 0x0f)
  45. #define header_get_tlabel(q) (((q) >> 10) & 0x3f)
  46. #define header_get_rcode(q) (((q) >> 4) & 0x0f)
  47. #define header_get_destination(q) (((q) >> 16) & 0xffff)
  48. #define header_get_source(q) (((q) >> 16) & 0xffff)
  49. #define header_get_offset_high(q) (((q) >> 0) & 0xffff)
  50. #define header_get_data_length(q) (((q) >> 16) & 0xffff)
  51. #define header_get_extended_tcode(q) (((q) >> 0) & 0xffff)
  52. #define phy_config_gap_count(gap_count) (((gap_count) << 16) | (1 << 22))
  53. #define phy_config_root_id(node_id) (((node_id) << 24) | (1 << 23))
  54. #define phy_identifier(id) ((id) << 30)
  55. static void
  56. close_transaction(struct fw_transaction *t, struct fw_card *card, int rcode,
  57. u32 * payload, size_t length)
  58. {
  59. unsigned long flags;
  60. spin_lock_irqsave(&card->lock, flags);
  61. card->tlabel_mask &= ~(1 << t->tlabel);
  62. list_del(&t->link);
  63. spin_unlock_irqrestore(&card->lock, flags);
  64. t->callback(card, rcode, payload, length, t->callback_data);
  65. }
  66. static void
  67. transmit_complete_callback(struct fw_packet *packet,
  68. struct fw_card *card, int status)
  69. {
  70. struct fw_transaction *t =
  71. container_of(packet, struct fw_transaction, packet);
  72. switch (status) {
  73. case ACK_COMPLETE:
  74. close_transaction(t, card, RCODE_COMPLETE, NULL, 0);
  75. break;
  76. case ACK_PENDING:
  77. t->timestamp = packet->timestamp;
  78. break;
  79. case ACK_BUSY_X:
  80. case ACK_BUSY_A:
  81. case ACK_BUSY_B:
  82. close_transaction(t, card, RCODE_BUSY, NULL, 0);
  83. break;
  84. case ACK_DATA_ERROR:
  85. case ACK_TYPE_ERROR:
  86. close_transaction(t, card, RCODE_SEND_ERROR, NULL, 0);
  87. break;
  88. default:
  89. /* FIXME: In this case, status is a negative errno,
  90. * corresponding to an OHCI specific transmit error
  91. * code. We should map that to an RCODE instead of
  92. * just the generic RCODE_SEND_ERROR. */
  93. close_transaction(t, card, RCODE_SEND_ERROR, NULL, 0);
  94. break;
  95. }
  96. }
  97. void
  98. fw_fill_packet(struct fw_packet *packet, int tcode, int tlabel,
  99. int node_id, int generation, int speed,
  100. unsigned long long offset, void *payload, size_t length)
  101. {
  102. int ext_tcode;
  103. if (tcode > 0x10) {
  104. ext_tcode = tcode - 0x10;
  105. tcode = TCODE_LOCK_REQUEST;
  106. } else
  107. ext_tcode = 0;
  108. packet->header[0] =
  109. header_retry(RETRY_X) |
  110. header_tlabel(tlabel) |
  111. header_tcode(tcode) |
  112. header_destination(node_id | LOCAL_BUS);
  113. packet->header[1] =
  114. header_offset_high(offset >> 32) | header_source(0);
  115. packet->header[2] =
  116. offset;
  117. switch (tcode) {
  118. case TCODE_WRITE_QUADLET_REQUEST:
  119. packet->header[3] = *(u32 *)payload;
  120. packet->header_length = 16;
  121. packet->payload_length = 0;
  122. break;
  123. case TCODE_LOCK_REQUEST:
  124. case TCODE_WRITE_BLOCK_REQUEST:
  125. packet->header[3] =
  126. header_data_length(length) |
  127. header_extended_tcode(ext_tcode);
  128. packet->header_length = 16;
  129. packet->payload = payload;
  130. packet->payload_length = length;
  131. break;
  132. case TCODE_READ_QUADLET_REQUEST:
  133. packet->header_length = 12;
  134. packet->payload_length = 0;
  135. break;
  136. case TCODE_READ_BLOCK_REQUEST:
  137. packet->header[3] =
  138. header_data_length(length) |
  139. header_extended_tcode(ext_tcode);
  140. packet->header_length = 16;
  141. packet->payload_length = 0;
  142. break;
  143. }
  144. packet->speed = speed;
  145. packet->generation = generation;
  146. }
  147. /**
  148. * This function provides low-level access to the IEEE1394 transaction
  149. * logic. Most C programs would use either fw_read(), fw_write() or
  150. * fw_lock() instead - those function are convenience wrappers for
  151. * this function. The fw_send_request() function is primarily
  152. * provided as a flexible, one-stop entry point for languages bindings
  153. * and protocol bindings.
  154. *
  155. * FIXME: Document this function further, in particular the possible
  156. * values for rcode in the callback. In short, we map ACK_COMPLETE to
  157. * RCODE_COMPLETE, internal errors set errno and set rcode to
  158. * RCODE_SEND_ERROR (which is out of range for standard ieee1394
  159. * rcodes). All other rcodes are forwarded unchanged. For all
  160. * errors, payload is NULL, length is 0.
  161. *
  162. * Can not expect the callback to be called before the function
  163. * returns, though this does happen in some cases (ACK_COMPLETE and
  164. * errors).
  165. *
  166. * The payload is only used for write requests and must not be freed
  167. * until the callback has been called.
  168. *
  169. * @param card the card from which to send the request
  170. * @param tcode the tcode for this transaction. Do not use
  171. * TCODE_LOCK_REQUEST directly, insted use TCODE_LOCK_MASK_SWAP
  172. * etc. to specify tcode and ext_tcode.
  173. * @param node_id the node_id of the destination node
  174. * @param generation the generation for which node_id is valid
  175. * @param speed the speed to use for sending the request
  176. * @param offset the 48 bit offset on the destination node
  177. * @param payload the data payload for the request subaction
  178. * @param length the length in bytes of the data to read
  179. * @param callback function to be called when the transaction is completed
  180. * @param callback_data pointer to arbitrary data, which will be
  181. * passed to the callback
  182. */
  183. void
  184. fw_send_request(struct fw_card *card, struct fw_transaction *t,
  185. int tcode, int node_id, int generation, int speed,
  186. unsigned long long offset,
  187. void *payload, size_t length,
  188. fw_transaction_callback_t callback, void *callback_data)
  189. {
  190. unsigned long flags;
  191. int tlabel;
  192. /* Bump the flush timer up 100ms first of all so we
  193. * don't race with a flush timer callback. */
  194. mod_timer(&card->flush_timer, jiffies + DIV_ROUND_UP(HZ, 10));
  195. /* Allocate tlabel from the bitmap and put the transaction on
  196. * the list while holding the card spinlock. */
  197. spin_lock_irqsave(&card->lock, flags);
  198. tlabel = card->current_tlabel;
  199. if (card->tlabel_mask & (1 << tlabel)) {
  200. spin_unlock_irqrestore(&card->lock, flags);
  201. callback(card, RCODE_SEND_ERROR, NULL, 0, callback_data);
  202. return;
  203. }
  204. card->current_tlabel = (card->current_tlabel + 1) & 0x1f;
  205. card->tlabel_mask |= (1 << tlabel);
  206. list_add_tail(&t->link, &card->transaction_list);
  207. spin_unlock_irqrestore(&card->lock, flags);
  208. /* Initialize rest of transaction, fill out packet and send it. */
  209. t->node_id = node_id;
  210. t->tlabel = tlabel;
  211. t->callback = callback;
  212. t->callback_data = callback_data;
  213. fw_fill_packet(&t->packet, tcode, t->tlabel,
  214. node_id, generation, speed, offset, payload, length);
  215. t->packet.callback = transmit_complete_callback;
  216. card->driver->send_request(card, &t->packet);
  217. }
  218. EXPORT_SYMBOL(fw_send_request);
  219. static void
  220. transmit_phy_packet_callback(struct fw_packet *packet,
  221. struct fw_card *card, int status)
  222. {
  223. kfree(packet);
  224. }
  225. static void send_phy_packet(struct fw_card *card, u32 data, int generation)
  226. {
  227. struct fw_packet *packet;
  228. packet = kzalloc(sizeof *packet, GFP_ATOMIC);
  229. if (packet == NULL)
  230. return;
  231. packet->header[0] = data;
  232. packet->header[1] = ~data;
  233. packet->header_length = 8;
  234. packet->payload_length = 0;
  235. packet->speed = SCODE_100;
  236. packet->generation = generation;
  237. packet->callback = transmit_phy_packet_callback;
  238. card->driver->send_request(card, packet);
  239. }
  240. void fw_send_force_root(struct fw_card *card, int node_id, int generation)
  241. {
  242. u32 q;
  243. q = phy_identifier(PHY_PACKET_CONFIG) | phy_config_root_id(node_id);
  244. send_phy_packet(card, q, generation);
  245. }
  246. void fw_flush_transactions(struct fw_card *card)
  247. {
  248. struct fw_transaction *t, *next;
  249. struct list_head list;
  250. unsigned long flags;
  251. INIT_LIST_HEAD(&list);
  252. spin_lock_irqsave(&card->lock, flags);
  253. list_splice_init(&card->transaction_list, &list);
  254. card->tlabel_mask = 0;
  255. spin_unlock_irqrestore(&card->lock, flags);
  256. list_for_each_entry_safe(t, next, &list, link)
  257. t->callback(card, RCODE_CANCELLED, NULL, 0, t->callback_data);
  258. }
  259. static struct fw_address_handler *
  260. lookup_overlapping_address_handler(struct list_head *list,
  261. unsigned long long offset, size_t length)
  262. {
  263. struct fw_address_handler *handler;
  264. list_for_each_entry(handler, list, link) {
  265. if (handler->offset < offset + length &&
  266. offset < handler->offset + handler->length)
  267. return handler;
  268. }
  269. return NULL;
  270. }
  271. static struct fw_address_handler *
  272. lookup_enclosing_address_handler(struct list_head *list,
  273. unsigned long long offset, size_t length)
  274. {
  275. struct fw_address_handler *handler;
  276. list_for_each_entry(handler, list, link) {
  277. if (handler->offset <= offset &&
  278. offset + length <= handler->offset + handler->length)
  279. return handler;
  280. }
  281. return NULL;
  282. }
  283. static DEFINE_SPINLOCK(address_handler_lock);
  284. static LIST_HEAD(address_handler_list);
  285. struct fw_address_region fw_low_memory_region =
  286. { 0x000000000000ull, 0x000100000000ull };
  287. struct fw_address_region fw_high_memory_region =
  288. { 0x000100000000ull, 0xffffe0000000ull };
  289. struct fw_address_region fw_private_region =
  290. { 0xffffe0000000ull, 0xfffff0000000ull };
  291. struct fw_address_region fw_csr_region =
  292. { 0xfffff0000000ULL, 0xfffff0000800ull };
  293. struct fw_address_region fw_unit_space_region =
  294. { 0xfffff0000900ull, 0x1000000000000ull };
  295. EXPORT_SYMBOL(fw_low_memory_region);
  296. EXPORT_SYMBOL(fw_high_memory_region);
  297. EXPORT_SYMBOL(fw_private_region);
  298. EXPORT_SYMBOL(fw_csr_region);
  299. EXPORT_SYMBOL(fw_unit_space_region);
  300. /**
  301. * Allocate a range of addresses in the node space of the OHCI
  302. * controller. When a request is received that falls within the
  303. * specified address range, the specified callback is invoked. The
  304. * parameters passed to the callback give the details of the
  305. * particular request
  306. */
  307. int
  308. fw_core_add_address_handler(struct fw_address_handler *handler,
  309. struct fw_address_region *region)
  310. {
  311. struct fw_address_handler *other;
  312. unsigned long flags;
  313. int ret = -EBUSY;
  314. spin_lock_irqsave(&address_handler_lock, flags);
  315. handler->offset = region->start;
  316. while (handler->offset + handler->length <= region->end) {
  317. other =
  318. lookup_overlapping_address_handler(&address_handler_list,
  319. handler->offset,
  320. handler->length);
  321. if (other != NULL) {
  322. handler->offset += other->length;
  323. } else {
  324. list_add_tail(&handler->link, &address_handler_list);
  325. ret = 0;
  326. break;
  327. }
  328. }
  329. spin_unlock_irqrestore(&address_handler_lock, flags);
  330. return ret;
  331. }
  332. EXPORT_SYMBOL(fw_core_add_address_handler);
  333. /**
  334. * Deallocate a range of addresses allocated with fw_allocate. This
  335. * will call the associated callback one last time with a the special
  336. * tcode TCODE_DEALLOCATE, to let the client destroy the registered
  337. * callback data. For convenience, the callback parameters offset and
  338. * length are set to the start and the length respectively for the
  339. * deallocated region, payload is set to NULL.
  340. */
  341. void fw_core_remove_address_handler(struct fw_address_handler *handler)
  342. {
  343. unsigned long flags;
  344. spin_lock_irqsave(&address_handler_lock, flags);
  345. list_del(&handler->link);
  346. spin_unlock_irqrestore(&address_handler_lock, flags);
  347. }
  348. EXPORT_SYMBOL(fw_core_remove_address_handler);
  349. struct fw_request {
  350. struct fw_packet response;
  351. int ack;
  352. u32 length;
  353. u32 data[0];
  354. };
  355. static void
  356. free_response_callback(struct fw_packet *packet,
  357. struct fw_card *card, int status)
  358. {
  359. struct fw_request *request;
  360. request = container_of(packet, struct fw_request, response);
  361. kfree(request);
  362. }
  363. static void
  364. fw_fill_response(struct fw_packet *response,
  365. u32 *request, u32 *data, size_t length)
  366. {
  367. int tcode, tlabel, extended_tcode, source, destination;
  368. tcode = header_get_tcode(request[0]);
  369. tlabel = header_get_tlabel(request[0]);
  370. source = header_get_destination(request[0]);
  371. destination = header_get_source(request[1]);
  372. extended_tcode = header_get_extended_tcode(request[3]);
  373. response->header[0] =
  374. header_retry(RETRY_1) |
  375. header_tlabel(tlabel) |
  376. header_destination(destination);
  377. response->header[1] = header_source(source);
  378. response->header[2] = 0;
  379. switch (tcode) {
  380. case TCODE_WRITE_QUADLET_REQUEST:
  381. case TCODE_WRITE_BLOCK_REQUEST:
  382. response->header[0] |= header_tcode(TCODE_WRITE_RESPONSE);
  383. response->header_length = 12;
  384. response->payload_length = 0;
  385. break;
  386. case TCODE_READ_QUADLET_REQUEST:
  387. response->header[0] |=
  388. header_tcode(TCODE_READ_QUADLET_RESPONSE);
  389. response->header[3] = 0;
  390. response->header_length = 16;
  391. response->payload_length = 0;
  392. break;
  393. case TCODE_READ_BLOCK_REQUEST:
  394. case TCODE_LOCK_REQUEST:
  395. response->header[0] |= header_tcode(tcode + 2);
  396. response->header[3] =
  397. header_data_length(length) |
  398. header_extended_tcode(extended_tcode);
  399. response->header_length = 16;
  400. response->payload = data;
  401. response->payload_length = length;
  402. break;
  403. default:
  404. BUG();
  405. return;
  406. }
  407. }
  408. static struct fw_request *
  409. allocate_request(u32 *header, int ack,
  410. int speed, int timestamp, int generation)
  411. {
  412. struct fw_request *request;
  413. u32 *data, length;
  414. int request_tcode;
  415. request_tcode = header_get_tcode(header[0]);
  416. switch (request_tcode) {
  417. case TCODE_WRITE_QUADLET_REQUEST:
  418. data = &header[3];
  419. length = 4;
  420. break;
  421. case TCODE_WRITE_BLOCK_REQUEST:
  422. case TCODE_LOCK_REQUEST:
  423. data = &header[4];
  424. length = header_get_data_length(header[3]);
  425. break;
  426. case TCODE_READ_QUADLET_REQUEST:
  427. data = NULL;
  428. length = 4;
  429. break;
  430. case TCODE_READ_BLOCK_REQUEST:
  431. data = NULL;
  432. length = header_get_data_length(header[3]);
  433. break;
  434. default:
  435. BUG();
  436. return NULL;
  437. }
  438. request = kmalloc(sizeof *request + length, GFP_ATOMIC);
  439. if (request == NULL)
  440. return NULL;
  441. request->response.speed = speed;
  442. request->response.timestamp = timestamp;
  443. request->response.generation = generation;
  444. request->response.callback = free_response_callback;
  445. request->ack = ack;
  446. request->length = length;
  447. if (data)
  448. memcpy(request->data, data, length);
  449. fw_fill_response(&request->response, header, request->data, length);
  450. return request;
  451. }
  452. void
  453. fw_send_response(struct fw_card *card, struct fw_request *request, int rcode)
  454. {
  455. int response_tcode;
  456. /* Broadcast packets are reported as ACK_COMPLETE, so this
  457. * check is sufficient to ensure we don't send response to
  458. * broadcast packets or posted writes. */
  459. if (request->ack != ACK_PENDING)
  460. return;
  461. request->response.header[1] |= header_rcode(rcode);
  462. response_tcode = header_get_tcode(request->response.header[0]);
  463. if (rcode != RCODE_COMPLETE)
  464. /* Clear the data_length field. */
  465. request->response.header[3] &= 0xffff;
  466. else if (response_tcode == TCODE_READ_QUADLET_RESPONSE)
  467. request->response.header[3] = request->data[0];
  468. card->driver->send_response(card, &request->response);
  469. }
  470. EXPORT_SYMBOL(fw_send_response);
  471. void
  472. fw_core_handle_request(struct fw_card *card,
  473. int speed, int ack, int timestamp,
  474. int generation, u32 length, u32 *header)
  475. {
  476. struct fw_address_handler *handler;
  477. struct fw_request *request;
  478. unsigned long long offset;
  479. unsigned long flags;
  480. int tcode, destination, source, t;
  481. if (length > 2048) {
  482. /* FIXME: send error response. */
  483. return;
  484. }
  485. if (ack != ACK_PENDING && ack != ACK_COMPLETE)
  486. return;
  487. t = (timestamp & 0x1fff) + 4000;
  488. if (t >= 8000)
  489. t = (timestamp & ~0x1fff) + 0x2000 + t - 8000;
  490. else
  491. t = (timestamp & ~0x1fff) + t;
  492. request = allocate_request(header, ack, speed, t, generation);
  493. if (request == NULL) {
  494. /* FIXME: send statically allocated busy packet. */
  495. return;
  496. }
  497. offset =
  498. ((unsigned long long)
  499. header_get_offset_high(header[1]) << 32) | header[2];
  500. tcode = header_get_tcode(header[0]);
  501. destination = header_get_destination(header[0]);
  502. source = header_get_source(header[0]);
  503. spin_lock_irqsave(&address_handler_lock, flags);
  504. handler = lookup_enclosing_address_handler(&address_handler_list,
  505. offset, request->length);
  506. spin_unlock_irqrestore(&address_handler_lock, flags);
  507. /* FIXME: lookup the fw_node corresponding to the sender of
  508. * this request and pass that to the address handler instead
  509. * of the node ID. We may also want to move the address
  510. * allocations to fw_node so we only do this callback if the
  511. * upper layers registered it for this node. */
  512. if (handler == NULL)
  513. fw_send_response(card, request, RCODE_ADDRESS_ERROR);
  514. else
  515. handler->address_callback(card, request,
  516. tcode, destination, source,
  517. generation, speed, offset,
  518. request->data, request->length,
  519. handler->callback_data);
  520. }
  521. EXPORT_SYMBOL(fw_core_handle_request);
  522. void
  523. fw_core_handle_response(struct fw_card *card,
  524. int speed, int ack, int timestamp,
  525. u32 length, u32 *header)
  526. {
  527. struct fw_transaction *t;
  528. unsigned long flags;
  529. u32 *data;
  530. size_t data_length;
  531. int tcode, tlabel, destination, source, rcode;
  532. tcode = header_get_tcode(header[0]);
  533. tlabel = header_get_tlabel(header[0]);
  534. destination = header_get_destination(header[0]);
  535. source = header_get_source(header[1]);
  536. rcode = header_get_rcode(header[1]);
  537. spin_lock_irqsave(&card->lock, flags);
  538. list_for_each_entry(t, &card->transaction_list, link) {
  539. if (t->node_id == source && t->tlabel == tlabel) {
  540. list_del(&t->link);
  541. card->tlabel_mask &= ~(1 << t->tlabel);
  542. break;
  543. }
  544. }
  545. spin_unlock_irqrestore(&card->lock, flags);
  546. if (&t->link == &card->transaction_list) {
  547. fw_notify("Unsolicited response\n");
  548. return;
  549. }
  550. /* FIXME: sanity check packet, is length correct, does tcodes
  551. * and addresses match. */
  552. switch (tcode) {
  553. case TCODE_READ_QUADLET_RESPONSE:
  554. data = (u32 *) &header[3];
  555. data_length = 4;
  556. break;
  557. case TCODE_WRITE_RESPONSE:
  558. data = NULL;
  559. data_length = 0;
  560. break;
  561. case TCODE_READ_BLOCK_RESPONSE:
  562. case TCODE_LOCK_RESPONSE:
  563. data = &header[4];
  564. data_length = header_get_data_length(header[3]);
  565. break;
  566. default:
  567. /* Should never happen, this is just to shut up gcc. */
  568. data = NULL;
  569. data_length = 0;
  570. break;
  571. }
  572. t->callback(card, rcode, data, data_length, t->callback_data);
  573. }
  574. EXPORT_SYMBOL(fw_core_handle_response);
  575. MODULE_AUTHOR("Kristian Hoegsberg <krh@bitplanet.net>");
  576. MODULE_DESCRIPTION("Core IEEE1394 transaction logic");
  577. MODULE_LICENSE("GPL");
  578. static u32 vendor_textual_descriptor_data[] = {
  579. /* textual descriptor leaf () */
  580. 0x00080000,
  581. 0x00000000,
  582. 0x00000000,
  583. 0x4c696e75, /* L i n u */
  584. 0x78204669, /* x F i */
  585. 0x72657769, /* r e w i */
  586. 0x72652028, /* r e ( */
  587. 0x4a554a55, /* J U J U */
  588. 0x29000000, /* ) */
  589. };
  590. static struct fw_descriptor vendor_textual_descriptor = {
  591. .length = ARRAY_SIZE(vendor_textual_descriptor_data),
  592. .key = 0x81000000,
  593. .data = vendor_textual_descriptor_data
  594. };
  595. struct bus_type fw_bus_type = {
  596. .name = "fw",
  597. };
  598. static int __init fw_core_init(void)
  599. {
  600. int retval;
  601. retval = bus_register(&fw_bus_type);
  602. if (retval < 0)
  603. return retval;
  604. /* Add the vendor textual descriptor. */
  605. retval = fw_core_add_descriptor(&vendor_textual_descriptor);
  606. BUG_ON(retval < 0);
  607. return 0;
  608. }
  609. static void __exit fw_core_cleanup(void)
  610. {
  611. bus_unregister(&fw_bus_type);
  612. }
  613. module_init(fw_core_init);
  614. module_exit(fw_core_cleanup);