2012-12-12 12:16:24 +08:00
|
|
|
/*
|
|
|
|
* (C) Copyright 2012
|
|
|
|
* Joe Hershberger, National Instruments, joe.hershberger@ni.com
|
|
|
|
*
|
2013-07-08 15:37:19 +08:00
|
|
|
* SPDX-License-Identifier: GPL-2.0+
|
2012-12-12 12:16:24 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __ENV_CALLBACK_H__
|
|
|
|
#define __ENV_CALLBACK_H__
|
|
|
|
|
2012-12-12 12:16:31 +08:00
|
|
|
#include <env_flags.h>
|
2012-12-12 12:16:24 +08: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 12:16:30 +08:00
|
|
|
#ifdef CONFIG_SILENT_CONSOLE
|
|
|
|
#define SILENT_CALLBACK "silent:silent,"
|
|
|
|
#else
|
|
|
|
#define SILENT_CALLBACK
|
|
|
|
#endif
|
|
|
|
|
2013-02-25 05:28:43 +08:00
|
|
|
#ifdef CONFIG_SPLASHIMAGE_GUARD
|
|
|
|
#define SPLASHIMAGE_CALLBACK "splashimage:splashimage,"
|
|
|
|
#else
|
|
|
|
#define SPLASHIMAGE_CALLBACK
|
|
|
|
#endif
|
|
|
|
|
2015-05-21 03:27:20 +08:00
|
|
|
#ifdef CONFIG_REGEX
|
|
|
|
#define ENV_DOT_ESCAPE "\\"
|
2015-06-23 06:57:36 +08:00
|
|
|
#define ETHADDR_WILDCARD "\\d?"
|
2015-05-21 03:27:20 +08:00
|
|
|
#else
|
|
|
|
#define ENV_DOT_ESCAPE
|
2015-06-23 06:57:36 +08:00
|
|
|
#define ETHADDR_WILDCARD
|
2015-05-21 03:27:20 +08:00
|
|
|
#endif
|
|
|
|
|
2015-05-21 03:27:23 +08:00
|
|
|
#ifdef CONFIG_CMD_DNS
|
|
|
|
#define DNS_CALLBACK "dnsip:dnsip,"
|
|
|
|
#else
|
|
|
|
#define DNS_CALLBACK
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef CONFIG_NET
|
|
|
|
#define NET_CALLBACKS \
|
|
|
|
"bootfile:bootfile," \
|
|
|
|
"ipaddr:ipaddr," \
|
|
|
|
"gatewayip:gatewayip," \
|
|
|
|
"netmask:netmask," \
|
|
|
|
"serverip:serverip," \
|
|
|
|
"nvlan:nvlan," \
|
|
|
|
"vlan:vlan," \
|
2015-05-21 03:27:26 +08:00
|
|
|
DNS_CALLBACK \
|
2015-06-23 06:57:36 +08:00
|
|
|
"eth" ETHADDR_WILDCARD "addr:ethaddr,"
|
2015-05-21 03:27:23 +08:00
|
|
|
#else
|
|
|
|
#define NET_CALLBACKS
|
|
|
|
#endif
|
|
|
|
|
2012-12-12 12:16:24 +08:00
|
|
|
/*
|
|
|
|
* This list of callback bindings is static, but may be overridden by defining
|
|
|
|
* a new association in the ".callbacks" environment variable.
|
|
|
|
*/
|
2015-05-21 03:27:20 +08:00
|
|
|
#define ENV_CALLBACK_LIST_STATIC ENV_DOT_ESCAPE ENV_CALLBACK_VAR ":callbacks," \
|
|
|
|
ENV_DOT_ESCAPE ENV_FLAGS_VAR ":flags," \
|
2012-12-12 12:16:27 +08:00
|
|
|
"baudrate:baudrate," \
|
2015-05-21 03:27:23 +08:00
|
|
|
NET_CALLBACKS \
|
2012-12-12 12:16:28 +08:00
|
|
|
"loadaddr:loadaddr," \
|
2012-12-12 12:16:30 +08:00
|
|
|
SILENT_CALLBACK \
|
2013-02-25 05:28:43 +08:00
|
|
|
SPLASHIMAGE_CALLBACK \
|
2012-12-12 12:16:29 +08:00
|
|
|
"stdin:console,stdout:console,stderr:console," \
|
2012-12-12 12:16:24 +08: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 19:51:05 +08:00
|
|
|
#ifdef CONFIG_SPL_BUILD
|
|
|
|
#define U_BOOT_ENV_CALLBACK(name, callback) \
|
2014-07-11 02:38:35 +08:00
|
|
|
static inline __maybe_unused void _u_boot_env_noop_##name(void) \
|
2012-12-20 19:51:05 +08:00
|
|
|
{ \
|
|
|
|
(void)callback; \
|
|
|
|
}
|
|
|
|
#else
|
2012-12-12 12:16:24 +08:00
|
|
|
#define U_BOOT_ENV_CALLBACK(name, callback) \
|
2013-02-25 08:59:00 +08:00
|
|
|
ll_entry_declare(struct env_clbk_tbl, name, env_clbk) = \
|
2012-12-12 12:16:24 +08:00
|
|
|
{#name, callback}
|
2012-12-20 19:51:05 +08:00
|
|
|
#endif
|
2012-12-12 12:16:24 +08:00
|
|
|
|
|
|
|
#endif /* __ENV_CALLBACK_H__ */
|