1 /* 2 * Copyright (c) 2020 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 * ARM64 specific definitions for hibernation platform abstraction layer. 30 */ 31 32 #ifndef _ARM64_PAL_HIBERNATE_H 33 #define _ARM64_PAL_HIBERNATE_H 34 35 #include <IOKit/IOHibernatePrivate.h> 36 37 __BEGIN_DECLS 38 39 /*! 40 * @enum pal_hib_map_type_t 41 * @discussion Parameter to pal_hib_map used to signify which memory region to map. 42 */ 43 typedef enum { 44 DEST_COPY_AREA = 1, 45 COPY_PAGE_AREA, 46 BITMAP_AREA, 47 IMAGE_AREA, 48 IMAGE2_AREA, 49 SCRATCH_AREA, 50 WKDM_AREA, 51 } pal_hib_map_type_t; 52 53 /*! 54 * @struct pal_hib_ctx 55 * @discussion ARM64-specific PAL context; see pal_hib_ctx_t for details. 56 */ 57 struct pal_hib_ctx { 58 }; 59 60 /*! 61 * @typedef pal_hib_globals_t 62 * @discussion ARM64-specific state preserved pre-hibernation and needed during hibernation resume. 63 * 64 * @field dockChannelRegPhysBase Physical address of the dockchannel registers 65 * @field dockChannelRegVirtBase Virtual address of the dockchannel registers 66 * @field dockChannelWstatMask Mask to apply to dockchannel WSTAT register to compute available FIFO entries 67 * @field hibUartRegPhysBase Physical address of the UART registers 68 * @field hibUartRegVirtBase Virtual address of the UART registers 69 * @field hmacRegBase Physical address of the hmac block registers 70 * @field kernelSlide Offset from physical address to virtual address in the kernel map 71 */ 72 typedef struct { 73 uint64_t dockChannelRegPhysBase; 74 uint64_t dockChannelRegVirtBase; 75 uint32_t dockChannelWstatMask; 76 uint64_t hibUartRegPhysBase; 77 uint64_t hibUartRegVirtBase; 78 uint64_t hmacRegBase; 79 uint64_t kernelSlide; 80 } pal_hib_globals_t; 81 extern pal_hib_globals_t gHibernateGlobals; 82 83 /*! 84 * @function pal_hib_get_stack_pages 85 * @discussion Returns the stack base address and number of pages to use during hibernation resume. 86 * 87 * @param first_page Out parameter: the base address of the hibernation resume stack 88 * @param page_count Out parameter: the number of pages in the hibernation stack 89 */ 90 void pal_hib_get_stack_pages(vm_offset_t *first_page, vm_offset_t *page_count); 91 92 /*! 93 * @function pal_hib_resume_tramp 94 * @discussion Platform-specific system setup before calling hibernate_kernel_entrypoint. 95 * 96 * @param headerPpnum The page number of the IOHibernateImageHeader 97 */ 98 void pal_hib_resume_tramp(uint32_t headerPpnum); 99 100 /*! 101 * @typedef pal_hib_tramp_result_t 102 * @discussion This type is used to store the result of pal_hib_resume_tramp. 103 * 104 * @field ttbr0 Physical address of the first level translation table (low mem) 105 * @field ttbr1 Physical address of the first level translation table (high mem) 106 * @field memSlide Offset from physical address to virtual address during hibernation resume 107 */ 108 typedef struct{ 109 uint64_t ttbr0; 110 uint64_t ttbr1; 111 uint64_t memSlide; 112 } pal_hib_tramp_result_t; 113 114 #if HIBERNATE_TRAP_HANDLER 115 /*! 116 * @function hibernate_trap 117 * @discussion Platform-specific function for handling a trap during hibernation resume. 118 * 119 * @param context The context captured during the trap 120 * @param trap_addr The address of the low level trap handler that was invoked 121 */ 122 void hibernate_trap(arm_context_t *context, uint64_t trap_addr) __attribute__((noreturn)); 123 #endif /* HIBERNATE_TRAP_HANDLER */ 124 125 __END_DECLS 126 127 #endif /* _ARM64_PAL_HIBERNATE_H */ 128