]>
Commit | Line | Data |
---|---|---|
91447636 A |
1 | /* |
2 | * Copyright (c) 2003 Apple Computer, Inc. All rights reserved. | |
3 | * | |
2d21ac55 | 4 | * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ |
0a7de745 | 5 | * |
2d21ac55 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. | |
0a7de745 | 14 | * |
2d21ac55 A |
15 | * Please obtain a copy of the License at |
16 | * http://www.opensource.apple.com/apsl/ and read it before using this file. | |
0a7de745 | 17 | * |
2d21ac55 A |
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 | |
8f6c56a5 A |
20 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, |
21 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
2d21ac55 A |
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. | |
0a7de745 | 25 | * |
2d21ac55 | 26 | * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ |
91447636 A |
27 | */ |
28 | ||
29 | /* HISTORY | |
30 | * 8 Aug. 2003 - Created (Derek Kumar) | |
31 | */ | |
32 | ||
0a7de745 A |
33 | /* Various protocol definitions |
34 | * for the core transfer protocol, which is a variant of TFTP | |
55e303ae | 35 | */ |
3e170ce0 A |
36 | #ifndef __KDP_CORE_H |
37 | #define __KDP_CORE_H | |
55e303ae | 38 | |
5ba3f43e | 39 | #include <kern/thread.h> |
813fb2f6 | 40 | #include <kdp/kdp_protocol.h> |
5ba3f43e | 41 | #include <string.h> |
813fb2f6 | 42 | |
55e303ae A |
43 | /* |
44 | * Packet types. | |
45 | */ | |
0a7de745 A |
46 | #define KDP_RRQ 1 /* read request */ |
47 | #define KDP_WRQ 2 /* write request */ | |
48 | #define KDP_DATA 3 /* data packet */ | |
49 | #define KDP_ACK 4 /* acknowledgement */ | |
50 | #define KDP_ERROR 5 /* error code */ | |
55e303ae A |
51 | #define KDP_SEEK 6 /* Seek to specified offset */ |
52 | #define KDP_EOF 7 /* signal end of file */ | |
5ba3f43e | 53 | #define KDP_FLUSH 8 /* flush outstanding data */ |
0a7de745 | 54 | #define KDP_FEATURE_MASK_STRING "features" |
6d2010ae | 55 | |
0a7de745 A |
56 | enum {KDP_FEATURE_LARGE_CRASHDUMPS = 1, KDP_FEATURE_LARGE_PKT_SIZE = 2}; |
57 | extern uint32_t kdp_feature_large_crashdumps, kdp_feature_large_pkt_size; | |
6d2010ae | 58 | |
0a7de745 A |
59 | struct corehdr { |
60 | short th_opcode; /* packet type */ | |
55e303ae | 61 | union { |
0a7de745 A |
62 | unsigned int tu_block; /* block # */ |
63 | unsigned int tu_code; /* error code */ | |
64 | char tu_rpl[1]; /* request packet payload */ | |
55e303ae | 65 | } th_u; |
0a7de745 | 66 | char th_data[0]; /* data or error string */ |
55e303ae A |
67 | }__attribute__((packed)); |
68 | ||
0a7de745 A |
69 | #define th_block th_u.tu_block |
70 | #define th_code th_u.tu_code | |
71 | #define th_stuff th_u.tu_rpl | |
72 | #define th_msg th_data | |
55e303ae A |
73 | |
74 | /* | |
75 | * Error codes. | |
76 | */ | |
0a7de745 A |
77 | #define EUNDEF 0 /* not defined */ |
78 | #define ENOTFOUND 1 /* file not found */ | |
79 | #define EACCESS 2 /* access violation */ | |
80 | #define ENOSPACE 3 /* disk full or allocation exceeded */ | |
81 | #define EBADOP 4 /* illegal TFTP operation */ | |
82 | #define EBADID 5 /* unknown transfer ID */ | |
83 | #define EEXISTS 6 /* file already exists */ | |
84 | #define ENOUSER 7 /* no such user */ | |
55e303ae A |
85 | |
86 | #define CORE_REMOTE_PORT 1069 /* hardwired, we can't really query the services file */ | |
87 | ||
5ba3f43e | 88 | #if CONFIG_EMBEDDED |
39037602 A |
89 | /* |
90 | * xnu shared memory hardware debugger support | |
91 | * | |
92 | * A hardware debugger can connect, read the consistent debug | |
93 | * header to determine the physical location of the handshake | |
94 | * structure and communicate using commands in the structure as | |
95 | * defined below. | |
96 | * | |
97 | * Currently used for sending compressed coredumps to | |
98 | * astris. | |
99 | */ | |
100 | struct xnu_hw_shmem_dbg_command_info { | |
101 | volatile uint32_t xhsdci_status; | |
102 | uint32_t xhsdci_seq_no; | |
103 | volatile uint64_t xhsdci_buf_phys_addr; | |
104 | volatile uint32_t xhsdci_buf_data_length; | |
105 | /* end of version 0 structure */ | |
106 | uint64_t xhsdci_coredump_total_size_uncomp; | |
107 | uint64_t xhsdci_coredump_total_size_sent_uncomp; | |
108 | uint32_t xhsdci_page_size; | |
109 | } __attribute__((packed)); | |
110 | ||
111 | #define CUR_XNU_HWSDCI_STRUCT_VERS 1 | |
112 | ||
113 | #define XHSDCI_STATUS_NONE 0 /* default status */ | |
114 | #define XHSDCI_STATUS_KERNEL_BUSY 1 /* kernel is busy with other procedure */ | |
115 | #define XHSDCI_STATUS_KERNEL_READY 2 /* kernel ready to begin command */ | |
116 | #define XHSDCI_COREDUMP_BEGIN 3 /* indicates hardware debugger is ready to begin consuming coredump info */ | |
117 | #define XHSDCI_COREDUMP_BUF_READY 4 /* indicates the kernel has populated the buffer */ | |
118 | #define XHSDCI_COREDUMP_BUF_EMPTY 5 /* indicates hardware debugger is done consuming the current data */ | |
119 | #define XHSDCI_COREDUMP_STATUS_DONE 6 /* indicates last compressed data is in buffer */ | |
120 | #define XHSDCI_COREDUMP_ERROR 7 /* indicates an error was encountered */ | |
121 | #define XHSDCI_COREDUMP_REMOTE_DONE 8 /* indicates that hardware debugger is done */ | |
122 | ||
5ba3f43e A |
123 | void panic_spin_shmcon(void); |
124 | ||
125 | #endif /* CONFIG_EMBEDDED */ | |
39037602 | 126 | |
0a7de745 | 127 | void kdp_panic_dump(void); |
5ba3f43e | 128 | void begin_panic_transfer(void); |
0a7de745 | 129 | void abort_panic_transfer(void); |
7e4a7d39 | 130 | void kdp_set_dump_info(const uint32_t flags, const char *file, const char *destip, |
0a7de745 | 131 | const char *routerip, const uint32_t port); |
813fb2f6 | 132 | void kdp_get_dump_info(kdp_dumpinfo_reply_t *rp); |
7e4a7d39 | 133 | |
39037602 A |
134 | enum kern_dump_type { |
135 | KERN_DUMP_DISK, /* local, on device core dump */ | |
136 | KERN_DUMP_NET, /* kdp network core dump */ | |
5ba3f43e | 137 | #if CONFIG_EMBEDDED |
39037602 A |
138 | KERN_DUMP_HW_SHMEM_DBG, /* coordinated hardware shared memory debugger core dump */ |
139 | #endif | |
140 | }; | |
141 | ||
5ba3f43e A |
142 | int kern_dump(enum kern_dump_type kd_variant); |
143 | ||
144 | boolean_t dumped_kernel_core(void); | |
55e303ae A |
145 | |
146 | struct corehdr *create_panic_header(unsigned int request, const char *corename, unsigned length, unsigned block); | |
147 | ||
0a7de745 A |
148 | int kdp_send_crashdump_pkt(unsigned int request, char *corename, |
149 | uint64_t length, void *panic_data); | |
0c530ab8 | 150 | |
0a7de745 A |
151 | int kdp_send_crashdump_data(unsigned int request, char *corename, |
152 | uint64_t length, void * txstart); | |
3e170ce0 | 153 | |
5ba3f43e | 154 | void kern_collectth_state_size(uint64_t * tstate_count, uint64_t * tstate_size); |
3e170ce0 | 155 | |
5ba3f43e | 156 | void kern_collectth_state(thread_t thread, void *buffer, uint64_t size, void **iter); |
3e170ce0 A |
157 | |
158 | boolean_t kdp_has_polled_corefile(void); | |
d9a64523 | 159 | kern_return_t kdp_polled_corefile_error(void); |
3e170ce0 A |
160 | |
161 | void kdp_core_init(void); | |
6d2010ae | 162 | |
39037602 A |
163 | extern boolean_t kdp_corezip_disabled; |
164 | ||
6d2010ae | 165 | #define KDP_CRASHDUMP_POLL_COUNT (2500) |
3e170ce0 | 166 | |
5ba3f43e A |
167 | #if PRIVATE |
168 | kern_return_t kdp_core_output(void *kdp_core_out_vars, uint64_t length, void * data); | |
169 | ||
170 | kern_return_t kdp_reset_output_vars(void *kdp_core_out_vars, uint64_t totalbytes); | |
171 | ||
172 | int kern_dump_record_file(void *kdp_core_out_vars, const char *filename, uint64_t file_offset, uint64_t *out_file_length); | |
173 | ||
174 | int kern_dump_seek_to_next_file(void *kdp_core_out_varss, uint64_t next_file_offset); | |
175 | ||
176 | extern boolean_t efi_valid_page(ppnum_t ppn); | |
177 | #if defined(__x86_64__) | |
0a7de745 | 178 | #define EFI_VALID_PAGE(x) efi_valid_page(x) |
5ba3f43e | 179 | #elif defined(__arm__) || defined(__arm64__) |
0a7de745 | 180 | #define EFI_VALID_PAGE(x) (FALSE) |
5ba3f43e A |
181 | #endif /* defined (__x86_64__) */ |
182 | ||
183 | #endif /* PRIVATE */ | |
184 | ||
3e170ce0 | 185 | #endif /* __KDP_CORE_H */ |