xref: /xnu-8020.121.3/osfmk/arm/commpage/commpage_sigs.h (revision fdd8201d7b966f0c3ea610489d29bd841d358941)
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 #define BSWAP_32(x) \
29 	(((x) << 24) & 0xff000000) | \
30 	(((x) <<  8) & 0x00ff0000) | \
31 	(((x) >>  8) & 0x0000ff00) | \
32 	(((x) >> 24) & 0x000000ff)
33 
34 #define BSWAP_32_OFFSET(x) \
35 	BSWAP_32(x + _COMM_PAGE_SIGS_OFFSET)
36 
37 #define COMMPAGE_SIGS_BEGIN \
38 .const_data				; \
39 .align 2				; \
40 .private_extern _commpage_sigs_begin	; \
41 _commpage_sigs_begin:
42 
43 #define COMMPAGE_SIGS_DONE \
44 .private_extern _commpage_sigs_end	; \
45 _commpage_sigs_end:			; \
46 
47 #define COMMPAGE_SIG_START(x) \
48 .private_extern _commpage_sig ## x      ; \
49 _commpage_sig ## x ## :			; \
50 	.long BSWAP_32(0x14400000)	; \
51 	.long BSWAP_32(0x00000001)	; \
52 	.asciz # x                      ; \
53 	.align 2			; \
54 	.long BSWAP_32(0x14400000)
55 
56 #define COMMPAGE_SIG_END(x) \
57 	.long BSWAP_32(0x4e800020)	; \
58 	.long BSWAP_32(0x14400000)	; \
59 	.long BSWAP_32(0x00000000)	; \
60 	.asciz # x			; \
61 	.align 2			; \
62 	.long BSWAP_32(0x14400000)
63 
64 #define OBJCRTP_SIG_START(x) COMMPAGE_SIG_START(x)
65 
66 #define OBJCRTP_SIG_END(x) \
67 	.long BSWAP_32(0x14400000)      ; \
68 	.long BSWAP_32(0x00000000)      ; \
69 	.asciz # x                      ; \
70 	.align 2                        ; \
71 	.long BSWAP_32(0x14400000)
72 
73 #define OBJCRTP_SIG_CALL_SUBJECT(x) \
74 	.long BSWAP_32(0x14400002)      ; \
75 	.long BSWAP_32(0x00000000)      ; \
76 	.long BSWAP_32(0x00040000)      ; \
77 	.long BSWAP_32(0x00000000)      ; \
78 	.asciz # x                      ; \
79 	.align 2                        ; \
80 	.long BSWAP_32(0x14400002)
81 
82 #define ARG(n) \
83 	((((n * 2) + 6) << 20) + 4)
84 
85 #define COMMPAGE_SIG_ARG(n) \
86 	.long BSWAP_32(0x14400001)	; \
87 	.long BSWAP_32(ARG(n))		; \
88 	.long BSWAP_32(0x14400001)
89 
90 #define COMMPAGE_SIG_CALL(x, n) \
91 	.long BSWAP_32(0x14400002)	; \
92 	.long BSWAP_32(n)		; \
93 	.long BSWAP_32(0x00000000)	; \
94 	.long BSWAP_32(0x00000000)	; \
95 	.asciz # x			; \
96 	.align 2			; \
97 	.long BSWAP_32(0x14400002)
98 
99 #define COMMPAGE_SIG_CALL_VOID(x) \
100 	COMMPAGE_SIG_CALL(x, 0)
101 
102 #define COMMPAGE_SIG_CALL_RET0(x) \
103 	COMMPAGE_SIG_CALL(x, ARG(0))
104 
105 #define COMMPAGE_SIG_CALL_RET1(x) \
106 	COMMPAGE_SIG_CALL(x, ARG(1))
107 
108 #define COMMPAGE_FAST_TRAP(x) \
109 	.long BSWAP_32(0x14400005) ; \
110 	.long BSWAP_32_OFFSET(x) ; \
111 	.long BSWAP_32(0x14400005)
112