summaryrefslogtreecommitdiffstats
path: root/src/drivers/option/cbfs_file_option.c
blob: b87bba8fb92e57b4593e0111ab4cba4998eb0ac0 (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
/* SPDX-License-Identifier: GPL-2.0-only */

#include <cbfs.h>
#include <endian.h>
#include <option.h>

unsigned int get_uint_option(const char *name, const unsigned int fallback)
{
	size_t size;
	uint64_t value;
	char full_name[CBFS_METADATA_MAX_SIZE];
	snprintf(full_name, sizeof(full_name), "option/%s", name);

	void *p = cbfs_ro_map(full_name, &size);
	if (!p || size < sizeof(value)) {
		value = fallback;
	} else {
		value = le64dec(p);
		cbfs_unmap(p);
	}
	return (unsigned int)value;
}

enum cb_err set_uint_option(const char *name, unsigned int value)
{
	return CB_ERR_NOT_IMPLEMENTED;
}