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