coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
vpd.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: BSD-3-Clause */
2 
3 #ifndef __VPD_H__
4 #define __VPD_H__
5 
6 #include <types.h>
7 
8 #define GOOGLE_VPD_2_0_OFFSET 0x600
9 
10 enum vpd_region {
15 };
16 
17 /*
18  * Reads VPD string value by key.
19  *
20  * Reads in at most one less than size characters from VPD and stores them
21  * into buffer. A terminating null byte ('\0') is stored after the last
22  * character in the buffer.
23  *
24  * Returns NULL if key is not found, otherwise buffer.
25  */
26 char *vpd_gets(const char *key, char *buffer, int size, enum vpd_region region);
27 
28 /*
29  * Find VPD value by key.
30  *
31  * Searches for a VPD entry in the VPD cache. If found, places the size of the
32  * entry into '*size' and returns the pointer to the entry data.
33  *
34  * This function presumes that VPD is cached in DRAM (which is the case in the
35  * current implementation) and as such returns the pointer into the cache. The
36  * user is not supposed to modify the data, and does not have to free the
37  * memory.
38  *
39  * Returns NULL if key is not found.
40  */
41 
42 const void *vpd_find(const char *key, int *size, enum vpd_region region);
43 
44 /*
45  * Find value of boolean type vpd key.
46  *
47  * During the process, necessary checking is done, such as making
48  * sure the value length is 1, and value is either '1' or '0'.
49  */
50 bool vpd_get_bool(const char *key, enum vpd_region region,
51  uint8_t *val);
52 
53 /*
54  * Find value of integer type by vpd key.
55  *
56  * Expects to find a decimal string, trailing chars are ignored.
57  * Returns true if the key is found and the value is not too long and
58  * starts with a decimal digit.
59  */
60 bool vpd_get_int(const char *key, enum vpd_region region, int *val);
61 
62 #endif /* __VPD_H__ */
char * vpd_gets(const char *key, char *buffer, int size, enum vpd_region region)
Definition: vpd.c:229
vpd_region
Definition: vpd.h:10
@ VPD_RO_THEN_RW
Definition: vpd.h:13
@ VPD_RO
Definition: vpd.h:11
@ VPD_RW
Definition: vpd.h:12
@ VPD_RW_THEN_RO
Definition: vpd.h:14
const void * vpd_find(const char *key, int *size, enum vpd_region region)
Definition: vpd.c:203
bool vpd_get_int(const char *key, enum vpd_region region, int *val)
Definition: vpd.c:284
bool vpd_get_bool(const char *key, enum vpd_region region, uint8_t *val)
Definition: vpd.c:252
u8 buffer[C2P_BUFFER_MAXSIZE]
Definition: psp_smm.c:18
unsigned char uint8_t
Definition: stdint.h:8
Definition: region.h:76
u8 val
Definition: sys.c:300