xref: /illumos-gate/usr/src/uts/i86pc/sys/machsystm.h (revision a92282e44f968185a6bba094d1e5fece2da819cf)
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 (c) 1993, 2010, Oracle and/or its affiliates. All rights reserved.
24  */
25 /*
26  * Copyright (c) 2010, Intel Corporation.
27  * All rights reserved.
28  * Copyright 2018 Joyent, Inc.
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 int mach_cpu_halt(xc_arg_t, xc_arg_t, xc_arg_t);
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  * Interrupt handling hooks
131  */
132 extern void (*do_interrupt_common)(struct regs *, trap_trace_rec_t *);
133 extern uintptr_t (*get_intr_handler)(int, short);
134 
135 /*
136  * Dispatcher hooks.
137  */
138 void    (*idle_cpu)();
139 void    (*non_deep_idle_cpu)();
140 void    (*disp_enq_thread)(cpu_t *, int);
141 void    (*non_deep_idle_disp_enq_thread)(cpu_t *, int);
142 
143 #ifndef __xpv
144 extern unsigned int microdata;
145 #endif
146 
147 extern int use_mp;
148 
149 extern struct cpu	cpus[];		/* pointer to other cpus */
150 extern struct cpu	*cpu[];		/* pointer to all cpus */
151 
152 /* Operation types for extended mach_cpucontext interfaces */
153 #define	MACH_CPUCONTEXT_OP_START	0
154 #define	MACH_CPUCONTEXT_OP_STOP		1
155 
156 extern int mach_cpucontext_init(void);
157 extern void mach_cpucontext_fini(void);
158 extern void *mach_cpucontext_alloc(struct cpu *);
159 extern void mach_cpucontext_free(struct cpu *, void *, int);
160 extern void *mach_cpucontext_xalloc(struct cpu *, int);
161 extern void mach_cpucontext_xfree(struct cpu *, void *, int, int);
162 extern void rmp_gdt_init(rm_platter_t *);
163 
164 extern uintptr_t hole_start, hole_end;
165 
166 #define	INVALID_VADDR(a)	\
167 	(((a) >= (caddr_t)hole_start && (a) < (caddr_t)hole_end))
168 
169 /* kpm mapping window */
170 extern size_t   kpm_size;
171 extern uchar_t  kpm_size_shift;
172 extern caddr_t  kpm_vbase;
173 
174 struct memlist;
175 extern void memlist_add(uint64_t, uint64_t, struct memlist *,
176     struct memlist **);
177 extern page_t *page_get_physical(uintptr_t seed);
178 extern int linear_pc(struct regs *rp, proc_t *p, caddr_t *linearp);
179 extern int dtrace_linear_pc(struct regs *rp, proc_t *p, caddr_t *linearp);
180 
181 extern int force_shutdown_method;
182 
183 /* Dynamic Reconfiguration capability interface. */
184 #define	PLAT_DR_OPTIONS_NAME		"plat-dr-options"
185 #define	PLAT_DR_PHYSMAX_NAME		"plat-dr-physmax"
186 #define	PLAT_MAX_NCPUS_NAME		"plat-max-ncpus"
187 #define	BOOT_MAX_NCPUS_NAME		"boot-max-ncpus"
188 #define	BOOT_NCPUS_NAME			"boot-ncpus"
189 
190 #define	PLAT_DR_FEATURE_CPU		0x1
191 #define	PLAT_DR_FEATURE_MEMORY		0x2
192 #define	PLAT_DR_FEATURE_ENABLED		0x1000000
193 
194 #define	plat_dr_enabled()		\
195 	plat_dr_check_capability(PLAT_DR_FEATURE_ENABLED)
196 
197 #define	plat_dr_enable()		\
198 	plat_dr_enable_capability(PLAT_DR_FEATURE_ENABLED)
199 
200 #define	plat_dr_disable_cpu()		\
201 	plat_dr_disable_capability(PLAT_DR_FEATURE_CPU)
202 #define	plat_dr_disable_memory()	\
203 	plat_dr_disable_capability(PLAT_DR_FEATURE_MEMORY)
204 
205 extern boolean_t plat_dr_support_cpu(void);
206 extern boolean_t plat_dr_support_memory(void);
207 extern boolean_t plat_dr_check_capability(uint64_t features);
208 extern void plat_dr_enable_capability(uint64_t features);
209 extern void plat_dr_disable_capability(uint64_t features);
210 
211 #pragma	weak plat_dr_support_cpu
212 #pragma	weak plat_dr_support_memory
213 
214 /*
215  * Used to communicate DR updates to platform lgroup framework
216  */
217 typedef struct {
218 	uint64_t	u_base;
219 	uint64_t	u_length;
220 	uint32_t	u_domain;
221 	uint32_t	u_device_id;
222 	uint32_t	u_sli_cnt;
223 	uchar_t		*u_sli_ptr;
224 } update_membounds_t;
225 
226 /* Maximum physical page number (PFN) for memory DR operations. */
227 extern uint64_t plat_dr_physmax;
228 
229 #ifdef __xpv
230 #include <sys/xen_mmu.h>
231 extern page_t *page_get_high_mfn(mfn_t);
232 #endif
233 
234 extern hrtime_t tsc_gethrtime_tick_delta(void);
235 extern hrtime_t tsc_gethrtime_params(uint64_t *, uint32_t *, uint8_t *);
236 
237 #endif /* _KERNEL */
238 
239 #ifdef __cplusplus
240 }
241 #endif
242 
243 #endif	/* _SYS_MACHSYSTM_H */
244