]> git.saurik.com Git - apple/xnu.git/blob - osfmk/kern/ledger.h
xnu-517.11.1.tar.gz
[apple/xnu.git] / osfmk / kern / ledger.h
1 /*
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * The contents of this file constitute Original Code as defined in and
7 * are subject to the Apple Public Source License Version 1.1 (the
8 * "License"). You may not use this file except in compliance with the
9 * License. Please obtain a copy of the License at
10 * http://www.apple.com/publicsource and read it before using this file.
11 *
12 * This Original Code and all software distributed under the License are
13 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
17 * License for the specific language governing rights and limitations
18 * under the License.
19 *
20 * @APPLE_LICENSE_HEADER_END@
21 */
22 /*
23 * @OSF_COPYRIGHT@
24 */
25 #ifndef _KERN_LEDGER_H_
26 #define _KERN_LEDGER_H_
27
28
29 #include <mach/mach_types.h>
30 #include <ipc/ipc_port.h>
31
32 #include <sys/appleapiopts.h>
33
34 #ifdef __APPLE_API_PRIVATE
35
36 #ifdef MACH_KERNEL_PRIVATE
37
38 #include <kern/lock.h>
39 #include <mach/etap_events.h>
40
41 #define LEDGER_ITEM_INFINITY (~0)
42
43 struct ledger {
44 ipc_port_t ledger_self;
45 ipc_port_t ledger_service_port;
46 ledger_item_t ledger_balance;
47 ledger_item_t ledger_limit;
48 struct ledger *ledger_ledger;
49 struct ledger *ledger_parent;
50 decl_simple_lock_data(,lock)
51 };
52
53 typedef struct ledger ledger_data_t;
54
55 #define ledger_lock(ledger) simple_lock(&(ledger)->lock)
56 #define ledger_unlock(ledger) simple_unlock(&(ledger)->lock)
57 #define ledger_lock_init(ledger) \
58 simple_lock_init(&(ledger)->lock, ETAP_MISC_LEDGER)
59
60 extern ledger_t root_wired_ledger;
61 extern ledger_t root_paged_ledger;
62
63 #define root_wired_ledger_port root_wired_ledger->ledger_self
64 #define root_paged_ledger_port root_paged_ledger->ledger_self
65
66 extern void ledger_init(void);
67
68 extern ipc_port_t ledger_copy(ledger_t);
69
70 extern kern_return_t ledger_enter(ledger_t, ledger_item_t);
71
72 #endif /* MACH_KERNEL_PRIVATE */
73
74 #endif /* __APPLE_API_PRIVATE */
75
76 extern ledger_t convert_port_to_ledger(ipc_port_t);
77
78 extern ipc_port_t convert_ledger_to_port(ledger_t);
79
80 #endif /* _KERN_LEDGER_H_ */