1 /* 2 * Copyright (c) 2021 Apple 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 #pragma once 30 31 #include <kdp/kdp_out_stage.h> 32 33 /* 34 * A non-terminal output stage that merely buffers up any output data before 35 * sending it over to the next stage. This is useful when a subsequent stage 36 * expects data in specific chunks (e.g. the network stage expects chunks of 37 * a specific size to send as packets). 38 * 39 * Note that the buffer is flushed before any operation other than KDP_DATA, 40 * and is flushed when KDP_DATA is specified with an empty data buffer. 41 */ 42 kern_return_t buffer_stage_initialize(struct kdp_output_stage *stage, size_t buffer_size); 43 44 /* 45 * A non-terminal output stage that compresses the output data with LZ4 before 46 * sending it over to the next stage. 47 */ 48 kern_return_t lz4_stage_initialize(struct kdp_output_stage *stage); 49 50 /* 51 * Instructs the LZ4 stage to start monitoring for the Compression kext. 52 */ 53 void lz4_stage_monitor_availability(void); 54 55 /* 56 * A non-terminal output stage that compresses (using ZLib) the output data before 57 * sending it over to the next stage. 58 * 59 * Note that compression is bypassed (until the stage is reset) if the caller performs 60 * a KDP_SEEK operation. 61 */ 62 kern_return_t zlib_stage_initialize(struct kdp_output_stage *stage); 63 64 /* 65 * A non-terminal output stage that encrypts the data through AppleEncryptedArchive 66 * before sending it over to the next stage. 67 * 68 * Note that this stage requires that its subsequent stages be able to seek 69 * backwards and read data 70 * 71 * Double Note that this stage will technically only work if the subsequent stage is 72 * the disk stage. 73 */ 74 kern_return_t aea_stage_initialize(struct kdp_output_stage *stage, const void *recipient_public_key, size_t recipient_public_key_size); 75 76 /* 77 * Instructs the AEA stage to start monitoring for the availability of the AEA functionality. 78 */ 79 void aea_stage_monitor_availability(void); 80 81 /* 82 * Checks whether the AEA functionality is currently available. 83 */ 84 bool aea_stage_is_available(void); 85 86 /* 87 * A terminal output stage that writes data out to the corefile. 88 */ 89 kern_return_t disk_stage_initialize(struct kdp_output_stage *stage); 90 91 /* 92 * Write an arbitrary amount of data to an arbitrary offset in the on-disk corefile. 93 */ 94 kern_return_t disk_stage_write(struct kdp_output_stage *stage, uint64_t offset, uint64_t length, const void *data); 95 96 /* 97 * Read an arbitrary amount of data from an arbitrary offset in the on-disk corefile. 98 */ 99 kern_return_t disk_stage_read(struct kdp_output_stage *stage, uint64_t offset, uint64_t length, void *data); 100 101 /* 102 * A terminal output stage that streams the data out over the network. 103 */ 104 kern_return_t net_stage_initialize(struct kdp_output_stage *stage); 105 106 /* 107 * A non-terminal output stage that notifies registered panic callouts about coredump progress periodically. 108 */ 109 kern_return_t progress_notify_stage_initialize(struct kdp_output_stage *stage); 110 111 #if defined(__arm64__) 112 /* 113 * A non-terminal output stage that handles memory accesses to special device memory. 114 */ 115 kern_return_t memory_backing_aware_buffer_stage_initialize(struct kdp_output_stage *stage); 116 #endif /* defined(__arm64__) */ 117 118 #if defined(__arm64__) 119 /* 120 * A terminal output stage that streams the data out to an external 121 * agent (a debugger) over a shared memory region. 122 */ 123 kern_return_t shmem_stage_initialize(struct kdp_output_stage *stage); 124 #endif /* defined(__arm64__) */ 125