]> git.saurik.com Git - apple/xnu.git/blob - osfmk/i386/cpu_threads.h
xnu-792.tar.gz
[apple/xnu.git] / osfmk / i386 / cpu_threads.h
1 /*
2 * Copyright (c) 2003 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * The contents of this file constitute Original Code as defined in and
7 * are subject to the Apple Public Source License Version 1.1 (the
8 * "License"). You may not use this file except in compliance with the
9 * License. Please obtain a copy of the License at
10 * http://www.apple.com/publicsource and read it before using this file.
11 *
12 * This Original Code and all software distributed under the License are
13 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
17 * License for the specific language governing rights and limitations
18 * under the License.
19 *
20 * @APPLE_LICENSE_HEADER_END@
21 */
22 #ifndef _I386_CPU_THREADS_H_
23 #define _I386_CPU_THREADS_H_
24
25 #include <i386/mp.h>
26 #include <i386/cpu_data.h>
27
28 struct pmc;
29
30 typedef struct {
31 int base_cpu; /* Number of the cpu first in core */
32 int num_threads; /* Number of threads (logical cpus) */
33 int active_threads; /* Number of non-halted thredas */
34 struct pmc *pmc; /* Pointer to perfmon data */
35 } cpu_core_t;
36
37 #define CPU_THREAD_MASK 0x00000001
38 #define cpu_to_core_lapic(cpu) (cpu_to_lapic[cpu] & ~CPU_THREAD_MASK)
39 #define cpu_to_core_cpu(cpu) (lapic_to_cpu[cpu_to_core_lapic(cpu)])
40 #define cpu_to_logical_cpu(cpu) (cpu_to_lapic[cpu] & CPU_THREAD_MASK)
41 #define cpu_is_core_cpu(cpu) (cpu_to_logical_cpu(cpu) == 0)
42
43 #define cpu_to_core(cpu) (cpu_datap(cpu)->cpu_core)
44
45 /* Fast access: */
46 #define cpu_core() ((cpu_core_t *) get_cpu_core())
47
48 #define cpu_is_same_core(cpu1,cpu2) (cpu_to_core(cpu1) == cpu_to_core(cpu2))
49
50 extern void cpu_thread_init(void);
51 extern void cpu_thread_halt(void);
52
53 extern int idlehalt;
54
55 extern int ncore;
56 #endif /* _I386_CPU_THREADS_H_ */