more debug output
[linux-2.4.git] / drivers / ieee1394 / highlevel.h
1
2 #ifndef IEEE1394_HIGHLEVEL_H
3 #define IEEE1394_HIGHLEVEL_H
4
5
6 struct hpsb_address_serve {
7         struct list_head as_list; /* global list */
8         
9         struct list_head addr_list; /* hpsb_highlevel list */
10
11         struct hpsb_address_ops *op;
12
13         /* first address handled and first address behind, quadlet aligned */
14         u64 start, end;
15 };
16
17
18 /*
19  * The above structs are internal to highlevel driver handling.  Only the
20  * following structures are of interest to actual highlevel drivers.  
21  */
22
23 struct hpsb_highlevel {
24         const char *name;
25
26         /* Any of the following pointers can legally be NULL, except for
27          * iso_receive which can only be NULL when you don't request
28          * channels. */
29
30         /* New host initialized.  Will also be called during
31          * hpsb_register_highlevel for all hosts already installed. */
32         void (*add_host) (struct hpsb_host *host);
33
34         /* Host about to be removed.  Will also be called during
35          * hpsb_unregister_highlevel once for each host. */
36         void (*remove_host) (struct hpsb_host *host);
37
38         /* Host experienced bus reset with possible configuration changes.  Note
39          * that this one may occur during interrupt/bottom half handling.  You
40          * can not expect to be able to do stock hpsb_reads. */
41         void (*host_reset) (struct hpsb_host *host);
42
43         /* An isochronous packet was received.  Channel contains the channel
44          * number for your convenience, it is also contained in the included
45          * packet header (first quadlet, CRCs are missing).  You may get called
46          * for channel/host combinations you did not request. */
47         void (*iso_receive) (struct hpsb_host *host, int channel,
48                              quadlet_t *data, size_t length);
49
50         /* A write request was received on either the FCP_COMMAND (direction =
51          * 0) or the FCP_RESPONSE (direction = 1) register.  The cts arg
52          * contains the cts field (first byte of data).
53          */
54         void (*fcp_request) (struct hpsb_host *host, int nodeid, int direction,
55                              int cts, u8 *data, size_t length);
56
57
58         struct list_head hl_list;
59         struct list_head addr_list;
60
61         struct list_head host_info_list;
62         rwlock_t host_info_lock;
63 };
64
65 struct hpsb_address_ops {
66         /*
67          * Null function pointers will make the respective operation complete 
68          * with RCODE_TYPE_ERROR.  Makes for easy to implement read-only 
69          * registers (just leave everything but read NULL).
70          *
71          * All functions shall return appropriate IEEE 1394 rcodes.
72          */
73
74         /* These functions have to implement block reads for themselves. */
75         /* These functions either return a response code
76            or a negative number. In the first case a response will be generated; in the 
77            later case, no response will be sent and the driver, that handled the request
78            will send the response itself
79         */
80         int (*read) (struct hpsb_host *host, int nodeid, quadlet_t *buffer,
81                      u64 addr, size_t length, u16 flags);
82         int (*write) (struct hpsb_host *host, int nodeid, int destid,
83                       quadlet_t *data, u64 addr, size_t length, u16 flags);
84
85         /* Lock transactions: write results of ext_tcode operation into
86          * *store. */
87         int (*lock) (struct hpsb_host *host, int nodeid, quadlet_t *store,
88                      u64 addr, quadlet_t data, quadlet_t arg, int ext_tcode, u16 flags);
89         int (*lock64) (struct hpsb_host *host, int nodeid, octlet_t *store,
90                        u64 addr, octlet_t data, octlet_t arg, int ext_tcode, u16 flags);
91 };
92
93
94 void init_hpsb_highlevel(void);
95
96 void highlevel_add_host(struct hpsb_host *host);
97 void highlevel_remove_host(struct hpsb_host *host);
98 void highlevel_host_reset(struct hpsb_host *host);
99
100
101 /* these functions are called to handle transactions. They are called, when
102    a packet arrives. The flags argument contains the second word of the first header
103    quadlet of the incoming packet (containing transaction label, retry code,
104    transaction code and priority). These functions either return a response code
105    or a negative number. In the first case a response will be generated; in the 
106    later case, no response will be sent and the driver, that handled the request
107    will send the response itself.
108 */
109 int highlevel_read(struct hpsb_host *host, int nodeid, void *data,
110                    u64 addr, unsigned int length, u16 flags);
111 int highlevel_write(struct hpsb_host *host, int nodeid, int destid,
112                     void *data, u64 addr, unsigned int length, u16 flags);
113 int highlevel_lock(struct hpsb_host *host, int nodeid, quadlet_t *store,
114                    u64 addr, quadlet_t data, quadlet_t arg, int ext_tcode, u16 flags);
115 int highlevel_lock64(struct hpsb_host *host, int nodeid, octlet_t *store,
116                      u64 addr, octlet_t data, octlet_t arg, int ext_tcode, u16 flags);
117
118 void highlevel_iso_receive(struct hpsb_host *host, void *data,
119                            size_t length);
120 void highlevel_fcp_request(struct hpsb_host *host, int nodeid, int direction,
121                            void *data, size_t length);
122
123
124 /*
125  * Register highlevel driver.  The name pointer has to stay valid at all times
126  * because the string is not copied.
127  */
128 void hpsb_register_highlevel(struct hpsb_highlevel *hl);
129 void hpsb_unregister_highlevel(struct hpsb_highlevel *hl);
130
131 /*
132  * Register handlers for host address spaces.  Start and end are 48 bit pointers
133  * and have to be quadlet aligned (end points to the first address behind the
134  * handled addresses.  This function can be called multiple times for a single
135  * hpsb_highlevel to implement sparse register sets.  The requested region must
136  * not overlap any previously allocated region, otherwise registering will fail.
137  *
138  * It returns true for successful allocation.  There is no unregister function,
139  * all address spaces are deallocated together with the hpsb_highlevel.
140  */
141 int hpsb_register_addrspace(struct hpsb_highlevel *hl,
142                             struct hpsb_address_ops *ops, u64 start, u64 end);
143
144 int hpsb_unregister_addrspace(struct hpsb_highlevel *hl, u64 start);
145
146 /*
147  * Enable or disable receving a certain isochronous channel through the
148  * iso_receive op.
149  */
150 int hpsb_listen_channel(struct hpsb_highlevel *hl, struct hpsb_host *host, 
151                          unsigned int channel);
152 void hpsb_unlisten_channel(struct hpsb_highlevel *hl, struct hpsb_host *host,
153                            unsigned int channel);
154
155
156 /* Retrieve a hostinfo pointer bound to this driver/host */
157 void *hpsb_get_hostinfo(struct hpsb_highlevel *hl, struct hpsb_host *host);
158
159 /* Allocate a hostinfo pointer of data_size bound to this driver/host */
160 void *hpsb_create_hostinfo(struct hpsb_highlevel *hl, struct hpsb_host *host,
161                            size_t data_size);
162
163 /* Free and remove the hostinfo pointer bound to this driver/host */
164 void hpsb_destroy_hostinfo(struct hpsb_highlevel *hl, struct hpsb_host *host);
165
166 /* Set an alternate lookup key for the hostinfo bound to this driver/host */
167 void hpsb_set_hostinfo_key(struct hpsb_highlevel *hl, struct hpsb_host *host, unsigned long key);
168
169 /* Retrieve the alternate lookup key for the hostinfo bound to this driver/host */
170 unsigned long hpsb_get_hostinfo_key(struct hpsb_highlevel *hl, struct hpsb_host *host);
171
172 /* Retrieve a hostinfo pointer bound to this driver using its alternate key */
173 void *hpsb_get_hostinfo_bykey(struct hpsb_highlevel *hl, unsigned long key);
174
175 /* Set the hostinfo pointer to something useful. Usually follows a call to
176  * hpsb_create_hostinfo, where the size is 0. */
177 int hpsb_set_hostinfo(struct hpsb_highlevel *hl, struct hpsb_host *host, void *data);
178
179 /* Retrieve hpsb_host using a highlevel handle and a key */
180 struct hpsb_host *hpsb_get_host_bykey(struct hpsb_highlevel *hl, unsigned long key);
181
182 #endif /* IEEE1394_HIGHLEVEL_H */