]> git.saurik.com Git - apple/xnu.git/blame - osfmk/kdp/kdp_core.h
xnu-3789.51.2.tar.gz
[apple/xnu.git] / osfmk / kdp / kdp_core.h
CommitLineData
91447636
A
1/*
2 * Copyright (c) 2003 Apple Computer, Inc. All rights reserved.
3 *
2d21ac55 4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
91447636 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.
8f6c56a5 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.
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
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.
8f6c56a5 25 *
2d21ac55 26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
91447636
A
27 */
28
29/* HISTORY
30 * 8 Aug. 2003 - Created (Derek Kumar)
31 */
32
55e303ae 33/* Various protocol definitions
91447636 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
813fb2f6
A
39#include <kdp/kdp_protocol.h>
40
55e303ae
A
41/*
42 * Packet types.
43 */
44#define KDP_RRQ 1 /* read request */
45#define KDP_WRQ 2 /* write request */
46#define KDP_DATA 3 /* data packet */
47#define KDP_ACK 4 /* acknowledgement */
48#define KDP_ERROR 5 /* error code */
49#define KDP_SEEK 6 /* Seek to specified offset */
50#define KDP_EOF 7 /* signal end of file */
b0d623f7 51#define KDP_FEATURE_MASK_STRING "features"
6d2010ae
A
52
53enum {KDP_FEATURE_LARGE_CRASHDUMPS = 1, KDP_FEATURE_LARGE_PKT_SIZE = 2};
54extern uint32_t kdp_feature_large_crashdumps, kdp_feature_large_pkt_size;
55
55e303ae
A
56struct corehdr {
57 short th_opcode; /* packet type */
58 union {
59 unsigned int tu_block; /* block # */
60 unsigned int tu_code; /* error code */
61 char tu_rpl[1]; /* request packet payload */
62 } th_u;
6d2010ae 63 char th_data[0]; /* data or error string */
55e303ae
A
64}__attribute__((packed));
65
66#define th_block th_u.tu_block
67#define th_code th_u.tu_code
68#define th_stuff th_u.tu_rpl
69#define th_msg th_data
70
71/*
72 * Error codes.
73 */
74#define EUNDEF 0 /* not defined */
75#define ENOTFOUND 1 /* file not found */
76#define EACCESS 2 /* access violation */
77#define ENOSPACE 3 /* disk full or allocation exceeded */
78#define EBADOP 4 /* illegal TFTP operation */
79#define EBADID 5 /* unknown transfer ID */
80#define EEXISTS 6 /* file already exists */
81#define ENOUSER 7 /* no such user */
82
83#define CORE_REMOTE_PORT 1069 /* hardwired, we can't really query the services file */
84
39037602
A
85#if WITH_CONSISTENT_DBG
86/*
87 * xnu shared memory hardware debugger support
88 *
89 * A hardware debugger can connect, read the consistent debug
90 * header to determine the physical location of the handshake
91 * structure and communicate using commands in the structure as
92 * defined below.
93 *
94 * Currently used for sending compressed coredumps to
95 * astris.
96 */
97struct xnu_hw_shmem_dbg_command_info {
98 volatile uint32_t xhsdci_status;
99 uint32_t xhsdci_seq_no;
100 volatile uint64_t xhsdci_buf_phys_addr;
101 volatile uint32_t xhsdci_buf_data_length;
102 /* end of version 0 structure */
103 uint64_t xhsdci_coredump_total_size_uncomp;
104 uint64_t xhsdci_coredump_total_size_sent_uncomp;
105 uint32_t xhsdci_page_size;
106} __attribute__((packed));
107
108#define CUR_XNU_HWSDCI_STRUCT_VERS 1
109
110#define XHSDCI_STATUS_NONE 0 /* default status */
111#define XHSDCI_STATUS_KERNEL_BUSY 1 /* kernel is busy with other procedure */
112#define XHSDCI_STATUS_KERNEL_READY 2 /* kernel ready to begin command */
113#define XHSDCI_COREDUMP_BEGIN 3 /* indicates hardware debugger is ready to begin consuming coredump info */
114#define XHSDCI_COREDUMP_BUF_READY 4 /* indicates the kernel has populated the buffer */
115#define XHSDCI_COREDUMP_BUF_EMPTY 5 /* indicates hardware debugger is done consuming the current data */
116#define XHSDCI_COREDUMP_STATUS_DONE 6 /* indicates last compressed data is in buffer */
117#define XHSDCI_COREDUMP_ERROR 7 /* indicates an error was encountered */
118#define XHSDCI_COREDUMP_REMOTE_DONE 8 /* indicates that hardware debugger is done */
119
120#endif /* WITH_CONSISTENT_DBG */
121
55e303ae 122void kdp_panic_dump (void);
55e303ae 123void abort_panic_transfer (void);
7e4a7d39
A
124void kdp_set_dump_info(const uint32_t flags, const char *file, const char *destip,
125 const char *routerip, const uint32_t port);
813fb2f6 126void kdp_get_dump_info(kdp_dumpinfo_reply_t *rp);
7e4a7d39 127
39037602
A
128enum kern_dump_type {
129 KERN_DUMP_DISK, /* local, on device core dump */
130 KERN_DUMP_NET, /* kdp network core dump */
131#if WITH_CONSISTENT_DBG
132 KERN_DUMP_HW_SHMEM_DBG, /* coordinated hardware shared memory debugger core dump */
133#endif
134};
135
136extern int kern_dump(enum kern_dump_type kd_variant);
55e303ae
A
137
138struct corehdr *create_panic_header(unsigned int request, const char *corename, unsigned length, unsigned block);
139
0c530ab8 140int kdp_send_crashdump_pkt(unsigned int request, char *corename,
b0d623f7 141 uint64_t length, void *panic_data);
0c530ab8
A
142
143int kdp_send_crashdump_data(unsigned int request, char *corename,
3e170ce0
A
144 uint64_t length, void * txstart);
145
146void kern_collectth_state_size(uint32_t * tstate_count, size_t * tstate_size);
147
148void kern_collectth_state(thread_t thread, void *buffer, size_t size, void **iter);
149
150boolean_t kdp_has_polled_corefile(void);
151
152void kdp_core_init(void);
6d2010ae 153
39037602
A
154extern boolean_t kdp_corezip_disabled;
155
6d2010ae 156#define KDP_CRASHDUMP_POLL_COUNT (2500)
3e170ce0
A
157
158#endif /* __KDP_CORE_H */