xref: /xnu-10002.41.9/EXTERNAL_HEADERS/img4/4xnu.h (revision 699cd48037512bf4380799317ca44ca453c82f57)
1 /*!
2  * @header
3  * xnu-specific interfaces. These are hacks that only exist because xnu doesn't
4  * like linking static libraries, and we have a pre-existing contract for how to
5  * export our interfaces to xnu.
6  */
7 #ifndef __IMG4_4XNU_H
8 #define __IMG4_4XNU_H
9 
10 #ifndef __IMG4_INDIRECT
11 #error "Please #include <img4/firmware.h> instead of this file directly"
12 #endif // __IMG4_INDIRECT
13 
14 __BEGIN_DECLS
15 OS_ASSUME_NONNULL_BEGIN
16 
17 /*!
18  * @function img4_get_manifest
19  * Returns a buffer representing the Image4 manifest bytes within the given DER
20  * blob.
21  *
22  * @param buff
23  * The buffer to examine for the Image4 manifest.
24  *
25  * @param len
26  * The length of {@link buff}.
27  *
28  * @param buff_storage
29  * Upon successful return, a buffer object which will contain a pointer to and
30  * the length of the Image4 manifest.
31  *
32  * @result
33  * Upon success, {@link buff_storage} is returned. If the DER blob contains no
34  * Image4 manifest, then NULL is returned.
35  */
36 #if !XNU_KERNEL_PRIVATE
37 IMG4_API_AVAILABLE_20211105
38 OS_EXPORT OS_WARN_RESULT OS_NONNULL1 OS_NONNULL3
39 const img4_buff_t *
40 img4_get_manifest(const void *buff, size_t len, img4_buff_t *buff_storage);
41 #else
42 #define img4_get_manifest(...) \
43 		(img4if->i4if_v15.get_manifest(__VA_ARGS__))
44 #endif
45 
46 /*!
47  * @function img4_get_payload
48  * Returns a buffer representing the Image4 payload bytes within the given DER
49  * blob.
50  *
51  * @param buff
52  * The buffer to examine for the Image4 payload.
53  *
54  * @param len
55  * The length of {@link buff}.
56  *
57  * @param buff_storage
58  * Upon successful return, a buffer object which will contain a pointer to and
59  * the length of the Image4 manifest.
60  *
61  * @result
62  * Upon success, {@link buff_storage} is returned. If the DER blob contains no
63  * Image4 payload, then NULL is returned.
64  */
65 #if !XNU_KERNEL_PRIVATE
66 IMG4_API_AVAILABLE_20211105
67 OS_EXPORT OS_WARN_RESULT OS_NONNULL1 OS_NONNULL3
68 const img4_buff_t *
69 img4_get_payload(const void *buff, size_t len, img4_buff_t *buff_storage);
70 #else
71 #define img4_get_payload(...) \
72 		(img4if->i4if_v15.get_payload(__VA_ARGS__))
73 #endif
74 
75 OS_ASSUME_NONNULL_END
76 __END_DECLS
77 
78 #endif // __IMG4_4XNU_H
79