1 /* $NetBSD: cpu.c,v 1.19 2022/03/03 06:27:03 riastradh Exp $ */ 2 /*- 3 * Copyright (c) 1999 Shin Takemura, All rights reserved. 4 * Copyright (c) 1999-2001 SATO Kazumi, All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: 9 * 1. Redistributions of source code must retain the above copyright 10 * notice, this list of conditions and the following disclaimer. 11 * 2. Redistributions in binary form must reproduce the above copyright 12 * notice, this list of conditions and the following disclaimer in the 13 * documentation and/or other materials provided with the distribution. 14 * 3. The name of the author may not be used to endorse or promote products 15 * derived from this software without specific prior written permission. 16 * 17 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * SUCH DAMAGE. 28 * 29 */ 30 31 /* 32 * Copyright (c) 1994, 1995 Carnegie-Mellon University. 33 * All rights reserved. 34 * 35 * Author: Chris G. Demetriou 36 * 37 * Permission to use, copy, modify and distribute this software and 38 * its documentation is hereby granted, provided that both the copyright 39 * notice and this permission notice appear in all copies of the 40 * software, derivative works or modified versions, and any portions 41 * thereof, and that both notices appear in supporting documentation. 42 * 43 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" 44 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND 45 * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. 46 * 47 * Carnegie Mellon requests users of this software to return to 48 * 49 * Software Distribution Coordinator or Software.Distribution (at) CS.CMU.EDU 50 * School of Computer Science 51 * Carnegie Mellon University 52 * Pittsburgh PA 15213-3890 53 * 54 * any improvements or extensions that they make and grant Carnegie the 55 * rights to redistribute these changes. 56 */ 57 58 #include <sys/cdefs.h> 59 __KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.19 2022/03/03 06:27:03 riastradh Exp $"); 60 61 #include <sys/param.h> 62 #include <sys/systm.h> 63 #include <sys/device.h> 64 #include <sys/cpu.h> 65 #include <sys/bus.h> 66 67 #include <mips/locore.h> 68 69 #include <machine/sysconf.h> 70 #include <machine/autoconf.h> 71 72 /* Definition of the driver for autoconfig. */ 73 static int cpumatch(device_t, cfdata_t, void *); 74 static void cpuattach(device_t, device_t, void *); 75 76 CFATTACH_DECL_NEW(cpu, 0, 77 cpumatch, cpuattach, NULL, NULL); 78 79 extern struct cfdriver cpu_cd; 80 81 static int 82 cpumatch(device_t parent, cfdata_t cf, void *aux) 83 { 84 struct mainbus_attach_args *ma = aux; 85 86 /* make sure that we're looking for a CPU. */ 87 return (strcmp(ma->ma_name, cpu_cd.cd_name) != 0 ? 0 : 1); 88 } 89 90 static void 91 cpuattach(device_t parent, device_t self, void *aux) 92 { 93 struct cpu_info * const ci = curcpu(); 94 95 ci->ci_dev = self; 96 device_set_private(self, ci); 97 98 aprint_normal(": "); 99 100 cpu_identify(self); 101 102 /* install CPU specific idle routine if any. */ 103 if (platform.cpu_idle != NULL) 104 mips_locoresw.lsw_cpu_idle = platform.cpu_idle; 105 } 106