xref: /illumos-gate/usr/src/uts/i86pc/cpu/generic_cpu/gcpu_main.c (revision 3ad553a7dabf3c8bcb69dd1ceeb13938fa526aed)
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 2006 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #pragma ident	"%Z%%M%	%I%	%E% SMI"
28 
29 /*
30  * Generic x86 CPU Module
31  *
32  * This CPU module is used for generic x86 CPUs when Solaris has no other
33  * CPU-specific support module available.  Code in this module should be the
34  * absolute bare-bones support and must be cognizant of both Intel and AMD etc.
35  */
36 
37 #include <sys/types.h>
38 #include <sys/cpu_module_impl.h>
39 #include <sys/cpuvar.h>
40 #include <sys/kmem.h>
41 #include <sys/modctl.h>
42 
43 #include "gcpu.h"
44 
45 /*ARGSUSED*/
46 static void
47 gcpu_nop(void *data)
48 {
49 }
50 
51 static int
52 gcpu_notsup(void)
53 {
54 	return (ENOTSUP);
55 }
56 
57 static int
58 gcpu_nil(void)
59 {
60 	return (0);
61 }
62 
63 /*ARGSUSED*/
64 static int
65 gcpu_init(cpu_t *cpu, void **datap)
66 {
67 	*datap = kmem_zalloc(sizeof (gcpu_data_t), KM_SLEEP);
68 	return (0);
69 }
70 
71 static void
72 gcpu_fini(void *data)
73 {
74 	gcpu_data_t *dp = data;
75 
76 	kmem_free(dp->gcpu_mca.gcpu_mca_data,
77 	    dp->gcpu_mca.gcpu_mca_nbanks * sizeof (gcpu_mca_data_t));
78 
79 	kmem_free(dp, sizeof (gcpu_data_t));
80 }
81 
82 const cmi_ops_t _cmi_ops = {
83 	gcpu_init,		/* cmi_init */
84 	gcpu_nop,		/* cmi_post_init */
85 	gcpu_nop,		/* cmi_post_mpstartup */
86 	gcpu_fini,		/* cmi_fini */
87 	gcpu_nop,		/* cmi_faulted_enter */
88 	gcpu_nop,		/* cmi_faulted_exit */
89 	(int (*)())gcpu_nil,	/* cmi_scrubber_enable */
90 	gcpu_mca_init,		/* cmi_mca_init */
91 	gcpu_mca_trap,		/* cmi_mca_trap */
92 	(int (*)())gcpu_notsup,	/* cmi_mca_inject */
93 	gcpu_nop,		/* cmi_mca_poke */
94 	(void (*)())gcpu_nop,			/* cmi_mc_register */
95 	(const cmi_mc_ops_t *(*)())gcpu_nop	/* cmi_mc_getops */
96 };
97 
98 static struct modlcpu modlcpu = {
99 	&mod_cpuops,
100 	"Generic x86 CPU Module"
101 };
102 
103 static struct modlinkage modlinkage = {
104 	MODREV_1,
105 	(void *)&modlcpu,
106 	NULL
107 };
108 
109 int
110 _init(void)
111 {
112 	return (mod_install(&modlinkage));
113 }
114 
115 int
116 _info(struct modinfo *modinfop)
117 {
118 	return (mod_info(&modlinkage, modinfop));
119 }
120 
121 int
122 _fini(void)
123 {
124 	return (mod_remove(&modlinkage));
125 }
126