2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
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.
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
20 * @APPLE_LICENSE_HEADER_END@
25 #ifndef _KERN_LEDGER_H_
26 #define _KERN_LEDGER_H_
29 #include <mach/mach_types.h>
30 #include <ipc/ipc_port.h>
32 #include <sys/appleapiopts.h>
34 #ifdef __APPLE_API_PRIVATE
36 #ifdef MACH_KERNEL_PRIVATE
38 #include <kern/lock.h>
39 #include <mach/etap_events.h>
41 #define LEDGER_ITEM_INFINITY (~0)
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
)
53 typedef struct ledger ledger_data_t
;
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)
60 extern ledger_t root_wired_ledger
;
61 extern ledger_t root_paged_ledger
;
63 #define root_wired_ledger_port root_wired_ledger->ledger_self
64 #define root_paged_ledger_port root_paged_ledger->ledger_self
66 extern void ledger_init(void);
68 extern ipc_port_t
ledger_copy(ledger_t
);
70 extern kern_return_t
ledger_enter(ledger_t
, ledger_item_t
);
72 #endif /* MACH_KERNEL_PRIVATE */
74 #endif /* __APPLE_API_PRIVATE */
76 extern ledger_t
convert_port_to_ledger(ipc_port_t
);
78 extern ipc_port_t
convert_ledger_to_port(ledger_t
);
80 #endif /* _KERN_LEDGER_H_ */