Lines Matching full:handle
56 static inline int get_entry(struct bindesc_handle *handle, const uint8_t *address, in get_entry() argument
63 if (IS_ENABLED(CONFIG_BINDESC_READ_FLASH) && handle->type == BINDESC_HANDLE_TYPE_FLASH) { in get_entry()
64 flash_retval = flash_read(handle->flash_device, (size_t)address, in get_entry()
65 handle->buffer, BINDESC_ENTRY_HEADER_SIZE); in get_entry()
72 if (((const struct bindesc_entry *)handle->buffer)->len + BINDESC_ENTRY_HEADER_SIZE in get_entry()
73 > sizeof(handle->buffer)) { in get_entry()
77 flash_retval = flash_read(handle->flash_device, in get_entry()
79 handle->buffer + BINDESC_ENTRY_HEADER_SIZE, in get_entry()
80 ((const struct bindesc_entry *)handle->buffer)->len); in get_entry()
86 *entry = (const struct bindesc_entry *)handle->buffer; in get_entry()
95 int bindesc_open_memory_mapped_flash(struct bindesc_handle *handle, size_t offset) in bindesc_open_memory_mapped_flash() argument
104 handle->address = address; in bindesc_open_memory_mapped_flash()
105 handle->type = BINDESC_HANDLE_TYPE_MEMORY_MAPPED_FLASH; in bindesc_open_memory_mapped_flash()
106 handle->size_limit = UINT16_MAX; in bindesc_open_memory_mapped_flash()
112 int bindesc_open_ram(struct bindesc_handle *handle, const uint8_t *address, size_t max_size) in bindesc_open_ram() argument
124 handle->address = address; in bindesc_open_ram()
125 handle->type = BINDESC_HANDLE_TYPE_RAM; in bindesc_open_ram()
126 handle->size_limit = max_size; in bindesc_open_ram()
132 int bindesc_open_flash(struct bindesc_handle *handle, size_t offset, in bindesc_open_flash() argument
137 retval = flash_read(flash_device, offset, handle->buffer, sizeof(BINDESC_MAGIC)); in bindesc_open_flash()
143 if (*(uint64_t *)handle->buffer != BINDESC_MAGIC) { in bindesc_open_flash()
148 handle->address = (uint8_t *)offset; in bindesc_open_flash()
149 handle->type = BINDESC_HANDLE_TYPE_FLASH; in bindesc_open_flash()
150 handle->flash_device = flash_device; in bindesc_open_flash()
151 handle->size_limit = UINT16_MAX; in bindesc_open_flash()
156 int bindesc_foreach(struct bindesc_handle *handle, bindesc_callback_t callback, void *user_data) in bindesc_foreach() argument
159 const uint8_t *address = handle->address; in bindesc_foreach()
165 retval = get_entry(handle, address, &entry); in bindesc_foreach()
179 ((address - handle->address) <= handle->size_limit)); in bindesc_foreach()
184 int bindesc_find_str(struct bindesc_handle *handle, uint16_t id, const char **result) in bindesc_find_str() argument
190 if (!bindesc_foreach(handle, find_callback, &data)) { in bindesc_find_str()
198 int bindesc_find_uint(struct bindesc_handle *handle, uint16_t id, const uint32_t **result) in bindesc_find_uint() argument
204 if (!bindesc_foreach(handle, find_callback, &data)) { in bindesc_find_uint()
212 int bindesc_find_bytes(struct bindesc_handle *handle, uint16_t id, const uint8_t **result, in bindesc_find_bytes() argument
219 if (!bindesc_foreach(handle, find_callback, &data)) { in bindesc_find_bytes()
228 int bindesc_get_size(struct bindesc_handle *handle, size_t *result) in bindesc_get_size() argument
232 return bindesc_foreach(handle, get_size_callback, result); in bindesc_get_size()