xref: /illumos-gate/usr/src/uts/i86pc/cpu/generic_cpu/gcpu_main.c (revision 6a074c93c5dee390d8ca2377f42e55418f0a9eb3)
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 2007 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 static void *
64 gcpu_null(void)
65 {
66 	return (NULL);
67 }
68 
69 /*ARGSUSED*/
70 static int
71 gcpu_init(cpu_t *cpu, void **datap)
72 {
73 	*datap = kmem_zalloc(sizeof (gcpu_data_t), KM_SLEEP);
74 	return (0);
75 }
76 
77 static void
78 gcpu_fini(void *data)
79 {
80 	gcpu_data_t *dp = data;
81 
82 	kmem_free(dp->gcpu_mca.gcpu_mca_data,
83 	    dp->gcpu_mca.gcpu_mca_nbanks * sizeof (gcpu_mca_data_t));
84 
85 	kmem_free(dp, sizeof (gcpu_data_t));
86 }
87 
88 const cmi_ops_t _cmi_ops = {
89 	gcpu_init,		/* cmi_init */
90 	gcpu_nop,		/* cmi_post_init */
91 	gcpu_nop,		/* cmi_post_mpstartup */
92 	gcpu_fini,		/* cmi_fini */
93 	gcpu_nop,		/* cmi_faulted_enter */
94 	gcpu_nop,		/* cmi_faulted_exit */
95 	(int (*)())gcpu_nil,	/* cmi_scrubber_enable */
96 	gcpu_mca_init,		/* cmi_mca_init */
97 	gcpu_mca_trap,		/* cmi_mca_trap */
98 	(int (*)())gcpu_notsup,	/* cmi_mca_inject */
99 	gcpu_nop,		/* cmi_mca_poke */
100 	(void (*)())gcpu_nop,			/* cmi_mc_register */
101 	(const cmi_mc_ops_t *(*)())gcpu_null	/* cmi_mc_getops */
102 };
103 
104 static struct modlcpu modlcpu = {
105 	&mod_cpuops,
106 	"Generic x86 CPU Module"
107 };
108 
109 static struct modlinkage modlinkage = {
110 	MODREV_1,
111 	(void *)&modlcpu,
112 	NULL
113 };
114 
115 int
116 _init(void)
117 {
118 	return (mod_install(&modlinkage));
119 }
120 
121 int
122 _info(struct modinfo *modinfop)
123 {
124 	return (mod_info(&modlinkage, modinfop));
125 }
126 
127 int
128 _fini(void)
129 {
130 	return (mod_remove(&modlinkage));
131 }
132