elog: Get rid of the staging_header variable.
The header is at the start of the log. There's no reason to either keep a seperate pointer to it, or to keep a copy of it in some other bit of memory. Built and booted on Link and used 'mosys eventlog list' to list the contents of the log. Ran for x in $(seq 1 2000); do cat elog.event.kernel_clean > /sys/firmware/gsmi/append_to_eventlog; done And ran mosys eventlog list again to verify that the log had been shrunk correctly. Change-Id: I2afcd52c0ce5bbb662ac56f2895cdbea28d5c2ce Signed-off-by: Gabe Black <gabeblack@google.com> Reviewed-on: https://gerrit.chromium.org/gerrit/49304 Reviewed-by: Duncan Laurie <dlaurie@chromium.org> Commit-Queue: Gabe Black <gabeblack@chromium.org> Tested-by: Gabe Black <gabeblack@chromium.org> Reviewed-on: http://review.coreboot.org/4239 Tested-by: build bot (Jenkins) Reviewed-by: Ronald G. Minnich <rminnich@gmail.com>
This commit is contained in:
parent
60f820835f
commit
e62e0369d5
|
@ -376,7 +376,7 @@ static void elog_validate_and_fill(struct elog_descriptor *elog)
|
||||||
elog->area_state = ELOG_AREA_HAS_CONTENT;
|
elog->area_state = ELOG_AREA_HAS_CONTENT;
|
||||||
|
|
||||||
/* Validate the header */
|
/* Validate the header */
|
||||||
if (!elog_is_header_valid(elog->staging_header)) {
|
if (!elog_is_header_valid(elog_get_header(elog))) {
|
||||||
elog->header_state = ELOG_HEADER_INVALID;
|
elog->header_state = ELOG_HEADER_INVALID;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -390,8 +390,7 @@ static void elog_validate_and_fill(struct elog_descriptor *elog)
|
||||||
*/
|
*/
|
||||||
static void elog_init_descriptor(struct elog_descriptor *elog,
|
static void elog_init_descriptor(struct elog_descriptor *elog,
|
||||||
elog_descriptor_type type,
|
elog_descriptor_type type,
|
||||||
u8 *buffer, u32 size,
|
u8 *buffer, u32 size)
|
||||||
struct elog_header *header)
|
|
||||||
{
|
{
|
||||||
elog_debug("elog_init_descriptor(type=%u buffer=0x%p size=%u)\n",
|
elog_debug("elog_init_descriptor(type=%u buffer=0x%p size=%u)\n",
|
||||||
type, buffer, size);
|
type, buffer, size);
|
||||||
|
@ -407,10 +406,6 @@ static void elog_init_descriptor(struct elog_descriptor *elog,
|
||||||
if (type == ELOG_DESCRIPTOR_FLASH)
|
if (type == ELOG_DESCRIPTOR_FLASH)
|
||||||
elog_spi->read(elog_spi, elog->flash_base, size, buffer);
|
elog_spi->read(elog_spi, elog->flash_base, size, buffer);
|
||||||
|
|
||||||
/* Get staging header from backing store */
|
|
||||||
elog->staging_header = header;
|
|
||||||
memcpy(header, buffer, sizeof(struct elog_header));
|
|
||||||
|
|
||||||
/* Data starts immediately after header */
|
/* Data starts immediately after header */
|
||||||
elog->data = &buffer[sizeof(struct elog_header)];
|
elog->data = &buffer[sizeof(struct elog_header)];
|
||||||
elog->data_size = size - sizeof(struct elog_header);
|
elog->data_size = size - sizeof(struct elog_header);
|
||||||
|
@ -430,7 +425,7 @@ static void elog_reinit_descriptor(struct elog_descriptor *elog)
|
||||||
{
|
{
|
||||||
elog_debug("elog_reinit_descriptor()\n");
|
elog_debug("elog_reinit_descriptor()\n");
|
||||||
elog_init_descriptor(elog, elog->type, elog->backing_store,
|
elog_init_descriptor(elog, elog->type, elog->backing_store,
|
||||||
elog->total_size, elog->staging_header);
|
elog->total_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -438,7 +433,6 @@ static void elog_reinit_descriptor(struct elog_descriptor *elog)
|
||||||
*/
|
*/
|
||||||
static int elog_setup_descriptors(u32 flash_base, u32 area_size)
|
static int elog_setup_descriptors(u32 flash_base, u32 area_size)
|
||||||
{
|
{
|
||||||
struct elog_header *staging_header;
|
|
||||||
u8 *area;
|
u8 *area;
|
||||||
|
|
||||||
elog_debug("elog_setup_descriptors(base=0x%08x size=%u)\n",
|
elog_debug("elog_setup_descriptors(base=0x%08x size=%u)\n",
|
||||||
|
@ -450,20 +444,14 @@ static int elog_setup_descriptors(u32 flash_base, u32 area_size)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
staging_header = malloc(sizeof(struct elog_header));
|
|
||||||
if (!staging_header) {
|
|
||||||
printk(BIOS_ERR, "ELOG: Unable to allocate header\n");
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
area = malloc(area_size);
|
area = malloc(area_size);
|
||||||
if (!area) {
|
if (!area) {
|
||||||
printk(BIOS_ERR, "ELOG: Unable to determine flash address\n");
|
printk(BIOS_ERR, "ELOG: Unable to allocate backing store\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
elog_get_flash()->flash_base = flash_base;
|
elog_get_flash()->flash_base = flash_base;
|
||||||
elog_init_descriptor(elog_get_flash(), ELOG_DESCRIPTOR_FLASH,
|
elog_init_descriptor(elog_get_flash(), ELOG_DESCRIPTOR_FLASH,
|
||||||
area, area_size, staging_header);
|
area, area_size);
|
||||||
|
|
||||||
/* Initialize the memory area to look like a cleared flash area */
|
/* Initialize the memory area to look like a cleared flash area */
|
||||||
area = malloc(area_size);
|
area = malloc(area_size);
|
||||||
|
@ -472,8 +460,7 @@ static int elog_setup_descriptors(u32 flash_base, u32 area_size)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
memset(area, ELOG_TYPE_EOL, area_size);
|
memset(area, ELOG_TYPE_EOL, area_size);
|
||||||
elog_init_descriptor(elog_get_mem(), ELOG_DESCRIPTOR_MEMORY,
|
elog_init_descriptor(elog_get_mem(), ELOG_DESCRIPTOR_MEMORY,area, area_size);
|
||||||
area, area_size, (struct elog_header *)area);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -500,7 +487,7 @@ static void elog_prepare_empty(struct elog_descriptor *elog,
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* Write out the header */
|
/* Write out the header */
|
||||||
header = elog->staging_header;
|
header = elog_get_header(elog);
|
||||||
header->magic = ELOG_SIGNATURE;
|
header->magic = ELOG_SIGNATURE;
|
||||||
header->version = ELOG_VERSION;
|
header->version = ELOG_VERSION;
|
||||||
header->header_size = sizeof(struct elog_header);
|
header->header_size = sizeof(struct elog_header);
|
||||||
|
|
|
@ -77,7 +77,6 @@ struct elog_descriptor {
|
||||||
elog_area_state area_state;
|
elog_area_state area_state;
|
||||||
elog_header_state header_state;
|
elog_header_state header_state;
|
||||||
elog_event_buffer_state event_buffer_state;
|
elog_event_buffer_state event_buffer_state;
|
||||||
struct elog_header *staging_header;
|
|
||||||
void *backing_store;
|
void *backing_store;
|
||||||
u8 *data;
|
u8 *data;
|
||||||
u32 flash_base;
|
u32 flash_base;
|
||||||
|
|
Loading…
Reference in New Issue