]> git.kernelconcepts.de Git - karo-tx-uboot.git/blob - include/env_callback.h
env: Add a baudrate env handler
[karo-tx-uboot.git] / include / env_callback.h
1 /*
2  * (C) Copyright 2012
3  * Joe Hershberger, National Instruments, joe.hershberger@ni.com
4  *
5  * See file CREDITS for list of people who contributed to this
6  * project.
7  *
8  * This program is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License as
10  * published by the Free Software Foundation; either version 2 of
11  * the License, or (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
21  * MA 02111-1307 USA
22  */
23
24 #ifndef __ENV_CALLBACK_H__
25 #define __ENV_CALLBACK_H__
26
27 #include <linker_lists.h>
28 #include <search.h>
29
30 #define ENV_CALLBACK_VAR ".callbacks"
31
32 /* Board configs can define additional static callback bindings */
33 #ifndef CONFIG_ENV_CALLBACK_LIST_STATIC
34 #define CONFIG_ENV_CALLBACK_LIST_STATIC
35 #endif
36
37 /*
38  * This list of callback bindings is static, but may be overridden by defining
39  * a new association in the ".callbacks" environment variable.
40  */
41 #define ENV_CALLBACK_LIST_STATIC ENV_CALLBACK_VAR ":callbacks," \
42         "baudrate:baudrate," \
43         "bootfile:bootfile," \
44         CONFIG_ENV_CALLBACK_LIST_STATIC
45
46 struct env_clbk_tbl {
47         const char *name;               /* Callback name */
48         int (*callback)(const char *name, const char *value, enum env_op op,
49                 int flags);
50 };
51
52 struct env_clbk_tbl *find_env_callback(const char *);
53 void env_callback_init(ENTRY *var_entry);
54
55 /*
56  * Define a callback that can be associated with variables.
57  * when associated through the ".callbacks" environment variable, the callback
58  * will be executed any time the variable is inserted, overwritten, or deleted.
59  */
60 #define U_BOOT_ENV_CALLBACK(name, callback) \
61         ll_entry_declare(struct env_clbk_tbl, name, env_clbk, env_clbk) = \
62         {#name, callback}
63
64 #endif /* __ENV_CALLBACK_H__ */