]> git.saurik.com Git - apple/xnu.git/blame - pexpert/pexpert/arm/consistent_debug.h
xnu-4570.51.1.tar.gz
[apple/xnu.git] / pexpert / pexpert / arm / consistent_debug.h
CommitLineData
5ba3f43e 1/*
a39ff7e2 2 * Copyright (c) 2011-2018 Apple Inc. All rights reserved.
5ba3f43e 3 *
a39ff7e2 4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
5ba3f43e 5 *
a39ff7e2
A
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@
5ba3f43e 27 */
a39ff7e2 28
5ba3f43e
A
29#ifndef PE_CONSISTENT_DEBUG_H
30#define PE_CONSISTENT_DEBUG_H
31
32#include <stdint.h>
33
34#define DEBUG_RECORD_ID_LONG(a, b,c ,d, e, f, g, h) \
35 ( ((uint64_t)( (((h) << 24) & 0xFF000000) | \
36 (((g) << 16) & 0x00FF0000) | \
37 (((f) << 8) & 0x0000FF00) | \
38 ((e) & 0x000000FF) ) << 32) | \
39 (uint64_t)( (((d) << 24) & 0xFF000000) | \
40 (((c) << 16) & 0x00FF0000) | \
41 (((b) << 8) & 0x0000FF00) | \
42 ((a) & 0x000000FF) ) )
43#define DEBUG_RECORD_ID_SHORT(a,b,c,d) DEBUG_RECORD_ID_LONG(a,b,c,d,0,0,0,0)
44
45/*
46 * Shared Memory Console Descriptors:
47 * Record ID: One per SHMConsole
48 */
49
50typedef enum {
51 DBG_PROCESSOR_AP = 1,
52 DBG_COPROCESSOR_ANS,
53 DBG_COPROCESSOR_SEP,
54 DBG_COPROCESSOR_SIO,
55 DBG_COPROCESSOR_ISP,
56 DBG_COPROCESSOR_OSCAR,
57 DBG_NUM_PROCESSORS
58} dbg_processor_t;
59
60#define DbgIdConsoleHeaderForIOP(which_dbg_processor, which_num) (DEBUG_RECORD_ID_LONG('C','O','N',0,0,0,which_dbg_processor,which_num))
61
62#define kDbgIdConsoleHeaderAP DbgIdConsoleHeaderForIOP(DBG_PROCESSOR_AP, 0)
63#define kDbgIdConsoleHeaderANS DbgIdConsoleHeaderForIOP(DBG_COPROCESSOR_ANS, 0)
64#define kDbgIdConsoleHeaderSIO DbgIdConsoleHeaderForIOP(DBG_COPROCESSOR_SIO, 0)
65#define kDbgIdConsoleHeaderSEP DbgIdConsoleHeaderForIOP(DBG_COPROCESSOR_SEP, 0)
66#define kDbgIdConsoleHeaderISP DbgIdConsoleHeaderForIOP(DBG_COPROCESSOR_ISP, 0)
67#define kDbgIdConsoleHeaderOscar DbgIdConsoleHeaderForIOP(DBG_COPROCESSOR_OSCAR, 0)
68
69#define kDbgIdAstrisConnection DEBUG_RECORD_ID_LONG('A','S','T','R','C','N','X','N')
70#define kDbgIdAstrisConnectionVers DEBUG_RECORD_ID_LONG('A','S','T','R','C','V','E','R')
71
72#define kDbgIdUnusedEntry 0x0ULL
73#define kDbgIdReservedEntry DEBUG_RECORD_ID_LONG('R','E','S','E','R','V','E', 'D')
74#define kDbgIdFreeReqEntry DEBUG_RECORD_ID_LONG('F','R','E','E','-','R','E','Q')
75#define kDbgIdFreeAckEntry DEBUG_RECORD_ID_LONG('F','R','E','E','-','A','C','K')
76
77#define DEBUG_REGISTRY_MAX_RECORDS 512
78
79typedef struct {
80 uint64_t record_id; // = kDbgIdTopLevelHeader
81 uint32_t num_records; // = DEBUG_REGISTRY_MAX_RECORDS
82 uint32_t record_size_bytes; // = sizeof(dbg_record_header_t)
83} dbg_top_level_header_t;
84
85typedef struct {
86 uint64_t record_id; // 32-bit unique ID identifying the record
87 uint64_t length; // Length of the payload
88 uint64_t physaddr; // System physical address of entry
89} dbg_record_header_t;
90
91typedef struct {
92 uint64_t timestamp;
93 uint32_t cp_state; // One of the cp_state_t enumerations
94 uint32_t cp_state_arg; // IOP-defined supplemental value
95} dbg_cpr_state_entry_t;
96
97#define CPR_MAX_STATE_ENTRIES 16 // Arbitrary value
98
99// This second-level struct should be what the Debug Registry record (e.g. kDbgIdCPRHeaderANS) points to.
100typedef struct {
101 uint32_t rdptr;
102 uint32_t wrptr;
103 uint32_t num_cp_state_entries;
104 uint32_t checksum;
105 dbg_cpr_state_entry_t cp_state_entries[CPR_MAX_STATE_ENTRIES];
106} dbg_cpr_t;
107
108typedef struct {
109 dbg_top_level_header_t top_level_header;
110 dbg_record_header_t records[DEBUG_REGISTRY_MAX_RECORDS];
111
112 // Stuff the AP's Progress Report buffer at the end of this
113 // structure. It's currently the only processor that doesn't
114 // have some easier form of persistent memory that survives the
115 // iBoot->iOS handoff (e.g. ANS has its private heap)
116 dbg_cpr_t ap_cpr_region;
117} dbg_registry_t;
118
119/*
120 * Inherit the consistent debug structure from bootloader
121 */
122int PE_consistent_debug_inherit(void);
123
124/*
125 * Register a region in the consistent debug structure
126 */
127int PE_consistent_debug_register(uint64_t record_id, uint64_t physaddr, uint64_t length);
128
129/*
130 * Returns whether consistent debug is enabled on the current device.
131 */
132int PE_consistent_debug_enabled(void);
133
134#endif // PE_CONSISTENT_DEBUG_H
135