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