aboutsummaryrefslogtreecommitdiffstats
path: root/include/asm-ia64/sn/cdl.h
blob: 35c7f8ec37b231cc758c33048766f0df78315120 (plain)
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
/* $Id$
 *
 * This file is subject to the terms and conditions of the GNU General Public
 * License.  See the file "COPYING" in the main directory of this archive
 * for more details.
 *
 * Copyright (C) 1992 - 1997, 2000-2001 Silicon Graphics, Inc. All rights reserved.
 */
#ifndef _ASM_IA64_SN_CDL_H
#define _ASM_IA64_SN_CDL_H

#include <asm/sn/sgi.h>

/*
 *	cdl: connection/driver list
 *
 *	support code for bus infrastructure for busses
 *	that have self-identifying devices; initially
 *	constructed for xtalk, pciio and gioio modules.
 */
typedef struct cdl     *cdl_p;

/*
 *	cdl_itr_f is the type for the functions
 *	that are handled by cdl_iterate.
 */

typedef void	
cdl_iter_f		(devfs_handle_t vhdl);

/*
 *	cdl_drv_f is the type for the functions
 *	that are called by cdl_add_driver and 
 *      cdl_del_driver.
 */

typedef void	
cdl_drv_f		(devfs_handle_t vhdl, int key1, int key2, int error);

/*
 *	If CDL_PRI_HI is specified in the flags
 *	parameter for cdl_add_driver, then that driver's
 *	attach routine will be called for future connect
 *	points before any (non-CDL_PRI_HI) drivers.
 *
 *	The IOC3 driver uses this facility to make sure
 *	that the ioc3_attach() function is called before
 *	the attach routines of any subdevices.
 *
 *	Drivers for bridge-based crosstalk cards that
 *	are almost but not quite generic can use it to
 *	arrange that their attach() functions get called
 *	before the generic bridge drivers, so they can
 *	leave behind "hint" structures that will
 *	properly configure the generic driver.
 */
#define	CDL_PRI_HI	0x0001

/*
 *	cdl_new: construct a new connection/driver list
 *
 *	Called once for each "kind" of bus. Returns an
 *	opaque cookie representing the particular list
 *	that will be operated on by the other calls.
 */
extern cdl_p		cdl_new(char *, char *, char *);

/*
 *	cdl_del: destroy a connection/driver list.
 *
 *	Releases all dynamically allocated resources
 *	associated with the specified list. Forgets what
 *	drivers might be involved in this kind of bus,
 *	forgets what connection points have been noticed
 *	on this kind of bus.
 */
extern void		cdl_del(cdl_p reg);

/*
 *	cdl_add_driver: register a device driver
 *
 *	Calls the driver's attach routine with all
 *	connection points on the list that have the same
 *	key information as the driver; call-back the 
 *      specified function to notify the driver of the 
 *      attach status for each device.  Place the driver
 *      on the list so that any connection points
 *	discovered in the future that match the driver
 *	can be handed off to the driver's attach
 *	routine.
 *
 *	CDL_PRI_HI may be specified (see above).
 */

extern int		cdl_add_driver(cdl_p reg,
				       int key1,
				       int key2,
				       char *prefix,
				       int flags,
				       cdl_drv_f *func);

/*
 *	cdl_del_driver: remove a device driver
 *
 *	Calls the driver's detach routine with all
 *	connection points on the list that match the
 *	driver;  call-back the specified function to
 *      notify the driver of the detach status for each
 *      device.  Then forget about the driver.  Future
 *	calls to cdl_add_connpt with connections that
 *	would match this driver no longer trigger calls
 *	to the driver's attach routine.
 *
 *	NOTE: Yes, I said CONNECTION POINTS, not
 *	verticies that the driver has been attached to
 *	with hwgraph_driver_add(); this gives the driver
 *	a chance to clean up anything it did to the
 *	connection point in its attach routine. Also,
 *	this is done whether or not the attach routine
 *	was successful.
 */
extern void		cdl_del_driver(cdl_p reg, 
				       char *prefix,
				       cdl_drv_f *func);

/*
 *	cdl_add_connpt: add a connection point
 *
 *	Calls the attach routines of all the drivers on
 *	the list that match this connection point, in
 *	the order that they were added to the list,
 *	except that CDL_PRI_HI drivers are called first.
 *
 *	Then the vertex is added to the list, so it can
 *	be presented to any matching drivers that may be
 *	subsequently added to the list.
 */
extern int		cdl_add_connpt(cdl_p reg,
				       int key1,
				       int key2,
				       devfs_handle_t conn,
				       int drv_flags);

/*
 *	cdl_del_connpt: delete a connection point
 *
 *	Calls the detach routines of all matching
 *	drivers for this connection point, in the same
 *	order that the attach routines were called; then
 *	forgets about this vertex, so drivers added in
 *	the future will not be told about it.
 *
 *	NOTE: Same caveat here about the detach calls as
 *	in the cdl_del_driver() comment above.
 */
extern int		cdl_del_connpt(cdl_p reg,
				       int key1,
				       int key2,
				       devfs_handle_t conn,
				       int drv_flags);

/*
 *	cdl_iterate: find all verticies in the registry
 *	corresponding to the named driver and call them
 *	with the specified function (giving the vertex
 *	as the parameter).
 */

extern void		cdl_iterate(cdl_p reg,
				    char *prefix,
				    cdl_iter_f *func);

/*
 * An INFO_LBL_ASYNC_ATTACH label is attached to a vertex, pointing to
 * an instance of async_attach_s to indicate that asynchronous
 * attachment may be applied to that device ... if the corresponding
 * driver allows it.
 */

struct async_attach_s {
	struct semaphore async_sema;
	int    async_count;
};
typedef struct async_attach_s *async_attach_t;

async_attach_t	async_attach_new(void);
void		async_attach_free(async_attach_t);
async_attach_t  async_attach_get_info(devfs_handle_t);
void            async_attach_add_info(devfs_handle_t, async_attach_t);
void            async_attach_del_info(devfs_handle_t);
void		async_attach_signal_start(async_attach_t);
void		async_attach_signal_done(async_attach_t);
void		async_attach_waitall(async_attach_t);

#endif /* _ASM_IA64_SN_CDL_H */