1 /* $NetBSD: cpu_data.h,v 1.38 2014/09/05 05:45:34 matt Exp $ */ 2 3 /*- 4 * Copyright (c) 2004, 2006, 2007, 2008 The NetBSD Foundation, Inc. 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: 10 * 1. Redistributions of source code must retain the above copyright 11 * notice, this list of conditions and the following disclaimer. 12 * 2. Redistributions in binary form must reproduce the above copyright 13 * notice, this list of conditions and the following disclaimer in the 14 * documentation and/or other materials provided with the distribution. 15 * 16 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 17 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 18 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 19 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 20 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 * POSSIBILITY OF SUCH DAMAGE. 27 */ 28 29 /* 30 * based on arch/i386/include/cpu.h: 31 * NetBSD: cpu.h,v 1.115 2004/05/16 12:32:53 yamt Exp 32 */ 33 34 #ifndef _SYS_CPU_DATA_H_ 35 #define _SYS_CPU_DATA_H_ 36 37 struct callout; 38 struct lwp; 39 40 #include <sys/sched.h> /* for schedstate_percpu */ 41 #include <sys/condvar.h> 42 #include <sys/pcu.h> 43 #include <sys/percpu_types.h> 44 #include <sys/queue.h> 45 #include <sys/kcpuset.h> 46 #include <sys/ipi.h> 47 48 /* 49 * MI per-cpu data 50 * 51 * this structure is intended to be included in MD cpu_info structure. 52 * struct cpu_info { 53 * struct cpu_data ci_data; 54 * } 55 * 56 * note that cpu_data is not expected to contain much data, 57 * as cpu_info is size-limited on most ports. 58 */ 59 60 struct lockdebug; 61 62 struct cpu_data { 63 /* 64 * The first section is likely to be touched by other CPUs - 65 * it is cache hot. 66 */ 67 lwp_t *cpu_biglock_wanted; /* LWP spinning on biglock */ 68 void *cpu_callout; /* per-CPU callout state */ 69 void *cpu_unused1; /* unused */ 70 u_int cpu_unused2; /* unused */ 71 struct schedstate_percpu cpu_schedstate; /* scheduler state */ 72 kcondvar_t cpu_xcall; /* cross-call support */ 73 int cpu_xcall_pending; /* cross-call support */ 74 lwp_t *cpu_onproc; /* bottom level LWP */ 75 uint32_t cpu_ipipend[IPI_BITWORDS]; /* pending IPIs */ 76 77 cpuid_t cpu_package_id; 78 cpuid_t cpu_core_id; 79 cpuid_t cpu_smt_id; 80 81 struct lwp * volatile cpu_pcu_curlwp[PCU_UNIT_COUNT]; 82 83 /* 84 * This section is mostly CPU-private. 85 */ 86 lwp_t *cpu_idlelwp; /* idle lwp */ 87 void *cpu_lockstat; /* lockstat private tables */ 88 u_int cpu_index; /* CPU index */ 89 u_int cpu_biglock_count; /* # recursive holds */ 90 u_int cpu_spin_locks; /* # of spinlockmgr locks */ 91 u_int cpu_simple_locks; /* # of simple locks held */ 92 u_int cpu_spin_locks2; /* # of spin locks held XXX */ 93 u_int cpu_lkdebug_recurse; /* LOCKDEBUG recursion */ 94 u_int cpu_softints; /* pending (slow) softints */ 95 uint64_t cpu_nsyscall; /* syscall counter */ 96 uint64_t cpu_ntrap; /* trap counter */ 97 uint64_t cpu_nswtch; /* context switch counter */ 98 uint64_t cpu_nintr; /* interrupt count */ 99 uint64_t cpu_nsoft; /* soft interrupt count */ 100 uint64_t cpu_nfault; /* pagefault counter */ 101 struct uvm_cpu *cpu_uvm; /* uvm per-cpu data */ 102 void *cpu_softcpu; /* soft interrupt table */ 103 TAILQ_HEAD(,buf) cpu_biodone; /* finished block xfers */ 104 percpu_cpu_t cpu_percpu; /* per-cpu data */ 105 struct selcluster *cpu_selcluster; /* per-CPU select() info */ 106 void *cpu_nch; /* per-cpu vfs_cache data */ 107 _TAILQ_HEAD(,struct lockdebug,volatile) cpu_ld_locks;/* !: lockdebug */ 108 __cpu_simple_lock_t cpu_ld_lock; /* lockdebug */ 109 uint64_t cpu_cc_freq; /* cycle counter frequency */ 110 int64_t cpu_cc_skew; /* counter skew vs cpu0 */ 111 char cpu_name[8]; /* eg, "cpu4" */ 112 kcpuset_t *cpu_kcpuset; /* kcpuset_t of this cpu only */ 113 }; 114 115 /* compat definitions */ 116 #define ci_schedstate ci_data.cpu_schedstate 117 #define ci_index ci_data.cpu_index 118 #define ci_biglock_count ci_data.cpu_biglock_count 119 #define ci_biglock_wanted ci_data.cpu_biglock_wanted 120 #define ci_cpuname ci_data.cpu_name 121 #define ci_spin_locks ci_data.cpu_spin_locks 122 #define ci_simple_locks ci_data.cpu_simple_locks 123 #define ci_lockstat ci_data.cpu_lockstat 124 #define ci_spin_locks2 ci_data.cpu_spin_locks2 125 #define ci_lkdebug_recurse ci_data.cpu_lkdebug_recurse 126 #define ci_pcu_curlwp ci_data.cpu_pcu_curlwp 127 #define ci_kcpuset ci_data.cpu_kcpuset 128 #define ci_ipipend ci_data.cpu_ipipend 129 130 #define ci_package_id ci_data.cpu_package_id 131 #define ci_core_id ci_data.cpu_core_id 132 #define ci_smt_id ci_data.cpu_smt_id 133 134 void mi_cpu_init(void); 135 int mi_cpu_attach(struct cpu_info *); 136 137 #endif /* _SYS_CPU_DATA_H_ */ 138