xref: /titanic_50/usr/src/uts/i86pc/sys/machsystm.h (revision 3e14f97f673e8a630f076077de35afdd43dc1587)
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 /*
23  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 /*
27  * Copyright (c) 2010, Intel Corporation.
28  * All rights reserved.
29  */
30 
31 #ifndef _SYS_MACHSYSTM_H
32 #define	_SYS_MACHSYSTM_H
33 
34 /*
35  * Numerous platform-dependent interfaces that don't seem to belong
36  * in any other header file.
37  *
38  * This file should not be included by code that purports to be
39  * platform-independent.
40  *
41  */
42 
43 #include <sys/machparam.h>
44 #include <sys/varargs.h>
45 #include <sys/thread.h>
46 #include <sys/cpuvar.h>
47 #include <sys/privregs.h>
48 #include <sys/systm.h>
49 #include <sys/traptrace.h>
50 #include <vm/page.h>
51 
52 #ifdef __cplusplus
53 extern "C" {
54 #endif
55 
56 #ifdef _KERNEL
57 
58 typedef enum mach_cpu_add_arg_type {
59 	MACH_CPU_ARG_LOCAL_APIC,
60 	MACH_CPU_ARG_LOCAL_X2APIC,
61 } mach_cpu_add_arg_type_t;
62 
63 typedef struct mach_cpu_add_arg {
64 	mach_cpu_add_arg_type_t		type;
65 	union {
66 		struct {
67 			uint32_t	apic_id;
68 			uint32_t	proc_id;
69 		} apic;
70 	} arg;
71 } mach_cpu_add_arg_t;
72 
73 extern void mach_cpu_idle(void);
74 extern void mach_cpu_halt(char *);
75 extern int mach_cpu_start(cpu_t *, void *);
76 extern int mach_cpuid_start(processorid_t, void *);
77 extern int mach_cpu_stop(cpu_t *, void *);
78 extern int mach_cpu_add(mach_cpu_add_arg_t *, processorid_t *);
79 extern int mach_cpu_remove(processorid_t);
80 extern int mach_cpu_create_device_node(cpu_t *, dev_info_t **);
81 extern int mach_cpu_get_device_node(cpu_t *, dev_info_t **);
82 
83 extern int Cpudelay;
84 extern void setcpudelay(void);
85 
86 extern void send_dirint(int, int);
87 extern void siron(void);
88 extern void sir_on(int);
89 
90 extern void return_instr(void);
91 
92 extern int kcpc_hw_load_pcbe(void);
93 extern void kcpc_hw_init(cpu_t *cp);
94 extern void kcpc_hw_fini(cpu_t *cp);
95 extern int kcpc_hw_overflow_intr_installed;
96 
97 struct panic_trap_info {
98 	struct regs *trap_regs;
99 	uint_t trap_type;
100 	caddr_t trap_addr;
101 };
102 
103 struct memconf {
104 	pfn_t	mcf_spfn;	/* begin page frame number */
105 	pfn_t	mcf_epfn;	/* end page frame number */
106 };
107 
108 struct system_hardware {
109 	int		hd_nodes;		/* number of nodes */
110 	int		hd_cpus_per_node; 	/* max cpus in a node */
111 	struct memconf 	hd_mem[MAXNODES];
112 						/*
113 						 * memory layout for each
114 						 * node.
115 						 */
116 };
117 extern struct system_hardware system_hardware;
118 extern void get_system_configuration(void);
119 extern void mmu_init(void);
120 extern int cpuid2nodeid(int);
121 extern void map_kaddr(caddr_t, pfn_t, int, int);
122 
123 extern void memscrub_init(void);
124 extern void trap(struct regs *, caddr_t, processorid_t);
125 
126 extern void do_interrupt(struct regs *, trap_trace_rec_t *);
127 extern void memscrub_disable(void);
128 
129 /*
130  * Dispatcher hooks.
131  */
132 void    (*idle_cpu)();
133 void    (*non_deep_idle_cpu)();
134 void    (*disp_enq_thread)(cpu_t *, int);
135 void    (*non_deep_idle_disp_enq_thread)(cpu_t *, int);
136 
137 #ifndef __xpv
138 extern unsigned int microdata;
139 #endif
140 
141 extern int use_mp;
142 
143 extern struct cpu	cpus[];		/* pointer to other cpus */
144 extern struct cpu	*cpu[];		/* pointer to all cpus */
145 
146 /* Operation types for extended mach_cpucontext interfaces */
147 #define	MACH_CPUCONTEXT_OP_START	0
148 #define	MACH_CPUCONTEXT_OP_STOP		1
149 
150 extern int mach_cpucontext_init(void);
151 extern void mach_cpucontext_fini(void);
152 extern void *mach_cpucontext_alloc(struct cpu *);
153 extern void mach_cpucontext_free(struct cpu *, void *, int);
154 extern void *mach_cpucontext_xalloc(struct cpu *, int);
155 extern void mach_cpucontext_xfree(struct cpu *, void *, int, int);
156 extern void rmp_gdt_init(rm_platter_t *);
157 
158 extern uintptr_t hole_start, hole_end;
159 
160 #define	INVALID_VADDR(a)	\
161 	(((a) >= (caddr_t)hole_start && (a) < (caddr_t)hole_end))
162 
163 /* kpm mapping window */
164 extern size_t   kpm_size;
165 extern uchar_t  kpm_size_shift;
166 extern caddr_t  kpm_vbase;
167 
168 struct memlist;
169 extern void memlist_add(uint64_t, uint64_t, struct memlist *,
170     struct memlist **);
171 extern page_t *page_get_physical(uintptr_t seed);
172 extern int linear_pc(struct regs *rp, proc_t *p, caddr_t *linearp);
173 extern int dtrace_linear_pc(struct regs *rp, proc_t *p, caddr_t *linearp);
174 
175 extern int force_shutdown_method;
176 
177 /* Dynamic Reconfiguration capability interface. */
178 #define	PLAT_DR_OPTIONS_NAME		"plat-dr-options"
179 #define	PLAT_DR_PHYSMAX_NAME		"plat-dr-physmax"
180 #define	PLAT_MAX_NCPUS_NAME		"plat-max-ncpus"
181 #define	BOOT_MAX_NCPUS_NAME		"boot-max-ncpus"
182 #define	BOOT_NCPUS_NAME			"boot-ncpus"
183 
184 #define	PLAT_DR_FEATURE_CPU		0x1
185 #define	PLAT_DR_FEATURE_MEMORY		0x2
186 #define	PLAT_DR_FEATURE_ENABLED		0x1000000
187 
188 #define	plat_dr_enabled()		\
189 	plat_dr_check_capability(PLAT_DR_FEATURE_ENABLED)
190 
191 #define	plat_dr_enable()		\
192 	plat_dr_enable_capability(PLAT_DR_FEATURE_ENABLED)
193 
194 #define	plat_dr_disable_cpu()		\
195 	plat_dr_disable_capability(PLAT_DR_FEATURE_CPU)
196 #define	plat_dr_disable_memory()	\
197 	plat_dr_disable_capability(PLAT_DR_FEATURE_MEMORY)
198 
199 extern boolean_t plat_dr_support_cpu(void);
200 extern boolean_t plat_dr_support_memory(void);
201 extern boolean_t plat_dr_check_capability(uint64_t features);
202 extern void plat_dr_enable_capability(uint64_t features);
203 extern void plat_dr_disable_capability(uint64_t features);
204 
205 #pragma	weak plat_dr_support_cpu
206 #pragma	weak plat_dr_support_memory
207 
208 /*
209  * Used to communicate DR updates to platform lgroup framework
210  */
211 typedef struct {
212 	uint64_t	u_base;
213 	uint64_t	u_length;
214 	uint32_t	u_domain;
215 	uint32_t	u_device_id;
216 	uint32_t	u_sli_cnt;
217 	uchar_t		*u_sli_ptr;
218 } update_membounds_t;
219 
220 /* Maximum physical page number (PFN) for memory DR operations. */
221 extern uint64_t plat_dr_physmax;
222 
223 #ifdef __xpv
224 #include <sys/xen_mmu.h>
225 extern page_t *page_get_high_mfn(mfn_t);
226 #endif
227 
228 
229 #endif /* _KERNEL */
230 
231 #ifdef __cplusplus
232 }
233 #endif
234 
235 #endif	/* _SYS_MACHSYSTM_H */
236