2018-05-06 21:58:06 +00:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0+ */
|
2012-12-12 04:16:24 +00:00
|
|
|
/*
|
|
|
|
* (C) Copyright 2012
|
|
|
|
* Joe Hershberger, National Instruments, joe.hershberger@ni.com
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __ENV_CALLBACK_H__
|
|
|
|
#define __ENV_CALLBACK_H__
|
|
|
|
|
2012-12-12 04:16:31 +00:00
|
|
|
#include <env_flags.h>
|
2012-12-12 04:16:24 +00:00
|
|
|
#include <linker_lists.h>
|
|
|
|
#include <search.h>
|
|
|
|
|
|
|
|
#define ENV_CALLBACK_VAR ".callbacks"
|
|
|
|
|
|
|
|
/* Board configs can define additional static callback bindings */
|
|
|
|
#ifndef CONFIG_ENV_CALLBACK_LIST_STATIC
|
|
|
|
#define CONFIG_ENV_CALLBACK_LIST_STATIC
|
|
|
|
#endif
|
|
|
|
|
2012-12-12 04:16:30 +00:00
|
|
|
#ifdef CONFIG_SILENT_CONSOLE
|
|
|
|
#define SILENT_CALLBACK "silent:silent,"
|
|
|
|
#else
|
|
|
|
#define SILENT_CALLBACK
|
|
|
|
#endif
|
|
|
|
|
2013-02-24 21:28:43 +00:00
|
|
|
#ifdef CONFIG_SPLASHIMAGE_GUARD
|
|
|
|
#define SPLASHIMAGE_CALLBACK "splashimage:splashimage,"
|
|
|
|
#else
|
|
|
|
#define SPLASHIMAGE_CALLBACK
|
|
|
|
#endif
|
|
|
|
|
2015-05-20 19:27:20 +00:00
|
|
|
#ifdef CONFIG_REGEX
|
|
|
|
#define ENV_DOT_ESCAPE "\\"
|
|
|
|
#else
|
|
|
|
#define ENV_DOT_ESCAPE
|
|
|
|
#endif
|
|
|
|
|
2015-05-20 19:27:23 +00:00
|
|
|
#ifdef CONFIG_CMD_DNS
|
|
|
|
#define DNS_CALLBACK "dnsip:dnsip,"
|
|
|
|
#else
|
|
|
|
#define DNS_CALLBACK
|
|
|
|
#endif
|
|
|
|
|
2018-02-26 15:01:02 +00:00
|
|
|
#ifdef CONFIG_CMD_NET
|
2015-05-20 19:27:23 +00:00
|
|
|
#define NET_CALLBACKS \
|
|
|
|
"bootfile:bootfile," \
|
|
|
|
"ipaddr:ipaddr," \
|
|
|
|
"gatewayip:gatewayip," \
|
|
|
|
"netmask:netmask," \
|
|
|
|
"serverip:serverip," \
|
|
|
|
"nvlan:nvlan," \
|
|
|
|
"vlan:vlan," \
|
2015-05-20 19:27:26 +00:00
|
|
|
DNS_CALLBACK \
|
2015-06-22 22:57:36 +00:00
|
|
|
"eth" ETHADDR_WILDCARD "addr:ethaddr,"
|
2015-05-20 19:27:23 +00:00
|
|
|
#else
|
|
|
|
#define NET_CALLBACKS
|
|
|
|
#endif
|
|
|
|
|
2012-12-12 04:16:24 +00:00
|
|
|
/*
|
|
|
|
* This list of callback bindings is static, but may be overridden by defining
|
|
|
|
* a new association in the ".callbacks" environment variable.
|
|
|
|
*/
|
2015-05-20 19:27:20 +00:00
|
|
|
#define ENV_CALLBACK_LIST_STATIC ENV_DOT_ESCAPE ENV_CALLBACK_VAR ":callbacks," \
|
|
|
|
ENV_DOT_ESCAPE ENV_FLAGS_VAR ":flags," \
|
2012-12-12 04:16:27 +00:00
|
|
|
"baudrate:baudrate," \
|
2015-05-20 19:27:23 +00:00
|
|
|
NET_CALLBACKS \
|
2012-12-12 04:16:28 +00:00
|
|
|
"loadaddr:loadaddr," \
|
2012-12-12 04:16:30 +00:00
|
|
|
SILENT_CALLBACK \
|
2013-02-24 21:28:43 +00:00
|
|
|
SPLASHIMAGE_CALLBACK \
|
2012-12-12 04:16:29 +00:00
|
|
|
"stdin:console,stdout:console,stderr:console," \
|
2017-09-01 12:42:03 +00:00
|
|
|
"serial#:serialno," \
|
2012-12-12 04:16:24 +00:00
|
|
|
CONFIG_ENV_CALLBACK_LIST_STATIC
|
|
|
|
|
|
|
|
struct env_clbk_tbl {
|
|
|
|
const char *name; /* Callback name */
|
|
|
|
int (*callback)(const char *name, const char *value, enum env_op op,
|
|
|
|
int flags);
|
|
|
|
};
|
|
|
|
|
|
|
|
void env_callback_init(ENTRY *var_entry);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Define a callback that can be associated with variables.
|
|
|
|
* when associated through the ".callbacks" environment variable, the callback
|
|
|
|
* will be executed any time the variable is inserted, overwritten, or deleted.
|
|
|
|
*/
|
2012-12-20 11:51:05 +00:00
|
|
|
#ifdef CONFIG_SPL_BUILD
|
|
|
|
#define U_BOOT_ENV_CALLBACK(name, callback) \
|
2014-07-10 18:38:35 +00:00
|
|
|
static inline __maybe_unused void _u_boot_env_noop_##name(void) \
|
2012-12-20 11:51:05 +00:00
|
|
|
{ \
|
|
|
|
(void)callback; \
|
|
|
|
}
|
|
|
|
#else
|
2012-12-12 04:16:24 +00:00
|
|
|
#define U_BOOT_ENV_CALLBACK(name, callback) \
|
2013-02-25 00:59:00 +00:00
|
|
|
ll_entry_declare(struct env_clbk_tbl, name, env_clbk) = \
|
2012-12-12 04:16:24 +00:00
|
|
|
{#name, callback}
|
2012-12-20 11:51:05 +00:00
|
|
|
#endif
|
2012-12-12 04:16:24 +00:00
|
|
|
|
|
|
|
#endif /* __ENV_CALLBACK_H__ */
|