/*
- * Copyright (c) 2003 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 2003-2007 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
#ifndef _I386_CPU_THREADS_H_
#define _I386_CPU_THREADS_H_
-#include <i386/mp.h>
#include <i386/cpu_data.h>
+#include <i386/mp.h>
+#include <i386/cpu_topology.h>
-struct pmc;
-
-typedef struct {
- int base_cpu; /* Number of the cpu first in core */
- int num_threads; /* Number of threads (logical cpus) */
- int active_threads; /* Number of non-halted thredas */
- struct pmc *pmc; /* Pointer to perfmon data */
-} cpu_core_t;
-
+/*
+ * These are defined here rather than in cpu_topology.h so as to keep
+ * cpu_topology.h from having a dependency on cpu_data.h.
+ */
#define CPU_THREAD_MASK 0x00000001
#define cpu_to_core_lapic(cpu) (cpu_to_lapic[cpu] & ~CPU_THREAD_MASK)
#define cpu_to_core_cpu(cpu) (lapic_to_cpu[cpu_to_core_lapic(cpu)])
#define cpu_to_logical_cpu(cpu) (cpu_to_lapic[cpu] & CPU_THREAD_MASK)
#define cpu_is_core_cpu(cpu) (cpu_to_logical_cpu(cpu) == 0)
-#define cpu_to_core(cpu) (cpu_datap(cpu)->cpu_core)
+#define cpu_to_lcpu(cpu) (&cpu_datap(cpu)->lcpu)
+#define cpu_to_core(cpu) (cpu_to_lcpu(cpu)->core)
+#define cpu_to_package(cpu) (cpu_to_core(cpu)->package)
/* Fast access: */
-#define cpu_core() ((cpu_core_t *) get_cpu_core())
+#define x86_lcpu() (¤t_cpu_datap()->lcpu)
+#define x86_core() (x86_lcpu()->core)
+#define x86_package() (x86_core()->package)
#define cpu_is_same_core(cpu1,cpu2) (cpu_to_core(cpu1) == cpu_to_core(cpu2))
+#define cpu_is_same_package(cpu1,cpu2) (cpu_to_package(cpu1) == cpu_to_package(cpu2))
+#define cpus_share_cache(cpu1,cpu2,_cl) (cpu_to_lcpu(cpu1)->caches[_cl] == cpu_to_lcpu(cpu2)->caches[_cl])
+extern decl_simple_lock_data(, x86_topo_lock);
+
+extern void *cpu_thread_alloc(int);
extern void cpu_thread_init(void);
extern void cpu_thread_halt(void);
-extern int idlehalt;
-
-extern int ncore;
#endif /* _I386_CPU_THREADS_H_ */