]> git.saurik.com Git - apple/xnu.git/blob - osfmk/kern/ledger.h
xnu-792.6.61.tar.gz
[apple/xnu.git] / osfmk / kern / ledger.h
1 /*
2 * Copyright (c) 2000-2004 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
26 #ifdef MACH_KERNEL_PRIVATE
27
28 #ifndef _KERN_LEDGER_H_
29 #define _KERN_LEDGER_H_
30
31 #include <mach/mach_types.h>
32
33 #include <kern/kern_types.h>
34 #include <kern/lock.h>
35 #include <ipc/ipc_types.h>
36
37 struct ledger {
38 ipc_port_t ledger_self;
39 ipc_port_t ledger_service_port;
40 ledger_item_t ledger_balance;
41 ledger_item_t ledger_limit;
42 struct ledger *ledger_ledger;
43 struct ledger *ledger_parent;
44 decl_simple_lock_data(,lock)
45 };
46
47 typedef struct ledger ledger_data_t;
48
49 #define ledger_lock(ledger) simple_lock(&(ledger)->lock)
50 #define ledger_unlock(ledger) simple_unlock(&(ledger)->lock)
51 #define ledger_lock_init(ledger) \
52 simple_lock_init(&(ledger)->lock, 0)
53
54 extern ledger_t root_wired_ledger;
55 extern ledger_t root_paged_ledger;
56
57 #define root_wired_ledger_port root_wired_ledger->ledger_self
58 #define root_paged_ledger_port root_paged_ledger->ledger_self
59
60 extern void ledger_init(void);
61
62 extern ipc_port_t ledger_copy(ledger_t);
63
64 extern kern_return_t ledger_enter(ledger_t, ledger_item_t);
65
66 extern ledger_t convert_port_to_ledger(ipc_port_t);
67
68 extern ipc_port_t convert_ledger_to_port(ledger_t);
69
70 #endif /* _KERN_LEDGER_H_ */
71
72 #endif /* MACH_KERNEL_PRIVATE */