2 * Copyright (c) 2015 Apple Inc. All rights reserved.
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
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.
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
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.
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
33 #include <mach/vm_types.h>
34 #include <mach/mach_types.h>
37 #define PGTRACE_STACK_DEPTH 8
48 } pgtrace_addr_data_t
;
54 pgtrace_addr_data_t rr_addrdata
[RR_NUM_MAX
];
55 } pgtrace_run_result_t
;
57 #ifdef CONFIG_PGTRACE_NONKEXT
58 #ifdef XNU_KERNEL_PRIVATE
59 #define PGTRACE_OPTION_KPRINTF 0x1
60 #define PGTRACE_OPTION_STACK 0x2
61 #define PGTRACE_OPTION_SPIN 0x4
95 void pgtrace_init(void);
96 int pgtrace_add_probe(thread_t thread
, vm_offset_t start
, vm_offset_t end
);
97 void pgtrace_clear_probe(void);
98 void pgtrace_start(void);
99 void pgtrace_stop(void);
100 uint32_t pgtrace_get_size(void);
101 bool pgtrace_set_size(uint32_t);
102 void pgtrace_clear_trace(void);
103 boolean_t
pgtrace_active(void);
104 uint32_t pgtrace_get_option(void);
105 void pgtrace_set_option(uint32_t option
);
106 int64_t pgtrace_read_log(uint8_t *buf
, uint32_t size
);
107 void pgtrace_write_log(pgtrace_run_result_t res
);
108 int pgtrace_get_stats(pgtrace_stats_t
*stats
);
110 #else // CONFIG_PGTRACE_NONKEXT
117 } pgtrace_instruction_info_t
;
121 pgtrace_run_result_t res
;
122 void *stack
[PGTRACE_STACK_DEPTH
];
125 typedef int (*run_func_t
)(uint32_t inst
, vm_offset_t pa
, vm_offset_t va
, void *ss
, pgtrace_run_result_t
*res
);
126 typedef bool (*decode_func_t
)(uint32_t inst
, void *ss
, pgtrace_instruction_info_t
*info
);
127 typedef void (*write_func_t
)(pgtrace_run_result_t res
);
133 decode_func_t decode
;
144 //------------------------------------
145 // for pmap fault handler
146 //------------------------------------
147 int pgtrace_decode_and_run(uint32_t inst
, vm_offset_t fva
, vm_map_offset_t
*cva_page
, arm_saved_state_t
*ss
, pgtrace_run_result_t
*res
);
148 int pgtrace_write_log(pgtrace_run_result_t res
);
150 //------------------------------------
152 //------------------------------------
153 int pgtrace_init(decoder_t
*decoder
, logger_t
*logger
);
154 int pgtrace_add_probe(thread_t thread
, vm_offset_t start
, vm_offset_t end
);
155 void pgtrace_clear_probe(void);
156 void pgtrace_start(void);
157 void pgtrace_stop(void);
158 bool pgtrace_active(void);
162 #endif // CONFIG_PGTRACE_NONKEXT