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
15OS_ASSUME_NONNULL_BEGIN
16OS_ASSUME_PTR_ABI_SINGLE_BEGIN
17
18/*!
19 * @function img4_get_manifest
20 * Returns a buffer representing the Image4 manifest bytes within the given DER
21 * blob.
22 *
23 * @param buff
24 * The buffer to examine for the Image4 manifest.
25 *
26 * @param len
27 * The length of {@link buff}.
28 *
29 * @param buff_storage
30 * Upon successful return, a buffer object which will contain a pointer to and
31 * the length of the Image4 manifest.
32 *
33 * @result
34 * Upon success, {@link buff_storage} is returned. If the DER blob contains no
35 * Image4 manifest, then NULL is returned.
36 */
37#if !XNU_KERNEL_PRIVATE
38IMG4_API_AVAILABLE_20211105
39OS_EXPORT OS_WARN_RESULT OS_NONNULL1 OS_NONNULL3
40const img4_buff_t *
41img4_get_manifest(const void *__sized_by(len) buff, size_t len,
42 img4_buff_t *buff_storage);
43#else
44#define img4_get_manifest(...) \
45 (img4if->i4if_v15.get_manifest(__VA_ARGS__))
46#endif
47
48/*!
49 * @function img4_get_payload
50 * Returns a buffer representing the Image4 payload bytes within the given DER
51 * blob.
52 *
53 * @param buff
54 * The buffer to examine for the Image4 payload.
55 *
56 * @param len
57 * The length of {@link buff}.
58 *
59 * @param buff_storage
60 * Upon successful return, a buffer object which will contain a pointer to and
61 * the length of the Image4 manifest.
62 *
63 * @result
64 * Upon success, {@link buff_storage} is returned. If the DER blob contains no
65 * Image4 payload, then NULL is returned.
66 */
67#if !XNU_KERNEL_PRIVATE
68IMG4_API_AVAILABLE_20211105
69OS_EXPORT OS_WARN_RESULT OS_NONNULL1 OS_NONNULL3
70const img4_buff_t *
71img4_get_payload(const void *__sized_by(len) buff, size_t len,
72 img4_buff_t *buff_storage);
73#else
74#define img4_get_payload(...) \
75 (img4if->i4if_v15.get_payload(__VA_ARGS__))
76#endif
77
78OS_ASSUME_PTR_ABI_SINGLE_END
79OS_ASSUME_NONNULL_END
80__END_DECLS
81
82#endif // __IMG4_4XNU_H
83