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

Function eventlog_init_event

util/cbfstool/eventlog.c:729–761  ·  view source on GitHub ↗

* Initializes the eventlog header with the given type and data, * and calculates the checksum. * buffer_get() points to the event to be initialized. * On success it returns 1, otherwise 0. */

Source from the content-addressed store, hash-verified

727 * On success it returns 1, otherwise 0.
728 */
729int eventlog_init_event(const struct buffer *buf, uint8_t type,
730 const void *data, int data_size)
731{
732 struct event_header *event;
733 time_t secs = time(NULL);
734 struct tm tm;
735
736 /* Must have at least size for data + checksum byte */
737 if (buffer_size(buf) < (size_t)data_size + 1)
738 return 0;
739
740 event = buffer_get(buf);
741
742 event->type = type;
743 gmtime_r(&secs, &tm);
744 /* Month should be +1, since gmtime uses 0 as first month */
745 elog_fill_timestamp(event, tm.tm_sec, tm.tm_min, tm.tm_hour,
746 tm.tm_mday, tm.tm_mon + 1, tm.tm_year);
747
748 if (data && data_size) {
749 uint32_t *ptr = (uint32_t *)&event[1];
750 memcpy(ptr, data, data_size);
751 }
752
753 /* Header + data + checksum */
754 event->length = sizeof(*event) + data_size + 1;
755
756 /* Zero the checksum byte and then compute checksum */
757 elog_update_checksum(event, 0);
758 elog_update_checksum(event, -(elog_checksum_event(event)));
759
760 return 1;
761}

Callers 3

shrink_bufferFunction · 0.85
cmd_clearFunction · 0.85
cmd_addFunction · 0.85

Calls 7

timeFunction · 0.85
buffer_sizeFunction · 0.85
buffer_getFunction · 0.85
elog_fill_timestampFunction · 0.85
elog_update_checksumFunction · 0.85
elog_checksum_eventFunction · 0.85
memcpyFunction · 0.50

Tested by

no test coverage detected