xref: /titanic_50/usr/src/uts/sun4u/starfire/sys/drmach.h (revision 3c112a2b34403220c06c3e2fcac403358cfba168)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef _SYS_DRMACH_H_
28 #define	_SYS_DRMACH_H_
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #include <sys/types.h>
33 #include <sys/memlist.h>
34 #include <sys/processor.h>
35 #include <sys/starfire.h>
36 #include <sys/sbd_ioctl.h>
37 #include <sys/sysevent.h>
38 
39 #ifdef	__cplusplus
40 extern "C" {
41 #endif
42 
43 #define	MAX_BOARDS		plat_max_boards()
44 #define	MAX_CPU_UNITS_PER_BOARD	plat_max_cpu_units_per_board()
45 #define	MAX_MEM_UNITS_PER_BOARD	plat_max_mem_units_per_board()
46 #define	MAX_IO_UNITS_PER_BOARD	plat_max_io_units_per_board()
47 #define	MAX_CMP_UNITS_PER_BOARD	MAX_CPU_UNITS_PER_BOARD
48 #define	MAX_CORES_PER_CMP	1
49 
50 /* flags for drmach_configure() and drmach_unconfigure() */
51 #define	DRMACH_DEVI_FORCE	1
52 #define	DRMACH_DEVI_REMOVE	2
53 
54 /* returned with drmach_board_find_devices callback */
55 #define	DRMACH_DEVTYPE_CPU	"cpu"
56 #define	DRMACH_DEVTYPE_MEM	"memory"
57 #define	DRMACH_DEVTYPE_PCI	"pci"
58 #define	DRMACH_DEVTYPE_SBUS	"sbus"
59 
60 /* number of bytes in smallest coherency unit of this machine */
61 #define	DRMACH_COHERENCY_UNIT	64
62 
63 typedef void *drmachid_t;
64 
65 typedef struct {
66 	boolean_t	assigned;
67 	boolean_t	powered;
68 	boolean_t	configured;
69 	boolean_t	busy;
70 	boolean_t	empty;
71 	sbd_cond_t	cond;
72 	char		type[MAXNAMELEN];
73 	char		info[MAXPATHLEN];	/* TODO: what size? */
74 } drmach_status_t;
75 
76 typedef struct {
77 	int	size;
78 	char	*copts;
79 } drmach_opts_t;
80 
81 extern sbd_error_t	*drmach_copy_rename_init(
82 				drmachid_t dst_id, uint64_t dst_slice_offset,
83 				drmachid_t src_id, struct memlist *src_copy_ml,
84 				drmachid_t *pgm_id);
85 extern sbd_error_t	*drmach_copy_rename_fini(drmachid_t id);
86 extern void		 drmach_copy_rename(drmachid_t id);
87 
88 extern sbd_error_t	*drmach_pre_op(int cmd, drmachid_t id,
89 						drmach_opts_t *opts);
90 extern sbd_error_t	*drmach_post_op(int cmd, drmachid_t id,
91 						drmach_opts_t *opts);
92 
93 extern sbd_error_t	*drmach_board_assign(int bnum, drmachid_t *id);
94 extern sbd_error_t	*drmach_board_connect(drmachid_t id,
95 						drmach_opts_t *opts);
96 extern sbd_error_t	*drmach_board_deprobe(drmachid_t id);
97 extern sbd_error_t	*drmach_board_disconnect(drmachid_t id,
98 						drmach_opts_t *opts);
99 extern sbd_error_t	*drmach_board_find_devices(drmachid_t id, void *a,
100 		sbd_error_t *(*found)(void *a, const char *, int, drmachid_t));
101 extern int		drmach_board_lookup(int bnum, drmachid_t *id);
102 extern sbd_error_t	*drmach_passthru(drmachid_t id,
103 						drmach_opts_t *opts);
104 
105 extern sbd_error_t	*drmach_board_name(int bnum, char *buf, int buflen);
106 
107 extern sbd_error_t	*drmach_board_poweroff(drmachid_t id);
108 extern sbd_error_t	*drmach_board_poweron(drmachid_t id);
109 extern sbd_error_t	*drmach_board_test(drmachid_t id, drmach_opts_t *opts,
110 				int force);
111 
112 extern sbd_error_t	*drmach_board_unassign(drmachid_t id);
113 
114 extern sbd_error_t	*drmach_configure(drmachid_t id, int flags);
115 
116 extern sbd_error_t	*drmach_cpu_disconnect(drmachid_t id);
117 extern sbd_error_t	*drmach_cpu_get_id(drmachid_t id, processorid_t *cpuid);
118 extern sbd_error_t	*drmach_cpu_get_impl(drmachid_t id, int *ip);
119 extern void		 drmach_cpu_flush_ecache_sync(void);
120 
121 extern sbd_error_t	*drmach_get_dip(drmachid_t id, dev_info_t **dip);
122 
123 extern sbd_error_t	*drmach_io_is_attached(drmachid_t id, int *yes);
124 extern sbd_error_t	*drmach_io_post_attach(drmachid_t id);
125 extern sbd_error_t	*drmach_io_post_release(drmachid_t id);
126 extern sbd_error_t	*drmach_io_pre_release(drmachid_t id);
127 extern sbd_error_t	*drmach_io_unrelease(drmachid_t id);
128 
129 extern sbd_error_t	*drmach_mem_add_span(drmachid_t id,
130 				uint64_t basepa, uint64_t size);
131 extern sbd_error_t	*drmach_mem_del_span(drmachid_t id,
132 				uint64_t basepa, uint64_t size);
133 extern sbd_error_t	*drmach_mem_disable(drmachid_t id);
134 extern sbd_error_t	*drmach_mem_enable(drmachid_t id);
135 extern sbd_error_t	*drmach_mem_get_alignment(drmachid_t id, uint64_t *pa);
136 extern sbd_error_t	*drmach_mem_get_base_physaddr(drmachid_t id,
137 				uint64_t *pa);
138 extern sbd_error_t	*drmach_mem_get_memlist(drmachid_t id,
139 				struct memlist **ml);
140 extern sbd_error_t	*drmach_mem_get_size(drmachid_t id, uint64_t *bytes);
141 extern sbd_error_t	*drmach_mem_get_slice_size(drmachid_t id,
142 				uint64_t *bytes);
143 extern processorid_t	 drmach_mem_cpu_affinity(drmachid_t id);
144 extern int		 drmach_allow_memrange_modify(drmachid_t id);
145 
146 extern sbd_error_t	*drmach_release(drmachid_t id);
147 extern sbd_error_t	*drmach_status(drmachid_t id, drmach_status_t *stat);
148 extern sbd_error_t	*drmach_unconfigure(drmachid_t id, int flags);
149 extern int		drmach_log_sysevent(int board, char *hint, int flag,
150 					    int verbose);
151 
152 extern int		drmach_verify_sr(dev_info_t *dip, int sflag);
153 extern void		drmach_suspend_last();
154 extern void		drmach_resume_first();
155 
156 #ifdef __cplusplus
157 }
158 #endif
159 
160 #endif /* _SYS_DRMACH_H_ */
161