xref: /titanic_52/usr/src/uts/sun4u/sys/machsystm.h (revision 6c9596d46e3a733328712fdad3ea5ee362795acc)
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_MACHSYSTM_H
27 #define	_SYS_MACHSYSTM_H
28 
29 #pragma ident	"%Z%%M%	%I%	%E% SMI"
30 
31 /*
32  * Numerous platform-dependent interfaces that don't seem to belong
33  * in any other header file.
34  *
35  * This file should not be included by code that purports to be
36  * platform-independent.
37  */
38 
39 #ifndef _ASM
40 #include <sys/types.h>
41 #include <sys/scb.h>
42 #include <sys/varargs.h>
43 #include <sys/machparam.h>
44 #include <sys/thread.h>
45 #include <vm/seg_enum.h>
46 #include <sys/processor.h>
47 #include <sys/sunddi.h>
48 #include <sys/memlist.h>
49 #include <sys/async.h>
50 #include <sys/errorq.h>
51 #endif /* _ASM */
52 
53 #ifdef __cplusplus
54 extern "C" {
55 #endif
56 
57 #ifdef _KERNEL
58 
59 #ifndef _ASM
60 /*
61  * The following enum types determine how interrupts are distributed
62  * on a sun4u system.
63  */
64 enum intr_policies {
65 	/*
66 	 * Target interrupt at the CPU running the add_intrspec
67 	 * thread. Also used to target all interrupts at the panicing
68 	 * CPU.
69 	 */
70 	INTR_CURRENT_CPU = 0,
71 
72 	/*
73 	 * Target all interrupts at the boot cpu
74 	 */
75 	INTR_BOOT_CPU,
76 
77 	/*
78 	 * Flat distribution of all interrupts
79 	 */
80 	INTR_FLAT_DIST,
81 
82 	/*
83 	 * Weighted distribution of all interrupts
84 	 */
85 	INTR_WEIGHTED_DIST
86 };
87 
88 
89 /*
90  * Structure that defines the interrupt distribution list. It contains
91  * enough info about the interrupt so that it can callback the parent
92  * nexus driver and retarget the interrupt to a different CPU.
93  */
94 struct intr_dist {
95 	struct intr_dist *next;	/* link to next in list */
96 	void (*func)(void *);	/* Callback function */
97 	void *arg;		/* Nexus parent callback arg 1 */
98 };
99 
100 /*
101  * Miscellaneous cpu_state changes
102  */
103 extern void power_down(const char *);
104 extern void do_shutdown(void);
105 
106 /*
107  * Number of seconds until power is shut off
108  */
109 extern int thermal_powerdown_delay;
110 
111 
112 /*
113  * prom-related
114  */
115 extern int obpdebug;
116 extern int forthdebug_supported;
117 extern uint_t tba_taken_over;
118 extern void forthdebug_init(void);
119 extern void init_vx_handler(void);
120 extern void kern_preprom(void);
121 extern void kern_postprom(void);
122 
123 /*
124  * externally (debugger or prom) initiated panic
125  */
126 extern struct regs sync_reg_buf;
127 extern uint64_t sync_tt;
128 extern void sync_handler(void);
129 
130 /*
131  * Trap-related
132  */
133 struct regs;
134 extern void trap(struct regs *rp, caddr_t addr, uint32_t type,
135     uint32_t mmu_fsr);
136 extern void *get_tba(void);
137 extern void *set_tba(void *);
138 extern caddr_t set_trap_table(void);
139 extern struct scb trap_table;
140 
141 struct panic_trap_info {
142 	struct regs *trap_regs;
143 	uint_t	trap_type;
144 	caddr_t trap_addr;
145 	uint_t	trap_mmu_fsr;
146 };
147 
148 /*
149  * misc. primitives
150  */
151 extern void debug_flush_windows(void);
152 extern void flush_windows(void);
153 extern int getprocessorid(void);
154 extern void reestablish_curthread(void);
155 
156 extern void stphys(uint64_t physaddr, int value);
157 extern int ldphys(uint64_t physaddr);
158 extern void stdphys(uint64_t physaddr, uint64_t value);
159 extern uint64_t lddphys(uint64_t physaddr);
160 
161 extern void stphysio(u_longlong_t physaddr, uint_t value);
162 extern uint_t ldphysio(u_longlong_t physaddr);
163 extern void sthphysio(u_longlong_t physaddr, ushort_t value);
164 extern ushort_t ldhphysio(u_longlong_t physaddr);
165 extern void stbphysio(u_longlong_t physaddr, uchar_t value);
166 extern uchar_t ldbphysio(u_longlong_t physaddr);
167 extern void stdphysio(u_longlong_t physaddr, u_longlong_t value);
168 extern u_longlong_t lddphysio(u_longlong_t physaddr);
169 
170 extern int pf_is_dmacapable(pfn_t);
171 
172 extern int dip_to_cpu_id(dev_info_t *dip, processorid_t *cpu_id);
173 
174 extern void set_cmp_error_steering(void);
175 
176 /*
177  * SPARCv9 %ver register and field definitions
178  */
179 
180 #define	ULTRA_VER_MANUF(x)	((x) >> 48)
181 #define	ULTRA_VER_IMPL(x)	(((x) >> 32) & 0xFFFF)
182 #define	ULTRA_VER_MASK(x)	(((x) >> 24) & 0xFF)
183 
184 extern uint64_t ultra_getver(void);
185 
186 /*
187  * bootup-time
188  */
189 extern int ncpunode;
190 extern int niobus;
191 
192 extern void segnf_init(void);
193 extern void kern_setup1(void);
194 extern void startup(void);
195 extern void post_startup(void);
196 extern void install_va_to_tte(void);
197 extern void setwstate(uint_t);
198 extern void create_va_to_tte(void);
199 extern int memscrub_init(void);
200 
201 extern void kcpc_hw_init(void);
202 extern void kcpc_hw_startup_cpu(ushort_t);
203 extern int kcpc_hw_load_pcbe(void);
204 
205 /*
206  * Interrupts
207  */
208 struct cpu;
209 extern struct cpu cpu0;
210 extern struct scb *set_tbr(struct scb *);
211 
212 extern uint_t disable_vec_intr(void);
213 extern void enable_vec_intr(uint_t);
214 extern void setintrenable(int);
215 
216 extern void intr_dist_add(void (*f)(void *), void *);
217 extern void intr_dist_rem(void (*f)(void *), void *);
218 extern void intr_dist_add_weighted(void (*f)(void *, int32_t, int32_t), void *);
219 extern void intr_dist_rem_weighted(void (*f)(void *, int32_t, int32_t), void *);
220 
221 extern uint32_t intr_dist_cpuid(void);
222 
223 void intr_dist_cpuid_add_device_weight(uint32_t cpuid, dev_info_t *dip,
224 		int32_t weight);
225 void intr_dist_cpuid_rem_device_weight(uint32_t cpuid, dev_info_t *dip);
226 
227 extern void intr_redist_all_cpus(void);
228 extern void intr_redist_all_cpus_shutdown(void);
229 
230 extern void send_dirint(int, int);
231 extern void setsoftint(uint64_t);
232 extern void setsoftint_tl1(uint64_t, uint64_t);
233 extern void siron(void);
234 extern void sir_on(int);
235 extern uint64_t getidsr(void);
236 extern void intr_enqueue_req(uint_t pil, uint64_t inum);
237 extern void intr_dequeue_req(uint_t pil, uint64_t inum);
238 extern void wr_clr_softint(uint_t);
239 
240 /*
241  * Time- and %tick-related
242  */
243 extern hrtime_t rdtick(void);
244 extern void tick_write_delta(uint64_t);
245 extern void tickcmpr_set(uint64_t);
246 extern void tickcmpr_reset(void);
247 extern void tickcmpr_disable(void);
248 extern int tickcmpr_disabled(void);
249 extern uint64_t cbe_level14_inum;
250 
251 /*
252  * Caches
253  */
254 extern int vac;
255 extern int cache;
256 extern int use_mp;
257 extern uint_t vac_mask;
258 extern uint64_t ecache_flushaddr;
259 extern int dcache_size;		/* Maximum dcache size */
260 extern int dcache_linesize;	/* Minimum dcache linesize */
261 extern int icache_size;		/* Maximum icache size */
262 extern int icache_linesize;	/* Minimum icache linesize */
263 extern int ecache_alignsize;	/* Maximum ecache linesize for struct align */
264 extern int ecache_size;		/* Maximum ecache size */
265 extern int ecache_associativity;	/* ecache associativity */
266 extern int ecache_setsize;	/* Maximum ecache setsize possible */
267 extern int cpu_setsize;		/* Maximum ecache setsize of configured cpus */
268 
269 /*
270  * VM
271  */
272 extern int do_pg_coloring;
273 extern int use_page_coloring;
274 extern uint_t vac_colors_mask;
275 
276 extern int ndata_alloc_page_freelists(struct memlist *, int);
277 extern int ndata_alloc_dmv(struct memlist *);
278 extern int ndata_alloc_tsbs(struct memlist *, pgcnt_t);
279 extern int ndata_alloc_hat(struct memlist *, pgcnt_t, pgcnt_t);
280 extern caddr_t alloc_page_freelists(int, caddr_t, int);
281 extern caddr_t alloc_hme_buckets(caddr_t, int);
282 extern size_t page_ctrs_sz(void);
283 extern caddr_t page_ctrs_alloc(caddr_t);
284 extern void page_freelist_coalesce_all(int);
285 extern void ppmapinit(void);
286 extern void hwblkpagecopy(const void *, void *);
287 extern void hw_pa_bcopy32(uint64_t, uint64_t);
288 
289 extern int pp_slots;
290 extern int pp_consistent_coloring;
291 
292 /*
293  * ppcopy/hwblkpagecopy interaction.  See ppage.c.
294  */
295 #define	PPAGE_STORE_VCOLORING	0x1 /* use vcolors to maintain consistency */
296 #define	PPAGE_LOAD_VCOLORING	0x2 /* use vcolors to maintain consistency */
297 #define	PPAGE_STORES_POLLUTE	0x4 /* stores pollute VAC */
298 #define	PPAGE_LOADS_POLLUTE	0x8 /* loads pollute VAC */
299 
300 /*
301  * VIS-accelerated copy/zero
302  */
303 extern int use_hw_bcopy;
304 extern uint_t hw_copy_limit_1;
305 extern uint_t hw_copy_limit_2;
306 extern uint_t hw_copy_limit_4;
307 extern uint_t hw_copy_limit_8;
308 extern int use_hw_bzero;
309 
310 #ifdef CHEETAH
311 #define	VIS_COPY_THRESHOLD 256
312 #else
313 #define	VIS_COPY_THRESHOLD 900
314 #endif
315 
316 /*
317  * MP
318  */
319 extern void idle_other_cpus(void);
320 extern void resume_other_cpus(void);
321 extern void stop_other_cpus(void);
322 extern void idle_stop_xcall(void);
323 extern void set_idle_cpu(int);
324 extern void unset_idle_cpu(int);
325 extern void mp_cpu_quiesce(struct cpu *);
326 
327 /*
328  * Error handling
329  */
330 extern void set_error_enable(uint64_t neer);
331 extern void set_error_enable_tl1(uint64_t neer, uint64_t action);
332 extern uint64_t get_error_enable(void);
333 extern void get_asyncflt(uint64_t *afsr);
334 extern void set_asyncflt(uint64_t afsr);
335 extern void get_asyncaddr(uint64_t *afar);
336 extern void scrubphys(uint64_t paddr, int ecache_size);
337 extern void clearphys(uint64_t paddr, int ecache_size, int ecache_linesize);
338 extern void flushecacheline(uint64_t paddr, int ecache_size);
339 extern int ce_scrub_xdiag_recirc(struct async_flt *, errorq_t *,
340     errorq_elem_t *, size_t);
341 extern char *flt_to_error_type(struct async_flt *);
342 
343 /*
344  * Panic at TL > 0
345  */
346 extern uint64_t cpu_pa[];
347 extern void ptl1_init_cpu(struct cpu *);
348 
349 /*
350  * Defines for DR interfaces
351  */
352 #define	DEVI_BRANCH_CHILD	0x01	/* Walk immediate children of root  */
353 #define	DEVI_BRANCH_CONFIGURE	0x02	/* Configure branch after create    */
354 #define	DEVI_BRANCH_DESTROY	0x04	/* Destroy branch after unconfigure */
355 #define	DEVI_BRANCH_EVENT	0x08	/* Post NDI event		    */
356 #define	DEVI_BRANCH_PROM	0x10	/* Branches derived from PROM nodes */
357 #define	DEVI_BRANCH_SID		0x20	/* SID node branches		    */
358 #define	DEVI_BRANCH_ROOT	0x40	/* Node is the root of a branch	    */
359 
360 typedef struct devi_branch {
361 	void		*arg;
362 	void		(*devi_branch_callback)(dev_info_t *, void *, uint_t);
363 	int		type;
364 	union {
365 		int	(*prom_branch_select)(pnode_t, void *, uint_t);
366 		int	(*sid_branch_create)(dev_info_t *, void *, uint_t);
367 	} create;
368 } devi_branch_t;
369 
370 
371 /*
372  * Prototypes which really belongs to sunddi.c, and should be moved to
373  * sunddi.c if there is another platform using these calls.
374  */
375 extern int e_ddi_branch_create(dev_info_t *pdip, devi_branch_t *bp,
376     dev_info_t **dipp, uint_t flags);
377 extern int e_ddi_branch_configure(dev_info_t *rdip, dev_info_t **dipp,
378     uint_t flags);
379 extern int e_ddi_branch_unconfigure(dev_info_t *rdip, dev_info_t **dipp,
380     uint_t flags);
381 extern int e_ddi_branch_destroy(dev_info_t *rdip, dev_info_t **dipp,
382     uint_t flags);
383 extern void e_ddi_branch_hold(dev_info_t *rdip);
384 extern void e_ddi_branch_rele(dev_info_t *rdip);
385 extern int e_ddi_branch_held(dev_info_t *rdip);
386 extern int e_ddi_branch_referenced(dev_info_t *rdip,
387     int (*cb)(dev_info_t *dip, void *, uint_t), void *arg);
388 
389 /*
390  * Constants which define the "hole" in the 64-bit sfmmu address space.
391  * These are set to specific values by the CPU module code.
392  */
393 extern caddr_t	hole_start, hole_end;
394 
395 /* kpm mapping window */
396 extern size_t	kpm_size;
397 extern uchar_t	kpm_size_shift;
398 extern caddr_t	kpm_vbase;
399 
400 #define	INVALID_VADDR(a)	(((a) >= hole_start && (a) < hole_end))
401 
402 extern void adjust_hw_copy_limits(int);
403 
404 #endif /* _ASM */
405 
406 /*
407  * Actions for set_error_enable_tl1
408  */
409 #define	EER_SET_ABSOLUTE	0x0
410 #define	EER_SET_SETBITS		0x1
411 #define	EER_SET_CLRBITS		0x2
412 
413 #endif /* _KERNEL */
414 
415 #ifdef __cplusplus
416 }
417 #endif
418 
419 #endif	/* _SYS_MACHSYSTM_H */
420