]> git.saurik.com Git - apple/xnu.git/blobdiff - osfmk/kern/coalition.h
xnu-3247.1.106.tar.gz
[apple/xnu.git] / osfmk / kern / coalition.h
index 1c996968849d5e00993771317919eaf39c6af238..0bd9d2d88c1207255e5d77c41a9d2fc9c912028b 100644 (file)
 #ifndef _KERN_COALITION_H_
 #define _KERN_COALITION_H_
 
+/* only kernel-private interfaces */
 #ifdef XNU_KERNEL_PRIVATE
+#include <mach/coalition.h>
 
-void coalition_init(void);
+#if CONFIG_COALITIONS
+
+void coalitions_init(void);
 
 /* These may return:
  * KERN_ALREADY_IN_SET task is already in a coalition (maybe this one, maybe a different one)
  * KERN_TERMINATED     coalition is already terminated (so it may not adopt any more tasks)
  */
-kern_return_t coalition_adopt_task(coalition_t coal, task_t task);
-kern_return_t coalition_default_adopt_task(task_t task);
+kern_return_t coalitions_adopt_task(coalition_t *coaltions, task_t task);
+kern_return_t coalitions_adopt_init_task(task_t task);
 
 /* Currently, no error conditions. If task is not already in a coalition,
  * KERN_SUCCESS is returned because removing it did not fail.
  */
-kern_return_t coalition_remove_task(task_t task);
+kern_return_t coalitions_remove_task(task_t task);
+void          task_release_coalitions(task_t task);
+
+/*
+ *
+ */
+kern_return_t coalitions_set_roles(coalition_t coalitions[COALITION_NUM_TYPES],
+                                  task_t task, int roles[COALITION_NUM_TYPES]);
 
 uint64_t coalition_id(coalition_t coal);
-uint64_t task_coalition_id(task_t task);
+void     task_coalition_ids(task_t task, uint64_t ids[COALITION_NUM_TYPES]);
+void     task_coalition_roles(task_t task, int roles[COALITION_NUM_TYPES]);
+int      coalition_type(coalition_t coal);
+
+void     task_coalition_update_gpu_stats(task_t task, uint64_t gpu_ns_delta);
+uint32_t task_coalition_adjust_focal_count(task_t task, int count);
+uint32_t task_coalition_focal_count(task_t task);
+uint32_t task_coalition_adjust_nonfocal_count(task_t task, int count);
+uint32_t task_coalition_nonfocal_count(task_t task);
+
+void coalition_for_each_task(coalition_t coal, void *ctx,
+                            void (*callback)(coalition_t, void *, task_t));
 
 /* Returns with a reference, or COALITION_NULL.
  * There is no coalition with id 0.
@@ -58,13 +80,6 @@ coalition_t coalition_find_by_id(uint64_t coal_id);
  */
 coalition_t coalition_find_and_activate_by_id(uint64_t coal_id);
 
-/* This may return:
- * KERN_TERMINATED     coalition is terminated
- * This will panic if the coalition is already reaped, which implies
- * that it wasn't active.
- */
-kern_return_t coalition_extend_active(coalition_t coal);
-
 void coalition_remove_active(coalition_t coal);
 
 void coalition_release(coalition_t coal);
@@ -94,35 +109,53 @@ kern_return_t coalition_request_terminate_internal(coalition_t coal);
  * KERN_RESOURCE_SHORTAGE      Unable to allocate kernel resources for a
  *                             new coalition.
  */
-kern_return_t coalition_create_internal(coalition_t *out, boolean_t privileged);
+kern_return_t coalition_create_internal(int type, boolean_t privileged, coalition_t *out);
 
 boolean_t coalition_is_privileged(coalition_t coal);
-boolean_t task_is_in_privileged_coalition(task_t task);
-
-/* This struct is also defined in bsd/sys/coalition.h. Keep in sync. */
-struct coalition_resource_usage {
-       uint64_t tasks_started;
-       uint64_t tasks_exited;
-       uint64_t time_nonempty;
-       uint64_t cpu_time;
-       uint64_t interrupt_wakeups;
-       uint64_t platform_idle_wakeups;
-       uint64_t bytesread;
-       uint64_t byteswritten;
-       uint64_t gpu_time;
-};
+boolean_t task_is_in_privileged_coalition(task_t task, int type);
 
 kern_return_t coalition_resource_usage_internal(coalition_t coal, struct coalition_resource_usage *cru_out);
 
-ledger_t coalition_get_ledger(coalition_t coal);
-
-uint32_t coalition_adjust_focal_task_count(coalition_t coal, int count);
-uint32_t coalition_focal_task_count(coalition_t coal);
-uint32_t coalition_adjust_non_focal_task_count(coalition_t coal, int count);
-uint32_t coalition_non_focal_task_count(coalition_t coal);
-
-void coalition_sfi_reevaluate(coalition_t coal, task_t updated_task);
-
+/*
+ * development/debug interfaces
+ */
+#if defined(DEVELOPMENT) || defined(DEBUG)
+int coalition_should_notify(coalition_t coal);
+void coalition_set_notify(coalition_t coal, int notify);
+#endif
+
+#else /* !CONFIG_COALITIONS */
+
+static inline void task_coalition_update_gpu_stats(__unused task_t task,
+                                                  __unused uint64_t gpu_ns_delta)
+{
+       return;
+}
+
+static inline uint32_t task_coalition_adjust_focal_count(__unused task_t task,
+                                                        __unused int count)
+{
+       return 0;
+}
+
+static inline uint32_t task_coalition_adjust_nonfocal_count(__unused task_t task,
+                                                           __unused int count)
+{
+       return 0;
+}
+
+static inline uint32_t task_coalition_focal_count(__unused task_t task)
+{
+       return 0;
+}
+
+static inline void coalition_for_each_task(__unused coalition_t coal,
+                                          __unused void *ctx,
+                                          __unused void (*callback)(coalition_t, void *, task_t))
+{
+       return;
+}
+
+#endif /* CONFIG_COALITIONS */
 #endif /* XNU_KERNEL_PRIVATE */
-
 #endif /* _KERN_COALITION_H */