Simon Glass | dd7fb9b | 2019-12-06 21:41:34 -0700 | [diff] [blame] | 1 | /* SPDX-License-Identifier: Intel */ |
| 2 | /* |
| 3 | * Access to binman information at runtime |
| 4 | * |
| 5 | * Copyright 2019 Google LLC |
| 6 | * Written by Simon Glass <sjg@chromium.org> |
| 7 | */ |
| 8 | |
| 9 | #ifndef _BINMAN_H_ |
| 10 | #define _BINMAN_H_ |
| 11 | |
Simon Glass | c4d9faf | 2020-07-07 21:32:04 -0600 | [diff] [blame] | 12 | #include <dm/ofnode.h> |
| 13 | |
Simon Glass | dd7fb9b | 2019-12-06 21:41:34 -0700 | [diff] [blame] | 14 | /** |
| 15 | *struct binman_entry - information about a binman entry |
| 16 | * |
| 17 | * @image_pos: Position of entry in the image |
| 18 | * @size: Size of entry |
| 19 | */ |
| 20 | struct binman_entry { |
| 21 | u32 image_pos; |
| 22 | u32 size; |
| 23 | }; |
| 24 | |
| 25 | /** |
Simon Glass | c4d9faf | 2020-07-07 21:32:04 -0600 | [diff] [blame] | 26 | * binman_entry_map() - Look up the address of an entry in memory |
| 27 | * |
| 28 | * @parent: Parent binman node |
| 29 | * @name: Name of entry |
| 30 | * @bufp: Returns a pointer to the entry |
| 31 | * @sizep: Returns the size of the entry |
Heinrich Schuchardt | 47b4c02 | 2022-01-19 18:05:50 +0100 | [diff] [blame] | 32 | * Return: 0 on success, -EPERM if the ROM offset is not set, -ENOENT if the |
Simon Glass | c4d9faf | 2020-07-07 21:32:04 -0600 | [diff] [blame] | 33 | * entry cannot be found, other error code other error |
| 34 | */ |
| 35 | int binman_entry_map(ofnode parent, const char *name, void **bufp, int *sizep); |
| 36 | |
| 37 | /** |
Simon Glass | c0ef789 | 2020-07-07 21:32:02 -0600 | [diff] [blame] | 38 | * binman_set_rom_offset() - Set the ROM memory-map offset |
| 39 | * |
| 40 | * @rom_offset: Offset from an image_pos to the memory-mapped address. This |
| 41 | * tells binman that ROM image_pos x can be addressed at rom_offset + x |
| 42 | */ |
| 43 | void binman_set_rom_offset(int rom_offset); |
| 44 | |
| 45 | /** |
Simon Glass | dff2ea1 | 2020-09-27 18:46:19 -0600 | [diff] [blame] | 46 | * binman_get_rom_offset() - Get the ROM memory-map offset |
| 47 | * |
| 48 | * @returns offset from an image_pos to the memory-mapped address |
| 49 | */ |
| 50 | int binman_get_rom_offset(void); |
| 51 | |
| 52 | /** |
Simon Glass | dd7fb9b | 2019-12-06 21:41:34 -0700 | [diff] [blame] | 53 | * binman_entry_find() - Find a binman symbol |
| 54 | * |
| 55 | * This searches the binman information in the device tree for a symbol of the |
| 56 | * given name |
| 57 | * |
| 58 | * @name: Path to entry to examine (e.g. "/read-only/u-boot") |
| 59 | * @entry: Returns information about the entry |
Heinrich Schuchardt | 47b4c02 | 2022-01-19 18:05:50 +0100 | [diff] [blame] | 60 | * Return: 0 if OK, -ENOENT if the path is not found, other -ve value if the |
Simon Glass | dd7fb9b | 2019-12-06 21:41:34 -0700 | [diff] [blame] | 61 | * binman information is invalid (missing image-pos or size) |
| 62 | */ |
| 63 | int binman_entry_find(const char *name, struct binman_entry *entry); |
| 64 | |
| 65 | /** |
Simon Glass | c4d9faf | 2020-07-07 21:32:04 -0600 | [diff] [blame] | 66 | * binman_section_find_node() - Find a binman node |
| 67 | * |
| 68 | * @name: Name of node to look for |
Heinrich Schuchardt | 47b4c02 | 2022-01-19 18:05:50 +0100 | [diff] [blame] | 69 | * Return: Node that was found, ofnode_null() if not found |
Simon Glass | c4d9faf | 2020-07-07 21:32:04 -0600 | [diff] [blame] | 70 | */ |
| 71 | ofnode binman_section_find_node(const char *name); |
| 72 | |
| 73 | /** |
Simon Glass | 23c0ea5 | 2021-01-13 20:29:57 -0700 | [diff] [blame] | 74 | * binman_select_subnode() - Select a subnode to use to find entries |
| 75 | * |
| 76 | * Normally binman selects the top-level node for future entry requests, such as |
| 77 | * binman_entry_find(). This function allows a subnode to be chosen instead. |
| 78 | * |
| 79 | * @name: Name of subnode, typically a section. This must be in the top-level |
| 80 | * binman node |
Heinrich Schuchardt | 47b4c02 | 2022-01-19 18:05:50 +0100 | [diff] [blame] | 81 | * Return: 0 if OK, -EINVAL if there is no /binman node, -ECHILD if multiple |
Simon Glass | 23c0ea5 | 2021-01-13 20:29:57 -0700 | [diff] [blame] | 82 | * images are being used but the first image is not available, -ENOENT if |
| 83 | * the requested subnode cannot be found |
| 84 | */ |
| 85 | int binman_select_subnode(const char *name); |
| 86 | |
| 87 | /** |
Simon Glass | dd7fb9b | 2019-12-06 21:41:34 -0700 | [diff] [blame] | 88 | * binman_init() - Set up the binman symbol information |
| 89 | * |
| 90 | * This locates the binary symbol information in the device tree ready for use |
| 91 | * |
Heinrich Schuchardt | 47b4c02 | 2022-01-19 18:05:50 +0100 | [diff] [blame] | 92 | * Return: 0 if OK, -ENOMEM if out of memory, -EINVAL if there is no binman node |
Simon Glass | dd7fb9b | 2019-12-06 21:41:34 -0700 | [diff] [blame] | 93 | */ |
| 94 | int binman_init(void); |
| 95 | |
| 96 | #endif |