119790632SSimon Glass /* 219790632SSimon Glass * Symbol access for symbols set up by binman as part of the build. 319790632SSimon Glass * 419790632SSimon Glass * This allows C code to access the position of a particular part of the image 519790632SSimon Glass * assembled by binman. 619790632SSimon Glass * 719790632SSimon Glass * Copyright (c) 2017 Google, Inc 819790632SSimon Glass * 919790632SSimon Glass * SPDX-License-Identifier: GPL-2.0+ 1019790632SSimon Glass */ 1119790632SSimon Glass 1219790632SSimon Glass #ifndef __BINMAN_SYM_H 1319790632SSimon Glass #define __BINMAN_SYM_H 1419790632SSimon Glass 1519790632SSimon Glass #define BINMAN_SYM_MISSING (-1UL) 1619790632SSimon Glass 1719790632SSimon Glass #ifdef CONFIG_BINMAN 1819790632SSimon Glass 1919790632SSimon Glass /** 2019790632SSimon Glass * binman_symname() - Internal fnuction to get a binman symbol name 2119790632SSimon Glass * 2219790632SSimon Glass * @entry_name: Name of the entry to look for (e.g. 'u_boot_spl') 2319790632SSimon Glass * @_prop_name: Property value to get from that entry (e.g. 'pos') 2419790632SSimon Glass * @returns name of the symbol for that entry and property 2519790632SSimon Glass */ 2619790632SSimon Glass #define binman_symname(_entry_name, _prop_name) \ 2719790632SSimon Glass _binman_ ## _entry_name ## _prop_ ## _prop_name 2819790632SSimon Glass 2919790632SSimon Glass /** 3019790632SSimon Glass * binman_sym_declare() - Declare a symbol that will be used at run-time 3119790632SSimon Glass * 3219790632SSimon Glass * @_type: Type f the symbol (e.g. unsigned long) 3319790632SSimon Glass * @entry_name: Name of the entry to look for (e.g. 'u_boot_spl') 3419790632SSimon Glass * @_prop_name: Property value to get from that entry (e.g. 'pos') 3519790632SSimon Glass */ 3619790632SSimon Glass #define binman_sym_declare(_type, _entry_name, _prop_name) \ 3719790632SSimon Glass _type binman_symname(_entry_name, _prop_name) \ 3819790632SSimon Glass __attribute__((aligned(4), unused, section(".binman_sym"))) 3919790632SSimon Glass 4019790632SSimon Glass /** 41*8bee2d25SSimon Glass * binman_sym_extern() - Declare a extern symbol that will be used at run-time 42*8bee2d25SSimon Glass * 43*8bee2d25SSimon Glass * @_type: Type f the symbol (e.g. unsigned long) 44*8bee2d25SSimon Glass * @entry_name: Name of the entry to look for (e.g. 'u_boot_spl') 45*8bee2d25SSimon Glass * @_prop_name: Property value to get from that entry (e.g. 'pos') 46*8bee2d25SSimon Glass */ 47*8bee2d25SSimon Glass #define binman_sym_extern(_type, _entry_name, _prop_name) \ 48*8bee2d25SSimon Glass extern _type binman_symname(_entry_name, _prop_name) \ 49*8bee2d25SSimon Glass __attribute__((aligned(4), unused, section(".binman_sym"))) 50*8bee2d25SSimon Glass 51*8bee2d25SSimon Glass /** 5219790632SSimon Glass * binman_sym_declare_optional() - Declare an optional symbol 5319790632SSimon Glass * 5419790632SSimon Glass * If this symbol cannot be provided by binman, an error will not be generated. 5519790632SSimon Glass * Instead the image will be assigned the value BINMAN_SYM_MISSING. 5619790632SSimon Glass * 5719790632SSimon Glass * @_type: Type f the symbol (e.g. unsigned long) 5819790632SSimon Glass * @entry_name: Name of the entry to look for (e.g. 'u_boot_spl') 5919790632SSimon Glass * @_prop_name: Property value to get from that entry (e.g. 'pos') 6019790632SSimon Glass */ 6119790632SSimon Glass #define binman_sym_declare_optional(_type, _entry_name, _prop_name) \ 6219790632SSimon Glass _type binman_symname(_entry_name, _prop_name) \ 6319790632SSimon Glass __attribute__((aligned(4), weak, unused, \ 6419790632SSimon Glass section(".binman_sym"))) 6519790632SSimon Glass 6619790632SSimon Glass /** 6719790632SSimon Glass * binman_sym() - Access a previously declared symbol 6819790632SSimon Glass * 6919790632SSimon Glass * This is used to get the value of a symbol. E.g.: 7019790632SSimon Glass * 7119790632SSimon Glass * ulong address = binman_sym(ulong, u_boot_spl, pos); 7219790632SSimon Glass * 7319790632SSimon Glass * @_type: Type f the symbol (e.g. unsigned long) 7419790632SSimon Glass * @entry_name: Name of the entry to look for (e.g. 'u_boot_spl') 7519790632SSimon Glass * @_prop_name: Property value to get from that entry (e.g. 'pos') 7619790632SSimon Glass * @returns value of that property (filled in by binman) 7719790632SSimon Glass */ 7819790632SSimon Glass #define binman_sym(_type, _entry_name, _prop_name) \ 7919790632SSimon Glass (*(_type *)&binman_symname(_entry_name, _prop_name)) 8019790632SSimon Glass 8119790632SSimon Glass #else /* !BINMAN */ 8219790632SSimon Glass 8319790632SSimon Glass #define binman_sym_declare(_type, _entry_name, _prop_name) 8419790632SSimon Glass 8519790632SSimon Glass #define binman_sym_declare_optional(_type, _entry_name, _prop_name) 8619790632SSimon Glass 87*8bee2d25SSimon Glass #define binman_sym_extern(_type, _entry_name, _prop_name) 88*8bee2d25SSimon Glass 8919790632SSimon Glass #define binman_sym(_type, _entry_name, _prop_name) BINMAN_SYM_MISSING 9019790632SSimon Glass 9119790632SSimon Glass #endif /* BINMAN */ 9219790632SSimon Glass 9319790632SSimon Glass #endif 94