]>
Commit | Line | Data |
---|---|---|
91447636 | 1 | /* |
2d21ac55 | 2 | * Copyright (c) 2003-2007 Apple Inc. All rights reserved. |
91447636 | 3 | * |
2d21ac55 | 4 | * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ |
91447636 | 5 | * |
2d21ac55 A |
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. | |
8f6c56a5 | 14 | * |
2d21ac55 A |
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 | |
8f6c56a5 A |
20 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, |
21 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
2d21ac55 A |
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. | |
8f6c56a5 | 25 | * |
2d21ac55 | 26 | * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ |
91447636 A |
27 | */ |
28 | #ifndef _I386_CPU_THREADS_H_ | |
29 | #define _I386_CPU_THREADS_H_ | |
30 | ||
91447636 | 31 | #include <i386/cpu_data.h> |
2d21ac55 A |
32 | #include <i386/mp.h> |
33 | #include <i386/cpu_topology.h> | |
91447636 | 34 | |
2d21ac55 A |
35 | /* |
36 | * These are defined here rather than in cpu_topology.h so as to keep | |
37 | * cpu_topology.h from having a dependency on cpu_data.h. | |
38 | */ | |
91447636 A |
39 | #define CPU_THREAD_MASK 0x00000001 |
40 | #define cpu_to_core_lapic(cpu) (cpu_to_lapic[cpu] & ~CPU_THREAD_MASK) | |
41 | #define cpu_to_core_cpu(cpu) (lapic_to_cpu[cpu_to_core_lapic(cpu)]) | |
42 | #define cpu_to_logical_cpu(cpu) (cpu_to_lapic[cpu] & CPU_THREAD_MASK) | |
43 | #define cpu_is_core_cpu(cpu) (cpu_to_logical_cpu(cpu) == 0) | |
44 | ||
2d21ac55 A |
45 | #define cpu_to_lcpu(cpu) (&cpu_datap(cpu)->lcpu) |
46 | #define cpu_to_core(cpu) (cpu_to_lcpu(cpu)->core) | |
47 | #define cpu_to_package(cpu) (cpu_to_core(cpu)->package) | |
91447636 A |
48 | |
49 | /* Fast access: */ | |
2d21ac55 A |
50 | #define x86_lcpu() (¤t_cpu_datap()->lcpu) |
51 | #define x86_core() (x86_lcpu()->core) | |
52 | #define x86_package() (x86_core()->package) | |
91447636 A |
53 | |
54 | #define cpu_is_same_core(cpu1,cpu2) (cpu_to_core(cpu1) == cpu_to_core(cpu2)) | |
2d21ac55 A |
55 | #define cpu_is_same_package(cpu1,cpu2) (cpu_to_package(cpu1) == cpu_to_package(cpu2)) |
56 | #define cpus_share_cache(cpu1,cpu2,_cl) (cpu_to_lcpu(cpu1)->caches[_cl] == cpu_to_lcpu(cpu2)->caches[_cl]) | |
57 | ||
58 | extern decl_simple_lock_data(, x86_topo_lock); | |
91447636 | 59 | |
0c530ab8 | 60 | extern void *cpu_thread_alloc(int); |
91447636 A |
61 | extern void cpu_thread_init(void); |
62 | extern void cpu_thread_halt(void); | |
63 | ||
91447636 | 64 | #endif /* _I386_CPU_THREADS_H_ */ |