xref: /openbmc/u-boot/board/synopsys/hsdk/env-lib.h (revision bf494d7e)
1 /* SPDX-License-Identifier: GPL-2.0+ */
2 /*
3  * Copyright (C) 2018 Synopsys, Inc. All rights reserved.
4  * Author: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
5  */
6 
7 #ifndef __BOARD_ENV_LIB_H
8 #define __BOARD_ENV_LIB_H
9 
10 #include <common.h>
11 #include <config.h>
12 #include <linux/kernel.h>
13 
14 enum env_type {
15 	ENV_DEC,
16 	ENV_HEX
17 };
18 
19 typedef struct {
20 	u32 val;
21 	bool set;
22 } u32_env;
23 
24 struct env_map_common {
25 	const char *const env_name;
26 	enum env_type type;
27 	bool mandatory;
28 	u32 min;
29 	u32 max;
30 	u32_env *val;
31 };
32 
33 struct env_map_percpu {
34 	const char *const env_name;
35 	enum env_type type;
36 	bool mandatory;
37 	u32 min[NR_CPUS];
38 	u32 max[NR_CPUS];
39 	u32_env (*val)[NR_CPUS];
40 };
41 
42 void envs_cleanup_common(const struct env_map_common *map);
43 int envs_read_common(const struct env_map_common *map);
44 int envs_validate_common(const struct env_map_common *map);
45 int envs_read_validate_common(const struct env_map_common *map);
46 
47 void envs_cleanup_core(const struct env_map_percpu *map);
48 int envs_read_validate_core(const struct env_map_percpu *map,
49 			    bool (*cpu_used)(u32));
50 int envs_process_and_validate(const struct env_map_common *common,
51 			      const struct env_map_percpu *core,
52 			      bool (*cpu_used)(u32));
53 
54 int args_envs_enumerate(const struct env_map_common *map,
55 			int enum_by, int argc, char *const argv[]);
56 
57 #endif /* __BOARD_ENV_LIB_H */
58