From 28cee59ca294422056d983fc06d5d8d5800a4390 Mon Sep 17 00:00:00 2001 From: Patrick Rudolph Date: Thu, 8 Mar 2018 15:43:12 +0100 Subject: drivers/vpd: Add VPD support VPD reference: https://chromium.googlesource.com/chromiumos/platform/vpd/+/master/README.md Copy ChromeOS VPD driver to add support for VPD without CROMEOS. Possible use case: * Storing calibration data * Storing MAC address * Storing serial * Storing boot options + Now it's possible to define the VPD space by choosing one of the following enums: VPD_ANY, VPD_RW, VPD_RO. + CHROMEOS selects now VPD as part of it. + VPD is implemented as driver. Change-Id: Id9263bd39bf25d024e93daa57053fefcb1adc53a Signed-off-by: Patrick Rudolph Reviewed-on: https://review.coreboot.org/25046 Reviewed-by: David Hendricks Tested-by: build bot (Jenkins) --- src/drivers/vpd/vpd.h | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 src/drivers/vpd/vpd.h (limited to 'src/drivers/vpd/vpd.h') diff --git a/src/drivers/vpd/vpd.h b/src/drivers/vpd/vpd.h new file mode 100644 index 0000000000..6009b8bc0d --- /dev/null +++ b/src/drivers/vpd/vpd.h @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2014 The Chromium OS Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#ifndef __VPD_H__ +#define __VPD_H__ + +enum vpd_region { + VPD_ANY = 0, + VPD_RO = 1, + VPD_RW = 2 +}; +/* + * Reads VPD string value by key. + * + * Reads in at most one less than size characters from VPD and stores them + * into buffer. A terminating null byte ('\0') is stored after the last + * character in the buffer. + * + * Returns NULL if key is not found, otherwise buffer. + */ +char *vpd_gets(const char *key, char *buffer, int size, enum vpd_region region); + +/* + * Find VPD value by key. + * + * Searches for a VPD entry in the VPD cache. If found, places the size of the + * entry into '*size' and returns the pointer to the entry data. + * + * This function presumes that VPD is cached in DRAM (which is the case in the + * current implementation) and as such returns the pointer into the cache. The + * user is not supposed to modify the data, and does not have to free the + * memory. + * + * Returns NULL if key is not found. + */ + +const void *vpd_find(const char *key, int *size, enum vpd_region region); + +#endif /* __VPD_H__ */ -- cgit v1.2.3