]> git.saurik.com Git - apple/xnu.git/blame - osfmk/kern/ledger.h
xnu-792.25.20.tar.gz
[apple/xnu.git] / osfmk / kern / ledger.h
CommitLineData
1c79356b 1/*
91447636 2 * Copyright (c) 2000-2004 Apple Computer, Inc. All rights reserved.
1c79356b 3 *
6601e61a 4 * @APPLE_LICENSE_HEADER_START@
1c79356b 5 *
6601e61a
A
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.
8f6c56a5 11 *
6601e61a
A
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
8f6c56a5
A
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
6601e61a
A
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.
8f6c56a5 19 *
6601e61a 20 * @APPLE_LICENSE_HEADER_END@
1c79356b
A
21 */
22/*
23 * @OSF_COPYRIGHT@
24 */
91447636
A
25
26#ifdef MACH_KERNEL_PRIVATE
27
1c79356b
A
28#ifndef _KERN_LEDGER_H_
29#define _KERN_LEDGER_H_
30
1c79356b 31#include <mach/mach_types.h>
9bccf70c 32
91447636 33#include <kern/kern_types.h>
9bccf70c 34#include <kern/lock.h>
91447636 35#include <ipc/ipc_types.h>
1c79356b
A
36
37struct 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
47typedef struct ledger ledger_data_t;
48
1c79356b
A
49#define ledger_lock(ledger) simple_lock(&(ledger)->lock)
50#define ledger_unlock(ledger) simple_unlock(&(ledger)->lock)
51#define ledger_lock_init(ledger) \
91447636 52 simple_lock_init(&(ledger)->lock, 0)
1c79356b
A
53
54extern ledger_t root_wired_ledger;
55extern 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
9bccf70c
A
60extern void ledger_init(void);
61
1c79356b
A
62extern ipc_port_t ledger_copy(ledger_t);
63
64extern kern_return_t ledger_enter(ledger_t, ledger_item_t);
9bccf70c 65
9bccf70c
A
66extern ledger_t convert_port_to_ledger(ipc_port_t);
67
68extern ipc_port_t convert_ledger_to_port(ledger_t);
1c79356b
A
69
70#endif /* _KERN_LEDGER_H_ */
91447636
A
71
72#endif /* MACH_KERNEL_PRIVATE */