summaryrefslogtreecommitdiff
path: root/src/include/option.h
blob: 26cd0d5245cdf5d1a265ff7b25c2f4e32f037b93 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/* SPDX-License-Identifier: GPL-2.0-only */

#ifndef _OPTION_H_
#define _OPTION_H_

#include <types.h>

void sanitize_cmos(void);

enum cb_err cmos_set_option(const char *name, void *val);
enum cb_err cmos_get_option(void *dest, const char *name);

static inline enum cb_err set_option(const char *name, void *val)
{
	if (CONFIG(USE_OPTION_TABLE))
		return cmos_set_option(name, val);

	return CB_CMOS_OTABLE_DISABLED;
}

static inline enum cb_err get_option(void *dest, const char *name)
{
	if (CONFIG(USE_OPTION_TABLE))
		return cmos_get_option(dest, name);

	return CB_CMOS_OTABLE_DISABLED;
}

static inline enum cb_err set_int_option(const char *name, int value)
{
	return set_option(name, &value);
}

static inline int get_int_option(const char *name, const int fallback)
{
	int value = 0;
	return get_option(&value, name) == CB_SUCCESS ? value : fallback;
}

#endif /* _OPTION_H_ */