1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
|
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 1999-2002 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#ifndef _SYS_1394_H1394_H
#define _SYS_1394_H1394_H
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* h1394.h
* Contains the structure and error codes used to communicate
* between the HAL and the rest of the 1394 Software Framework
*/
#include <sys/types.h>
#include <sys/modctl.h>
#include <sys/ddi.h>
#include <sys/sunddi.h>
#include <sys/note.h>
#include <sys/1394/cmd1394.h>
#include <sys/1394/id1394.h>
#ifdef __cplusplus
extern "C" {
#endif
#define H1394_CLEANUP_LEVEL7 7
#define H1394_CLEANUP_LEVEL6 6
#define H1394_CLEANUP_LEVEL5 5
#define H1394_CLEANUP_LEVEL4 4
#define H1394_CLEANUP_LEVEL3 3
#define H1394_CLEANUP_LEVEL2 2
#define H1394_CLEANUP_LEVEL1 1
#define H1394_CLEANUP_LEVEL0 0
/* h1394_phy_t */
typedef enum {
H1394_PHY_1995 = 0,
H1394_PHY_1394A = 1
} h1394_phy_t;
/* h1394_error_t */
typedef enum {
H1394_LOCK_RESP_ERR = 1,
H1394_POSTED_WR_ERR = 2,
H1394_SELF_INITIATED_SHUTDOWN = 3,
H1394_CYCLE_TOO_LONG = 4
} h1394_error_t;
/*
* h1394_posted_wr_err_t
* The upper 16 bits contain the source id (bus/node) of the source node,
* the lower 48 bits contain the address that the error occured at.
*/
typedef struct h1394_posted_wr_err_s {
uint64_t addr;
} h1394_posted_wr_err_t;
/*
* h1394_node_pwr_flags_t
* Node power flags info
*/
typedef enum {
H1394_NODE_PWR_FLAGS_NONE = (1 << 1),
H1394_BUS_PWRD_NODES_ONE_MORE = (1 << 2),
H1394_BUS_PWRD_NODES_ONE_LESS = (1 << 3),
H1394_ACTIVE_NODES_ONE_MORE = (1 << 4),
H1394_ACTIVE_NODES_ONE_LESS = (1 << 5)
} h1394_node_pwr_flags_t;
/*
* h1394_addr_type_t
* h1394_addr_map.addr_type
*/
typedef enum {
H1394_ADDR_POSTED_WRITE = 0,
H1394_ADDR_NORMAL = 1,
H1394_ADDR_CSR = 2,
H1394_ADDR_PHYSICAL = 3,
H1394_ADDR_RESERVED = 4
} h1394_addr_type_t;
/* h1394_mblk_t */
typedef struct h1394_mblk_s {
mblk_t *curr_mblk;
unsigned char *curr_offset;
uint_t length;
mblk_t *next_mblk;
unsigned char *next_offset;
} h1394_mblk_t;
/* h1394_cmd_priv_t */
typedef struct h1394_cmd_priv_s {
uint_t speed;
uint_t ack_tstamp;
uint_t recv_tstamp;
uint_t bus_generation;
h1394_mblk_t mblk;
void *hal_overhead;
} h1394_cmd_priv_t;
_NOTE(SCHEME_PROTECTS_DATA("Used by a single thread", h1394_cmd_priv_s \
h1394_mblk_s::next_mblk h1394_mblk_s::next_offset))
/* h1394_evts_t */
typedef struct h1394_evts_s {
uint_t hal_version;
uint_t reserved;
void (*shutdown)(void *hal_private);
int (*send_phy_configuration_packet)(void *hal_private,
cmd1394_cmd_t *phy_pkt, h1394_cmd_priv_t *cmd_private,
int *result);
int (*read)(void *hal_private, cmd1394_cmd_t *req,
h1394_cmd_priv_t *cmd_private, int *result);
int (*read_response)(void *hal_private, cmd1394_cmd_t *resp,
h1394_cmd_priv_t *cmd_private, int *result);
int (*write)(void *hal_private, cmd1394_cmd_t *req,
h1394_cmd_priv_t *cmd_private, int *result);
int (*write_response)(void *hal_private, cmd1394_cmd_t *resp,
h1394_cmd_priv_t *cmd_private, int *result);
void (*response_complete)(void *hal_private, cmd1394_cmd_t *resp,
h1394_cmd_priv_t *cmd_private);
int (*lock)(void *hal_private, cmd1394_cmd_t *req,
h1394_cmd_priv_t *cmd_private, int *result);
int (*lock_response)(void *hal_private, cmd1394_cmd_t *resp,
h1394_cmd_priv_t *cmd_private, int *result);
int (*alloc_isoch_dma)(void *hal_private,
id1394_isoch_dmainfo_t *idi, void **hal_idma_handle,
int *result);
void (*free_isoch_dma)(void *hal_private,
void *hal_isoch_dma_handle);
int (*start_isoch_dma)(void *hal_private,
void *hal_isoch_dma_handle,
id1394_isoch_dma_ctrlinfo_t *idma_ctrlinfo, uint_t flags,
int *result);
void (*stop_isoch_dma)(void *hal_private, void *hal_isoch_dma_handle,
int *result);
int (*update_isoch_dma)(void *hal_private,
void *hal_isoch_dma_handle,
id1394_isoch_dma_updateinfo_t *idma_updateinfo,
uint_t flags, int *result);
int (*update_config_rom)(void *hal_private, void *local_buf,
uint_t quadlet_count);
int (*bus_reset)(void *hal_private);
int (*short_bus_reset)(void *hal_private);
int (*set_contender_bit)(void *hal_private);
int (*set_root_holdoff_bit)(void *hal_private);
int (*set_gap_count)(void *hal_private, uint_t gap_count);
int (*csr_read)(void *hal_private, uint_t offset, uint32_t *data);
int (*csr_write)(void *hal_private, uint_t offset, uint32_t data);
int (*csr_cswap32)(void *hal_private, uint_t generation,
uint_t offset, uint32_t compare, uint32_t swap,
uint32_t *old);
int (*physical_arreq_enable_set)(void *hal_private, uint64_t mask,
uint_t generation);
int (*physical_arreq_enable_clr)(void *hal_private, uint64_t mask,
uint_t generation);
void (*node_power_state_change)(void *hal_private,
h1394_node_pwr_flags_t nodeflags);
} h1394_evts_t;
/* Version value for h1394_evts_t */
#define H1394_EVTS_V1 1
#define HAL_CALL(hal) (hal)->halinfo.hal_events
/* Result field returned by read/write/lock requests */
#define H1394_STATUS_NO_ERROR 0
#define H1394_STATUS_INVALID_BUSGEN 1
#define H1394_STATUS_EMPTY_TLABEL 2
#define H1394_STATUS_NOMORE_SPACE 3
#define H1394_STATUS_INTERNAL_ERROR 4
/* h1394_addr_map_t */
typedef struct h1394_addr_map_s {
uint64_t address;
uint64_t length;
h1394_addr_type_t addr_type;
} h1394_addr_map_t;
/* h1394_halinfo_t */
typedef struct h1394_halinfo_s {
void *hal_private;
dev_info_t *dip;
h1394_evts_t hal_events;
ddi_iblock_cookie_t hw_interrupt;
/* Buffer attributes */
ddi_device_acc_attr_t acc_attr;
ddi_dma_attr_t dma_attr;
/* Type of PHY on HAL */
h1394_phy_t phy;
uint_t hal_overhead; /* in bytes */
uint32_t bus_capabilities;
uint64_t guid;
uint32_t node_capabilities;
/*
* The maximum value generation can have before
* it rolls over (inclusive)
*/
uint_t max_generation;
/* Description of the 1394 Address Space */
h1394_addr_map_t *addr_map;
uint_t addr_map_num_entries;
/* Description of the reserved spaces */
h1394_addr_map_t *resv_map;
uint_t resv_map_num_entries;
} h1394_halinfo_t;
/* Calls to Services layer during HAL driver _init() and _fini() */
int h1394_init(struct modlinkage *modlp);
void h1394_fini(struct modlinkage *modlp);
/* Calls to Services layer during HAL driver attach/detach */
int h1394_attach(h1394_halinfo_t *halinfo, ddi_attach_cmd_t cmd,
void **sl_private);
int h1394_detach(void **sl_private, ddi_detach_cmd_t cmd);
/* Calls to Services layer during HW interrupt processing */
void h1394_cmd_is_complete(void *sl_private, cmd1394_cmd_t *command_id,
uint32_t cmd_type, int status);
/* Command types (passed to h1394_command_is_complete) */
#define H1394_AT_REQ 0
#define H1394_AT_RESP 1
/* Command statuses (passed to h1394_command_is_complete) */
#define H1394_CMD_SUCCESS 0x00 /* ack_complete */
#define H1394_CMD_ETIMEOUT 0x01 /* evt_missing_ack */
#define H1394_CMD_EBUSRESET 0x02 /* evt_flushed */
#define H1394_CMD_EDEVICE_BUSY 0x03 /* ack_busy_? */
#define H1394_CMD_EDATA_ERROR 0x04 /* ack_data_error */
#define H1394_CMD_ETYPE_ERROR 0x05 /* ack_type_error */
#define H1394_CMD_EADDR_ERROR 0x06 /* resp_address_error */
#define H1394_CMD_ERSRC_CONFLICT 0x07 /* resp_conflict_error */
#define H1394_CMD_EDEVICE_POWERUP 0x08 /* ack_tardy */
#define H1394_CMD_EDEVICE_ERROR 0x09 /* device error */
#define H1394_CMD_EUNKNOWN_ERROR 0x0A /* unknown error type */
void h1394_bus_reset(void *sl_private, void **selfid_buf_addr);
void h1394_self_ids(void *sl_private, void *selfid_buf_addr,
uint32_t selfid_size, uint32_t node_id, uint32_t generation_count);
void h1394_write_request(void *sl_private, cmd1394_cmd_t *req);
void h1394_read_request(void *sl_private, cmd1394_cmd_t *req);
void h1394_lock_request(void *sl_private, cmd1394_cmd_t *req);
int h1394_alloc_cmd(void *sl_private, uint_t flags, cmd1394_cmd_t **cmdp,
h1394_cmd_priv_t **hal_priv_ptr);
/* Flags for h1394_alloc_cmd() */
#define H1394_ALLOC_CMD_SLEEP 0x00000000 /* can sleep allocating */
#define H1394_ALLOC_CMD_NOSLEEP 0x00000001 /* don't sleep allocating */
int h1394_free_cmd(void *sl_private, cmd1394_cmd_t **cmdp);
int h1394_ioctl(void *sl_private, int cmd, intptr_t arg, int mode,
cred_t *cred_p, int *rval_p);
void h1394_phy_packet(void *sl_private, uint32_t *packet_data,
uint_t quadlet_count, uint_t timestamp);
void h1394_error_detected(void *sl_private, h1394_error_t type, void *arg);
#ifdef __cplusplus
}
#endif
#endif /* _SYS_1394_H1394_H */
|