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