xref: /illumos-gate/usr/src/uts/i86pc/cpu/generic_cpu/gcpu_main.c (revision 7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fe)
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, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 
23 /*
24  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
25  * Use is subject to license terms.
26  */
27 
28 #pragma ident	"%Z%%M%	%I%	%E% SMI"
29 
30 /*
31  * Generic x86 CPU Module
32  *
33  * This CPU module is used for generic x86 CPUs when Solaris has no other
34  * CPU-specific support module available.  Code in this module should be the
35  * absolute bare-bones support and must be cognizant of both Intel and AMD etc.
36  */
37 
38 #include <sys/types.h>
39 #include <sys/cpu_module_impl.h>
40 #include <sys/cpuvar.h>
41 #include <sys/kmem.h>
42 #include <sys/modctl.h>
43 
44 #include "gcpu.h"
45 
46 /*ARGSUSED*/
47 static void
48 gcpu_nop(void *data)
49 {
50 }
51 
52 static int
53 gcpu_notsup(void)
54 {
55 	return (ENOTSUP);
56 }
57 
58 static int
59 gcpu_nil(void)
60 {
61 	return (0);
62 }
63 
64 /*ARGSUSED*/
65 static int
66 gcpu_init(cpu_t *cpu, void **datap)
67 {
68 	*datap = kmem_zalloc(sizeof (gcpu_data_t), KM_SLEEP);
69 	return (0);
70 }
71 
72 static void
73 gcpu_fini(void *data)
74 {
75 	gcpu_data_t *dp = data;
76 
77 	kmem_free(dp->gcpu_mca.gcpu_mca_data,
78 	    dp->gcpu_mca.gcpu_mca_nbanks * sizeof (gcpu_mca_data_t));
79 
80 	kmem_free(dp, sizeof (gcpu_data_t));
81 }
82 
83 const cmi_ops_t _cmi_ops = {
84 	gcpu_init,		/* cmi_init */
85 	gcpu_nop,		/* cmi_post_init */
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