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 (using ZLib) the output data before 46 * sending it over to the next stage. 47 * 48 * Note that compression is bypassed (until the stage is reset) if the caller performs 49 * a KDP_SEEK operation. 50 */ 51 kern_return_t zlib_stage_initialize(struct kdp_output_stage *stage); 52 53 /* 54 * A non-terminal output stage that encrypts the data through AppleEncryptedArchive 55 * before sending it over to the next stage. 56 * 57 * Note that this stage requires that its subsequent stages be able to seek 58 * backwards and read data 59 * 60 * Double Note that this stage will technically only work if the subsequent stage is 61 * the disk stage. 62 */ 63 kern_return_t aea_stage_initialize(struct kdp_output_stage *stage, const void *recipient_public_key, size_t recipient_public_key_size); 64 65 /* 66 * Instructs the AEA stage to start monitoring for the availability of the AEA functionality. 67 */ 68 void aea_stage_monitor_availability(void); 69 70 /* 71 * Checks whether the AEA functionality is currently available. 72 */ 73 bool aea_stage_is_available(void); 74 75 /* 76 * A terminal output stage that writes data out to the corefile. 77 */ 78 kern_return_t disk_stage_initialize(struct kdp_output_stage *stage); 79 80 /* 81 * Write an arbitrary amount of data to an arbitrary offset in the on-disk corefile. 82 */ 83 kern_return_t disk_stage_write(struct kdp_output_stage *stage, uint64_t offset, uint64_t length, const void *data); 84 85 /* 86 * Read an arbitrary amount of data from an arbitrary offset in the on-disk corefile. 87 */ 88 kern_return_t disk_stage_read(struct kdp_output_stage *stage, uint64_t offset, uint64_t length, void *data); 89 90 /* 91 * A terminal output stage that streams the data out over the network. 92 */ 93 kern_return_t net_stage_initialize(struct kdp_output_stage *stage); 94 95 /* 96 * A non-terminal output stage that notifies registered panic callouts about coredump progress periodically. 97 */ 98 kern_return_t progress_notify_stage_initialize(struct kdp_output_stage *stage); 99 100 #if defined(__arm64__) 101 /* 102 * A non-terminal output stage that handles memory accesses to special device memory if the memory 103 * being saved is outside of DRAM. 104 */ 105 kern_return_t memory_backing_aware_buffer_stage_initialize(struct kdp_output_stage *stage); 106 #endif /* defined(__arm64__) */ 107 108 #if defined(__arm__) || defined(__arm64__) 109 /* 110 * A terminal output stage that streams the data out to an external 111 * agent (a debugger) over a shared memory region. 112 */ 113 kern_return_t shmem_stage_initialize(struct kdp_output_stage *stage); 114 115 void shmem_mark_as_busy(void); 116 117 #endif /* defined(__arm__) || defined(__arm64__) */ 118