1 /* SPDX-License-Identifier: GPL-2.0+ */
2 /*
3  * (C) Copyright 2012
4  * Joe Hershberger, National Instruments, joe.hershberger@ni.com
5  */
6 
7 #ifndef __ENV_CALLBACK_H__
8 #define __ENV_CALLBACK_H__
9 
10 #include <config.h>
11 #include <env_flags.h>
12 #include <linker_lists.h>
13 #include <search.h>
14 
15 #define ENV_CALLBACK_VAR ".callbacks"
16 
17 #ifdef CONFIG_SILENT_CONSOLE
18 #define SILENT_CALLBACK "silent:silent,"
19 #else
20 #define SILENT_CALLBACK
21 #endif
22 
23 #ifdef CONFIG_REGEX
24 #define ENV_DOT_ESCAPE "\\"
25 #else
26 #define ENV_DOT_ESCAPE
27 #endif
28 
29 #ifdef CONFIG_CMD_DNS
30 #define DNS_CALLBACK "dnsip:dnsip,"
31 #else
32 #define DNS_CALLBACK
33 #endif
34 
35 #if CONFIG_IS_ENABLED(NET) || CONFIG_IS_ENABLED(NET_LWIP)
36 #define NET_CALLBACKS \
37 	"bootfile:bootfile," \
38 	"ipaddr:ipaddr," \
39 	"gatewayip:gatewayip," \
40 	"netmask:netmask," \
41 	"serverip:serverip," \
42 	"nvlan:nvlan," \
43 	"vlan:vlan," \
44 	DNS_CALLBACK \
45 	"eth" ETHADDR_WILDCARD "addr:ethaddr,"
46 #else
47 #define NET_CALLBACKS
48 #endif
49 
50 #ifdef CONFIG_IPV6
51 #define NET6_CALLBACKS \
52 	"ip6addr:ip6addr," \
53 	"serverip6:serverip6," \
54 	"gatewayip6:gatewayip6,"
55 #else
56 #define NET6_CALLBACKS
57 #endif
58 
59 #ifdef CONFIG_BOOTSTD_FULL
60 #define BOOTSTD_CALLBACK \
61 	"bootmeths:bootmeths," \
62 	"bootargs:bootargs,"
63 #else
64 #define BOOTSTD_CALLBACK
65 #endif
66 
67 #ifdef CONFIG_DFU
68 #define DFU_CALLBACK "dfu_alt_info:dfu_alt_info,"
69 #else
70 #define DFU_CALLBACK
71 #endif
72 
73 /*
74  * This list of callback bindings is static, but may be overridden by defining
75  * a new association in the ".callbacks" environment variable.
76  */
77 #define ENV_CALLBACK_LIST_STATIC ENV_DOT_ESCAPE ENV_CALLBACK_VAR ":callbacks," \
78 	ENV_DOT_ESCAPE ENV_FLAGS_VAR ":flags," \
79 	"baudrate:baudrate," \
80 	NET_CALLBACKS \
81 	NET6_CALLBACKS \
82 	BOOTSTD_CALLBACK \
83 	DFU_CALLBACK \
84 	"loadaddr:loadaddr," \
85 	SILENT_CALLBACK \
86 	"stdin:console,stdout:console,stderr:console," \
87 	"serial#:serialno," \
88 	CONFIG_ENV_CALLBACK_LIST_STATIC
89 
90 #ifndef CONFIG_XPL_BUILD
91 void env_callback_init(struct env_entry *var_entry);
92 #else
env_callback_init(struct env_entry * var_entry)93 static inline void env_callback_init(struct env_entry *var_entry)
94 {
95 }
96 #endif
97 
98 #endif /* __ENV_CALLBACK_H__ */
99