* Copyright (c) 2012 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
- *
+ *
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
- *
+ *
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
- *
+ *
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
- *
+ *
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
-#ifndef __KERN_KPC_H__
-#define __KERN_KPC_H__
+#ifndef KERN_KPC_H
+#define KERN_KPC_H
/* Kernel interfaces to KPC PMC infrastructure. */
#include <machine/machine_kpc.h>
#include <kern/thread.h> /* thread_* */
+__BEGIN_DECLS
+
/* cross-platform class constants */
#define KPC_CLASS_FIXED (0)
#define KPC_CLASS_CONFIGURABLE (1)
*/
struct cpu_data;
extern boolean_t kpc_register_cpu(struct cpu_data *cpu_data);
+extern void kpc_unregister_cpu(struct cpu_data *cpu_data);
/* bootstrap */
extern void kpc_init(void);
/* AST callback for KPC */
extern void kpc_thread_ast_handler( thread_t thread );
-/* context switch accounting between two threads */
-extern void kpc_switch_context( thread_t old_thread, thread_t new_thread );
+#ifdef MACH_KERNEL_PRIVATE
+
+/* context switch callback for KPC */
+
+extern boolean_t kpc_off_cpu_active;
+
+extern void kpc_off_cpu_internal(thread_t thread);
+extern void kpc_off_cpu_update(void);
+
+static inline void
+kpc_off_cpu(thread_t thread)
+{
+ if (__improbable(kpc_off_cpu_active)) {
+ kpc_off_cpu_internal(thread);
+ }
+}
+
+#endif /* defined(MACH_KERNEL_PRIVATE) */
/* acquire/release the counters used by the Power Manager */
extern int kpc_force_all_ctrs( task_t task, int val );
*
* @param handler
* Notification callback to use when PMCs are acquired/released by a task.
+ * Power management must acknowledge the change using kpc_pm_acknowledge.
*
* @param pmc_mask
* Bitmask of the configurable PMCs used by the Power Manager. The number of bits
*/
extern void kpc_release_pm_counters(void);
+/*
+ * Acknowledge the callback that PMCs are available to power management.
+ *
+ * @param available_to_pm Whether the counters were made available to power
+ * management in the callback. Pass in whatever was passed into the handler
+ * function. After this point, power management is able to use POWER_CLASS
+ * counters.
+ */
+extern void kpc_pm_acknowledge(boolean_t available_to_pm);
+
/*
* Is the PMU used by both the power manager and userspace?
*
int (*set_period)(uint32_t classes, uint64_t *period);
};
-#endif /* __KERN_KPC_H__ */
+__END_DECLS
+
+#endif /* !definde(KERN_KPC_H) */