]>
Commit | Line | Data |
---|---|---|
1c79356b A |
1 | /* |
2 | * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. | |
3 | * | |
4 | * @APPLE_LICENSE_HEADER_START@ | |
5 | * | |
43866e37 | 6 | * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. |
1c79356b | 7 | * |
43866e37 A |
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 | |
1c79356b A |
17 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, |
18 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
43866e37 A |
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. | |
1c79356b A |
22 | * |
23 | * @APPLE_LICENSE_HEADER_END@ | |
24 | */ | |
25 | /* | |
26 | * @OSF_COPYRIGHT@ | |
27 | */ | |
28 | #ifndef _KERN_LEDGER_H_ | |
29 | #define _KERN_LEDGER_H_ | |
30 | ||
9bccf70c | 31 | |
1c79356b | 32 | #include <mach/mach_types.h> |
9bccf70c A |
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> | |
1c79356b A |
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 | ||
1c79356b A |
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 | ||
9bccf70c A |
69 | extern void ledger_init(void); |
70 | ||
1c79356b A |
71 | extern ipc_port_t ledger_copy(ledger_t); |
72 | ||
73 | extern kern_return_t ledger_enter(ledger_t, ledger_item_t); | |
9bccf70c A |
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); | |
1c79356b A |
82 | |
83 | #endif /* _KERN_LEDGER_H_ */ |