Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0+ */ |
Joe Hershberger | 60fd3ad | 2012-12-11 22:16:24 -0600 | [diff] [blame] | 2 | /* |
| 3 | * (C) Copyright 2012 |
| 4 | * Joe Hershberger, National Instruments, joe.hershberger@ni.com |
Joe Hershberger | 60fd3ad | 2012-12-11 22:16:24 -0600 | [diff] [blame] | 5 | */ |
| 6 | |
| 7 | #ifndef __ENV_CALLBACK_H__ |
| 8 | #define __ENV_CALLBACK_H__ |
| 9 | |
Joe Hershberger | 71497d0 | 2012-12-11 22:16:31 -0600 | [diff] [blame] | 10 | #include <env_flags.h> |
Joe Hershberger | 60fd3ad | 2012-12-11 22:16:24 -0600 | [diff] [blame] | 11 | #include <linker_lists.h> |
| 12 | #include <search.h> |
| 13 | |
| 14 | #define ENV_CALLBACK_VAR ".callbacks" |
| 15 | |
| 16 | /* Board configs can define additional static callback bindings */ |
| 17 | #ifndef CONFIG_ENV_CALLBACK_LIST_STATIC |
| 18 | #define CONFIG_ENV_CALLBACK_LIST_STATIC |
| 19 | #endif |
| 20 | |
Joe Hershberger | 03ddaba | 2012-12-11 22:16:30 -0600 | [diff] [blame] | 21 | #ifdef CONFIG_SILENT_CONSOLE |
| 22 | #define SILENT_CALLBACK "silent:silent," |
| 23 | #else |
| 24 | #define SILENT_CALLBACK |
| 25 | #endif |
| 26 | |
Nikita Kiryanov | 2f3e2ca | 2013-02-24 21:28:43 +0000 | [diff] [blame] | 27 | #ifdef CONFIG_SPLASHIMAGE_GUARD |
| 28 | #define SPLASHIMAGE_CALLBACK "splashimage:splashimage," |
| 29 | #else |
| 30 | #define SPLASHIMAGE_CALLBACK |
| 31 | #endif |
| 32 | |
Joe Hershberger | 6db9fd4 | 2015-05-20 14:27:20 -0500 | [diff] [blame] | 33 | #ifdef CONFIG_REGEX |
| 34 | #define ENV_DOT_ESCAPE "\\" |
Joe Hershberger | 8ab8b72 | 2015-06-22 17:57:36 -0500 | [diff] [blame] | 35 | #define ETHADDR_WILDCARD "\\d?" |
Joe Hershberger | 6db9fd4 | 2015-05-20 14:27:20 -0500 | [diff] [blame] | 36 | #else |
| 37 | #define ENV_DOT_ESCAPE |
Joe Hershberger | 8ab8b72 | 2015-06-22 17:57:36 -0500 | [diff] [blame] | 38 | #define ETHADDR_WILDCARD |
Joe Hershberger | 6db9fd4 | 2015-05-20 14:27:20 -0500 | [diff] [blame] | 39 | #endif |
| 40 | |
Joe Hershberger | 875b6bf | 2015-05-20 14:27:23 -0500 | [diff] [blame] | 41 | #ifdef CONFIG_CMD_DNS |
| 42 | #define DNS_CALLBACK "dnsip:dnsip," |
| 43 | #else |
| 44 | #define DNS_CALLBACK |
| 45 | #endif |
| 46 | |
Michal Simek | 2f785a1 | 2018-02-26 16:01:02 +0100 | [diff] [blame] | 47 | #ifdef CONFIG_CMD_NET |
Joe Hershberger | 875b6bf | 2015-05-20 14:27:23 -0500 | [diff] [blame] | 48 | #define NET_CALLBACKS \ |
| 49 | "bootfile:bootfile," \ |
| 50 | "ipaddr:ipaddr," \ |
| 51 | "gatewayip:gatewayip," \ |
| 52 | "netmask:netmask," \ |
| 53 | "serverip:serverip," \ |
| 54 | "nvlan:nvlan," \ |
| 55 | "vlan:vlan," \ |
Joe Hershberger | 7e0b015 | 2015-05-20 14:27:26 -0500 | [diff] [blame] | 56 | DNS_CALLBACK \ |
Joe Hershberger | 8ab8b72 | 2015-06-22 17:57:36 -0500 | [diff] [blame] | 57 | "eth" ETHADDR_WILDCARD "addr:ethaddr," |
Joe Hershberger | 875b6bf | 2015-05-20 14:27:23 -0500 | [diff] [blame] | 58 | #else |
| 59 | #define NET_CALLBACKS |
| 60 | #endif |
| 61 | |
Joe Hershberger | 60fd3ad | 2012-12-11 22:16:24 -0600 | [diff] [blame] | 62 | /* |
| 63 | * This list of callback bindings is static, but may be overridden by defining |
| 64 | * a new association in the ".callbacks" environment variable. |
| 65 | */ |
Joe Hershberger | 6db9fd4 | 2015-05-20 14:27:20 -0500 | [diff] [blame] | 66 | #define ENV_CALLBACK_LIST_STATIC ENV_DOT_ESCAPE ENV_CALLBACK_VAR ":callbacks," \ |
| 67 | ENV_DOT_ESCAPE ENV_FLAGS_VAR ":flags," \ |
Joe Hershberger | 3928bb6 | 2012-12-11 22:16:27 -0600 | [diff] [blame] | 68 | "baudrate:baudrate," \ |
Joe Hershberger | 875b6bf | 2015-05-20 14:27:23 -0500 | [diff] [blame] | 69 | NET_CALLBACKS \ |
Joe Hershberger | d1f5ae9 | 2012-12-11 22:16:28 -0600 | [diff] [blame] | 70 | "loadaddr:loadaddr," \ |
Joe Hershberger | 03ddaba | 2012-12-11 22:16:30 -0600 | [diff] [blame] | 71 | SILENT_CALLBACK \ |
Nikita Kiryanov | 2f3e2ca | 2013-02-24 21:28:43 +0000 | [diff] [blame] | 72 | SPLASHIMAGE_CALLBACK \ |
Joe Hershberger | 5c89d6d | 2012-12-11 22:16:29 -0600 | [diff] [blame] | 73 | "stdin:console,stdout:console,stderr:console," \ |
Sam Protsenko | 708bc68 | 2017-09-01 15:42:03 +0300 | [diff] [blame] | 74 | "serial#:serialno," \ |
Joe Hershberger | 60fd3ad | 2012-12-11 22:16:24 -0600 | [diff] [blame] | 75 | CONFIG_ENV_CALLBACK_LIST_STATIC |
| 76 | |
| 77 | struct env_clbk_tbl { |
| 78 | const char *name; /* Callback name */ |
| 79 | int (*callback)(const char *name, const char *value, enum env_op op, |
| 80 | int flags); |
| 81 | }; |
| 82 | |
Joe Hershberger | 60fd3ad | 2012-12-11 22:16:24 -0600 | [diff] [blame] | 83 | void env_callback_init(ENTRY *var_entry); |
| 84 | |
| 85 | /* |
| 86 | * Define a callback that can be associated with variables. |
| 87 | * when associated through the ".callbacks" environment variable, the callback |
| 88 | * will be executed any time the variable is inserted, overwritten, or deleted. |
| 89 | */ |
Scott Wood | 3eae189 | 2012-12-20 11:51:05 +0000 | [diff] [blame] | 90 | #ifdef CONFIG_SPL_BUILD |
| 91 | #define U_BOOT_ENV_CALLBACK(name, callback) \ |
Jeroen Hofstee | 1bd2a6d | 2014-07-10 20:38:35 +0200 | [diff] [blame] | 92 | static inline __maybe_unused void _u_boot_env_noop_##name(void) \ |
Scott Wood | 3eae189 | 2012-12-20 11:51:05 +0000 | [diff] [blame] | 93 | { \ |
| 94 | (void)callback; \ |
| 95 | } |
| 96 | #else |
Joe Hershberger | 60fd3ad | 2012-12-11 22:16:24 -0600 | [diff] [blame] | 97 | #define U_BOOT_ENV_CALLBACK(name, callback) \ |
Albert ARIBAUD | c24895e | 2013-02-25 00:59:00 +0000 | [diff] [blame] | 98 | ll_entry_declare(struct env_clbk_tbl, name, env_clbk) = \ |
Joe Hershberger | 60fd3ad | 2012-12-11 22:16:24 -0600 | [diff] [blame] | 99 | {#name, callback} |
Scott Wood | 3eae189 | 2012-12-20 11:51:05 +0000 | [diff] [blame] | 100 | #endif |
Joe Hershberger | 60fd3ad | 2012-12-11 22:16:24 -0600 | [diff] [blame] | 101 | |
| 102 | #endif /* __ENV_CALLBACK_H__ */ |