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