]>
Commit | Line | Data |
---|---|---|
f427ee49 A |
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 { | |
f427ee49 A |
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 dockChannelRegBase Physical address of the dockchannel registers | |
65 | * @field dockChannelWstatMask Mask to apply to dockchannel WSTAT register to compute available FIFO entries | |
66 | * @field hibUartRegBase Physical address of the UART registers | |
67 | * @field hmacRegBase Physical address of the hmac block registers | |
2a1bd2d3 | 68 | * @field kernelSlide Offset from physical address to virtual address in the kernel map |
f427ee49 A |
69 | */ |
70 | typedef struct { | |
71 | uint64_t dockChannelRegBase; | |
72 | uint64_t dockChannelWstatMask; | |
73 | uint64_t hibUartRegBase; | |
74 | uint64_t hmacRegBase; | |
2a1bd2d3 | 75 | uint64_t kernelSlide; |
f427ee49 A |
76 | } pal_hib_globals_t; |
77 | extern pal_hib_globals_t gHibernateGlobals; | |
78 | ||
79 | /*! | |
80 | * @function pal_hib_get_stack_pages | |
81 | * @discussion Returns the stack base address and number of pages to use during hibernation resume. | |
82 | * | |
83 | * @param first_page Out parameter: the base address of the hibernation resume stack | |
84 | * @param page_count Out parameter: the number of pages in the hibernation stack | |
85 | */ | |
86 | void pal_hib_get_stack_pages(vm_offset_t *first_page, vm_offset_t *page_count); | |
87 | ||
88 | /*! | |
89 | * @function pal_hib_resume_tramp | |
90 | * @discussion Platform-specific system setup before calling hibernate_kernel_entrypoint. | |
91 | * | |
92 | * @param headerPpnum The page number of the IOHibernateImageHeader | |
93 | */ | |
94 | void pal_hib_resume_tramp(uint32_t headerPpnum); | |
95 | ||
96 | /*! | |
97 | * @typedef pal_hib_tramp_result_t | |
98 | * @discussion This type is used to store the result of pal_hib_resume_tramp. | |
99 | * | |
100 | * @field ttbr0 Physical address of the first level translation table (low mem) | |
101 | * @field ttbr1 Physical address of the first level translation table (high mem) | |
102 | * @field memSlide Offset from physical address to virtual address during hibernation resume | |
f427ee49 A |
103 | */ |
104 | typedef struct{ | |
105 | uint64_t ttbr0; | |
106 | uint64_t ttbr1; | |
107 | uint64_t memSlide; | |
f427ee49 A |
108 | } pal_hib_tramp_result_t; |
109 | ||
110 | #if HIBERNATE_TRAP_HANDLER | |
111 | /*! | |
112 | * @function hibernate_trap | |
113 | * @discussion Platform-specific function for handling a trap during hibernation resume. | |
114 | * | |
115 | * @param context The context captured during the trap | |
116 | * @param trap_addr The address of the low level trap handler that was invoked | |
117 | */ | |
118 | void hibernate_trap(arm_context_t *context, uint64_t trap_addr) __attribute__((noreturn)); | |
119 | #endif /* HIBERNATE_TRAP_HANDLER */ | |
120 | ||
121 | __END_DECLS | |
122 | ||
123 | #endif /* _ARM64_PAL_HIBERNATE_H */ |