2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
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
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.
23 * @APPLE_LICENSE_HEADER_END@
28 #ifndef _KERN_LEDGER_H_
29 #define _KERN_LEDGER_H_
32 #include <mach/mach_types.h>
33 #include <ipc/ipc_port.h>
35 #include <sys/appleapiopts.h>
37 #ifdef __APPLE_API_PRIVATE
39 #ifdef MACH_KERNEL_PRIVATE
41 #include <kern/lock.h>
42 #include <mach/etap_events.h>
44 #define LEDGER_ITEM_INFINITY (~0)
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
)
56 typedef struct ledger ledger_data_t
;
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)
63 extern ledger_t root_wired_ledger
;
64 extern ledger_t root_paged_ledger
;
66 #define root_wired_ledger_port root_wired_ledger->ledger_self
67 #define root_paged_ledger_port root_paged_ledger->ledger_self
69 extern void ledger_init(void);
71 extern ipc_port_t
ledger_copy(ledger_t
);
73 extern kern_return_t
ledger_enter(ledger_t
, ledger_item_t
);
75 #endif /* MACH_KERNEL_PRIVATE */
77 #endif /* __APPLE_API_PRIVATE */
79 extern ledger_t
convert_port_to_ledger(ipc_port_t
);
81 extern ipc_port_t
convert_ledger_to_port(ledger_t
);
83 #endif /* _KERN_LEDGER_H_ */