MCPcopy Create free account
hub / github.com/coreboot/coreboot / elog_read

Function elog_read

util/cbfstool/elogtool.c:85–104  ·  view source on GitHub ↗

* If filename is empty, read RW_ELOG from flashrom. * Otherwise read the RW_ELOG from a file. * It fails if the ELOG header is invalid. * On success, buffer must be freed by caller. */

Source from the content-addressed store, hash-verified

83 * On success, buffer must be freed by caller.
84 */
85static int elog_read(struct buffer *buffer, const char *filename)
86{
87 if (filename == NULL) {
88 if (flashrom_host_read(buffer, ELOG_RW_REGION_NAME) != 0) {
89 fprintf(stderr, "Could not read RW_ELOG region using flashrom\n");
90 return ELOGTOOL_EXIT_READ_ERROR;
91 }
92 } else if (buffer_from_file(buffer, filename) != 0) {
93 fprintf(stderr, "Could not read input file: %s\n", filename);
94 return ELOGTOOL_EXIT_READ_ERROR;
95 }
96
97 if (elog_verify_header(buffer_get(buffer)) != CB_SUCCESS) {
98 fprintf(stderr, "FATAL: Invalid elog header\n");
99 buffer_delete(buffer);
100 return ELOGTOOL_EXIT_INVALID_ELOG_FORMAT;
101 }
102
103 return ELOGTOOL_EXIT_SUCCESS;
104}
105
106/*
107 * If filename is NULL, it saves the buffer using flashrom.

Callers 1

mainFunction · 0.85

Calls 6

flashrom_host_readFunction · 0.85
fprintfFunction · 0.85
buffer_from_fileFunction · 0.85
elog_verify_headerFunction · 0.85
buffer_getFunction · 0.85
buffer_deleteFunction · 0.85

Tested by

no test coverage detected