highlevel.h 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. #ifndef IEEE1394_HIGHLEVEL_H
  2. #define IEEE1394_HIGHLEVEL_H
  3. #include <linux/list.h>
  4. #include <linux/spinlock.h>
  5. #include <linux/types.h>
  6. struct module;
  7. #include "ieee1394_types.h"
  8. struct hpsb_host;
  9. /* internal to ieee1394 core */
  10. struct hpsb_address_serve {
  11. struct list_head host_list; /* per host list */
  12. struct list_head hl_list; /* hpsb_highlevel list */
  13. const struct hpsb_address_ops *op;
  14. struct hpsb_host *host;
  15. u64 start; /* first address handled, quadlet aligned */
  16. u64 end; /* first address behind, quadlet aligned */
  17. };
  18. /* Only the following structures are of interest to actual highlevel drivers. */
  19. struct hpsb_highlevel {
  20. const char *name;
  21. /* Any of the following pointers can legally be NULL. */
  22. /* New host initialized. Will also be called during
  23. * hpsb_register_highlevel for all hosts already installed. */
  24. void (*add_host)(struct hpsb_host *host);
  25. /* Host about to be removed. Will also be called during
  26. * hpsb_unregister_highlevel once for each host. */
  27. void (*remove_host)(struct hpsb_host *host);
  28. /* Host experienced bus reset with possible configuration changes.
  29. * Note that this one may occur during interrupt/bottom half handling.
  30. * You can not expect to be able to do stock hpsb_reads. */
  31. void (*host_reset)(struct hpsb_host *host);
  32. /* A write request was received on either the FCP_COMMAND (direction =
  33. * 0) or the FCP_RESPONSE (direction = 1) register. The cts arg
  34. * contains the cts field (first byte of data). */
  35. void (*fcp_request)(struct hpsb_host *host, int nodeid, int direction,
  36. int cts, u8 *data, size_t length);
  37. /* These are initialized by the subsystem when the
  38. * hpsb_higlevel is registered. */
  39. struct list_head hl_list;
  40. struct list_head irq_list;
  41. struct list_head addr_list;
  42. struct list_head host_info_list;
  43. rwlock_t host_info_lock;
  44. };
  45. struct hpsb_address_ops {
  46. /*
  47. * Null function pointers will make the respective operation complete
  48. * with RCODE_TYPE_ERROR. Makes for easy to implement read-only
  49. * registers (just leave everything but read NULL).
  50. *
  51. * All functions shall return appropriate IEEE 1394 rcodes.
  52. */
  53. /* These functions have to implement block reads for themselves.
  54. *
  55. * These functions either return a response code or a negative number.
  56. * In the first case a response will be generated. In the latter case,
  57. * no response will be sent and the driver which handled the request
  58. * will send the response itself. */
  59. int (*read)(struct hpsb_host *host, int nodeid, quadlet_t *buffer,
  60. u64 addr, size_t length, u16 flags);
  61. int (*write)(struct hpsb_host *host, int nodeid, int destid,
  62. quadlet_t *data, u64 addr, size_t length, u16 flags);
  63. /* Lock transactions: write results of ext_tcode operation into
  64. * *store. */
  65. int (*lock)(struct hpsb_host *host, int nodeid, quadlet_t *store,
  66. u64 addr, quadlet_t data, quadlet_t arg, int ext_tcode,
  67. u16 flags);
  68. int (*lock64)(struct hpsb_host *host, int nodeid, octlet_t *store,
  69. u64 addr, octlet_t data, octlet_t arg, int ext_tcode,
  70. u16 flags);
  71. };
  72. void highlevel_add_host(struct hpsb_host *host);
  73. void highlevel_remove_host(struct hpsb_host *host);
  74. void highlevel_host_reset(struct hpsb_host *host);
  75. int highlevel_read(struct hpsb_host *host, int nodeid, void *data, u64 addr,
  76. unsigned int length, u16 flags);
  77. int highlevel_write(struct hpsb_host *host, int nodeid, int destid, void *data,
  78. u64 addr, unsigned int length, u16 flags);
  79. int highlevel_lock(struct hpsb_host *host, int nodeid, quadlet_t *store,
  80. u64 addr, quadlet_t data, quadlet_t arg, int ext_tcode,
  81. u16 flags);
  82. int highlevel_lock64(struct hpsb_host *host, int nodeid, octlet_t *store,
  83. u64 addr, octlet_t data, octlet_t arg, int ext_tcode,
  84. u16 flags);
  85. void highlevel_fcp_request(struct hpsb_host *host, int nodeid, int direction,
  86. void *data, size_t length);
  87. /**
  88. * hpsb_init_highlevel - initialize a struct hpsb_highlevel
  89. *
  90. * This is only necessary if hpsb_get_hostinfo_bykey can be called
  91. * before hpsb_register_highlevel.
  92. */
  93. static inline void hpsb_init_highlevel(struct hpsb_highlevel *hl)
  94. {
  95. rwlock_init(&hl->host_info_lock);
  96. INIT_LIST_HEAD(&hl->host_info_list);
  97. }
  98. void hpsb_register_highlevel(struct hpsb_highlevel *hl);
  99. void hpsb_unregister_highlevel(struct hpsb_highlevel *hl);
  100. u64 hpsb_allocate_and_register_addrspace(struct hpsb_highlevel *hl,
  101. struct hpsb_host *host,
  102. const struct hpsb_address_ops *ops,
  103. u64 size, u64 alignment,
  104. u64 start, u64 end);
  105. int hpsb_register_addrspace(struct hpsb_highlevel *hl, struct hpsb_host *host,
  106. const struct hpsb_address_ops *ops,
  107. u64 start, u64 end);
  108. int hpsb_unregister_addrspace(struct hpsb_highlevel *hl, struct hpsb_host *host,
  109. u64 start);
  110. void *hpsb_get_hostinfo(struct hpsb_highlevel *hl, struct hpsb_host *host);
  111. void *hpsb_create_hostinfo(struct hpsb_highlevel *hl, struct hpsb_host *host,
  112. size_t data_size);
  113. void hpsb_destroy_hostinfo(struct hpsb_highlevel *hl, struct hpsb_host *host);
  114. void hpsb_set_hostinfo_key(struct hpsb_highlevel *hl, struct hpsb_host *host,
  115. unsigned long key);
  116. void *hpsb_get_hostinfo_bykey(struct hpsb_highlevel *hl, unsigned long key);
  117. int hpsb_set_hostinfo(struct hpsb_highlevel *hl, struct hpsb_host *host,
  118. void *data);
  119. #endif /* IEEE1394_HIGHLEVEL_H */