fw-transaction.c 20 KB

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