1#ifndef _IEEE1394_CORE_H
2#define _IEEE1394_CORE_H
3
4#include <linux/device.h>
5#include <linux/fs.h>
6#include <linux/list.h>
7#include <linux/types.h>
8#include <linux/cdev.h>
9#include <asm/atomic.h>
10
11#include "hosts.h"
12#include "ieee1394_types.h"
13
14struct hpsb_packet {
15
16
17
18
19
20
21
22
23
24 struct list_head driver_list;
25
26 nodeid_t node_id;
27
28
29 enum { hpsb_async, hpsb_raw } __attribute__((packed)) type;
30
31
32
33
34
35
36 enum {
37 hpsb_unused, hpsb_queued, hpsb_pending, hpsb_complete
38 } __attribute__((packed)) state;
39
40
41 signed char tlabel;
42 signed char ack_code;
43 unsigned char tcode;
44
45 unsigned expect_response:1;
46 unsigned no_waiter:1;
47
48
49 unsigned speed_code:2;
50
51 struct hpsb_host *host;
52 unsigned int generation;
53
54 atomic_t refcnt;
55 struct list_head queue;
56
57
58
59 void (*complete_routine)(void *);
60 void *complete_data;
61
62
63 unsigned long sendtime;
64
65
66 size_t allocated_data_size;
67
68
69 size_t data_size;
70 size_t header_size;
71
72
73 quadlet_t *data;
74 quadlet_t header[5];
75 quadlet_t embedded_data[0];
76};
77
78void hpsb_set_packet_complete_task(struct hpsb_packet *packet,
79 void (*routine)(void *), void *data);
80static inline struct hpsb_packet *driver_packet(struct list_head *l)
81{
82 return list_entry(l, struct hpsb_packet, driver_list);
83}
84void abort_timedouts(unsigned long __opaque);
85struct hpsb_packet *hpsb_alloc_packet(size_t data_size);
86void hpsb_free_packet(struct hpsb_packet *packet);
87
88
89
90
91
92
93
94static inline unsigned int get_hpsb_generation(struct hpsb_host *host)
95{
96 return atomic_read(&host->generation);
97}
98
99int hpsb_send_phy_config(struct hpsb_host *host, int rootid, int gapcnt);
100int hpsb_send_packet(struct hpsb_packet *packet);
101int hpsb_send_packet_and_wait(struct hpsb_packet *packet);
102int hpsb_reset_bus(struct hpsb_host *host, int type);
103int hpsb_read_cycle_timer(struct hpsb_host *host, u32 *cycle_timer,
104 u64 *local_time);
105
106int hpsb_bus_reset(struct hpsb_host *host);
107void hpsb_selfid_received(struct hpsb_host *host, quadlet_t sid);
108void hpsb_selfid_complete(struct hpsb_host *host, int phyid, int isroot);
109void hpsb_packet_sent(struct hpsb_host *host, struct hpsb_packet *packet,
110 int ackcode);
111void hpsb_packet_received(struct hpsb_host *host, quadlet_t *data, size_t size,
112 int write_acked);
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137#define IEEE1394_MAJOR 171
138
139#define IEEE1394_MINOR_BLOCK_RAW1394 0
140#define IEEE1394_MINOR_BLOCK_VIDEO1394 1
141#define IEEE1394_MINOR_BLOCK_DV1394 2
142#define IEEE1394_MINOR_BLOCK_EXPERIMENTAL 15
143
144#define IEEE1394_CORE_DEV MKDEV(IEEE1394_MAJOR, 0)
145#define IEEE1394_RAW1394_DEV MKDEV(IEEE1394_MAJOR, \
146 IEEE1394_MINOR_BLOCK_RAW1394 * 16)
147#define IEEE1394_VIDEO1394_DEV MKDEV(IEEE1394_MAJOR, \
148 IEEE1394_MINOR_BLOCK_VIDEO1394 * 16)
149#define IEEE1394_DV1394_DEV MKDEV(IEEE1394_MAJOR, \
150 IEEE1394_MINOR_BLOCK_DV1394 * 16)
151#define IEEE1394_EXPERIMENTAL_DEV MKDEV(IEEE1394_MAJOR, \
152 IEEE1394_MINOR_BLOCK_EXPERIMENTAL * 16)
153
154
155
156
157static inline unsigned char ieee1394_file_to_instance(struct file *file)
158{
159 int idx = cdev_index(file->f_path.dentry->d_inode);
160 if (idx < 0)
161 idx = 0;
162 return idx;
163}
164
165extern int hpsb_disable_irm;
166
167
168extern struct bus_type ieee1394_bus_type;
169extern struct class hpsb_host_class;
170extern struct class *hpsb_protocol_class;
171
172#endif
173