blob: 8b89a9666d5940bfdba8694928e3c2dc58c4e607 [file] [log] [blame]
Simon Glassdd7fb9b2019-12-06 21:41:34 -07001/* 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 Glassc4d9faf2020-07-07 21:32:04 -060012#include <dm/ofnode.h>
13
Simon Glassdd7fb9b2019-12-06 21:41:34 -070014/**
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 */
20struct binman_entry {
21 u32 image_pos;
22 u32 size;
23};
24
25/**
Simon Glassc4d9faf2020-07-07 21:32:04 -060026 * 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
32 * @return 0 on success, -EPERM if the ROM offset is not set, -ENOENT if the
33 * entry cannot be found, other error code other error
34 */
35int binman_entry_map(ofnode parent, const char *name, void **bufp, int *sizep);
36
37/**
Simon Glassc0ef7892020-07-07 21:32:02 -060038 * 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 */
43void binman_set_rom_offset(int rom_offset);
44
45/**
Simon Glassdff2ea12020-09-27 18:46:19 -060046 * binman_get_rom_offset() - Get the ROM memory-map offset
47 *
48 * @returns offset from an image_pos to the memory-mapped address
49 */
50int binman_get_rom_offset(void);
51
52/**
Simon Glassdd7fb9b2019-12-06 21:41:34 -070053 * 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
60 * @return 0 if OK, -ENOENT if the path is not found, other -ve value if the
61 * binman information is invalid (missing image-pos or size)
62 */
63int binman_entry_find(const char *name, struct binman_entry *entry);
64
65/**
Simon Glassc4d9faf2020-07-07 21:32:04 -060066 * binman_section_find_node() - Find a binman node
67 *
68 * @name: Name of node to look for
69 * @return Node that was found, ofnode_null() if not found
70 */
71ofnode binman_section_find_node(const char *name);
72
73/**
Simon Glassdd7fb9b2019-12-06 21:41:34 -070074 * binman_init() - Set up the binman symbol information
75 *
76 * This locates the binary symbol information in the device tree ready for use
77 *
78 * @return 0 if OK, -ENOMEM if out of memory, -EINVAL if there is no binman node
79 */
80int binman_init(void);
81
82#endif