summaryrefslogtreecommitdiff
path: root/include/binman.h
blob: 5958dfb44852062175038ec9cf01fd86b961bbb9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
/* SPDX-License-Identifier: Intel */
/*
 * Access to binman information at runtime
 *
 * Copyright 2019 Google LLC
 * Written by Simon Glass <sjg@chromium.org>
 */

#ifndef _BINMAN_H_
#define _BINMAN_H_

#include <dm/ofnode.h>

/**
 *struct binman_entry - information about a binman entry
 *
 * @image_pos: Position of entry in the image
 * @size: Size of entry
 */
struct binman_entry {
	u32 image_pos;
	u32 size;
};

/**
 * binman_entry_map() - Look up the address of an entry in memory
 *
 * @parent: Parent binman node
 * @name: Name of entry
 * @bufp: Returns a pointer to the entry
 * @sizep: Returns the size of the entry
 * @return 0 on success, -EPERM if the ROM offset is not set, -ENOENT if the
 *	entry cannot be found, other error code other error
 */
int binman_entry_map(ofnode parent, const char *name, void **bufp, int *sizep);

/**
 * binman_set_rom_offset() - Set the ROM memory-map offset
 *
 * @rom_offset: Offset from an image_pos to the memory-mapped address. This
 *	tells binman that ROM image_pos x can be addressed at rom_offset + x
 */
void binman_set_rom_offset(int rom_offset);

/**
 * binman_get_rom_offset() - Get the ROM memory-map offset
 *
 * @returns offset from an image_pos to the memory-mapped address
 */
int binman_get_rom_offset(void);

/**
 * binman_entry_find() - Find a binman symbol
 *
 * This searches the binman information in the device tree for a symbol of the
 * given name
 *
 * @name: Path to entry to examine (e.g. "/read-only/u-boot")
 * @entry: Returns information about the entry
 * @return 0 if OK, -ENOENT if the path is not found, other -ve value if the
 *	binman information is invalid (missing image-pos or size)
 */
int binman_entry_find(const char *name, struct binman_entry *entry);

/**
 * binman_section_find_node() - Find a binman node
 *
 * @name: Name of node to look for
 * @return Node that was found, ofnode_null() if not found
 */
ofnode binman_section_find_node(const char *name);

/**
 * binman_select_subnode() - Select a subnode to use to find entries
 *
 * Normally binman selects the top-level node for future entry requests, such as
 * binman_entry_find(). This function allows a subnode to be chosen instead.
 *
 * @name: Name of subnode, typically a section. This must be in the top-level
 *	binman node
 * @return 0 if OK, -EINVAL if there is no /binman node, -ECHILD if multiple
 *	images are being used but the first image is not available, -ENOENT if
 *	the requested subnode cannot be found
 */
int binman_select_subnode(const char *name);

/**
 * binman_init() - Set up the binman symbol information
 *
 * This locates the binary symbol information in the device tree ready for use
 *
 * @return 0 if OK, -ENOMEM if out of memory, -EINVAL if there is no binman node
 */
int binman_init(void);

#endif