system76-coreboot/src/drivers/elog/elog_internal.h
Gabe Black 331eb084bb elog: Eliminate the second in memory copy of the event log.
The event log driver keeps two copies of the event log in memory, one to
take the place of the historically memory mapped image of flash which is now
read and written manually, and one originally intended to be an in memory
cache of flash. Since both are now just copies in memory, there's no value in
having them both and keeping them in sync.

Built and booted on Link. Ran mosys eventlog list. Added 2000 events to
the log and ran mosys eventlog list again. Cleared the log by echoing a 1 into
/sys/firmware/gsmi/clear_eventlog and ran mosys eventlog list again.

Change-Id: Ibed62a10c78884849726aa15ec795ab2914afc35
Signed-off-by: Gabe Black <gabeblack@google.com>
Reviewed-on: https://gerrit.chromium.org/gerrit/49306
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/4241
Tested-by: build bot (Jenkins)
Reviewed-by: Ronald G. Minnich <rminnich@gmail.com>
2013-12-02 15:16:44 +01:00

85 lines
2.1 KiB
C

/*
* This file is part of the coreboot project.
*
* Copyright (C) 2012 The ChromiumOS Authors. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 2 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA, 02110-1301 USA
*/
#ifndef ELOG_INTERNAL_H_
#define ELOG_INTERNAL_H_
/* ELOG header */
struct elog_header {
u32 magic;
u8 version;
u8 header_size;
u8 reserved[2];
} __attribute__ ((packed));
/* ELOG related constants */
#define ELOG_SIGNATURE 0x474f4c45 /* 'ELOG' */
#define ELOG_VERSION 1
/* SMBIOS event log header */
struct event_header {
u8 type;
u8 length;
u8 year;
u8 month;
u8 day;
u8 hour;
u8 minute;
u8 second;
} __attribute__ ((packed));
/* SMBIOS Type 15 related constants */
#define ELOG_HEADER_TYPE_OEM 0x88
typedef enum elog_area_state {
ELOG_AREA_UNDEFINED, /* Initial boot strap state */
ELOG_AREA_EMPTY, /* Entire area is empty */
ELOG_AREA_HAS_CONTENT, /* Area has some content */
} elog_area_state;
typedef enum elog_header_state {
ELOG_HEADER_INVALID,
ELOG_HEADER_VALID,
} elog_header_state;
typedef enum elog_event_buffer_state {
ELOG_EVENT_BUFFER_OK,
ELOG_EVENT_BUFFER_CORRUPTED,
} elog_event_buffer_state;
/*
* Internal handler for event log buffers
*/
struct elog_descriptor {
elog_area_state area_state;
elog_header_state header_state;
elog_event_buffer_state event_buffer_state;
void *backing_store;
u8 *data;
u32 flash_base;
u16 total_size;
u16 data_size;
u16 next_event_offset;
u16 last_event_offset;
u16 last_event_size;
u16 event_count;
};
#endif /* ELOG_INTERNAL_H_ */