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