1*5e3eaea3SApple OSS Distributions /*
2*5e3eaea3SApple OSS Distributions * Copyright (c) 2012 Apple Inc. All rights reserved.
3*5e3eaea3SApple OSS Distributions *
4*5e3eaea3SApple OSS Distributions * @APPLE_LICENSE_HEADER_START@
5*5e3eaea3SApple OSS Distributions *
6*5e3eaea3SApple OSS Distributions * This file contains Original Code and/or Modifications of Original Code
7*5e3eaea3SApple OSS Distributions * as defined in and that are subject to the Apple Public Source License
8*5e3eaea3SApple OSS Distributions * Version 2.0 (the 'License'). You may not use this file except in
9*5e3eaea3SApple OSS Distributions * compliance with the License. Please obtain a copy of the License at
10*5e3eaea3SApple OSS Distributions * http://www.opensource.apple.com/apsl/ and read it before using this
11*5e3eaea3SApple OSS Distributions * file.
12*5e3eaea3SApple OSS Distributions *
13*5e3eaea3SApple OSS Distributions * The Original Code and all software distributed under the License are
14*5e3eaea3SApple OSS Distributions * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15*5e3eaea3SApple OSS Distributions * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16*5e3eaea3SApple OSS Distributions * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17*5e3eaea3SApple OSS Distributions * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18*5e3eaea3SApple OSS Distributions * Please see the License for the specific language governing rights and
19*5e3eaea3SApple OSS Distributions * limitations under the License.
20*5e3eaea3SApple OSS Distributions *
21*5e3eaea3SApple OSS Distributions * @APPLE_LICENSE_HEADER_END@
22*5e3eaea3SApple OSS Distributions */
23*5e3eaea3SApple OSS Distributions #include <sys/cdefs.h>
24*5e3eaea3SApple OSS Distributions #include <sys/types.h>
25*5e3eaea3SApple OSS Distributions #include <stdarg.h>
26*5e3eaea3SApple OSS Distributions #include <stdint.h>
27*5e3eaea3SApple OSS Distributions #include <sys/fcntl.h>
28*5e3eaea3SApple OSS Distributions #include <sys/coalition.h>
29*5e3eaea3SApple OSS Distributions
30*5e3eaea3SApple OSS Distributions /* Syscall entry points */
31*5e3eaea3SApple OSS Distributions int __coalition(uint32_t operation, uint64_t *cid, uint32_t flags);
32*5e3eaea3SApple OSS Distributions int __coalition_info(uint32_t operation, uint64_t *cid, void *buffer, size_t *bufsize);
33*5e3eaea3SApple OSS Distributions int __coalition_ledger(uint32_t operation, uint64_t *cid, void *buffer, size_t *bufsize);
34*5e3eaea3SApple OSS Distributions
35*5e3eaea3SApple OSS Distributions int
coalition_create(uint64_t * cid_out,uint32_t flags)36*5e3eaea3SApple OSS Distributions coalition_create(uint64_t *cid_out, uint32_t flags)
37*5e3eaea3SApple OSS Distributions {
38*5e3eaea3SApple OSS Distributions return __coalition(COALITION_OP_CREATE, cid_out, flags);
39*5e3eaea3SApple OSS Distributions }
40*5e3eaea3SApple OSS Distributions
41*5e3eaea3SApple OSS Distributions int
coalition_terminate(uint64_t cid,uint32_t flags)42*5e3eaea3SApple OSS Distributions coalition_terminate(uint64_t cid, uint32_t flags)
43*5e3eaea3SApple OSS Distributions {
44*5e3eaea3SApple OSS Distributions return __coalition(COALITION_OP_TERMINATE, &cid, flags);
45*5e3eaea3SApple OSS Distributions }
46*5e3eaea3SApple OSS Distributions
47*5e3eaea3SApple OSS Distributions int
coalition_reap(uint64_t cid,uint32_t flags)48*5e3eaea3SApple OSS Distributions coalition_reap(uint64_t cid, uint32_t flags)
49*5e3eaea3SApple OSS Distributions {
50*5e3eaea3SApple OSS Distributions return __coalition(COALITION_OP_REAP, &cid, flags);
51*5e3eaea3SApple OSS Distributions }
52*5e3eaea3SApple OSS Distributions
53*5e3eaea3SApple OSS Distributions int
coalition_info_resource_usage(uint64_t cid,struct coalition_resource_usage * cru,size_t sz)54*5e3eaea3SApple OSS Distributions coalition_info_resource_usage(uint64_t cid, struct coalition_resource_usage *cru, size_t sz)
55*5e3eaea3SApple OSS Distributions {
56*5e3eaea3SApple OSS Distributions return __coalition_info(COALITION_INFO_RESOURCE_USAGE, &cid, cru, &sz);
57*5e3eaea3SApple OSS Distributions }
58*5e3eaea3SApple OSS Distributions
59*5e3eaea3SApple OSS Distributions int
coalition_info_debug_info(uint64_t cid,struct coalinfo_debuginfo * cru,size_t sz)60*5e3eaea3SApple OSS Distributions coalition_info_debug_info(uint64_t cid, struct coalinfo_debuginfo *cru, size_t sz)
61*5e3eaea3SApple OSS Distributions {
62*5e3eaea3SApple OSS Distributions return __coalition_info(COALITION_INFO_GET_DEBUG_INFO, &cid, cru, &sz);
63*5e3eaea3SApple OSS Distributions }
64*5e3eaea3SApple OSS Distributions
65*5e3eaea3SApple OSS Distributions int
coalition_info_set_name(uint64_t cid,const char * name,size_t size)66*5e3eaea3SApple OSS Distributions coalition_info_set_name(uint64_t cid, const char *name, size_t size)
67*5e3eaea3SApple OSS Distributions {
68*5e3eaea3SApple OSS Distributions return __coalition_info(COALITION_INFO_SET_NAME, &cid, (void *)name, &size);
69*5e3eaea3SApple OSS Distributions }
70*5e3eaea3SApple OSS Distributions
71*5e3eaea3SApple OSS Distributions int
coalition_info_set_efficiency(uint64_t cid,uint64_t flags)72*5e3eaea3SApple OSS Distributions coalition_info_set_efficiency(uint64_t cid, uint64_t flags)
73*5e3eaea3SApple OSS Distributions {
74*5e3eaea3SApple OSS Distributions size_t size = sizeof(flags);
75*5e3eaea3SApple OSS Distributions return __coalition_info(COALITION_INFO_SET_EFFICIENCY, &cid, (void *)&flags, &size);
76*5e3eaea3SApple OSS Distributions }
77*5e3eaea3SApple OSS Distributions
78*5e3eaea3SApple OSS Distributions int
coalition_ledger_set_logical_writes_limit(uint64_t cid,int64_t limit)79*5e3eaea3SApple OSS Distributions coalition_ledger_set_logical_writes_limit(uint64_t cid, int64_t limit)
80*5e3eaea3SApple OSS Distributions {
81*5e3eaea3SApple OSS Distributions size_t size = sizeof(limit);
82*5e3eaea3SApple OSS Distributions return __coalition_ledger(COALITION_LEDGER_SET_LOGICAL_WRITES_LIMIT, &cid, (void *)&limit, &size);
83*5e3eaea3SApple OSS Distributions }
84