]> git.saurik.com Git - apple/xnu.git/blame - osfmk/kern/ledger.h
xnu-517.11.1.tar.gz
[apple/xnu.git] / osfmk / kern / ledger.h
CommitLineData
1c79356b
A
1/*
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
e5568f75
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.
1c79356b 11 *
e5568f75
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
1c79356b
A
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
e5568f75
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.
1c79356b
A
19 *
20 * @APPLE_LICENSE_HEADER_END@
21 */
22/*
23 * @OSF_COPYRIGHT@
24 */
25#ifndef _KERN_LEDGER_H_
26#define _KERN_LEDGER_H_
27
9bccf70c 28
1c79356b 29#include <mach/mach_types.h>
9bccf70c
A
30#include <ipc/ipc_port.h>
31
32#include <sys/appleapiopts.h>
33
34#ifdef __APPLE_API_PRIVATE
35
36#ifdef MACH_KERNEL_PRIVATE
37
38#include <kern/lock.h>
39#include <mach/etap_events.h>
1c79356b
A
40
41#define LEDGER_ITEM_INFINITY (~0)
42
43struct ledger {
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)
51};
52
53typedef struct ledger ledger_data_t;
54
1c79356b
A
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)
59
60extern ledger_t root_wired_ledger;
61extern ledger_t root_paged_ledger;
62
63#define root_wired_ledger_port root_wired_ledger->ledger_self
64#define root_paged_ledger_port root_paged_ledger->ledger_self
65
9bccf70c
A
66extern void ledger_init(void);
67
1c79356b
A
68extern ipc_port_t ledger_copy(ledger_t);
69
70extern kern_return_t ledger_enter(ledger_t, ledger_item_t);
9bccf70c
A
71
72#endif /* MACH_KERNEL_PRIVATE */
73
74#endif /* __APPLE_API_PRIVATE */
75
76extern ledger_t convert_port_to_ledger(ipc_port_t);
77
78extern ipc_port_t convert_ledger_to_port(ledger_t);
1c79356b
A
79
80#endif /* _KERN_LEDGER_H_ */