xref: /onnv-gate/usr/src/uts/sun4u/lw8/sys/sgfru_priv.h (revision 1708:ea74d8598a3a)
1*1708Sstevel /*
2*1708Sstevel  * CDDL HEADER START
3*1708Sstevel  *
4*1708Sstevel  * The contents of this file are subject to the terms of the
5*1708Sstevel  * Common Development and Distribution License (the "License").
6*1708Sstevel  * You may not use this file except in compliance with the License.
7*1708Sstevel  *
8*1708Sstevel  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9*1708Sstevel  * or http://www.opensolaris.org/os/licensing.
10*1708Sstevel  * See the License for the specific language governing permissions
11*1708Sstevel  * and limitations under the License.
12*1708Sstevel  *
13*1708Sstevel  * When distributing Covered Code, include this CDDL HEADER in each
14*1708Sstevel  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15*1708Sstevel  * If applicable, add the following below this CDDL HEADER, with the
16*1708Sstevel  * fields enclosed by brackets "[]" replaced with your own identifying
17*1708Sstevel  * information: Portions Copyright [yyyy] [name of copyright owner]
18*1708Sstevel  *
19*1708Sstevel  * CDDL HEADER END
20*1708Sstevel  */
21*1708Sstevel 
22*1708Sstevel /*
23*1708Sstevel  * Copyright 2000 Sun Microsystems, Inc.  All rights reserved.
24*1708Sstevel  * Use is subject to license terms.
25*1708Sstevel  */
26*1708Sstevel 
27*1708Sstevel #ifndef _SGFRU_PRIV_H
28*1708Sstevel #define	_SGFRU_PRIV_H
29*1708Sstevel 
30*1708Sstevel #pragma ident	"%Z%%M%	%I%	%E% SMI"
31*1708Sstevel 
32*1708Sstevel #ifdef	__cplusplus
33*1708Sstevel extern "C" {
34*1708Sstevel #endif
35*1708Sstevel 
36*1708Sstevel #include <sys/sgfru.h>
37*1708Sstevel #include <sys/conf.h>
38*1708Sstevel #include <sys/ddi_impldefs.h>
39*1708Sstevel 
40*1708Sstevel #define	SGFRU_DRV_NAME		"sgfru"
41*1708Sstevel 
42*1708Sstevel #ifdef DEBUG
43*1708Sstevel extern uint_t sgfru_debug;
44*1708Sstevel 
45*1708Sstevel #define	SGFRU_DBG_STATE		0x00000001
46*1708Sstevel #define	SGFRU_DBG_HANDLE	0x00000002
47*1708Sstevel #define	SGFRU_DBG_NODE		0x00000004
48*1708Sstevel #define	SGFRU_DBG_SECTION	0x00000008
49*1708Sstevel #define	SGFRU_DBG_SEGMENT	0x00000010
50*1708Sstevel #define	SGFRU_DBG_PACKET	0x00000020
51*1708Sstevel #define	SGFRU_DBG_PAYLOAD	0x00000040
52*1708Sstevel #define	SGFRU_DBG_MBOX		0x00000080
53*1708Sstevel #define	SGFRU_DBG_ALL		0x000000FF
54*1708Sstevel 
55*1708Sstevel #define	PR_ALL		if (sgfru_debug)			printf
56*1708Sstevel #define	PR_STATE	if (sgfru_debug & SGFRU_DBG_STATE)	printf
57*1708Sstevel #define	PR_HANDLE	if (sgfru_debug & SGFRU_DBG_HANDLE)	printf
58*1708Sstevel #define	PR_NODE		if (sgfru_debug & SGFRU_DBG_NODE)	printf
59*1708Sstevel #define	PR_SECTION	if (sgfru_debug & SGFRU_DBG_SECTION)	printf
60*1708Sstevel #define	PR_SEGMENT	if (sgfru_debug & SGFRU_DBG_SEGMENT)	printf
61*1708Sstevel #define	PR_PACKET	if (sgfru_debug & SGFRU_DBG_PACKET)	printf
62*1708Sstevel #define	PR_PAYLOAD	if (sgfru_debug & SGFRU_DBG_PAYLOAD)	printf
63*1708Sstevel #define	PR_MBOX		if (sgfru_debug & SGFRU_DBG_MBOX)	printf
64*1708Sstevel #else /* DEBUG */
65*1708Sstevel #define	PR_ALL		if (0) printf
66*1708Sstevel #define	PR_STATE	PR_ALL
67*1708Sstevel #define	PR_HANDLE	PR_ALL
68*1708Sstevel #define	PR_NODE		PR_ALL
69*1708Sstevel #define	PR_SECTION	PR_ALL
70*1708Sstevel #define	PR_SEGMENT	PR_ALL
71*1708Sstevel #define	PR_PACKET	PR_ALL
72*1708Sstevel #define	PR_PAYLOAD	PR_ALL
73*1708Sstevel #define	PR_MBOX		PR_ALL
74*1708Sstevel #endif /* DEBUG */
75*1708Sstevel 
76*1708Sstevel #define	MAX_HANDLES		100
77*1708Sstevel #define	MAX_SECTIONS		8
78*1708Sstevel #define	MAX_SEGMENTS		200
79*1708Sstevel #define	MAX_PACKETS		200
80*1708Sstevel #define	MAX_PAYLOADSIZE		0x1000	/* No support for Tag Type G 2**48 */
81*1708Sstevel #define	MAX_SEGMENTSIZE		0x10000	/* New SEEPROM size likely to be 64k */
82*1708Sstevel 
83*1708Sstevel typedef struct sgfru_soft_state {
84*1708Sstevel 	dev_info_t *fru_dip;		/* devinfo structure */
85*1708Sstevel 	dev_info_t *fru_pdip;		/* parent's devinfo structure */
86*1708Sstevel 	int instance;
87*1708Sstevel } sgfru_soft_state_t;
88*1708Sstevel 
89*1708Sstevel typedef struct {
90*1708Sstevel 	dev_t dev;
91*1708Sstevel 	int cmd;
92*1708Sstevel 	int mode;
93*1708Sstevel 	intptr_t argp;
94*1708Sstevel } sgfru_init_arg_t;
95*1708Sstevel 
96*1708Sstevel /*
97*1708Sstevel  * Prototypes
98*1708Sstevel  */
99*1708Sstevel static int sgfru_attach(dev_info_t *dip, ddi_attach_cmd_t cmd);
100*1708Sstevel static int sgfru_detach(dev_info_t *dip, ddi_detach_cmd_t cmd);
101*1708Sstevel static int sgfru_open(dev_t *dev_p, int flag, int otyp, cred_t *cred_p);
102*1708Sstevel static int sgfru_close(dev_t dev, int flag, int otyp, cred_t *cred_p);
103*1708Sstevel static int sgfru_ioctl(dev_t dev, int cmd, intptr_t arg, int mode,
104*1708Sstevel     cred_t *cred_p, int *rval_p);
105*1708Sstevel 
106*1708Sstevel /*
107*1708Sstevel  * functions local to this driver.
108*1708Sstevel  */
109*1708Sstevel static int sgfru_getchildlist(const sgfru_init_arg_t *iargp);
110*1708Sstevel static int sgfru_getchildhandles(const sgfru_init_arg_t *iargp);
111*1708Sstevel static int sgfru_getnodeinfo(const sgfru_init_arg_t *iargp);
112*1708Sstevel static int sgfru_getsections(const sgfru_init_arg_t *iargp);
113*1708Sstevel static int sgfru_getsegments(const sgfru_init_arg_t *iargp);
114*1708Sstevel static int sgfru_addsegment(const sgfru_init_arg_t *iargp);
115*1708Sstevel static int sgfru_readsegment(const sgfru_init_arg_t *iargp);
116*1708Sstevel static int sgfru_writesegment(const sgfru_init_arg_t *iargp);
117*1708Sstevel static int sgfru_getpackets(const sgfru_init_arg_t *iargp);
118*1708Sstevel static int sgfru_appendpacket(const sgfru_init_arg_t *iargp);
119*1708Sstevel static int sgfru_getpayload(const sgfru_init_arg_t *iargp);
120*1708Sstevel static int sgfru_updatepayload(const sgfru_init_arg_t *iargp);
121*1708Sstevel static int sgfru_getnum(const sgfru_init_arg_t *iargp);
122*1708Sstevel static int sgfru_delete(const sgfru_init_arg_t *iargp);
123*1708Sstevel 
124*1708Sstevel static int sgfru_copyin_frup(const sgfru_init_arg_t *argp, frup_info_t *frup);
125*1708Sstevel static int sgfru_copyin_fru(const sgfru_init_arg_t *argp, fru_info_t *fru);
126*1708Sstevel static int sgfru_copyin_segment(const sgfru_init_arg_t *argp,
127*1708Sstevel     const frup_info_t *frup, segment_t *segp);
128*1708Sstevel static int sgfru_copyin_append(const sgfru_init_arg_t *argp,
129*1708Sstevel     append_info_t *app);
130*1708Sstevel static int sgfru_copyin_buffer(const sgfru_init_arg_t *argp,
131*1708Sstevel     const caddr_t data, const int cnt, char *buffer);
132*1708Sstevel 
133*1708Sstevel static int sgfru_copyout_fru(const sgfru_init_arg_t *argp,
134*1708Sstevel     const fru_info_t *fru);
135*1708Sstevel static int sgfru_copyout_handle(const sgfru_init_arg_t *argp,
136*1708Sstevel     const void *addr, const fru_hdl_t *hdlp);
137*1708Sstevel static int sgfru_copyout_handles(const sgfru_init_arg_t *argp,
138*1708Sstevel     const frup_info_t *frup, const fru_hdl_t *hdlp);
139*1708Sstevel static int sgfru_copyout_nodes(const sgfru_init_arg_t *argp,
140*1708Sstevel     const frup_info_t *frup, const node_t *nodep);
141*1708Sstevel static int sgfru_copyout_sections(const sgfru_init_arg_t *argp,
142*1708Sstevel     const frup_info_t *frup, const section_t *sectp);
143*1708Sstevel static int sgfru_copyout_segments(const sgfru_init_arg_t *argp,
144*1708Sstevel     const frup_info_t *frup, const segment_t *segp);
145*1708Sstevel static int sgfru_copyout_packets(const sgfru_init_arg_t *argp,
146*1708Sstevel     const frup_info_t *frup, const packet_t *packp);
147*1708Sstevel static int sgfru_copyout_buffer(const sgfru_init_arg_t *argp,
148*1708Sstevel     const frup_info_t *frup, const char *buffer);
149*1708Sstevel 
150*1708Sstevel #ifdef	__cplusplus
151*1708Sstevel }
152*1708Sstevel #endif
153*1708Sstevel 
154*1708Sstevel #endif	/* _SGFRU_PRIV_H */
155