+
+#ifdef PLATFORM_BridgeOS
+struct pmap_legacy_trust_cache {
+ struct pmap_legacy_trust_cache *next;
+ uuid_t uuid;
+ uint32_t num_hashes;
+ uint8_t hashes[][CS_CDHASH_LEN];
+};
+#else
+struct pmap_legacy_trust_cache;
+#endif
+
+extern kern_return_t pmap_load_legacy_trust_cache(struct pmap_legacy_trust_cache *trust_cache,
+ const vm_size_t trust_cache_len);
+
+typedef enum {
+ PMAP_TC_TYPE_PERSONALIZED,
+ PMAP_TC_TYPE_PDI,
+ PMAP_TC_TYPE_CRYPTEX,
+ PMAP_TC_TYPE_ENGINEERING,
+ PMAP_TC_TYPE_GLOBAL_FF00,
+ PMAP_TC_TYPE_GLOBAL_FF01,
+} pmap_tc_type_t;
+
+#define PMAP_IMAGE4_TRUST_CACHE_HAS_TYPE 1
+struct pmap_image4_trust_cache {
+ // Filled by pmap layer.
+ struct pmap_image4_trust_cache const *next; // linked list linkage
+ struct trust_cache_module1 const *module; // pointer into module (within data below)
+
+ // Filled by caller.
+ // data is either an image4,
+ // or just the trust cache payload itself if the image4 manifest is external.
+ pmap_tc_type_t type;
+ size_t bnch_len;
+ uint8_t const bnch[48];
+ size_t data_len;
+ uint8_t const data[];
+};
+
+typedef enum {
+ PMAP_TC_SUCCESS = 0,
+ PMAP_TC_UNKNOWN_FORMAT = -1,
+ PMAP_TC_TOO_SMALL_FOR_HEADER = -2,
+ PMAP_TC_TOO_SMALL_FOR_ENTRIES = -3,
+ PMAP_TC_UNKNOWN_VERSION = -4,
+ PMAP_TC_ALREADY_LOADED = -5,
+ PMAP_TC_TOO_BIG = -6,
+ PMAP_TC_RESOURCE_SHORTAGE = -7,
+ PMAP_TC_MANIFEST_TOO_BIG = -8,
+ PMAP_TC_MANIFEST_VIOLATION = -9,
+ PMAP_TC_PAYLOAD_VIOLATION = -10,
+ PMAP_TC_EXPIRED = -11,
+ PMAP_TC_CRYPTO_WRONG = -12,
+ PMAP_TC_OBJECT_WRONG = -13,
+ PMAP_TC_UNKNOWN_CALLER = -14,
+ PMAP_TC_UNKNOWN_FAILURE = -15,
+} pmap_tc_ret_t;
+
+#define PMAP_HAS_LOCKDOWN_IMAGE4_SLAB 1
+extern void pmap_lockdown_image4_slab(vm_offset_t slab, vm_size_t slab_len, uint64_t flags);
+
+extern pmap_tc_ret_t pmap_load_image4_trust_cache(
+ struct pmap_image4_trust_cache *trust_cache, vm_size_t trust_cache_len,
+ uint8_t const *img4_manifest,
+ vm_size_t img4_manifest_buffer_len,
+ vm_size_t img4_manifest_actual_len,
+ bool dry_run);
+
+extern bool pmap_is_trust_cache_loaded(const uuid_t uuid);
+extern uint32_t pmap_lookup_in_static_trust_cache(const uint8_t cdhash[CS_CDHASH_LEN]);
+extern bool pmap_lookup_in_loaded_trust_caches(const uint8_t cdhash[CS_CDHASH_LEN]);
+
+extern bool pmap_in_ppl(void);
+
+extern void *pmap_claim_reserved_ppl_page(void);
+extern void pmap_free_reserved_ppl_page(void *kva);
+
+extern void pmap_ledger_alloc_init(size_t);
+extern ledger_t pmap_ledger_alloc(void);
+extern void pmap_ledger_free(ledger_t);
+
+#if __arm64__
+extern bool pmap_is_exotic(pmap_t pmap);
+#else /* __arm64__ */
+#define pmap_is_exotic(pmap) false
+#endif /* __arm64__ */
+