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

Function cmd_clear

util/cbfstool/elogtool.c:228–251  ·  view source on GitHub ↗

* Clears the elog events from the given buffer, which is a valid RW_ELOG region. * A LOG_CLEAR event is appended. */

Source from the content-addressed store, hash-verified

226 * A LOG_CLEAR event is appended.
227 */
228static int cmd_clear(const struct buffer *buf,
229 enum elogtool_flag flags __maybe_unused)
230{
231 uint32_t used_data_size;
232 struct buffer copy;
233
234 /* Clone the buffer to avoid changing the offset of the original buffer */
235 buffer_clone(&copy, buf);
236 buffer_seek(&copy, sizeof(struct elog_header));
237
238 /*
239 * Calculate the size of the "used" buffer, needed for ELOG_TYPE_LOG_CLEAR.
240 * Then overwrite the entire buffer with ELOG_TYPE_EOL.
241 * Finally insert a LOG_CLEAR event into the buffer.
242 */
243 used_data_size = next_available_event_offset(&copy);
244 memset(buffer_get(&copy), ELOG_TYPE_EOL, buffer_size(&copy));
245
246 if (!eventlog_init_event(&copy, ELOG_TYPE_LOG_CLEAR,
247 &used_data_size, sizeof(used_data_size)))
248 return ELOGTOOL_EXIT_NOT_ENOUGH_BUFFER_SPACE;
249
250 return ELOGTOOL_EXIT_SUCCESS;
251}
252
253static void cmd_add_usage(void)
254{

Callers

nothing calls this directly

Calls 7

buffer_cloneFunction · 0.85
buffer_seekFunction · 0.85
buffer_getFunction · 0.85
buffer_sizeFunction · 0.85
eventlog_init_eventFunction · 0.85
memsetFunction · 0.50

Tested by

no test coverage detected