xref: /netbsd-src/sys/arch/hpcmips/hpcmips/cpu.c (revision 42362de5c5d3e56bfb7cde4673410087cb67521c)
1*42362de5Sriastradh /*	$NetBSD: cpu.c,v 1.19 2022/03/03 06:27:03 riastradh Exp $	*/
29d92917cSsato /*-
39d92917cSsato  * Copyright (c) 1999 Shin Takemura, All rights reserved.
49d92917cSsato  * Copyright (c) 1999-2001 SATO Kazumi, All rights reserved.
59d92917cSsato  *
69d92917cSsato  * Redistribution and use in source and binary forms, with or without
79d92917cSsato  * modification, are permitted provided that the following conditions
89d92917cSsato  * are met:
99d92917cSsato  * 1. Redistributions of source code must retain the above copyright
109d92917cSsato  *    notice, this list of conditions and the following disclaimer.
119d92917cSsato  * 2. Redistributions in binary form must reproduce the above copyright
129d92917cSsato  *    notice, this list of conditions and the following disclaimer in the
139d92917cSsato  *    documentation and/or other materials provided with the distribution.
149d92917cSsato  * 3. The name of the author may not be used to endorse or promote products
159d92917cSsato  *    derived from this software without specific prior written permission.
169d92917cSsato  *
179d92917cSsato  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
189d92917cSsato  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
199d92917cSsato  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
209d92917cSsato  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
219d92917cSsato  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
229d92917cSsato  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
239d92917cSsato  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
249d92917cSsato  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
259d92917cSsato  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
269d92917cSsato  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
279d92917cSsato  * SUCH DAMAGE.
289d92917cSsato  *
299d92917cSsato  */
30db2b0adeStakemura 
31db2b0adeStakemura /*
32db2b0adeStakemura  * Copyright (c) 1994, 1995 Carnegie-Mellon University.
33db2b0adeStakemura  * All rights reserved.
34db2b0adeStakemura  *
35db2b0adeStakemura  * Author: Chris G. Demetriou
36db2b0adeStakemura  *
37db2b0adeStakemura  * Permission to use, copy, modify and distribute this software and
38db2b0adeStakemura  * its documentation is hereby granted, provided that both the copyright
39db2b0adeStakemura  * notice and this permission notice appear in all copies of the
40db2b0adeStakemura  * software, derivative works or modified versions, and any portions
41db2b0adeStakemura  * thereof, and that both notices appear in supporting documentation.
42db2b0adeStakemura  *
43db2b0adeStakemura  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
44db2b0adeStakemura  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
45db2b0adeStakemura  * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
46db2b0adeStakemura  *
47db2b0adeStakemura  * Carnegie Mellon requests users of this software to return to
48db2b0adeStakemura  *
49db2b0adeStakemura  *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
50db2b0adeStakemura  *  School of Computer Science
51db2b0adeStakemura  *  Carnegie Mellon University
52db2b0adeStakemura  *  Pittsburgh PA 15213-3890
53db2b0adeStakemura  *
54db2b0adeStakemura  * any improvements or extensions that they make and grant Carnegie the
55db2b0adeStakemura  * rights to redistribute these changes.
56db2b0adeStakemura  */
57db2b0adeStakemura 
580c82163cSlukem #include <sys/cdefs.h>
59*42362de5Sriastradh __KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.19 2022/03/03 06:27:03 riastradh Exp $");
600c82163cSlukem 
61db2b0adeStakemura #include <sys/param.h>
62db2b0adeStakemura #include <sys/systm.h>
63fb1e16b4Sad #include <sys/device.h>
640351e901Smatt #include <sys/cpu.h>
65fb1e16b4Sad #include <sys/bus.h>
66db2b0adeStakemura 
67b543d3edStsutsui #include <mips/locore.h>
68b543d3edStsutsui 
696a9bbffcSuch #include <machine/sysconf.h>
70db2b0adeStakemura #include <machine/autoconf.h>
71db2b0adeStakemura 
72db2b0adeStakemura /* Definition of the driver for autoconfig. */
730351e901Smatt static int	cpumatch(device_t, cfdata_t, void *);
740351e901Smatt static void	cpuattach(device_t, device_t, void *);
75db2b0adeStakemura 
760351e901Smatt CFATTACH_DECL_NEW(cpu, 0,
77c5e91d44Sthorpej     cpumatch, cpuattach, NULL, NULL);
78db2b0adeStakemura 
79db2b0adeStakemura extern struct cfdriver cpu_cd;
80db2b0adeStakemura 
81db2b0adeStakemura static int
cpumatch(device_t parent,cfdata_t cf,void * aux)820351e901Smatt cpumatch(device_t parent, cfdata_t cf, void *aux)
83db2b0adeStakemura {
84db2b0adeStakemura 	struct mainbus_attach_args *ma = aux;
85db2b0adeStakemura 
86db2b0adeStakemura 	/* make sure that we're looking for a CPU. */
876a9bbffcSuch 	return (strcmp(ma->ma_name, cpu_cd.cd_name) != 0 ? 0 : 1);
88db2b0adeStakemura }
89db2b0adeStakemura 
90db2b0adeStakemura static void
cpuattach(device_t parent,device_t self,void * aux)910351e901Smatt cpuattach(device_t parent, device_t self, void *aux)
92db2b0adeStakemura {
930351e901Smatt 	struct cpu_info * const ci = curcpu();
94db2b0adeStakemura 
950351e901Smatt 	ci->ci_dev = self;
96*42362de5Sriastradh 	device_set_private(self, ci);
97db2b0adeStakemura 
980351e901Smatt 	aprint_normal(": ");
990351e901Smatt 
1000351e901Smatt 	cpu_identify(self);
101ae6160e2Stakemura 
1026a9bbffcSuch 	/* install CPU specific idle routine if any. */
1036a9bbffcSuch 	if (platform.cpu_idle != NULL)
104290a34a0Smatt 		mips_locoresw.lsw_cpu_idle = platform.cpu_idle;
105db2b0adeStakemura }
106