xref: /titanic_50/usr/src/uts/sun4u/sys/cpu_module.h (revision 64cfc8ed0c5da83f827c424588bfe709e3fb5a7a)
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 (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #ifndef _SYS_CPU_MODULE_H
27 #define	_SYS_CPU_MODULE_H
28 
29 #pragma ident	"%Z%%M%	%I%	%E% SMI"
30 
31 #include <sys/pte.h>
32 #include <sys/async.h>
33 #include <sys/x_call.h>
34 #include <sys/conf.h>
35 #include <sys/obpdefs.h>
36 
37 #ifdef	__cplusplus
38 extern "C" {
39 #endif
40 
41 
42 #ifdef _KERNEL
43 
44 /*
45  * The are functions that are expected of the cpu modules.
46  */
47 
48 extern struct module_ops *moduleops;
49 
50 struct kdi;
51 
52 /*
53  * module initialization
54  */
55 void	cpu_setup(void);
56 void	cpu_kdi_init(struct kdi *);
57 
58 /*
59  * set CPU implementation details
60  *
61  * set Panther CPU implementation details
62  *
63  * On Panther-only domains and Olympus-C, mmu_init_mmu_page_sizes
64  * changes the mmu_page_sizes variable from the default 4 page sizes
65  * to 6 page sizes and is called from fillsysinfo.c:check_cpus_set
66  * at early bootup time.
67  */
68 void	cpu_fiximp(pnode_t dnode);
69 #pragma weak cpu_fix_allpanther
70 void	cpu_fix_allpanther(void);
71 #pragma weak cpu_fix_alljupiter
72 void	cpu_fix_alljupiter(void);
73 #pragma weak mmu_init_mmu_page_sizes
74 int	mmu_init_mmu_page_sizes(int cinfo);
75 
76 /*
77  * virtual demap flushes (tlbs & virtual tag caches)
78  */
79 void	vtag_flushpage(caddr_t addr, uint64_t sfmmup);
80 void	vtag_flushall(void);
81 #pragma weak vtag_flushall_uctxs
82 void	vtag_flushall_uctxs(void);
83 void	vtag_flushpage_tl1(uint64_t addr, uint64_t sfmmup);
84 void	vtag_flush_pgcnt_tl1(uint64_t addr, uint64_t sfmmup_pgcnt);
85 void	vtag_flushall_tl1(uint64_t dummy1, uint64_t dummy2);
86 
87 /*
88  * virtual alias flushes (virtual address caches)
89  */
90 void	vac_flushpage(pfn_t pf, int color);
91 void	vac_flushpage_tl1(uint64_t pf, uint64_t color);
92 void	vac_flushcolor(int color, pfn_t pf);
93 void	vac_flushcolor_tl1(uint64_t color, uint64_t dummy);
94 
95 /*
96  * sending x-calls
97  */
98 void	init_mondo(xcfunc_t *func, uint64_t arg1, uint64_t arg2);
99 void	send_one_mondo(int cpuid);
100 #ifdef _MACHDEP
101 void	send_mondo_set(cpuset_t set);
102 #endif
103 
104 /*
105  * flag to support optimal dtlb pagesize setting, for ISM and mpss, to support
106  * cpus with non-fully-associative dtlbs. Page size is stored in hat sfmmu_cext
107  */
108 extern uint_t cpu_impl_dual_pgsz;
109 
110 /*
111  * flush instruction cache if needed
112  */
113 void	flush_instr_mem(caddr_t addr, size_t len);
114 
115 /*
116  * flush instruction and data caches
117  */
118 void	kdi_flush_caches(void);
119 
120 /*
121  * take pending fp traps if fpq present
122  * this function is also defined in fpusystm.h
123  */
124 void	syncfpu(void);
125 
126 /*
127  * Cpu-specific error and ecache handling routines
128  */
129 void	ce_err(void);
130 void	ce_err_tl1(void);
131 void	async_err(void);
132 void	cpu_flush_ecache(void);
133 void	cpu_disable_errors(void);
134 /* It could be removed later if prom enables errors */
135 void	cpu_enable_errors(void);
136 void	cpu_faulted_enter(struct cpu *);
137 void	cpu_faulted_exit(struct cpu *);
138 void	cpu_ce_count_unum(struct async_flt *ecc, int len, char *unum);
139 void	cpu_ce_scrub_mem_err(struct async_flt *, boolean_t);
140 void	cpu_ce_log_err(struct async_flt *, errorq_elem_t *);
141 void	cpu_ue_log_err(struct async_flt *);
142 int	cpu_aflt_size(void);
143 void	cpu_async_panic_callb(void);
144 void	cpu_check_allcpus(struct async_flt *aflt);
145 int	cpu_get_cpu_unum(int cpuid, char *buf, int buflen, int *lenp);
146 
147 /* Interfaces for getting memory-related information */
148 int	cpu_get_mem_name(uint64_t synd, uint64_t *afsr, uint64_t afar,
149 	    char *buf, int buflen, int *lenp);
150 int	cpu_get_mem_info(uint64_t synd, uint64_t afar,
151 	    uint64_t *mem_sizep, uint64_t *seg_sizep, uint64_t *bank_sizep,
152 	    int *segsp, int *banksp, int *mcidp);
153 size_t	cpu_get_name_bufsize();
154 extern int cpu_get_mem_addr(char *unum, char *sid, uint64_t offset,
155 	    uint64_t *addrp);
156 
157 /*
158  * FMA Event Memory Routines
159  *
160  * The following routines are used by FMA Event generators to retrieve data
161  * to store in memory ereports.  These routines may call through to platform-
162  * specific code and/or drivers, and can be called from passive context, low-
163  * level interrupt context, or panic context.  They may grab adaptive locks,
164  * but should not be allocating new data structures or calling cv_wait().
165  */
166 int	cpu_get_mem_unum(int synd_status, ushort_t synd, uint64_t afsr,
167 	    uint64_t afar, int cpuid, int flt_in_memory,
168 	    ushort_t flt_status, char *buf, int buflen, int *lenp);
169 int	cpu_get_mem_unum_aflt(int synd_status, struct async_flt *aflt,
170 	    char *buf, int buflen, int *lenp);
171 extern int cpu_get_mem_sid(char *unum, char *buf, int buflen, int *lenp);
172 extern int cpu_get_mem_offset(uint64_t flt_addr, uint64_t *offp);
173 
174 void	read_ecc_data(struct async_flt *ecc, short verbose, short ce_err);
175 /* add clr_datapath to aviod lint warning for ac_test.c temporarily */
176 void	clr_datapath(void);
177 
178 #pragma weak itlb_parity_trap
179 void itlb_parity_trap(void);
180 
181 #pragma weak dtlb_parity_trap
182 void dtlb_parity_trap(void);
183 
184 /*
185  * FMA Protocol and error handling support routines
186  */
187 
188 void cpu_ereport_post(struct async_flt *);
189 void cpu_run_bus_error_handlers(struct async_flt *, int);
190 void cpu_errorq_dispatch(char *, void *, size_t, errorq_t *, uint_t);
191 
192 /*
193  * retrieve information from the specified tlb entry. these functions are
194  * called by "cpr" module
195  */
196 void	itlb_rd_entry(uint_t entry, tte_t *tte, uint64_t *va_tag);
197 void	dtlb_rd_entry(uint_t entry, tte_t *tte, uint64_t *va_tag);
198 
199 /*
200  * this symbol appears as a second label for vtag_flushall
201  * only for cpus that implement DEMAP_ALL_TYPE
202  */
203 #pragma	weak demap_all
204 
205 /*
206  * change cpu speed
207  */
208 void	cpu_change_speed(uint64_t divisor, uint64_t arg2);
209 
210 /*
211  * ecache scrub operations
212  */
213 void cpu_init_cache_scrub(void);
214 void cpu_idle_ecache_scrub(struct cpu *);
215 void cpu_busy_ecache_scrub(struct cpu *);
216 
217 /*
218  * Cpu private initialize/uninitialize, including ecache scrubber.
219  */
220 void	cpu_init_private(struct cpu *);
221 void	cpu_uninit_private(struct cpu *);
222 
223 #pragma weak cpu_mp_init
224 void    cpu_mp_init(void);
225 
226 #pragma weak cpu_feature_init
227 void    cpu_feature_init(void);
228 
229 #pragma weak cpu_error_init
230 void	cpu_error_init(int);
231 
232 /*
233  * clock/tick register operations
234  */
235 void	cpu_clearticknpt(void);
236 void	cpu_init_tick_freq(void);
237 
238 /*
239  * stick synchronization
240  */
241 void	sticksync_slave(void);
242 void	sticksync_master(void);
243 
244 /*
245  * flags for calling cpu_check_ce
246  */
247 #define	SCRUBBER_CEEN_CHECK		0
248 #define	TIMEOUT_CEEN_CHECK		1
249 
250 /*
251  * Check for Correctable Errors that may have occurred
252  * while CEEN was disabled.
253  */
254 void cpu_check_ce(int, uint64_t, caddr_t, uint_t);
255 
256 /* initialize kernel context pgsz codes in DMMU primary context register */
257 void mmu_init_kernel_pgsz(struct hat *hat);
258 
259 /* get large page size for kernel heap */
260 size_t mmu_get_kernel_lpsize(size_t value);
261 
262 #endif /* _KERNEL */
263 
264 #ifdef	__cplusplus
265 }
266 #endif
267 
268 #endif /* _SYS_CPU_MODULE_H */
269