blob: 48c17c4d4f62f2939bcaa856c1c2e04f0bdf221a [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001/* SPDX-License-Identifier: GPL-2.0+ */
Eugeniy Paltsevada8aff2018-03-26 15:57:37 +03002/*
3 * Copyright (C) 2018 Synopsys, Inc. All rights reserved.
4 * Author: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
Eugeniy Paltsevada8aff2018-03-26 15:57:37 +03005 */
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
14enum env_type {
15 ENV_DEC,
16 ENV_HEX
17};
18
19typedef struct {
20 u32 val;
21 bool set;
22} u32_env;
23
24struct 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
33struct 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
42void envs_cleanup_common(const struct env_map_common *map);
43int envs_read_common(const struct env_map_common *map);
44int envs_validate_common(const struct env_map_common *map);
45int envs_read_validate_common(const struct env_map_common *map);
46
47void envs_cleanup_core(const struct env_map_percpu *map);
48int envs_read_validate_core(const struct env_map_percpu *map,
49 bool (*cpu_used)(u32));
50int envs_process_and_validate(const struct env_map_common *common,
51 const struct env_map_percpu *core,
52 bool (*cpu_used)(u32));
53
54int 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 */