2 * Symbol access for symbols set up by binman as part of the build.
4 * This allows C code to access the position of a particular part of the image
7 * Copyright (c) 2017 Google, Inc
9 * SPDX-License-Identifier: GPL-2.0+
12 #ifndef __BINMAN_SYM_H
13 #define __BINMAN_SYM_H
15 #define BINMAN_SYM_MISSING (-1UL)
20 * binman_symname() - Internal fnuction to get a binman symbol name
22 * @entry_name: Name of the entry to look for (e.g. 'u_boot_spl')
23 * @_prop_name: Property value to get from that entry (e.g. 'pos')
24 * @returns name of the symbol for that entry and property
26 #define binman_symname(_entry_name, _prop_name) \
27 _binman_ ## _entry_name ## _prop_ ## _prop_name
30 * binman_sym_declare() - Declare a symbol that will be used at run-time
32 * @_type: Type f the symbol (e.g. unsigned long)
33 * @entry_name: Name of the entry to look for (e.g. 'u_boot_spl')
34 * @_prop_name: Property value to get from that entry (e.g. 'pos')
36 #define binman_sym_declare(_type, _entry_name, _prop_name) \
37 _type binman_symname(_entry_name, _prop_name) \
38 __attribute__((aligned(4), unused, section(".binman_sym")))
41 * binman_sym_extern() - Declare a extern symbol that will be used at run-time
43 * @_type: Type f the symbol (e.g. unsigned long)
44 * @entry_name: Name of the entry to look for (e.g. 'u_boot_spl')
45 * @_prop_name: Property value to get from that entry (e.g. 'pos')
47 #define binman_sym_extern(_type, _entry_name, _prop_name) \
48 extern _type binman_symname(_entry_name, _prop_name) \
49 __attribute__((aligned(4), unused, section(".binman_sym")))
52 * binman_sym_declare_optional() - Declare an optional symbol
54 * If this symbol cannot be provided by binman, an error will not be generated.
55 * Instead the image will be assigned the value BINMAN_SYM_MISSING.
57 * @_type: Type f the symbol (e.g. unsigned long)
58 * @entry_name: Name of the entry to look for (e.g. 'u_boot_spl')
59 * @_prop_name: Property value to get from that entry (e.g. 'pos')
61 #define binman_sym_declare_optional(_type, _entry_name, _prop_name) \
62 _type binman_symname(_entry_name, _prop_name) \
63 __attribute__((aligned(4), weak, unused, \
64 section(".binman_sym")))
67 * binman_sym() - Access a previously declared symbol
69 * This is used to get the value of a symbol. E.g.:
71 * ulong address = binman_sym(ulong, u_boot_spl, pos);
73 * @_type: Type f the symbol (e.g. unsigned long)
74 * @entry_name: Name of the entry to look for (e.g. 'u_boot_spl')
75 * @_prop_name: Property value to get from that entry (e.g. 'pos')
76 * @returns value of that property (filled in by binman)
78 #define binman_sym(_type, _entry_name, _prop_name) \
79 (*(_type *)&binman_symname(_entry_name, _prop_name))
83 #define binman_sym_declare(_type, _entry_name, _prop_name)
85 #define binman_sym_declare_optional(_type, _entry_name, _prop_name)
87 #define binman_sym_extern(_type, _entry_name, _prop_name)
89 #define binman_sym(_type, _entry_name, _prop_name) BINMAN_SYM_MISSING