]>
Commit | Line | Data |
---|---|---|
5ba3f43e A |
1 | /* |
2 | * Copyright (c) 2012-2013 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 | #include <mach_kdp.h> | |
30 | #include <mach/vm_param.h> | |
31 | #include <arm64/lowglobals.h> | |
32 | #include <vm/vm_object.h> | |
33 | #include <vm/vm_page.h> | |
34 | ||
35 | /* | |
36 | * On arm64, the low globals get mapped low via machine_init() during kernel | |
37 | * bootstrap. | |
38 | */ | |
39 | ||
40 | extern vm_offset_t vm_kernel_stext; | |
0a7de745 A |
41 | extern void *version; |
42 | extern void *kmod; | |
43 | extern void *kdp_trans_off; | |
44 | extern void *osversion; | |
45 | extern void *flag_kdp_trigger_reboot; | |
46 | extern void *manual_pkt; | |
47 | extern struct vm_object pmap_object_store; /* store pt pages */ | |
5ba3f43e A |
48 | |
49 | lowglo lowGlo __attribute__ ((aligned(PAGE_MAX_SIZE))) = { | |
50 | // Increment the major version for changes that break the current Astris | |
51 | // usage of lowGlo values | |
52 | // Increment the minor version for changes that provide additonal info/function | |
53 | // but does not break current usage | |
54 | .lgLayoutMajorVersion = 3, | |
55 | .lgLayoutMinorVersion = 0, | |
56 | .lgLayoutMagic = LOWGLO_LAYOUT_MAGIC, | |
0a7de745 | 57 | .lgVerCode = { 'K', 'r', 'a', 'k', 'e', 'n', ' ', ' ' }, |
5ba3f43e A |
58 | .lgZero = 0, |
59 | .lgStext = 0, // To be filled in below | |
60 | .lgVersion = (uint64_t) &version, | |
61 | .lgOSVersion = (uint64_t) &osversion, | |
62 | .lgKmodptr = (uint64_t) &kmod, | |
63 | #if MACH_KDP && CONFIG_KDP_INTERACTIVE_DEBUGGING | |
64 | .lgTransOff = (uint64_t) &kdp_trans_off, | |
65 | .lgRebootFlag = (uint64_t) &flag_kdp_trigger_reboot, | |
66 | .lgManualPktAddr = (uint64_t) &manual_pkt, | |
67 | #endif | |
68 | .lgPmapMemQ = (uint64_t)&(pmap_object_store.memq), | |
d9a64523 A |
69 | .lgPmapMemPageOffset = offsetof(struct vm_page_with_ppnum, vmp_phys_page), |
70 | .lgPmapMemChainOffset = offsetof(struct vm_page, vmp_listq), | |
5ba3f43e A |
71 | .lgPmapMemPagesize = (uint64_t)sizeof(struct vm_page), |
72 | .lgPmapMemFromArrayMask = VM_PACKED_FROM_VM_PAGES_ARRAY, | |
73 | .lgPmapMemPackedShift = VM_PACKED_POINTER_SHIFT, | |
74 | .lgPmapMemPackedBaseAddr = VM_MIN_KERNEL_AND_KEXT_ADDRESS, | |
75 | .lgPmapMemStartAddr = -1, | |
76 | .lgPmapMemEndAddr = -1, | |
d9a64523 A |
77 | .lgPmapMemFirstppnum = -1, |
78 | .lgPageShift = ARM_PGSHIFT | |
5ba3f43e A |
79 | }; |
80 | ||
0a7de745 A |
81 | void |
82 | patch_low_glo(void) | |
5ba3f43e A |
83 | { |
84 | lowGlo.lgStext = (uint64_t)vm_kernel_stext; | |
5ba3f43e A |
85 | } |
86 | ||
0a7de745 A |
87 | void |
88 | patch_low_glo_static_region(uint64_t address, uint64_t size) | |
5ba3f43e A |
89 | { |
90 | lowGlo.lgStaticAddr = address; | |
91 | lowGlo.lgStaticSize = size; | |
92 | } | |
93 | ||
94 | ||
0a7de745 A |
95 | void |
96 | patch_low_glo_vm_page_info(void * start_addr, void * end_addr, uint32_t first_ppnum) | |
5ba3f43e A |
97 | { |
98 | lowGlo.lgPmapMemStartAddr = (uint64_t)start_addr; | |
99 | lowGlo.lgPmapMemEndAddr = (uint64_t)end_addr; | |
100 | lowGlo.lgPmapMemFirstppnum = first_ppnum; | |
d9a64523 | 101 | lowGlo.lgPageShift = PAGE_SHIFT; |
5ba3f43e | 102 | } |