2 * Copyright (c) 2020 Apple Inc. All rights reserved.
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
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.
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
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.
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
29 * ARM64 specific definitions for hibernation platform abstraction layer.
32 #ifndef _ARM64_PAL_HIBERNATE_H
33 #define _ARM64_PAL_HIBERNATE_H
35 #include <IOKit/IOHibernatePrivate.h>
40 * @enum pal_hib_map_type_t
41 * @discussion Parameter to pal_hib_map used to signify which memory region to map.
55 * @discussion ARM64-specific PAL context; see pal_hib_ctx_t for details.
58 #if HIBERNATE_HMAC_IMAGE
59 struct ccdigest_info di
;
60 hibernate_scratch_t pagesRestored
;
61 #endif /* HIBERNATE_HMAC_IMAGE */
65 * @typedef pal_hib_globals_t
66 * @discussion ARM64-specific state preserved pre-hibernation and needed during hibernation resume.
68 * @field dockChannelRegBase Physical address of the dockchannel registers
69 * @field dockChannelWstatMask Mask to apply to dockchannel WSTAT register to compute available FIFO entries
70 * @field hibUartRegBase Physical address of the UART registers
71 * @field hmacRegBase Physical address of the hmac block registers
74 uint64_t dockChannelRegBase
;
75 uint64_t dockChannelWstatMask
;
76 uint64_t hibUartRegBase
;
79 extern pal_hib_globals_t gHibernateGlobals
;
82 * @function pal_hib_get_stack_pages
83 * @discussion Returns the stack base address and number of pages to use during hibernation resume.
85 * @param first_page Out parameter: the base address of the hibernation resume stack
86 * @param page_count Out parameter: the number of pages in the hibernation stack
88 void pal_hib_get_stack_pages(vm_offset_t
*first_page
, vm_offset_t
*page_count
);
91 * @function pal_hib_resume_tramp
92 * @discussion Platform-specific system setup before calling hibernate_kernel_entrypoint.
94 * @param headerPpnum The page number of the IOHibernateImageHeader
96 void pal_hib_resume_tramp(uint32_t headerPpnum
);
99 * @typedef pal_hib_tramp_result_t
100 * @discussion This type is used to store the result of pal_hib_resume_tramp.
102 * @field ttbr0 Physical address of the first level translation table (low mem)
103 * @field ttbr1 Physical address of the first level translation table (high mem)
104 * @field memSlide Offset from physical address to virtual address during hibernation resume
105 * @field kernelSlide Offset from physical address to virtual address in the kernel map
111 uint64_t kernelSlide
;
112 } pal_hib_tramp_result_t
;
114 #if HIBERNATE_TRAP_HANDLER
116 * @function hibernate_trap
117 * @discussion Platform-specific function for handling a trap during hibernation resume.
119 * @param context The context captured during the trap
120 * @param trap_addr The address of the low level trap handler that was invoked
122 void hibernate_trap(arm_context_t
*context
, uint64_t trap_addr
) __attribute__((noreturn
));
123 #endif /* HIBERNATE_TRAP_HANDLER */
127 #endif /* _ARM64_PAL_HIBERNATE_H */