summaryrefslogtreecommitdiff
path: root/usr/src/uts/i86pc/sys/apic_common.h
blob: 440f817beb7680d793ff7828d643785381705b55 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License (the "License").
 * You may not use this file except in compliance with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*
 * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
 * Copyright (c) 2017 by Delphix. All rights reserved.
 */
/*
 * Copyright 2019, Joyent, Inc.
 */

#ifndef _SYS_APIC_COMMON_H
#define	_SYS_APIC_COMMON_H

#include <sys/psm_types.h>
#include <sys/avintr.h>
#include <sys/privregs.h>
#include <sys/pci.h>
#include <sys/cyclic.h>

#ifdef	__cplusplus
extern "C" {
#endif

/*
 * Functions & Variables common to pcplusmp & apix
 */

#include <sys/psm_common.h>

/* Methods for multiple IOAPIC */
enum apic_ioapic_method_type {
	APIC_MUL_IOAPIC_NONE,		/* use to disable pcplusmp fallback */
	APIC_MUL_IOAPIC_MASK,		/* Set RT Entry Mask bit before EOI */
	APIC_MUL_IOAPIC_DEOI,		/* Directed EOI */
	APIC_MUL_IOAPIC_IOXAPIC,	/* IOxAPIC */
	APIC_MUL_IOAPIC_IIR,		/* IOMMU interrup remapping */
	APIC_MUL_IOAPIC_PCPLUSMP	/* Fall back to old pcplusmp */
};

#define	APIX_IS_DIRECTED_EOI(type)	\
	((type) == APIC_MUL_IOAPIC_DEOI || (type) == APIC_MUL_IOAPIC_IIR)
#define	APIX_IS_MASK_RDT(type)	\
	((type) == APIC_MUL_IOAPIC_NONE || (type) == APIC_MUL_IOAPIC_MASK)

extern int	apix_enable;
extern int	apix_loaded(void);
extern enum apic_ioapic_method_type apix_mul_ioapic_method;

extern int	apic_oneshot;
/* to allow disabling one-shot capability */
extern int	apic_oneshot_enable;

/* Now the ones for Dynamic Interrupt distribution */
extern int	apic_enable_dynamic_migration;

extern int apic_have_32bit_cr8;

extern struct psm_ops *psmops;

/*
 * These variables are frequently accessed in apic_intr_enter(),
 * apic_intr_exit and apic_setspl, so group them together
 */
extern volatile uint32_t *apicadr;	/* virtual addr of local APIC	*/
extern uchar_t	apic_io_vectbase[MAX_IO_APIC];
extern uchar_t	apic_io_vectend[MAX_IO_APIC];
extern uchar_t	apic_io_ver[MAX_IO_APIC];
extern int	apic_io_max;
extern int	apic_nvidia_io_max;
extern int apic_setspl_delay;		/* apic_setspl - delay enable	*/
extern int apic_clkvect;

/* vector at which error interrupts come in */
extern int apic_errvect;
extern int apic_enable_error_intr;
extern int apic_error_display_delay;

/* vector at which performance counter overflow interrupts come in */
extern int apic_cpcovf_vect;
extern int apic_enable_cpcovf_intr;

/* vector at which CMCI interrupts come in */
extern int apic_cmci_vect;
extern int cmi_enable_cmci;
extern void cmi_cmci_trap(void);

extern kmutex_t cmci_cpu_setup_lock;	/* protects cmci_cpu_setup_registered */
extern int cmci_cpu_setup_registered;

extern int	apic_forceload;

extern int	apic_coarse_hrtime;	/* 0 - use accurate slow gethrtime() */
					/* 1 - use gettime() for performance */
extern int	apic_flat_model;		/* 0 - clustered. 1 - flat */

extern int	apic_panic_on_nmi;
extern int	apic_panic_on_apic_error;

extern int	apic_verbose;

extern int	apic_pir_vect;

#ifdef DEBUG
extern int	apic_debug;
extern int	apic_restrict_vector;

extern int	apic_debug_msgbuf[APIC_DEBUG_MSGBUFSIZE];
extern int	apic_debug_msgbufindex;

#endif /* DEBUG */

extern uint_t	apic_nsec_per_intr;
extern uint_t	apic_nticks;
extern uint_t	apic_skipped_redistribute;

extern uint_t	last_count_read;
extern lock_t	apic_mode_switch_lock;
extern lock_t	apic_gethrtime_lock;
extern volatile int	apic_hrtime_stamp;
extern volatile hrtime_t apic_nsec_since_boot;
extern uint_t	apic_hertz_count;

extern uint64_t apic_ticks_per_SFnsecs;	/* # of ticks in SF nsecs */

extern int	apic_hrtime_error;
extern int	apic_remote_hrterr;
extern int	apic_num_nmis;
extern int	apic_apic_error;
extern int	apic_num_apic_errors;
extern int	apic_num_cksum_errors;

extern int	apic_error;

/* use to make sure only one cpu handles the nmi */
extern lock_t	apic_nmi_lock;
/* use to make sure only one cpu handles the error interrupt */
extern lock_t	apic_error_lock;

/* Patchable global variables. */
extern uint32_t	apic_divide_reg_init;	/* 0 - divide by 2 */

extern apic_intrmap_ops_t *apic_vt_ops;

#ifdef	DEBUG
extern int	apic_break_on_cpu;
extern int	apic_stretch_interrupts;
extern int	apic_stretch_ISR;	/* IPL of 3 matches nothing now */
#endif

extern cyclic_id_t apic_cyclic_id;

extern uint_t apic_nmi_intr(caddr_t arg, caddr_t);
extern int	apic_clkinit();
extern hrtime_t apic_gettime();
extern hrtime_t apic_gethrtime();
extern int	apic_cpu_start(processorid_t cpuid, caddr_t ctx);
extern int	apic_cpu_stop(processorid_t cpuid, caddr_t ctx);
extern int	apic_cpu_add(psm_cpu_request_t *reqp);
extern int	apic_cpu_remove(psm_cpu_request_t *reqp);
extern int	apic_cpu_ops(psm_cpu_request_t *reqp);
extern void	apic_switch_ipi_callback(boolean_t enter);
extern void	apic_send_ipi(int cpun, int ipl);
extern void	apic_set_idlecpu(processorid_t cpun);
extern void	apic_unset_idlecpu(processorid_t cpun);
extern void	apic_shutdown(int cmd, int fcn);
extern void	apic_preshutdown(int cmd, int fcn);
extern processorid_t	apic_get_next_processorid(processorid_t cpun);
extern uint64_t	apic_calibrate();
extern int	apic_get_pir_ipivect(void);
extern void	apic_send_pir_ipi(processorid_t);

extern int apic_error_intr();
extern void apic_cpcovf_mask_clear(void);
extern void apic_cmci_setup(processorid_t, boolean_t);
extern void apic_intrmap_init(int apic_mode);
extern processorid_t apic_find_cpu(int flag);
extern processorid_t apic_get_next_bind_cpu(void);

extern int	apic_support_msi;
extern int	apic_multi_msi_enable;
extern int	apic_msix_enable;

extern uint32_t apic_get_localapicid(uint32_t cpuid);
extern uchar_t apic_get_ioapicid(uchar_t ioapicindex);

typedef enum nmi_action {
	NMI_ACTION_UNSET,
	NMI_ACTION_PANIC,
	NMI_ACTION_IGNORE,
	NMI_ACTION_KMDB
} nmi_action_t;

extern nmi_action_t nmi_action;

#ifdef	__cplusplus
}
#endif

#endif	/* _SYS_APIC_COMMON_H */