]> git.saurik.com Git - apple/xnu.git/blame - osfmk/i386/cpu_topology.h
xnu-1228.7.58.tar.gz
[apple/xnu.git] / osfmk / i386 / cpu_topology.h
CommitLineData
2d21ac55
A
1/*
2 * Copyright (c) 2003-2007 Apple Inc. All rights reserved.
3 *
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
5 *
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. The rights granted to you under the License
10 * may not be used to create, or enable the creation or redistribution of,
11 * unlawful or unlicensed copies of an Apple operating system, or to
12 * circumvent, violate, or enable the circumvention or violation of, any
13 * terms of an Apple operating system software license agreement.
14 *
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
17 *
18 * The Original Code and all software distributed under the License are
19 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 * Please see the License for the specific language governing rights and
24 * limitations under the License.
25 *
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
27 */
28#ifdef KERNEL_PRIVATE
29#ifndef _I386_CPU_TOPOLOGY_H_
30#define _I386_CPU_TOPOLOGY_H_
31
32/*
33 * This was originally part of cpu_threads.h. It was split out so that
34 * these structures could be referenced without pulling in all of the headers
35 * required for the definition of cpu_data. These data structures are
36 * used by KEXTs in order to deal with the physical topology.
37 *
38 * NOTE: this header must stand on its own as much as possible
39 * and not be dependent upon any unexported, kernel-private header.
40 */
41
42/*
43 * Cache structure that can be used to identify the cache heirarchy.
44 */
45typedef struct x86_cpu_cache
46{
47 struct x86_cpu_cache *next; /* next cache at this level/lcpu */
48 uint8_t maxcpus; /* maximum # of cpus that can share */
49 uint8_t nlcpus; /* # of logical cpus sharing this cache */
50 uint8_t type; /* type of cache */
51 uint8_t level; /* level of cache */
52 uint16_t ways; /* # of ways in cache */
53 uint16_t partitions; /* # of partitions in cache */
54 uint16_t line_size; /* size of a cache line */
55 uint32_t cache_size; /* total size of cache */
56 struct x86_lcpu *cpus[0]; /* cpus sharing this cache */
57} x86_cpu_cache_t;
58
59#define CPU_CACHE_TYPE_DATA 1 /* data cache */
60#define CPU_CACHE_TYPE_INST 2 /* instruction cache */
61#define CPU_CACHE_TYPE_UNIF 3 /* unified cache */
62
63#define CPU_CACHE_DEPTH_L1 0
64#define CPU_CACHE_DEPTH_L2 1
65#define CPU_CACHE_DEPTH_L3 2
66
67#define MAX_CACHE_DEPTH 3 /* deepest cache */
68
69struct pmc;
70struct cpu_data;
71
72typedef struct x86_lcpu
73{
74 struct x86_lcpu *next; /* next logical cpu in core */
75 struct x86_lcpu *lcpu; /* pointer back to self */
76 struct x86_core *core; /* core containing the logical cpu */
77 struct cpu_data *cpu; /* cpu_data structure */
78 uint32_t lnum; /* logical cpu number */
79 uint32_t pnum; /* physical cpu number */
80 boolean_t master; /* logical cpu is the master (boot) CPU */
81 boolean_t primary;/* logical cpu is primary CPU in package */
82 boolean_t halted; /* logical cpu is halted */
83 boolean_t idle; /* logical cpu is idle */
84 uint64_t rtcPop; /* when etimer wants a timer pop */
85 uint64_t rtcDeadline;
86 x86_cpu_cache_t *caches[MAX_CACHE_DEPTH];
87} x86_lcpu_t;
88
89#define X86CORE_FL_PRESENT 0x80000000 /* core is present */
90#define X86CORE_FL_READY 0x40000000 /* core struct is init'd */
91#define X86CORE_FL_HALTED 0x00008000 /* core is halted */
92#define X86CORE_FL_IDLE 0x00004000 /* core is idle */
93
94typedef struct x86_core
95{
96 struct x86_core *next; /* next core in package */
97 struct x86_lcpu *lcpus; /* list of logical cpus in core */
98 struct x86_pkg *package; /* package containing core */
99 uint32_t flags;
100 uint32_t lcore_num; /* logical core # (unique to package) */
101 uint32_t pcore_num; /* physical core # (globally unique) */
102 uint32_t num_lcpus; /* Number of logical cpus */
103 uint32_t active_lcpus; /* Number of non-halted cpus */
104 struct pmc *pmc; /* Pointer to perfmon data */
105 struct hpetTimer *Hpet; /* Address of the HPET for this core */
106 uint32_t HpetVec; /* Interrupt vector for HPET */
107 uint64_t HpetInt; /* Number of HPET Interrupts */
108 uint64_t HpetCmp; /* HPET Comparitor */
109 uint64_t HpetCfg; /* HPET configuration */
110 uint64_t HpetTime;
111 void *pmStats; /* Power management stats for core */
112 void *pmState; /* Power management state for core */
113} x86_core_t;
114
115#define X86PKG_FL_PRESENT 0x80000000 /* package is present */
116#define X86PKG_FL_READY 0x40000000 /* package struct init'd */
117#define X86PKG_FL_HAS_HPET 0x10000000 /* package has HPET assigned */
118#define X86PKG_FL_HALTED 0x00008000 /* package is halted */
119#define X86PKG_FL_IDLE 0x00004000 /* package is idle */
120
121typedef struct x86_pkg
122{
123 struct x86_pkg *next; /* next package */
124 struct x86_core *cores; /* list of cores in package */
125 uint32_t flags;
126 uint32_t lpkg_num; /* logical package # */
127 uint32_t ppkg_num; /* physical package # */
128 uint32_t num_cores; /* number of cores in package */
129 struct hpetTimer *Hpet; /* address of HPET for this package */
130 uint32_t HpetVec; /* Interrupt vector for HPET */
131 uint64_t HpetInt; /* Number of HPET interrupts */
132 uint64_t HpetCmp; /* HPET comparitor */
133 uint64_t HpetCfg; /* HPET configuration */
134 uint64_t HpetTime;
135 void *pmStats; /* Power Management stats for package*/
136 void *pmState; /* Power Management state for package*/
137} x86_pkg_t;
138
139extern x86_pkg_t *x86_pkgs; /* root of all CPU packages */
140
141/* Called after cpu discovery */
142extern void cpu_topology_start(void);
143
144extern int idlehalt;
145
146#endif /* _I386_CPU_TOPOLOGY_H_ */
147#endif /* KERNEL_PRIVATE */