mirror of
https://github.com/AsahiLinux/u-boot
synced 2024-12-30 15:03:18 +00:00
d8830cf840
Enabling CONFIG_BINMAN makes binman run after a build to package any images specified in the device-tree. It also enables a mechanism for SPL/TPL to declare and use special linker symbols that refer to other entries in the same binman image. A similar feature that gets this info from the device-tree exists for U-Boot proper, but it is gated behind a CONFIG_BINMAN_FDT unlike the symbols. Confusingly, CONFIG_SPL/TPL_BINMAN_SYMBOLS also exist. These configs don't actually enable/disable the symbols mechanism as one would expect, but declare some symbols for U-Boot using this mechanism. Reuse the BINMAN_SYMBOLS configs to make them toggle the symbols mechanism, and declare symbols for the U-Boot phases in a dependent BINMAN_UBOOT_SYMBOLS config. Extend it to cover symbols of all phases. Update the config prompt and help message to make it clearer about this. Fix binman test binaries to work with CONFIG_IS_ENABLED(BINMAN_SYMBOLS). Co-developed-by: Peng Fan <peng.fan@nxp.com> [Alper: New config for phase symbols, update Kconfigs, commit message] Signed-off-by: Alper Nebi Yasak <alpernebiyasak@gmail.com>
92 lines
3.1 KiB
C
92 lines
3.1 KiB
C
/* SPDX-License-Identifier: GPL-2.0+ */
|
|
/*
|
|
* Symbol access for symbols set up by binman as part of the build.
|
|
*
|
|
* This allows C code to access the position of a particular part of the image
|
|
* assembled by binman.
|
|
*
|
|
* Copyright (c) 2017 Google, Inc
|
|
*/
|
|
|
|
#ifndef __BINMAN_SYM_H
|
|
#define __BINMAN_SYM_H
|
|
|
|
#define BINMAN_SYM_MISSING (-1UL)
|
|
|
|
#if CONFIG_IS_ENABLED(BINMAN_SYMBOLS)
|
|
|
|
/**
|
|
* binman_symname() - Internal function to get a binman symbol name
|
|
*
|
|
* @entry_name: Name of the entry to look for (e.g. 'u_boot_spl')
|
|
* @_prop_name: Property value to get from that entry (e.g. 'pos')
|
|
* @returns name of the symbol for that entry and property
|
|
*/
|
|
#define binman_symname(_entry_name, _prop_name) \
|
|
_binman_ ## _entry_name ## _prop_ ## _prop_name
|
|
|
|
/**
|
|
* binman_sym_declare() - Declare a symbol that will be used at run-time
|
|
*
|
|
* @_type: Type f the symbol (e.g. unsigned long)
|
|
* @entry_name: Name of the entry to look for (e.g. 'u_boot_spl')
|
|
* @_prop_name: Property value to get from that entry (e.g. 'pos')
|
|
*/
|
|
#define binman_sym_declare(_type, _entry_name, _prop_name) \
|
|
_type binman_symname(_entry_name, _prop_name) \
|
|
__attribute__((aligned(4), unused, section(".binman_sym")))
|
|
|
|
/**
|
|
* binman_sym_extern() - Declare a extern symbol that will be used at run-time
|
|
*
|
|
* @_type: Type f the symbol (e.g. unsigned long)
|
|
* @entry_name: Name of the entry to look for (e.g. 'u_boot_spl')
|
|
* @_prop_name: Property value to get from that entry (e.g. 'pos')
|
|
*/
|
|
#define binman_sym_extern(_type, _entry_name, _prop_name) \
|
|
extern _type binman_symname(_entry_name, _prop_name) \
|
|
__attribute__((aligned(4), unused, section(".binman_sym")))
|
|
|
|
/**
|
|
* binman_sym_declare_optional() - Declare an optional symbol
|
|
*
|
|
* If this symbol cannot be provided by binman, an error will not be generated.
|
|
* Instead the image will be assigned the value BINMAN_SYM_MISSING.
|
|
*
|
|
* @_type: Type f the symbol (e.g. unsigned long)
|
|
* @entry_name: Name of the entry to look for (e.g. 'u_boot_spl')
|
|
* @_prop_name: Property value to get from that entry (e.g. 'pos')
|
|
*/
|
|
#define binman_sym_declare_optional(_type, _entry_name, _prop_name) \
|
|
_type binman_symname(_entry_name, _prop_name) \
|
|
__attribute__((aligned(4), weak, unused, \
|
|
section(".binman_sym")))
|
|
|
|
/**
|
|
* binman_sym() - Access a previously declared symbol
|
|
*
|
|
* This is used to get the value of a symbol. E.g.:
|
|
*
|
|
* ulong address = binman_sym(ulong, u_boot_spl, pos);
|
|
*
|
|
* @_type: Type f the symbol (e.g. unsigned long)
|
|
* @entry_name: Name of the entry to look for (e.g. 'u_boot_spl')
|
|
* @_prop_name: Property value to get from that entry (e.g. 'pos')
|
|
* @returns value of that property (filled in by binman)
|
|
*/
|
|
#define binman_sym(_type, _entry_name, _prop_name) \
|
|
(*(_type *)&binman_symname(_entry_name, _prop_name))
|
|
|
|
#else /* !CONFIG_IS_ENABLED(BINMAN_SYMBOLS) */
|
|
|
|
#define binman_sym_declare(_type, _entry_name, _prop_name)
|
|
|
|
#define binman_sym_declare_optional(_type, _entry_name, _prop_name)
|
|
|
|
#define binman_sym_extern(_type, _entry_name, _prop_name)
|
|
|
|
#define binman_sym(_type, _entry_name, _prop_name) BINMAN_SYM_MISSING
|
|
|
|
#endif /* CONFIG_IS_ENABLED(BINMAN_SYMBOLS) */
|
|
|
|
#endif
|