xref: /xnu-11215.1.10/pexpert/pexpert/arm64/platform.h (revision 8d741a5de7ff4191bf97d57b9f54c2f6d4a15585)
1 /*
2  * Copyright (c) 2021-2023 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 #ifndef _PEXPERT_ARM64_PLATFORM_H_
29 #define _PEXPERT_ARM64_PLATFORM_H_
30 
31 /*
32  * EmbeddedHeaders defines required: SPDS_ENABLE_STRUCTS and SPDS_ENABLE_ENUMS.
33  */
34 
35 #ifndef SPDS_ENABLE_STRUCTS
36 #define SPDS_ENABLE_STRUCTS                     1       // Enable structure definitions
37 #endif /* SPDS_ENABLE_STRUCTS */
38 #ifndef SPDS_ENABLE_ENUMS
39 #define SPDS_ENABLE_ENUMS                       1       // Enable enumeration definitions
40 #endif /* SPDS_ENABLE_ENUMS */
41 
42 #pragma mark EmbeddedHeaders include macros
43 /*
44  * Define a macro to construct an include path for a sub-platform file.
45  * Example: #include SUB_PLATFORM_SPDS_HEADER(p_acc)
46  * where ARM64_SOC_NAME is txxxx, and where SPDS_CHIP_REV_LC is a0
47  * Expands: #include <soc/txxxx/a0/module/p_acc.h>
48  * Lifted and adapted from iBoot/platform.h.
49  */
50 #define NOQUOTE(x) x
51 #define COMBINE3(a, b, c)                       NOQUOTE(a)NOQUOTE(b)NOQUOTE(c)
52 #define COMBINE5(a, b, c, d, e)                 NOQUOTE(a)NOQUOTE(b)NOQUOTE(c)NOQUOTE(d)NOQUOTE(e)
53 #define COMBINE7(a, b, c, d, e, f, g)           NOQUOTE(a)NOQUOTE(b)NOQUOTE(c)NOQUOTE(d)NOQUOTE(e)NOQUOTE(f)NOQUOTE(g)
54 
55 #define SUB_PLATFORM_HEADER(x)                  <COMBINE5(platform/,x,_,ARM64_SOC_NAME,.h)>
56 #define SUB_PLATFORM_SOC_HEADER(x)              <COMBINE5(platform/soc/,x,_,ARM64_SOC_NAME,.h)>
57 #define SUB_PLATFORM_NONMODULE_HEADER(x)        <COMBINE5(soc/,PLATFORM_SPDS_CHIP_REV_LC,/,x,.h)>
58 #define SUB_PLATFORM_SPDS_HEADER(x)             <COMBINE5(soc/,PLATFORM_SPDS_CHIP_REV_LC,/module/,x,.h)>
59 #define SUB_PLATFORM_TARGET_HEADER(x)           <COMBINE5(target/,x,_,ARM64_SOC_NAME,.h)>
60 #define SUB_PLATFORM_TUNABLE_HEADER(r, x)       <COMBINE7(platform/soc/tunables/,ARM64_SOC_NAME,/,r,/,x,.h)>
61 #define SUB_TARGET_TUNABLE_HEADER(r, t, x)      <COMBINE7(target/tunables/,t,/,r,/,x,.h)>
62 
63 #ifndef ARM64_SOC_NAME
64 #ifndef CURRENT_MACHINE_CONFIG_LC
65 #error CURRENT_MACHINE_CONFIG_LC must be defined in makedefs/MakeInc.def
66 #endif /* CURRENT_MACHINE_CONFIG_LC */
67 #define ARM64_SOC_NAME CURRENT_MACHINE_CONFIG_LC
68 #endif /* ARM64_SOC_NAME */
69 
70 #define SPDS_CHIP_REV_LC latest
71 #define PLATFORM_SPDS_CHIP_REV_LC ARM64_SOC_NAME/SPDS_CHIP_REV_LC
72 
73 #endif /* !_PEXPERT_ARM64_PLATFORM_H_ */
74