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