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