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