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#define PGO_RESET_ALL (8)
41
42#define PGO_ALL_FLAGS (PGO_HIB | PGO_WAIT_FOR_UNLOAD | PGO_METADATA | PGO_RESET_ALL)
43
44
45/**
46 * This is a serialization format for metadata related to a profile data buffer.
47 *
48 * If metadata is present, this footer will appear at the end of the file, so
49 * the last four bytes of the file will be the ASCII string "meta".
50 *
51 * The metadata is stored in a environment-string style buffer. The buffer
52 * consists of key-value pairs, which are delimited by null bytes. Each
53 * key-value pair is a string of the form "FOO=bar". Everything before the
54 * first equal sign is the key, everything after is the value.
55 *
56 * All members are in network byte order.
57 */
58struct pgo_metadata_footer {
59 /**
60 * number of pairs.
61 *
62 * This should be htonl(n), where n is the number of key-value pairs in the
63 * metadata buffer
64 */
65 uint32_t number_of_pairs;
66
67 /**
68 * pointer to the metadata buffer
69 *
70 * This should be htonl(offset), where offset is the backwards offset from
71 * the end of the file to the metadata buffer.
72 */
73 uint32_t offset_to_pairs;
74
75 /**
76 * magic number
77 *
78 * This should be htonl(0x6d657461);
79 */
80 uint32_t magic;
81};
82
83#ifndef KERNEL
84
85ssize_t grab_pgo_data(
86 uuid_t *uuid,
87 int flags,
88 unsigned char *buffer,
89 ssize_t size);
90
91
92#endif
93
94#ifdef XNU_KERNEL_PRIVATE
95kern_return_t do_pgo_reset_counters(void);
96#endif
97
98
99#endif
100