1 // © 2022 Qualcomm Innovation Center, Inc. All rights reserved. 2 // 3 // SPDX-License-Identifier: BSD-3-Clause 4 5 // Note that the GPT is not thread-safe by default; the caller must use an 6 // external lock or some other protection to prevent concurrent calls to these 7 // APIs. If the rcu_read option is set in the GPT's config, read-only operations 8 // will be protected by RCU, and external locking is only required for write 9 // operations. 10 11 // Initialise the GPT. 12 error_t 13 gpt_init(gpt_t *gpt, partition_t *partition, gpt_config_t config, 14 register_t allowed_types); 15 16 // Destroy the GPT. 17 void 18 gpt_destroy(gpt_t *gpt); 19 20 // Insert a range into the GPT. 21 // 22 // If expect_empty is true, the operation will fail if any part of the range is 23 // not found to be empty during insertion. Otherwise, any existing entries in 24 // the range will be overwritten. 25 error_t 26 gpt_insert(gpt_t *gpt, size_t base, size_t size, gpt_entry_t entry, 27 bool expect_empty); 28 29 // Update a range in the GPT. 30 // 31 // The update will fail if all entries over the range do not match the given old 32 // entry. If successful, all old entries will be replaced with the new entry. 33 error_t 34 gpt_update(gpt_t *gpt, size_t base, size_t size, gpt_entry_t old_entry, 35 gpt_entry_t new_entry); 36 37 // Remove a range from the GPT. 38 // 39 // This will fail if all entries over the range do not match the given entry. 40 error_t 41 gpt_remove(gpt_t *gpt, size_t base, size_t size, gpt_entry_t entry); 42 43 // Clear a range in the GPT. 44 error_t 45 gpt_clear(gpt_t *gpt, size_t base, size_t size); 46 47 // Clear the entire GPT. 48 void 49 gpt_clear_all(gpt_t *gpt); 50 51 // Returns true if the GPT is empty. 52 bool 53 gpt_is_empty(gpt_t *gpt); 54 55 // Lookup a range in the GPT. 56 // 57 // This function returns the entry found at the given base, and returns the size 58 // of this entry, which will be capped at max_size. 59 gpt_lookup_result_t 60 gpt_lookup(gpt_t *gpt, size_t base, size_t max_size); 61 62 // Returns true if an entry is contiguous over a range in the GPT. 63 bool 64 gpt_is_contiguous(gpt_t *gpt, size_t base, size_t size, gpt_entry_t entry); 65 66 // Walk over a range in the GPT and perform a callback for regions matching 67 // the given type. 68 error_t 69 gpt_walk(gpt_t *gpt, size_t base, size_t size, gpt_type_t type, 70 gpt_callback_t callback, gpt_arg_t arg); 71 72 // Walk over the GPT and dump all contiguous ranges. 73 // 74 // This function is intended for debug use only. 75 void 76 gpt_dump_ranges(gpt_t *gpt); 77 78 // Walk over the GPT and dump all levels. 79 // 80 // This function is intended for debug use only. 81 void 82 gpt_dump_levels(gpt_t *gpt); 83