Project-Cerberus/core/logging/logging_flash_static.h

59 строки
1.7 KiB
C
Исходник Обычный вид История

// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.
#ifndef LOGGING_FLASH_STATIC_H_
#define LOGGING_FLASH_STATIC_H_
#include "logging/logging_flash.h"
/* Internal functions declared to allow for static initialization. */
int logging_flash_create_entry (const struct logging *logging, uint8_t *entry, size_t length);
int logging_flash_flush (const struct logging *logging);
int logging_flash_clear (const struct logging *logging);
int logging_flash_get_size (const struct logging *logging);
int logging_flash_read_contents (const struct logging *logging, uint32_t offset, uint8_t *contents,
size_t length);
/**
Add flexibility to how firmware updates are handled. Improve platform porting. There are a few changes included here: 1. Enhanced the firmware updater to provide options on how and when the recovery and revocation steps get performed. It is now possible to always make sure the recovery image is updated and only do recovery updates and revocation after a device reset. To easily support implementations that want to use different mechanisms for update, the firmware update handler code was refactored out of the task context into another module, with various configurations and derivations to support the desired behavior. 2. The platform abstraction for tasks put too much logic in the task context that needs to be implemented for each platform. New task abstractions have been added that leave all the handling logic in the common code and only require the different platforms to provide a minimal wrapper for the actual task creation and execution. This was leveraged to manage the different ways firmware update can now be handled. Task ports for FreeRTOS were created. 3. There were a few places where the platform_clock APIs were being misused, making assumptions about the API that didn't hold across platform ports. These usages were cleaned up. Specifically for component attestation, the way it determined the time until the next event was not robust across platforms. A new platform API was added to serve this use case. This API was also required for the new platform task abstractions. 4. To avoid platform assumptions and platform API misuse, a common header file has been created that all core code now references. This platform API header file defines the functions that will exist for any port and specifies the contract and usage of these functions. 5. There was a bug in the way the Linux platform port calculated durations that caused it to add an extra second in certain scenarios.
2022-11-17 00:48:36 +03:00
* Constant initializer for the flush operation.
*/
#ifndef LOGGING_DISABLE_FLUSH
#define LOGGING_FLASH_FLUSH_API .flush = logging_flash_flush,
#else
#define LOGGING_FLASH_FLUSH_API
#endif
/**
* Constant initializer for the logging API.
*/
#define LOGGING_FLASH_API_INIT { \
.create_entry = logging_flash_create_entry, \
LOGGING_FLASH_FLUSH_API \
.clear = logging_flash_clear, \
.get_size = logging_flash_get_size, \
.read_contents = logging_flash_read_contents \
}
/**
* Initialize a static instance of a log that uses SPI flash. This can be a constant instance.
*
* There is no validation done on the arguments.
*
* @param state_ptr Variable context for the log.
* @param flash_ptr The flash device where log entries are stored.
* @param flash_base_addr The starting address for log entries. This must be aligned to the
* beginning of an erase block.
*/
#define logging_flash_static_init(state_ptr, flash_ptr, flash_base_addr) { \
.base = LOGGING_FLASH_API_INIT, \
.state = state_ptr, \
.flash = flash_ptr, \
.base_addr = flash_base_addr \
}
#endif /* LOGGING_FLASH_STATIC_H_ */