xref: /openbsd-src/sys/arch/amd64/include/cpuvar.h (revision 1a81a8e6e44bd2257ef7a22fd415dc9869080982)
1*1a81a8e6Sjsg /*	$OpenBSD: cpuvar.h,v 1.14 2024/10/22 10:14:49 jsg Exp $	*/
2f5df1827Smickey /* 	$NetBSD: cpuvar.h,v 1.1 2003/03/01 18:29:28 fvdl Exp $ */
3f5df1827Smickey 
4f5df1827Smickey /*-
5f5df1827Smickey  * Copyright (c) 2000 The NetBSD Foundation, Inc.
6f5df1827Smickey  * All rights reserved.
7f5df1827Smickey  *
8f5df1827Smickey  * This code is derived from software contributed to The NetBSD Foundation
9f5df1827Smickey  * by RedBack Networks Inc.
10f5df1827Smickey  *
11f5df1827Smickey  * Author: Bill Sommerfeld
12f5df1827Smickey  *
13f5df1827Smickey  * Redistribution and use in source and binary forms, with or without
14f5df1827Smickey  * modification, are permitted provided that the following conditions
15f5df1827Smickey  * are met:
16f5df1827Smickey  * 1. Redistributions of source code must retain the above copyright
17f5df1827Smickey  *    notice, this list of conditions and the following disclaimer.
18f5df1827Smickey  * 2. Redistributions in binary form must reproduce the above copyright
19f5df1827Smickey  *    notice, this list of conditions and the following disclaimer in the
20f5df1827Smickey  *    documentation and/or other materials provided with the distribution.
21f5df1827Smickey  *
22f5df1827Smickey  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
23f5df1827Smickey  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
24f5df1827Smickey  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
25f5df1827Smickey  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
26f5df1827Smickey  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27f5df1827Smickey  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28f5df1827Smickey  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29f5df1827Smickey  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30f5df1827Smickey  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31f5df1827Smickey  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32f5df1827Smickey  * POSSIBILITY OF SUCH DAMAGE.
33f5df1827Smickey  */
34f5df1827Smickey 
35f5df1827Smickey /*
36f5df1827Smickey  * Copyright (c) 1999 Stefan Grefen
37f5df1827Smickey  *
38f5df1827Smickey  * Redistribution and use in source and binary forms, with or without
39f5df1827Smickey  * modification, are permitted provided that the following conditions
40f5df1827Smickey  * are met:
41f5df1827Smickey  * 1. Redistributions of source code must retain the above copyright
42f5df1827Smickey  *    notice, this list of conditions and the following disclaimer.
43f5df1827Smickey  * 2. Redistributions in binary form must reproduce the above copyright
44f5df1827Smickey  *    notice, this list of conditions and the following disclaimer in the
45f5df1827Smickey  *    documentation and/or other materials provided with the distribution.
46f5df1827Smickey  * 3. All advertising materials mentioning features or use of this software
47f5df1827Smickey  *    must display the following acknowledgement:
48f5df1827Smickey  *      This product includes software developed by the NetBSD
49f5df1827Smickey  *      Foundation, Inc. and its contributors.
50f5df1827Smickey  * 4. Neither the name of The NetBSD Foundation nor the names of its
51f5df1827Smickey  *    contributors may be used to endorse or promote products derived
52f5df1827Smickey  *    from this software without specific prior written permission.
53f5df1827Smickey  *
54f5df1827Smickey  * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY
55f5df1827Smickey  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
56f5df1827Smickey  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
57f5df1827Smickey  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR AND CONTRIBUTORS BE LIABLE
58f5df1827Smickey  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
59f5df1827Smickey  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
60f5df1827Smickey  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
61f5df1827Smickey  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
62f5df1827Smickey  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
63f5df1827Smickey  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
64f5df1827Smickey  * SUCH DAMAGE.
65f5df1827Smickey  */
66f5df1827Smickey 
67f5df1827Smickey struct cpu_functions {
68f5df1827Smickey 	int (*start)(struct cpu_info *);
69f5df1827Smickey 	int (*stop)(struct cpu_info *);
70f5df1827Smickey 	void (*cleanup)(struct cpu_info *);
71f5df1827Smickey };
72f5df1827Smickey 
73f5df1827Smickey extern struct cpu_functions mp_cpu_funcs;
74f5df1827Smickey 
75f5df1827Smickey #define CPU_ROLE_SP	0
76f5df1827Smickey #define CPU_ROLE_BP	1
77f5df1827Smickey #define CPU_ROLE_AP	2
78f5df1827Smickey 
79f5df1827Smickey struct cpu_attach_args {
80f5df1827Smickey 	const char *caa_name;
81a2e7ce2eSkettenis 	int cpu_apicid;
82a2e7ce2eSkettenis 	int cpu_acpi_proc_id;
83f5df1827Smickey 	int cpu_role;
84f5df1827Smickey 	struct cpu_functions *cpu_func;
85f5df1827Smickey };
86f5df1827Smickey 
87f5df1827Smickey #ifdef _KERNEL
88f5df1827Smickey 
89984d4744Ssf #ifdef MULTIPROCESSOR
901245a68aSsf extern void (*x86_ipi)(int,int,int);
91bce2cee5Ssf void x86_ipi_init(int);
92984d4744Ssf #endif
93f5df1827Smickey 
94f5df1827Smickey void identifycpu(struct cpu_info *);
95f5df1827Smickey void cpu_init(struct cpu_info *);
96f5df1827Smickey 
9778156938Scheloha void tsc_test_sync_bp(struct cpu_info *);
9878156938Scheloha void tsc_test_sync_ap(struct cpu_info *);
998d9f4b32Spirofti 
100f5df1827Smickey #endif
101