xref: /xnu-8020.140.41/osfmk/arm/lowglobals.h (revision 27b03b360a988dfd3dfdf34262bb0042026747cc)
1 /*
2  * Copyright (c) 2017 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  *		Header files for the Low Memory Globals (lg)
30  */
31 #ifndef _LOW_MEMORY_GLOBALS_H_
32 #define _LOW_MEMORY_GLOBALS_H_
33 
34 #ifndef __arm__
35 #error  Wrong architecture - this file is meant for arm
36 #endif
37 
38 #define LOWGLO_LAYOUT_MAGIC             0xC0DEC0DE
39 
40 #pragma pack(4) /* Make sure the structure stays as we defined it */
41 typedef struct lowglo {
42 	unsigned char lgVerCode[8];         /* 0xffff1000 System verification code */
43 	uint32_t      lgZero[2];            /* 0xffff1008 Double constant 0 */
44 	uint32_t      lgStext;              /* 0xffff1010 Start of kernel text */
45 	uint32_t      lgRsv014[2];          /* 0xffff1014 Reserved */
46 	uint32_t      lgVersion;            /* 0xffff101C Pointer to kernel version string */
47 	uint32_t      lgRsv020[216];        /* 0xffff1020 Reserved */
48 	uint32_t      lgKmodptr;            /* 0xffff1380 Pointer to kmod, debugging aid */
49 	uint32_t      lgTransOff;           /* 0xffff1384 Pointer to kdp_trans_off, debugging aid */
50 	uint32_t      lgRsv388[3];          /* 0xffff1388 Reserved */
51 	uint32_t      lgOSVersion;          /* 0xffff1394 Pointer to OS version string */
52 	uint32_t      lgRsv398;             /* 0xffff1398 Reserved */
53 	uint32_t      lgRebootFlag;         /* 0xffff139C Pointer to debugger reboot trigger */
54 	uint32_t      lgManualPktAddr;      /* 0xffff13A0 Pointer to manual packet structure */
55 	uint32_t      lgRsv3A4;             /* 0xffff13A4 Reserved */
56 	uint32_t      lgPmapMemQ;           /* 0xffff13A8 Pointer to PMAP memory queue */
57 	uint32_t      lgPmapMemPageOffset;  /* 0xffff13AC Offset of physical page member in vm_page_with_ppnum_t */
58 	uint32_t      lgPmapMemChainOffset; /* 0xffff13B0 Offset of listq in vm_page_t or vm_page_with_ppnum_t */
59 	uint32_t      lgStaticAddr;         /* 0xffff13B4 Static allocation address */
60 	uint32_t      lgStaticSize;         /* 0xffff13B8 Static allocation size */
61 	uint32_t      lgLayoutMajorVersion; /* 0xffff13BC Lowglo layout major version */
62 	uint32_t      lgLayoutMagic;        /* 0xffff13C0 Magic value evaluated to determine if lgLayoutVersion is valid */
63 	uint32_t      lgPmapMemStartAddr;   /* 0xffff13C4 Pointer to start of vm_page_t array */
64 	uint32_t      lgPmapMemEndAddr;     /* 0xffff13C8 Pointer to end of vm_page_t array */
65 	uint32_t      lgPmapMemPagesize;    /* 0xffff13CC size of vm_page_t */
66 	uint32_t      lgPmapMemFirstppnum;  /* 0xffff13D0 physical page number of the first vm_page_t in the array */
67 	uint32_t      lgLayoutMinorVersion; /* 0xffff13D4 Lowglo layout minor version */
68 	uint32_t      lgPageShift;          /* 0xffff13D8 Number of shifts from page number to size */
69 	uint32_t      lgVmFirstPhys;        /* 0xffff13DC First physical address of kernel-managed DRAM (inclusive) */
70 	uint32_t      lgVmLastPhys;         /* 0xffff13E0 Last physical address of kernel-managed DRAM (exclusive) */
71 } lowglo;
72 #pragma pack()
73 
74 extern lowglo lowGlo;
75 
76 void patch_low_glo(void);
77 void patch_low_glo_static_region(uint32_t address, uint32_t size);
78 void patch_low_glo_vm_page_info(void *, void *, uint32_t);
79 
80 #endif /* _LOW_MEMORY_GLOBALS_H_ */
81