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 * Copyright (c) 1992, 1994, 1998 by Sun Microsystems, Inc. 24 * All rights reserved. 25 */ 26 27 #ident "%Z%%M% %I% %E% SMI" 28 29 #include <sys/types.h> 30 #include <sys/param.h> 31 #include <sys/var.h> 32 #include <sys/thread.h> 33 #include <sys/cpuvar.h> 34 #include <sys/kstat.h> 35 #include <sys/uadmin.h> 36 #include <sys/systm.h> 37 #include <sys/errno.h> 38 #include <sys/cmn_err.h> 39 #include <sys/procset.h> 40 #include <sys/processor.h> 41 #include <sys/debug.h> 42 43 /* 44 * processor_info(2) - return information on a processor. 45 */ 46 int 47 processor_info(processorid_t cpun, processor_info_t *infop) 48 { 49 cpu_t *cp; 50 processor_info_t temp; 51 52 mutex_enter(&cpu_lock); 53 if ((cp = cpu_get(cpun)) == NULL) { 54 mutex_exit(&cpu_lock); 55 return (set_errno(EINVAL)); 56 } 57 bcopy(&cp->cpu_type_info, &temp, sizeof (temp)); 58 mutex_exit(&cpu_lock); 59 60 /* 61 * The spec indicates that the rest of the information is meaningless 62 * if the CPU is offline, but if presented by the machine-dependent 63 * layer, it is probably still accurate. It seems OK to copy it all in 64 * either case. 65 */ 66 if (copyout((caddr_t)&temp, (caddr_t)infop, 67 sizeof (processor_info_t))) 68 return (set_errno(EFAULT)); 69 70 return (0); 71 } 72