]> git.saurik.com Git - apple/xnu.git/blob - bsd/sys/pgo.h
xnu-3248.60.10.tar.gz
[apple/xnu.git] / bsd / sys / pgo.h
1 /*
2 * Copyright (c) 2014 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
5 *
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. The rights granted to you under the License
10 * may not be used to create, or enable the creation or redistribution of,
11 * unlawful or unlicensed copies of an Apple operating system, or to
12 * circumvent, violate, or enable the circumvention or violation of, any
13 * terms of an Apple operating system software license agreement.
14 *
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
17 *
18 * The Original Code and all software distributed under the License are
19 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 * Please see the License for the specific language governing rights and
24 * limitations under the License.
25 *
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
27 */
28
29 #ifndef _SYS_PGO_H_
30 #define _SYS_PGO_H_
31
32 #include <sys/_types.h>
33 #include <sys/_types/_ssize_t.h>
34 #include <stdint.h>
35 #include <uuid/uuid.h>
36
37 #define PGO_HIB (1)
38 #define PGO_WAIT_FOR_UNLOAD (2)
39 #define PGO_METADATA (4)
40
41 #define PGO_ALL_FLAGS (PGO_HIB | PGO_WAIT_FOR_UNLOAD | PGO_METADATA)
42
43
44 /**
45 * This is a serialization format for metadata related to a profile data buffer.
46 *
47 * If metadata is present, this footer will appear at the end of the file, so
48 * the last four bytes of the file will be the ASCII string "meta".
49 *
50 * The metadata is stored in a environment-string style buffer. The buffer
51 * consists of key-value pairs, which are delimited by null bytes. Each
52 * key-value pair is a string of the form "FOO=bar". Everything before the
53 * first equal sign is the key, everything after is the value.
54 *
55 * All members are in network byte order.
56 */
57 struct pgo_metadata_footer {
58 /**
59 * number of pairs.
60 *
61 * This should be htonl(n), where n is the number of key-value pairs in the
62 * metadata buffer
63 */
64 uint32_t number_of_pairs;
65
66 /**
67 * pointer to the metadata buffer
68 *
69 * This should be htonl(offset), where offset is the backwards offset from
70 * the end of the file to the metadata buffer.
71 */
72 uint32_t offset_to_pairs;
73
74 /**
75 * magic number
76 *
77 * This should be htonl(0x6d657461);
78 */
79 uint32_t magic;
80 };
81
82 #ifndef KERNEL
83
84 ssize_t grab_pgo_data(
85 uuid_t *uuid,
86 int flags,
87 unsigned char *buffer,
88 ssize_t size);
89
90
91 #endif
92
93 #endif