Support operating in single flash mode.
Add mode to work only with a single flash device for host firmware: - All reads/writes to a single flash device. - Run-time protection is disabled. - Validate full flash on any change. Also support run-time activation of new firmware. This is different from previous behavior where the update was pre-validated, but not applied until host reboot.
This commit is contained in:
Родитель
fb0c2aab6e
Коммит
e3424ed6f1
|
@ -17,7 +17,7 @@
|
|||
*
|
||||
* @return A pointer to the derived type.
|
||||
*/
|
||||
#define TO_DERIVED_TYPE(ptr, type, field) (type*) (((uintptr_t) ptr) - offsetof (type, field));
|
||||
#define TO_DERIVED_TYPE(ptr, type, field) (type*) (((uintptr_t) ptr) - offsetof (type, field))
|
||||
|
||||
|
||||
#endif /* TYPE_CAST_H_ */
|
||||
|
|
|
@ -6,77 +6,8 @@
|
|||
#include <string.h>
|
||||
#include "host_flash_manager.h"
|
||||
#include "host_fw_util.h"
|
||||
#include "host_state_manager.h"
|
||||
|
||||
|
||||
static struct spi_flash* host_flash_manager_get_read_only_flash (struct host_flash_manager *manager)
|
||||
{
|
||||
if (manager == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (host_state_manager_get_read_only_flash (manager->host_state) == SPI_FILTER_CS_0) {
|
||||
return manager->flash_cs0;
|
||||
}
|
||||
else {
|
||||
return manager->flash_cs1;
|
||||
}
|
||||
}
|
||||
|
||||
static struct spi_flash* host_flash_manager_get_read_write_flash (
|
||||
struct host_flash_manager *manager)
|
||||
{
|
||||
if (manager == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (host_state_manager_get_read_only_flash (manager->host_state) == SPI_FILTER_CS_0) {
|
||||
return manager->flash_cs1;
|
||||
}
|
||||
else {
|
||||
return manager->flash_cs0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Find the entry in the PFM for the firmware version stored on flash.
|
||||
*
|
||||
* @param manager THe manager for the flash to inspect.
|
||||
* @param pfm The PFM to check the flash contents against.
|
||||
* @param rw_flash Flag indicating if the read/write flash should be checked.
|
||||
* @param fw_id Identifier for the firmware type to query in the PFM.
|
||||
* @param versions Output for the list of supported versions in the PFM.
|
||||
* @param version Output for the version entry that matches the flash contents.
|
||||
*
|
||||
* @return 0 if a match was found in the PFM or an error code.
|
||||
*/
|
||||
static int host_flash_manager_find_flash_version (struct host_flash_manager *manager,
|
||||
struct pfm *pfm, bool rw_flash, const char *fw_id, struct pfm_firmware_versions *versions,
|
||||
const struct pfm_firmware_version **version)
|
||||
{
|
||||
int status;
|
||||
|
||||
status = pfm->get_supported_versions (pfm, fw_id, versions);
|
||||
if (status != 0) {
|
||||
return status;
|
||||
}
|
||||
|
||||
if (rw_flash) {
|
||||
status = host_fw_determine_version (host_flash_manager_get_read_write_flash (manager),
|
||||
versions, version);
|
||||
}
|
||||
else {
|
||||
status = host_fw_determine_version (host_flash_manager_get_read_only_flash (manager),
|
||||
versions, version);
|
||||
}
|
||||
|
||||
if (status != 0) {
|
||||
pfm->free_fw_versions (pfm, versions);
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the information from a PFM entry for the image on flash.
|
||||
*
|
||||
|
@ -92,8 +23,8 @@ static int host_flash_manager_find_flash_version (struct host_flash_manager *man
|
|||
*
|
||||
* @return 0 if the entry information was successfully queried or an error code.
|
||||
*/
|
||||
static int host_flash_manager_get_image_entry (struct pfm *pfm, struct spi_flash *flash,
|
||||
uint32_t offset, const char *fw_id, struct pfm_firmware_versions *versions,
|
||||
int host_flash_manager_get_image_entry (struct pfm *pfm, struct spi_flash *flash, uint32_t offset,
|
||||
const char *fw_id, struct pfm_firmware_versions *versions,
|
||||
const struct pfm_firmware_version **version, struct pfm_image_list *fw_images,
|
||||
struct pfm_read_write_regions *writable)
|
||||
{
|
||||
|
@ -140,7 +71,7 @@ free_versions:
|
|||
*
|
||||
* @return 0 if the operation was successful or an error code.
|
||||
*/
|
||||
static int host_flash_manager_get_firmware_types (struct pfm *pfm, struct pfm_firmware *host_fw,
|
||||
int host_flash_manager_get_firmware_types (struct pfm *pfm, struct pfm_firmware *host_fw,
|
||||
struct host_flash_manager_images *host_img, struct host_flash_manager_rw_regions *host_rw)
|
||||
{
|
||||
int status;
|
||||
|
@ -178,7 +109,7 @@ free_firmware:
|
|||
return HOST_FLASH_MGR_NO_MEMORY;
|
||||
}
|
||||
|
||||
static void host_flash_manager_free_read_write_regions (struct host_flash_manager *manager,
|
||||
void host_flash_manager_free_read_write_regions (struct host_flash_manager *manager,
|
||||
struct host_flash_manager_rw_regions *host_rw)
|
||||
{
|
||||
size_t i;
|
||||
|
@ -201,7 +132,7 @@ static void host_flash_manager_free_read_write_regions (struct host_flash_manage
|
|||
*
|
||||
* @param host_img The list to free.
|
||||
*/
|
||||
static void host_flash_manager_free_images (struct host_flash_manager_images *host_img)
|
||||
void host_flash_manager_free_images (struct host_flash_manager_images *host_img)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
|
@ -373,44 +304,47 @@ free_host:
|
|||
return status;
|
||||
}
|
||||
|
||||
static int host_flash_manager_validate_read_only_flash (struct host_flash_manager *manager,
|
||||
struct pfm *pfm, struct pfm *good_pfm, struct hash_engine *hash, struct rsa_engine *rsa,
|
||||
bool full_validation, struct host_flash_manager_rw_regions *host_rw)
|
||||
/**
|
||||
* Find the entry in the PFM for the firmware version stored on flash.
|
||||
*
|
||||
* @param flash The flash to inspect.
|
||||
* @param pfm The PFM to check the flash contents against.
|
||||
* @param fw_id Identifier for the firmware type to query in the PFM.
|
||||
* @param versions Output for the list of supported versions in the PFM.
|
||||
* @param version Output for the version entry that matches the flash contents.
|
||||
*
|
||||
* @return 0 if a match was found in the PFM or an error code.
|
||||
*/
|
||||
static int host_flash_manager_find_flash_version (struct spi_flash *flash, struct pfm *pfm,
|
||||
const char *fw_id, struct pfm_firmware_versions *versions,
|
||||
const struct pfm_firmware_version **version)
|
||||
{
|
||||
int status;
|
||||
|
||||
if ((manager == NULL) || (pfm == NULL) || (hash == NULL) || (rsa == NULL) ||
|
||||
(host_rw == NULL)) {
|
||||
return HOST_FLASH_MGR_INVALID_ARGUMENT;
|
||||
status = pfm->get_supported_versions (pfm, fw_id, versions);
|
||||
if (status != 0) {
|
||||
return status;
|
||||
}
|
||||
|
||||
if (good_pfm && !full_validation) {
|
||||
status = host_flash_manager_validate_pfm (pfm, good_pfm, hash, rsa,
|
||||
host_flash_manager_get_read_only_flash (manager), host_rw);
|
||||
}
|
||||
else {
|
||||
status = host_flash_manager_validate_flash (pfm, hash, rsa, full_validation,
|
||||
host_flash_manager_get_read_only_flash (manager), host_rw);
|
||||
status = host_fw_determine_version (flash, versions, version);
|
||||
if (status != 0) {
|
||||
pfm->free_fw_versions (pfm, versions);
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
static int host_flash_manager_validate_read_write_flash (struct host_flash_manager *manager,
|
||||
struct pfm *pfm, struct hash_engine *hash, struct rsa_engine *rsa,
|
||||
/**
|
||||
* Determine the the read/write regions for the host firmware on flash.
|
||||
*
|
||||
* @param flash The flash containing the firmware.
|
||||
* @param pfm The PFM to use to determine R/W regions.
|
||||
* @param host_rw Output for the firmware read/write regions.
|
||||
*
|
||||
* @return 0 if the regions were successfully determined or an error code.
|
||||
*/
|
||||
int host_flash_manager_get_flash_read_write_regions (struct spi_flash *flash, struct pfm *pfm,
|
||||
struct host_flash_manager_rw_regions *host_rw)
|
||||
{
|
||||
if ((manager == NULL) || (pfm == NULL) || (hash == NULL) || (rsa == NULL) ||
|
||||
(host_rw == NULL)) {
|
||||
return HOST_FLASH_MGR_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
return host_flash_manager_validate_flash (pfm, hash, rsa, true,
|
||||
host_flash_manager_get_read_write_flash (manager), host_rw);
|
||||
}
|
||||
|
||||
static int host_flash_manager_get_flash_read_write_regions (struct host_flash_manager *manager,
|
||||
struct pfm *pfm, bool rw_flash, struct host_flash_manager_rw_regions *host_rw)
|
||||
{
|
||||
struct pfm_firmware host_fw;
|
||||
struct pfm_firmware_versions versions;
|
||||
|
@ -418,18 +352,14 @@ static int host_flash_manager_get_flash_read_write_regions (struct host_flash_ma
|
|||
size_t i;
|
||||
int status;
|
||||
|
||||
if ((manager == NULL) || (pfm == NULL) || (host_rw == NULL)) {
|
||||
return HOST_FLASH_MGR_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
status = host_flash_manager_get_firmware_types (pfm, &host_fw, NULL, host_rw);
|
||||
if (status != 0) {
|
||||
return status;
|
||||
}
|
||||
|
||||
for (i = 0; i < host_fw.count; i++, host_rw->count++) {
|
||||
status = host_flash_manager_find_flash_version (manager, pfm, rw_flash, host_fw.ids[i],
|
||||
&versions, &version);
|
||||
status = host_flash_manager_find_flash_version (flash, pfm, host_fw.ids[i], &versions,
|
||||
&version);
|
||||
if (status != 0) {
|
||||
goto free_rw;
|
||||
}
|
||||
|
@ -444,7 +374,7 @@ static int host_flash_manager_get_flash_read_write_regions (struct host_flash_ma
|
|||
|
||||
free_rw:
|
||||
if (status != 0) {
|
||||
host_flash_manager_free_read_write_regions (manager, host_rw);
|
||||
host_flash_manager_free_read_write_regions (NULL, host_rw);
|
||||
}
|
||||
|
||||
pfm->free_firmware (pfm, &host_fw);
|
||||
|
@ -454,26 +384,30 @@ free_rw:
|
|||
/**
|
||||
* Ensure both flash devices are operating in the same address mode.
|
||||
*
|
||||
* @param manager The manager for the flash devices to configure.
|
||||
* @param cs0 The flash device connected to CS0.
|
||||
* @param cs1 The flash device connected to CS1. Null if there is only a single flash device.
|
||||
* @param mode Output indicating the current address mode of both devices.
|
||||
*
|
||||
* @return 0 if the address mode was configured successfully or an error code.
|
||||
*/
|
||||
static int host_flash_manager_flash_address_mode (struct host_flash_manager *manager,
|
||||
static int host_flash_manager_flash_address_mode (struct spi_flash *cs0, struct spi_flash *cs1,
|
||||
spi_filter_address_mode *mode)
|
||||
{
|
||||
int addr_4byte;
|
||||
int status;
|
||||
|
||||
addr_4byte = spi_flash_is_4byte_address_mode (manager->flash_cs0);
|
||||
if (addr_4byte != spi_flash_is_4byte_address_mode (manager->flash_cs1)) {
|
||||
status = spi_flash_enable_4byte_address_mode (manager->flash_cs1, addr_4byte);
|
||||
if (status != 0) {
|
||||
if (status == SPI_FLASH_UNSUPPORTED_ADDR_MODE) {
|
||||
status = HOST_FLASH_MGR_MISMATCH_ADDR_MODE;
|
||||
}
|
||||
addr_4byte = spi_flash_is_4byte_address_mode (cs0);
|
||||
|
||||
return status;
|
||||
if (cs1) {
|
||||
if (addr_4byte != spi_flash_is_4byte_address_mode (cs1)) {
|
||||
status = spi_flash_enable_4byte_address_mode (cs1, addr_4byte);
|
||||
if (status != 0) {
|
||||
if (status == SPI_FLASH_UNSUPPORTED_ADDR_MODE) {
|
||||
status = HOST_FLASH_MGR_MISMATCH_ADDR_MODE;
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -484,7 +418,8 @@ static int host_flash_manager_flash_address_mode (struct host_flash_manager *man
|
|||
/**
|
||||
* Detect the address mode properties of the flash devices.
|
||||
*
|
||||
* @param manager The manager for the flash to query.
|
||||
* @param cs0 The flash device connected to CS0.
|
||||
* @param cs1 The flash device connected to CS1. Null if there is only a single flash device.
|
||||
* @param wen_required Output indicating if write enable is required to switch address modes.
|
||||
* @param fixed_addr Output indicating if the device address mode is fixed.
|
||||
* @param mode Output indicating the current address mode of the device.
|
||||
|
@ -492,18 +427,20 @@ static int host_flash_manager_flash_address_mode (struct host_flash_manager *man
|
|||
*
|
||||
* @return 0 if the address mode properties were successfully detected or an error code.
|
||||
*/
|
||||
static int host_flash_manager_detect_flash_address_mode_properties (
|
||||
struct host_flash_manager *manager, bool *wen_required, bool *fixed_addr,
|
||||
spi_filter_address_mode *mode, spi_filter_address_mode *reset_mode)
|
||||
static int host_flash_manager_detect_flash_address_mode_properties (struct spi_flash *cs0,
|
||||
struct spi_flash *cs1, bool *wen_required, bool *fixed_addr, spi_filter_address_mode *mode,
|
||||
spi_filter_address_mode *reset_mode)
|
||||
{
|
||||
int req_write_en[2];
|
||||
int reset_addr[2];
|
||||
int status;
|
||||
|
||||
req_write_en[0] = spi_flash_address_mode_requires_write_enable (manager->flash_cs0);
|
||||
req_write_en[1] = spi_flash_address_mode_requires_write_enable (manager->flash_cs1);
|
||||
if (req_write_en[0] != req_write_en[1]) {
|
||||
return HOST_FLASH_MGR_MISMATCH_ADDR_MODE;
|
||||
req_write_en[0] = spi_flash_address_mode_requires_write_enable (cs0);
|
||||
if (cs1) {
|
||||
req_write_en[1] = spi_flash_address_mode_requires_write_enable (cs1);
|
||||
if (req_write_en[0] != req_write_en[1]) {
|
||||
return HOST_FLASH_MGR_MISMATCH_ADDR_MODE;
|
||||
}
|
||||
}
|
||||
|
||||
if (req_write_en[0] == SPI_FLASH_ADDR_MODE_FIXED) {
|
||||
|
@ -515,30 +452,44 @@ static int host_flash_manager_detect_flash_address_mode_properties (
|
|||
*fixed_addr = false;
|
||||
}
|
||||
|
||||
status = host_flash_manager_flash_address_mode (manager, mode);
|
||||
status = host_flash_manager_flash_address_mode (cs0, cs1, mode);
|
||||
if (status != 0) {
|
||||
return status;
|
||||
}
|
||||
|
||||
reset_addr[0] = spi_flash_is_4byte_address_mode_on_reset (manager->flash_cs0);
|
||||
reset_addr[0] = spi_flash_is_4byte_address_mode_on_reset (cs0);
|
||||
if ((reset_addr[0] != 0) && (reset_addr[0] != 1)) {
|
||||
return reset_addr[0];
|
||||
}
|
||||
|
||||
reset_addr[1] = spi_flash_is_4byte_address_mode_on_reset (manager->flash_cs1);
|
||||
if ((reset_addr[1] != 0) && (reset_addr[1] != 1)) {
|
||||
return reset_addr[1];
|
||||
}
|
||||
if (cs1) {
|
||||
reset_addr[1] = spi_flash_is_4byte_address_mode_on_reset (cs1);
|
||||
if ((reset_addr[1] != 0) && (reset_addr[1] != 1)) {
|
||||
return reset_addr[1];
|
||||
}
|
||||
|
||||
if (reset_addr[0] != reset_addr[1]) {
|
||||
return HOST_FLASH_MGR_MISMATCH_ADDR_MODE;
|
||||
if (reset_addr[0] != reset_addr[1]) {
|
||||
return HOST_FLASH_MGR_MISMATCH_ADDR_MODE;
|
||||
}
|
||||
}
|
||||
|
||||
*reset_mode = (reset_addr[0] == 1) ? SPI_FILTER_ADDRESS_MODE_4 : SPI_FILTER_ADDRESS_MODE_3;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int host_flash_manager_config_spi_filter_flash_type (struct host_flash_manager *manager)
|
||||
/**
|
||||
* Detect the flash device properties and configure the SPI filter to match. If there are two flash
|
||||
* devices, they must match exactly or an error will be generated.
|
||||
*
|
||||
* @param cs0 The flash device connected to CS0.
|
||||
* @param cs1 The flash device connected to CS1. Null if there is only a single flash device.
|
||||
* @param filter The SPI filter to configure.
|
||||
* @param mfg_handler Handler for configuring flash manufacturer details into the filter.
|
||||
*
|
||||
* @return 0 if the flash is supported and the filter was configured successfully or an error code.
|
||||
*/
|
||||
int host_flash_manager_config_spi_filter_flash_type (struct spi_flash *cs0, struct spi_flash *cs1,
|
||||
struct spi_filter_interface *filter, struct flash_mfg_filter_handler *mfg_handler)
|
||||
{
|
||||
uint8_t vendor[2];
|
||||
uint16_t device[2];
|
||||
|
@ -549,69 +500,69 @@ static int host_flash_manager_config_spi_filter_flash_type (struct host_flash_ma
|
|||
spi_filter_address_mode reset_mode;
|
||||
int status;
|
||||
|
||||
if (manager == NULL) {
|
||||
return HOST_FLASH_MGR_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
/* Validate and configure the type of devices being used. */
|
||||
status = spi_flash_get_device_id (manager->flash_cs0, &vendor[0], &device[0]);
|
||||
status = spi_flash_get_device_id (cs0, &vendor[0], &device[0]);
|
||||
if (status != 0) {
|
||||
return status;
|
||||
}
|
||||
|
||||
status = spi_flash_get_device_id (manager->flash_cs1, &vendor[1], &device[1]);
|
||||
if (status != 0) {
|
||||
return status;
|
||||
if (cs1) {
|
||||
status = spi_flash_get_device_id (cs1, &vendor[1], &device[1]);
|
||||
if (status != 0) {
|
||||
return status;
|
||||
}
|
||||
|
||||
if (vendor[0] != vendor[1]) {
|
||||
return HOST_FLASH_MGR_MISMATCH_VENDOR;
|
||||
}
|
||||
else if (device[0] != device[1]) {
|
||||
return HOST_FLASH_MGR_MISMATCH_DEVICE;
|
||||
}
|
||||
}
|
||||
|
||||
if (vendor[0] != vendor[1]) {
|
||||
return HOST_FLASH_MGR_MISMATCH_VENDOR;
|
||||
}
|
||||
else if (device[0] != device[1]) {
|
||||
return HOST_FLASH_MGR_MISMATCH_DEVICE;
|
||||
}
|
||||
|
||||
status = manager->mfg_handler->set_flash_manufacturer (manager->mfg_handler, vendor[0],
|
||||
status = mfg_handler->set_flash_manufacturer (mfg_handler, vendor[0],
|
||||
device[0]);
|
||||
if (status != 0) {
|
||||
return status;
|
||||
}
|
||||
|
||||
/* Validate and configure the flash device capacity. */
|
||||
spi_flash_get_device_size (manager->flash_cs0, &bytes[0]);
|
||||
spi_flash_get_device_size (manager->flash_cs1, &bytes[1]);
|
||||
if (bytes[0] != bytes[1]) {
|
||||
return HOST_FLASH_MGR_MISMATCH_SIZES;
|
||||
spi_flash_get_device_size (cs0, &bytes[0]);
|
||||
if (cs1) {
|
||||
spi_flash_get_device_size (cs1, &bytes[1]);
|
||||
if (bytes[0] != bytes[1]) {
|
||||
return HOST_FLASH_MGR_MISMATCH_SIZES;
|
||||
}
|
||||
}
|
||||
|
||||
status = manager->filter->set_flash_size (manager->filter, bytes[0]);
|
||||
status = filter->set_flash_size (filter, bytes[0]);
|
||||
if ((status != 0) && (status != SPI_FILTER_UNSUPPORTED_OPERATION)) {
|
||||
return status;
|
||||
}
|
||||
|
||||
/* Validate and configure the address byte mode of the devices. */
|
||||
status = host_flash_manager_detect_flash_address_mode_properties (manager, &req_write_en,
|
||||
status = host_flash_manager_detect_flash_address_mode_properties (cs0, cs1, &req_write_en,
|
||||
&fixed, &mode, &reset_mode);
|
||||
if (status != 0) {
|
||||
return status;
|
||||
}
|
||||
|
||||
if (!fixed) {
|
||||
status = manager->filter->set_addr_byte_mode (manager->filter, mode);
|
||||
status = filter->set_addr_byte_mode (filter, mode);
|
||||
}
|
||||
else {
|
||||
status = manager->filter->set_fixed_addr_byte_mode (manager->filter, mode);
|
||||
status = filter->set_fixed_addr_byte_mode (filter, mode);
|
||||
}
|
||||
if (status != 0) {
|
||||
return status;
|
||||
}
|
||||
|
||||
status = manager->filter->require_addr_byte_mode_write_enable (manager->filter, req_write_en);
|
||||
status = filter->require_addr_byte_mode_write_enable (filter, req_write_en);
|
||||
if ((status != 0) && (status != SPI_FILTER_UNSUPPORTED_OPERATION)) {
|
||||
return status;
|
||||
}
|
||||
|
||||
status = manager->filter->set_reset_addr_byte_mode (manager->filter, reset_mode);
|
||||
status = filter->set_reset_addr_byte_mode (filter, reset_mode);
|
||||
if (status == SPI_FILTER_UNSUPPORTED_OPERATION) {
|
||||
status = 0;
|
||||
}
|
||||
|
@ -619,168 +570,6 @@ static int host_flash_manager_config_spi_filter_flash_type (struct host_flash_ma
|
|||
return status;
|
||||
}
|
||||
|
||||
static int host_flash_manager_config_spi_filter_flash_devices (struct host_flash_manager *manager)
|
||||
{
|
||||
spi_filter_cs ro;
|
||||
|
||||
if (manager == NULL) {
|
||||
return HOST_FLASH_MGR_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
ro = host_state_manager_get_read_only_flash (manager->host_state);
|
||||
return manager->filter->set_ro_cs (manager->filter, ro);
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy the read/write data regions from one flash to another.
|
||||
*
|
||||
* @param manager The flash manager to use for the data migration.
|
||||
* @param from The flash device to copy from.
|
||||
* @param writable The list of read/write regions that should be migrated.
|
||||
*
|
||||
* @return 0 if the data migration was successful or an error code.
|
||||
*/
|
||||
static int host_flash_manager_migrate_rw_data (struct host_flash_manager *manager,
|
||||
spi_filter_cs from, struct host_flash_manager_rw_regions *host_rw)
|
||||
{
|
||||
int status;
|
||||
|
||||
if (from == SPI_FILTER_CS_0) {
|
||||
status = host_fw_migrate_read_write_data_multiple_fw (manager->flash_cs1, host_rw->writable,
|
||||
host_rw->count, manager->flash_cs0, NULL, 0);
|
||||
}
|
||||
else {
|
||||
status = host_fw_migrate_read_write_data_multiple_fw (manager->flash_cs0, host_rw->writable,
|
||||
host_rw->count, manager->flash_cs1, NULL, 0);
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
static int host_flash_manager_swap_flash_devices (struct host_flash_manager *manager,
|
||||
struct host_flash_manager_rw_regions *host_rw, struct pfm_manager *used_pending)
|
||||
{
|
||||
spi_filter_cs rw;
|
||||
int status;
|
||||
|
||||
if (manager == NULL) {
|
||||
return HOST_FLASH_MGR_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
/* Clear the dirty bit in the SPI filter. */
|
||||
status = manager->filter->clear_flash_dirty_state (manager->filter);
|
||||
if (status != 0) {
|
||||
return status;
|
||||
}
|
||||
|
||||
/* Configure the SPI filter to switch the read and write flashes. */
|
||||
rw = (host_state_manager_get_read_only_flash (manager->host_state) == SPI_FILTER_CS_0) ?
|
||||
SPI_FILTER_CS_1 : SPI_FILTER_CS_0;
|
||||
status = manager->filter->set_ro_cs (manager->filter, rw);
|
||||
if (status != 0) {
|
||||
return status;
|
||||
}
|
||||
|
||||
/* Migrate the R/W data to the new write flash. */
|
||||
if (host_rw) {
|
||||
status = host_flash_manager_migrate_rw_data (manager, rw, host_rw);
|
||||
}
|
||||
|
||||
/* Save the current flash configuration. */
|
||||
if (status == 0) {
|
||||
state_manager_block_non_volatile_state_storage (manager->host_state, true);
|
||||
|
||||
host_state_manager_save_read_only_flash (manager->host_state, rw);
|
||||
host_state_manager_save_inactive_dirty (manager->host_state, false);
|
||||
|
||||
if (used_pending) {
|
||||
used_pending->base.activate_pending_manifest (&used_pending->base);
|
||||
}
|
||||
|
||||
state_manager_block_non_volatile_state_storage (manager->host_state, false);
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
static int host_flash_manager_initialize_flash_protection (struct host_flash_manager *manager,
|
||||
struct host_flash_manager_rw_regions *host_rw)
|
||||
{
|
||||
spi_filter_cs ro;
|
||||
struct spi_flash *ro_flash;
|
||||
struct spi_flash *rw_flash;
|
||||
int status;
|
||||
int addr_4byte;
|
||||
|
||||
if ((manager == NULL) || (host_rw == NULL)) {
|
||||
return HOST_FLASH_MGR_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
/* Make sure both flash devices are running with the same address mode. */
|
||||
ro_flash = host_flash_manager_get_read_only_flash (manager);
|
||||
rw_flash = host_flash_manager_get_read_write_flash (manager);
|
||||
|
||||
addr_4byte = spi_flash_is_4byte_address_mode (ro_flash);
|
||||
if (ROT_IS_ERROR (addr_4byte)) {
|
||||
return addr_4byte;
|
||||
}
|
||||
|
||||
if (addr_4byte != spi_flash_is_4byte_address_mode (rw_flash)) {
|
||||
status = spi_flash_enable_4byte_address_mode (rw_flash, addr_4byte);
|
||||
if (status != 0) {
|
||||
return status;
|
||||
}
|
||||
}
|
||||
|
||||
/* Make the R/W data available on the R/W flash device. */
|
||||
ro = host_state_manager_get_read_only_flash (manager->host_state);
|
||||
|
||||
status = host_flash_manager_migrate_rw_data (manager, ro, host_rw);
|
||||
if (status != 0) {
|
||||
return status;
|
||||
}
|
||||
|
||||
/* Protection is being initialized, so the R/W flash can't be dirty yet. */
|
||||
status = manager->filter->clear_flash_dirty_state (manager->filter);
|
||||
if (status != 0) {
|
||||
return status;
|
||||
}
|
||||
|
||||
host_state_manager_save_inactive_dirty (manager->host_state, false);
|
||||
|
||||
/* Make sure the SPI filter address mode matches the mode of the physical devices.
|
||||
*
|
||||
* If the device address mode is fixed, this was already configured during initial filter setup
|
||||
* and doesn't need to be done again. */
|
||||
if (!spi_flash_is_address_mode_fixed (ro_flash)) {
|
||||
status = manager->filter->set_addr_byte_mode (manager->filter,
|
||||
(addr_4byte == 1) ? SPI_FILTER_ADDRESS_MODE_4 : SPI_FILTER_ADDRESS_MODE_3);
|
||||
if (status != 0) {
|
||||
return status;
|
||||
}
|
||||
}
|
||||
|
||||
/* Turn on the SPI filter. */
|
||||
status = manager->filter->set_filter_mode (manager->filter, SPI_FILTER_FLASH_DUAL);
|
||||
if (status != 0) {
|
||||
return status;
|
||||
}
|
||||
|
||||
return manager->filter->set_ro_cs (manager->filter, ro);
|
||||
}
|
||||
|
||||
static int host_flash_manager_restore_flash_read_write_regions (struct host_flash_manager *manager,
|
||||
struct host_flash_manager_rw_regions *host_rw)
|
||||
{
|
||||
if ((manager == NULL) || (host_rw == NULL)) {
|
||||
return HOST_FLASH_MGR_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
return host_fw_restore_read_write_data_multiple_fw (
|
||||
host_flash_manager_get_read_write_flash (manager),
|
||||
host_flash_manager_get_read_only_flash (manager), host_rw->writable, host_rw->count);
|
||||
}
|
||||
|
||||
/**
|
||||
* Configure a single SPI flash device and the driver to allow the RoT access to the device.
|
||||
*
|
||||
|
@ -830,18 +619,27 @@ int host_flash_manager_configure_flash_for_rot_access (struct spi_flash *flash)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int host_flash_manager_set_flash_for_rot_access (struct host_flash_manager *manager,
|
||||
struct host_control *control)
|
||||
/**
|
||||
* Enable RoT access to the protected flash devices.
|
||||
*
|
||||
* @param control The interface for hardware controls for flash access.
|
||||
* @param filter The SPI filter connected to the flash devices.
|
||||
* @param cs0 Flash device connected to CS0.
|
||||
* @param cs1 Flash device connected to CS1. Null if there is only a single flash device.
|
||||
* @param flash_init Initialization handler for the protected flash devices. Null to skip
|
||||
* initialization.
|
||||
*
|
||||
* @return 0 if RoT flash accass has been enabled or an error code.
|
||||
*/
|
||||
int host_flash_manager_set_flash_for_rot_access (struct host_control *control,
|
||||
struct spi_filter_interface *filter, struct spi_flash *cs0, struct spi_flash *cs1,
|
||||
struct host_flash_initialization *flash_init)
|
||||
{
|
||||
struct spi_flash *flash;
|
||||
int i;
|
||||
int status;
|
||||
|
||||
if ((manager == NULL) || (control == NULL)) {
|
||||
return HOST_FLASH_MGR_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
status = manager->filter->enable_filter (manager->filter, false);
|
||||
status = filter->enable_filter (filter, false);
|
||||
if (status != 0) {
|
||||
return status;
|
||||
}
|
||||
|
@ -851,54 +649,64 @@ static int host_flash_manager_set_flash_for_rot_access (struct host_flash_manage
|
|||
return status;
|
||||
}
|
||||
|
||||
if (manager->flash_init) {
|
||||
status = host_flash_initialization_initialize_flash (manager->flash_init);
|
||||
if (flash_init) {
|
||||
status = host_flash_initialization_initialize_flash (flash_init);
|
||||
if (status != 0) {
|
||||
return status;
|
||||
}
|
||||
}
|
||||
|
||||
flash = manager->flash_cs0;
|
||||
flash = cs0;
|
||||
for (i = 0; i < 2; i++) {
|
||||
status = host_flash_manager_configure_flash_for_rot_access (flash);
|
||||
if (status != 0) {
|
||||
return status;
|
||||
if (flash) {
|
||||
status = host_flash_manager_configure_flash_for_rot_access (flash);
|
||||
if (status != 0) {
|
||||
return status;
|
||||
}
|
||||
}
|
||||
|
||||
flash = manager->flash_cs1;
|
||||
flash = cs1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int host_flash_manager_set_flash_for_host_access (struct host_flash_manager *manager,
|
||||
struct host_control *control)
|
||||
/**
|
||||
* Enable host access to the protected flash devices.
|
||||
*
|
||||
* @param control The interface for hardware controls for flash access.
|
||||
* @param filter The SPI filter connected to the flash devices.
|
||||
*
|
||||
* @return 0 if host flash access has been enabled or an error code.
|
||||
*/
|
||||
int host_flash_manager_set_flash_for_host_access (struct host_control *control,
|
||||
struct spi_filter_interface *filter)
|
||||
{
|
||||
int status;
|
||||
|
||||
if ((manager == NULL) || (control == NULL)) {
|
||||
return HOST_FLASH_MGR_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
status = control->enable_processor_flash_access (control, true);
|
||||
if (status != 0) {
|
||||
return status;
|
||||
}
|
||||
|
||||
return manager->filter->enable_filter (manager->filter, true);
|
||||
return filter->enable_filter (filter, true);
|
||||
}
|
||||
|
||||
static int host_flash_manager_host_has_flash_access (struct host_flash_manager *manager,
|
||||
struct host_control *control)
|
||||
/**
|
||||
* Determine if the host has access to the protected flash devices.
|
||||
*
|
||||
* @param control The interface for hardware controls for flash access.
|
||||
* @param filter The SPI filter connected to the flash devices.
|
||||
*
|
||||
* @return 0 if the host doesn't if access, 1 if it does, or an error code.
|
||||
*/
|
||||
int host_flash_manager_host_has_flash_access (struct host_control *control,
|
||||
struct spi_filter_interface *filter)
|
||||
{
|
||||
bool enabled;
|
||||
int status;
|
||||
|
||||
if ((manager == NULL) || (control == NULL)) {
|
||||
return HOST_FLASH_MGR_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
status = manager->filter->get_filter_enabled (manager->filter, &enabled);
|
||||
status = filter->get_filter_enabled (filter, &enabled);
|
||||
if (status != 0) {
|
||||
return status;
|
||||
}
|
||||
|
@ -914,96 +722,3 @@ static int host_flash_manager_host_has_flash_access (struct host_flash_manager *
|
|||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize the manager for host flash devices.
|
||||
*
|
||||
* @param manager The flash manager to initialize.
|
||||
* @param cs0 The flash device connected to chip select 0.
|
||||
* @param cs1 The flash device connected to chip select 1.
|
||||
* @param host_state The manager for host state information.
|
||||
* @param filter The SPI filter for the protected flash.
|
||||
* @param mfg_handler The SPI filter handler for configuring the flash device manufacturer.
|
||||
*
|
||||
* @return 0 if the manager was successfully initialized or an error code.
|
||||
*/
|
||||
int host_flash_manager_init (struct host_flash_manager *manager, struct spi_flash *cs0,
|
||||
struct spi_flash *cs1, struct state_manager *host_state, struct spi_filter_interface *filter,
|
||||
struct flash_mfg_filter_handler *mfg_handler)
|
||||
{
|
||||
if ((manager == NULL) || (cs0 == NULL) || (cs1 == NULL) || (host_state == NULL) ||
|
||||
(filter == NULL) || (mfg_handler == NULL)) {
|
||||
return HOST_FLASH_MGR_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
memset (manager, 0, sizeof (struct host_flash_manager));
|
||||
|
||||
manager->get_read_only_flash = host_flash_manager_get_read_only_flash;
|
||||
manager->get_read_write_flash = host_flash_manager_get_read_write_flash;
|
||||
manager->validate_read_only_flash = host_flash_manager_validate_read_only_flash;
|
||||
manager->validate_read_write_flash = host_flash_manager_validate_read_write_flash;
|
||||
manager->get_flash_read_write_regions = host_flash_manager_get_flash_read_write_regions;
|
||||
manager->free_read_write_regions = host_flash_manager_free_read_write_regions;
|
||||
manager->config_spi_filter_flash_type = host_flash_manager_config_spi_filter_flash_type;
|
||||
manager->config_spi_filter_flash_devices = host_flash_manager_config_spi_filter_flash_devices;
|
||||
manager->swap_flash_devices = host_flash_manager_swap_flash_devices;
|
||||
manager->initialize_flash_protection = host_flash_manager_initialize_flash_protection;
|
||||
manager->restore_flash_read_write_regions = host_flash_manager_restore_flash_read_write_regions;
|
||||
manager->set_flash_for_rot_access = host_flash_manager_set_flash_for_rot_access;
|
||||
manager->set_flash_for_host_access = host_flash_manager_set_flash_for_host_access;
|
||||
manager->host_has_flash_access = host_flash_manager_host_has_flash_access;
|
||||
|
||||
manager->flash_cs0 = cs0;
|
||||
manager->flash_cs1 = cs1;
|
||||
manager->host_state = host_state;
|
||||
manager->filter = filter;
|
||||
manager->mfg_handler = mfg_handler;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize the manager for host flash devices. The interfaces to the flash devices may be
|
||||
* uninitialized, but an initialization manager is provided to ensure they get initialized prior to
|
||||
* use.
|
||||
*
|
||||
* @param manager The flash manager to initialize.
|
||||
* @param cs0 The flash device connected to chip select 0.
|
||||
* @param cs1 The flash device connected to chip select 1.
|
||||
* @param host_state The manager for host state information.
|
||||
* @param filter The SPI filter for the protected flash.
|
||||
* @param mfg_handler The SPI filter handler for configuring the flash device manufacturer.
|
||||
* @param flash_init The initialization manager for SPI flash interfaces.
|
||||
*
|
||||
* @return 0 if the manager was successfully initialized or an error code.
|
||||
*/
|
||||
int host_flash_manager_init_with_managed_flash_initialization (struct host_flash_manager *manager,
|
||||
struct spi_flash *cs0, struct spi_flash *cs1, struct state_manager *host_state,
|
||||
struct spi_filter_interface *filter, struct flash_mfg_filter_handler *mfg_handler,
|
||||
struct host_flash_initialization *flash_init)
|
||||
{
|
||||
int status;
|
||||
|
||||
if (flash_init == NULL) {
|
||||
return HOST_FLASH_MGR_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
status = host_flash_manager_init (manager, cs0, cs1, host_state, filter, mfg_handler);
|
||||
if (status != 0) {
|
||||
return status;
|
||||
}
|
||||
|
||||
manager->flash_init = flash_init;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Release the resources used by host flash management.
|
||||
*
|
||||
* @param manager The manager to release.
|
||||
*/
|
||||
void host_flash_manager_release (struct host_flash_manager *manager)
|
||||
{
|
||||
|
||||
}
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
#include "status/rot_status.h"
|
||||
#include "host_control.h"
|
||||
#include "host_flash_initialization.h"
|
||||
#include "state_manager/state_manager.h"
|
||||
#include "flash/spi_flash.h"
|
||||
#include "spi_filter/spi_filter_interface.h"
|
||||
#include "spi_filter/flash_mfg_filter_handler.h"
|
||||
|
@ -222,26 +221,17 @@ struct host_flash_manager {
|
|||
*/
|
||||
int (*host_has_flash_access) (struct host_flash_manager *manager,
|
||||
struct host_control *control);
|
||||
|
||||
struct spi_flash *flash_cs0; /**< The flash device connected to CS0. */
|
||||
struct spi_flash *flash_cs1; /**< The flash device connected to CS1. */
|
||||
struct state_manager *host_state; /**< State information for the host using the flash. */
|
||||
struct spi_filter_interface *filter; /**< The SPI filter connected to the flash devices. */
|
||||
struct flash_mfg_filter_handler *mfg_handler; /**< The filter handler for flash device types. */
|
||||
struct host_flash_initialization *flash_init; /**< Host flash initialization manager. */
|
||||
};
|
||||
|
||||
|
||||
int host_flash_manager_init (struct host_flash_manager *manager, struct spi_flash *cs0,
|
||||
struct spi_flash *cs1, struct state_manager *host_state, struct spi_filter_interface *filter,
|
||||
struct flash_mfg_filter_handler *mfg_handler);
|
||||
int host_flash_manager_init_with_managed_flash_initialization (struct host_flash_manager *manager,
|
||||
struct spi_flash *cs0, struct spi_flash *cs1, struct state_manager *host_state,
|
||||
struct spi_filter_interface *filter, struct flash_mfg_filter_handler *mfg_handler,
|
||||
struct host_flash_initialization *flash_init);
|
||||
void host_flash_manager_release (struct host_flash_manager *manager);
|
||||
|
||||
/* Internal functions for use by derived types. */
|
||||
int host_flash_manager_get_image_entry (struct pfm *pfm, struct spi_flash *flash, uint32_t offset,
|
||||
const char *fw_id, struct pfm_firmware_versions *versions,
|
||||
const struct pfm_firmware_version **version, struct pfm_image_list *fw_images,
|
||||
struct pfm_read_write_regions *writable);
|
||||
int host_flash_manager_get_firmware_types (struct pfm *pfm, struct pfm_firmware *host_fw,
|
||||
struct host_flash_manager_images *host_img, struct host_flash_manager_rw_regions *host_rw);
|
||||
|
||||
int host_flash_manager_validate_flash (struct pfm *pfm, struct hash_engine *hash,
|
||||
struct rsa_engine *rsa, bool full_validation, struct spi_flash *flash,
|
||||
struct host_flash_manager_rw_regions *host_rw);
|
||||
|
@ -252,7 +242,24 @@ int host_flash_manager_validate_pfm (struct pfm *pfm, struct pfm *good_pfm,
|
|||
struct hash_engine *hash, struct rsa_engine *rsa, struct spi_flash *flash,
|
||||
struct host_flash_manager_rw_regions *host_rw);
|
||||
|
||||
int host_flash_manager_get_flash_read_write_regions (struct spi_flash *flash, struct pfm *pfm,
|
||||
struct host_flash_manager_rw_regions *host_rw);
|
||||
|
||||
void host_flash_manager_free_read_write_regions (struct host_flash_manager *manager,
|
||||
struct host_flash_manager_rw_regions *host_rw);
|
||||
void host_flash_manager_free_images (struct host_flash_manager_images *host_img);
|
||||
|
||||
int host_flash_manager_config_spi_filter_flash_type (struct spi_flash *cs0, struct spi_flash *cs1,
|
||||
struct spi_filter_interface *filter, struct flash_mfg_filter_handler *mfg_handler);
|
||||
|
||||
int host_flash_manager_configure_flash_for_rot_access (struct spi_flash *flash);
|
||||
int host_flash_manager_set_flash_for_rot_access (struct host_control *control,
|
||||
struct spi_filter_interface *filter, struct spi_flash *cs0, struct spi_flash *cs1,
|
||||
struct host_flash_initialization *flash_init);
|
||||
int host_flash_manager_set_flash_for_host_access (struct host_control *control,
|
||||
struct spi_filter_interface *filter);
|
||||
int host_flash_manager_host_has_flash_access (struct host_control *control,
|
||||
struct spi_filter_interface *filter);
|
||||
|
||||
|
||||
#define HOST_FLASH_MGR_ERROR(code) ROT_ERROR (ROT_MODULE_HOST_FLASH_MGR, code)
|
||||
|
@ -281,6 +288,7 @@ enum {
|
|||
HOST_FLASH_MGR_MISMATCH_SIZES = HOST_FLASH_MGR_ERROR (0x11), /**< The host flash devices are not the same size. */
|
||||
HOST_FLASH_MGR_MISMATCH_ADDR_MODE = HOST_FLASH_MGR_ERROR (0x12), /**< The host flash devices support different address mode behavior. */
|
||||
HOST_FLASH_MGR_RESTORE_RW_FAILED = HOST_FLASH_MGR_ERROR (0x13), /**< Flash read/write regions were not restore successfully. */
|
||||
HOST_FLASH_MGR_UNSUPPORTED_OPERATION = HOST_FLASH_MGR_ERROR (0x14), /**< The operation is unsupported by the flash manager. */
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,405 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
#include "host_flash_manager_dual.h"
|
||||
#include "host_fw_util.h"
|
||||
|
||||
|
||||
static struct spi_flash* host_flash_manager_dual_get_read_only_flash (
|
||||
struct host_flash_manager *manager)
|
||||
{
|
||||
struct host_flash_manager_dual *dual = (struct host_flash_manager_dual*) manager;
|
||||
|
||||
if (dual == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (host_state_manager_get_read_only_flash (dual->host_state) == SPI_FILTER_CS_0) {
|
||||
return dual->flash_cs0;
|
||||
}
|
||||
else {
|
||||
return dual->flash_cs1;
|
||||
}
|
||||
}
|
||||
|
||||
static struct spi_flash* host_flash_manager_dual_get_read_write_flash (
|
||||
struct host_flash_manager *manager)
|
||||
{
|
||||
struct host_flash_manager_dual *dual = (struct host_flash_manager_dual*) manager;
|
||||
|
||||
if (dual == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (host_state_manager_get_read_only_flash (dual->host_state) == SPI_FILTER_CS_0) {
|
||||
return dual->flash_cs1;
|
||||
}
|
||||
else {
|
||||
return dual->flash_cs0;
|
||||
}
|
||||
}
|
||||
|
||||
static int host_flash_manager_dual_validate_read_only_flash (struct host_flash_manager *manager,
|
||||
struct pfm *pfm, struct pfm *good_pfm, struct hash_engine *hash, struct rsa_engine *rsa,
|
||||
bool full_validation, struct host_flash_manager_rw_regions *host_rw)
|
||||
{
|
||||
int status;
|
||||
|
||||
if ((manager == NULL) || (pfm == NULL) || (hash == NULL) || (rsa == NULL) ||
|
||||
(host_rw == NULL)) {
|
||||
return HOST_FLASH_MGR_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
if (good_pfm && !full_validation) {
|
||||
status = host_flash_manager_validate_pfm (pfm, good_pfm, hash, rsa,
|
||||
host_flash_manager_dual_get_read_only_flash (manager), host_rw);
|
||||
}
|
||||
else {
|
||||
status = host_flash_manager_validate_flash (pfm, hash, rsa, full_validation,
|
||||
host_flash_manager_dual_get_read_only_flash (manager), host_rw);
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
static int host_flash_manager_dual_validate_read_write_flash (struct host_flash_manager *manager,
|
||||
struct pfm *pfm, struct hash_engine *hash, struct rsa_engine *rsa,
|
||||
struct host_flash_manager_rw_regions *host_rw)
|
||||
{
|
||||
if ((manager == NULL) || (pfm == NULL) || (hash == NULL) || (rsa == NULL) ||
|
||||
(host_rw == NULL)) {
|
||||
return HOST_FLASH_MGR_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
return host_flash_manager_validate_flash (pfm, hash, rsa, true,
|
||||
host_flash_manager_dual_get_read_write_flash (manager), host_rw);
|
||||
}
|
||||
|
||||
static int host_flash_manager_dual_get_flash_read_write_regions (struct host_flash_manager *manager,
|
||||
struct pfm *pfm, bool rw_flash, struct host_flash_manager_rw_regions *host_rw)
|
||||
{
|
||||
if ((manager == NULL) || (pfm == NULL) || (host_rw == NULL)) {
|
||||
return HOST_FLASH_MGR_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
return host_flash_manager_get_flash_read_write_regions (
|
||||
(rw_flash) ?
|
||||
host_flash_manager_dual_get_read_write_flash (manager) :
|
||||
host_flash_manager_dual_get_read_only_flash (manager),
|
||||
pfm, host_rw);
|
||||
}
|
||||
|
||||
static int host_flash_manager_dual_config_spi_filter_flash_type (struct host_flash_manager *manager)
|
||||
{
|
||||
struct host_flash_manager_dual *dual = (struct host_flash_manager_dual*) manager;
|
||||
|
||||
if (dual == NULL) {
|
||||
return HOST_FLASH_MGR_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
return host_flash_manager_config_spi_filter_flash_type (dual->flash_cs0, dual->flash_cs1,
|
||||
dual->filter, dual->mfg_handler);
|
||||
}
|
||||
|
||||
static int host_flash_manager_dual_config_spi_filter_flash_devices (
|
||||
struct host_flash_manager *manager)
|
||||
{
|
||||
struct host_flash_manager_dual *dual = (struct host_flash_manager_dual*) manager;
|
||||
spi_filter_cs ro;
|
||||
|
||||
if (dual == NULL) {
|
||||
return HOST_FLASH_MGR_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
ro = host_state_manager_get_read_only_flash (dual->host_state);
|
||||
return dual->filter->set_ro_cs (dual->filter, ro);
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy the read/write data regions from one flash to another.
|
||||
*
|
||||
* @param manager The flash manager to use for the data migration.
|
||||
* @param from The flash device to copy from.
|
||||
* @param writable The list of read/write regions that should be migrated.
|
||||
*
|
||||
* @return 0 if the data migration was successful or an error code.
|
||||
*/
|
||||
static int host_flash_manager_dual_migrate_rw_data (struct host_flash_manager_dual *manager,
|
||||
spi_filter_cs from, struct host_flash_manager_rw_regions *host_rw)
|
||||
{
|
||||
int status;
|
||||
|
||||
if (from == SPI_FILTER_CS_0) {
|
||||
status = host_fw_migrate_read_write_data_multiple_fw (manager->flash_cs1, host_rw->writable,
|
||||
host_rw->count, manager->flash_cs0, NULL, 0);
|
||||
}
|
||||
else {
|
||||
status = host_fw_migrate_read_write_data_multiple_fw (manager->flash_cs0, host_rw->writable,
|
||||
host_rw->count, manager->flash_cs1, NULL, 0);
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
static int host_flash_manager_dual_swap_flash_devices (struct host_flash_manager *manager,
|
||||
struct host_flash_manager_rw_regions *host_rw, struct pfm_manager *used_pending)
|
||||
{
|
||||
struct host_flash_manager_dual *dual = (struct host_flash_manager_dual*) manager;
|
||||
spi_filter_cs rw;
|
||||
int status;
|
||||
|
||||
if (dual == NULL) {
|
||||
return HOST_FLASH_MGR_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
/* Clear the dirty bit in the SPI filter. */
|
||||
status = dual->filter->clear_flash_dirty_state (dual->filter);
|
||||
if (status != 0) {
|
||||
return status;
|
||||
}
|
||||
|
||||
/* Configure the SPI filter to switch the read and write flashes. */
|
||||
rw = (host_state_manager_get_read_only_flash (dual->host_state) == SPI_FILTER_CS_0) ?
|
||||
SPI_FILTER_CS_1 : SPI_FILTER_CS_0;
|
||||
status = dual->filter->set_ro_cs (dual->filter, rw);
|
||||
if (status != 0) {
|
||||
return status;
|
||||
}
|
||||
|
||||
/* Migrate the R/W data to the new write flash. */
|
||||
if (host_rw) {
|
||||
status = host_flash_manager_dual_migrate_rw_data (dual, rw, host_rw);
|
||||
}
|
||||
|
||||
/* Save the current flash configuration. */
|
||||
if (status == 0) {
|
||||
state_manager_block_non_volatile_state_storage (&dual->host_state->base, true);
|
||||
|
||||
host_state_manager_save_read_only_flash (dual->host_state, rw);
|
||||
host_state_manager_save_inactive_dirty (dual->host_state, false);
|
||||
|
||||
if (used_pending) {
|
||||
used_pending->base.activate_pending_manifest (&used_pending->base);
|
||||
}
|
||||
|
||||
state_manager_block_non_volatile_state_storage (&dual->host_state->base, false);
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
static int host_flash_manager_dual_initialize_flash_protection (struct host_flash_manager *manager,
|
||||
struct host_flash_manager_rw_regions *host_rw)
|
||||
{
|
||||
struct host_flash_manager_dual *dual = (struct host_flash_manager_dual*) manager;
|
||||
spi_filter_cs ro;
|
||||
struct spi_flash *ro_flash;
|
||||
struct spi_flash *rw_flash;
|
||||
int status;
|
||||
int addr_4byte;
|
||||
|
||||
if ((dual == NULL) || (host_rw == NULL)) {
|
||||
return HOST_FLASH_MGR_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
/* Make sure both flash devices are running with the same address mode. */
|
||||
ro_flash = host_flash_manager_dual_get_read_only_flash (manager);
|
||||
rw_flash = host_flash_manager_dual_get_read_write_flash (manager);
|
||||
|
||||
addr_4byte = spi_flash_is_4byte_address_mode (ro_flash);
|
||||
if (ROT_IS_ERROR (addr_4byte)) {
|
||||
return addr_4byte;
|
||||
}
|
||||
|
||||
if (addr_4byte != spi_flash_is_4byte_address_mode (rw_flash)) {
|
||||
status = spi_flash_enable_4byte_address_mode (rw_flash, addr_4byte);
|
||||
if (status != 0) {
|
||||
return status;
|
||||
}
|
||||
}
|
||||
|
||||
/* Make the R/W data available on the R/W flash device. */
|
||||
ro = host_state_manager_get_read_only_flash (dual->host_state);
|
||||
|
||||
status = host_flash_manager_dual_migrate_rw_data (dual, ro, host_rw);
|
||||
if (status != 0) {
|
||||
return status;
|
||||
}
|
||||
|
||||
/* Protection is being initialized, so the R/W flash can't be dirty yet. */
|
||||
status = dual->filter->clear_flash_dirty_state (dual->filter);
|
||||
if (status != 0) {
|
||||
return status;
|
||||
}
|
||||
|
||||
host_state_manager_save_inactive_dirty (dual->host_state, false);
|
||||
|
||||
/* Make sure the SPI filter address mode matches the mode of the physical devices.
|
||||
*
|
||||
* If the device address mode is fixed, this was already configured during initial filter setup
|
||||
* and doesn't need to be done again. */
|
||||
if (!spi_flash_is_address_mode_fixed (ro_flash)) {
|
||||
status = dual->filter->set_addr_byte_mode (dual->filter,
|
||||
(addr_4byte == 1) ? SPI_FILTER_ADDRESS_MODE_4 : SPI_FILTER_ADDRESS_MODE_3);
|
||||
if (status != 0) {
|
||||
return status;
|
||||
}
|
||||
}
|
||||
|
||||
/* Turn on the SPI filter. */
|
||||
status = dual->filter->set_filter_mode (dual->filter, SPI_FILTER_FLASH_DUAL);
|
||||
if (status != 0) {
|
||||
return status;
|
||||
}
|
||||
|
||||
return dual->filter->set_ro_cs (dual->filter, ro);
|
||||
}
|
||||
|
||||
static int host_flash_manager_dual_restore_flash_read_write_regions (
|
||||
struct host_flash_manager *manager, struct host_flash_manager_rw_regions *host_rw)
|
||||
{
|
||||
if ((manager == NULL) || (host_rw == NULL)) {
|
||||
return HOST_FLASH_MGR_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
return host_fw_restore_read_write_data_multiple_fw (
|
||||
host_flash_manager_dual_get_read_write_flash (manager),
|
||||
host_flash_manager_dual_get_read_only_flash (manager), host_rw->writable, host_rw->count);
|
||||
}
|
||||
|
||||
static int host_flash_manager_dual_set_flash_for_rot_access (struct host_flash_manager *manager,
|
||||
struct host_control *control)
|
||||
{
|
||||
struct host_flash_manager_dual *dual = (struct host_flash_manager_dual*) manager;
|
||||
|
||||
if ((dual == NULL) || (control == NULL)) {
|
||||
return HOST_FLASH_MGR_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
return host_flash_manager_set_flash_for_rot_access (control, dual->filter, dual->flash_cs0,
|
||||
dual->flash_cs1, dual->flash_init);
|
||||
}
|
||||
|
||||
static int host_flash_manager_dual_set_flash_for_host_access (struct host_flash_manager *manager,
|
||||
struct host_control *control)
|
||||
{
|
||||
struct host_flash_manager_dual *dual = (struct host_flash_manager_dual*) manager;
|
||||
|
||||
if ((dual == NULL) || (control == NULL)) {
|
||||
return HOST_FLASH_MGR_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
return host_flash_manager_set_flash_for_host_access (control, dual->filter);
|
||||
}
|
||||
|
||||
static int host_flash_manager_dual_host_has_flash_access (struct host_flash_manager *manager,
|
||||
struct host_control *control)
|
||||
{
|
||||
struct host_flash_manager_dual *dual = (struct host_flash_manager_dual*) manager;
|
||||
|
||||
if ((dual == NULL) || (control == NULL)) {
|
||||
return HOST_FLASH_MGR_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
return host_flash_manager_host_has_flash_access (control, dual->filter);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize the manager for dual host flash devices.
|
||||
*
|
||||
* @param manager The flash manager to initialize.
|
||||
* @param cs0 The flash device connected to chip select 0.
|
||||
* @param cs1 The flash device connected to chip select 1.
|
||||
* @param host_state The manager for host state information.
|
||||
* @param filter The SPI filter for the protected flash.
|
||||
* @param mfg_handler The SPI filter handler for configuring the flash device manufacturer.
|
||||
*
|
||||
* @return 0 if the manager was successfully initialized or an error code.
|
||||
*/
|
||||
int host_flash_manager_dual_init (struct host_flash_manager_dual *manager, struct spi_flash *cs0,
|
||||
struct spi_flash *cs1, struct host_state_manager *host_state,
|
||||
struct spi_filter_interface *filter, struct flash_mfg_filter_handler *mfg_handler)
|
||||
{
|
||||
if ((manager == NULL) || (cs0 == NULL) || (cs1 == NULL) || (host_state == NULL) ||
|
||||
(filter == NULL) || (mfg_handler == NULL)) {
|
||||
return HOST_FLASH_MGR_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
memset (manager, 0, sizeof (struct host_flash_manager_dual));
|
||||
|
||||
manager->base.get_read_only_flash = host_flash_manager_dual_get_read_only_flash;
|
||||
manager->base.get_read_write_flash = host_flash_manager_dual_get_read_write_flash;
|
||||
manager->base.validate_read_only_flash = host_flash_manager_dual_validate_read_only_flash;
|
||||
manager->base.validate_read_write_flash = host_flash_manager_dual_validate_read_write_flash;
|
||||
manager->base.get_flash_read_write_regions =
|
||||
host_flash_manager_dual_get_flash_read_write_regions;
|
||||
manager->base.free_read_write_regions = host_flash_manager_free_read_write_regions;
|
||||
manager->base.config_spi_filter_flash_type =
|
||||
host_flash_manager_dual_config_spi_filter_flash_type;
|
||||
manager->base.config_spi_filter_flash_devices =
|
||||
host_flash_manager_dual_config_spi_filter_flash_devices;
|
||||
manager->base.swap_flash_devices = host_flash_manager_dual_swap_flash_devices;
|
||||
manager->base.initialize_flash_protection = host_flash_manager_dual_initialize_flash_protection;
|
||||
manager->base.restore_flash_read_write_regions =
|
||||
host_flash_manager_dual_restore_flash_read_write_regions;
|
||||
manager->base.set_flash_for_rot_access = host_flash_manager_dual_set_flash_for_rot_access;
|
||||
manager->base.set_flash_for_host_access = host_flash_manager_dual_set_flash_for_host_access;
|
||||
manager->base.host_has_flash_access = host_flash_manager_dual_host_has_flash_access;
|
||||
|
||||
manager->flash_cs0 = cs0;
|
||||
manager->flash_cs1 = cs1;
|
||||
manager->host_state = host_state;
|
||||
manager->filter = filter;
|
||||
manager->mfg_handler = mfg_handler;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize the manager for dual host flash devices. The interfaces to the flash devices may be
|
||||
* uninitialized, but an initialization manager is provided to ensure they get initialized prior to
|
||||
* use.
|
||||
*
|
||||
* @param manager The flash manager to initialize.
|
||||
* @param cs0 The flash device connected to chip select 0.
|
||||
* @param cs1 The flash device connected to chip select 1.
|
||||
* @param host_state The manager for host state information.
|
||||
* @param filter The SPI filter for the protected flash.
|
||||
* @param mfg_handler The SPI filter handler for configuring the flash device manufacturer.
|
||||
* @param flash_init The initialization manager for SPI flash interfaces.
|
||||
*
|
||||
* @return 0 if the manager was successfully initialized or an error code.
|
||||
*/
|
||||
int host_flash_manager_dual_init_with_managed_flash_initialization (
|
||||
struct host_flash_manager_dual *manager, struct spi_flash *cs0, struct spi_flash *cs1,
|
||||
struct host_state_manager *host_state, struct spi_filter_interface *filter,
|
||||
struct flash_mfg_filter_handler *mfg_handler, struct host_flash_initialization *flash_init)
|
||||
{
|
||||
int status;
|
||||
|
||||
if (flash_init == NULL) {
|
||||
return HOST_FLASH_MGR_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
status = host_flash_manager_dual_init (manager, cs0, cs1, host_state, filter, mfg_handler);
|
||||
if (status != 0) {
|
||||
return status;
|
||||
}
|
||||
|
||||
manager->flash_init = flash_init;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Release the resources used for dual host flash management.
|
||||
*
|
||||
* @param manager The manager to release.
|
||||
*/
|
||||
void host_flash_manager_dual_release (struct host_flash_manager_dual *manager)
|
||||
{
|
||||
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
#ifndef HOST_FLASH_MANAGER_DUAL_H_
|
||||
#define HOST_FLASH_MANAGER_DUAL_H_
|
||||
|
||||
#include "host_flash_manager.h"
|
||||
#include "host_state_manager.h"
|
||||
|
||||
|
||||
/**
|
||||
* Manager for protected flash devices for a single host processor with a dual flash configuration.
|
||||
*/
|
||||
struct host_flash_manager_dual {
|
||||
struct host_flash_manager base; /**< Base flash manager interface. */
|
||||
struct spi_flash *flash_cs0; /**< The flash device connected to CS0. */
|
||||
struct spi_flash *flash_cs1; /**< The flash device connected to CS1. */
|
||||
struct host_state_manager *host_state; /**< State information for the host using the flash. */
|
||||
struct spi_filter_interface *filter; /**< The SPI filter connected to the flash devices. */
|
||||
struct flash_mfg_filter_handler *mfg_handler; /**< The filter handler for flash device types. */
|
||||
struct host_flash_initialization *flash_init; /**< Host flash initialization manager. */
|
||||
};
|
||||
|
||||
|
||||
int host_flash_manager_dual_init (struct host_flash_manager_dual *manager, struct spi_flash *cs0,
|
||||
struct spi_flash *cs1, struct host_state_manager *host_state,
|
||||
struct spi_filter_interface *filter, struct flash_mfg_filter_handler *mfg_handler);
|
||||
int host_flash_manager_dual_init_with_managed_flash_initialization (
|
||||
struct host_flash_manager_dual *manager, struct spi_flash *cs0, struct spi_flash *cs1,
|
||||
struct host_state_manager *host_state, struct spi_filter_interface *filter,
|
||||
struct flash_mfg_filter_handler *mfg_handler, struct host_flash_initialization *flash_init);
|
||||
void host_flash_manager_dual_release (struct host_flash_manager_dual *manager);
|
||||
|
||||
|
||||
#endif /* HOST_FLASH_MANAGER_DUAL_H_ */
|
|
@ -0,0 +1,335 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
#include "host_flash_manager_single.h"
|
||||
|
||||
|
||||
static struct spi_flash* host_flash_manager_single_get_read_only_flash (
|
||||
struct host_flash_manager *manager)
|
||||
{
|
||||
struct host_flash_manager_single *single = (struct host_flash_manager_single*) manager;
|
||||
|
||||
if (single == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return single->flash;
|
||||
}
|
||||
|
||||
static struct spi_flash* host_flash_manager_single_get_read_write_flash (
|
||||
struct host_flash_manager *manager)
|
||||
{
|
||||
struct host_flash_manager_single *single = (struct host_flash_manager_single*) manager;
|
||||
|
||||
if (single == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return single->flash;
|
||||
}
|
||||
|
||||
static int host_flash_manager_single_validate_read_only_flash (struct host_flash_manager *manager,
|
||||
struct pfm *pfm, struct pfm *good_pfm, struct hash_engine *hash, struct rsa_engine *rsa,
|
||||
bool full_validation, struct host_flash_manager_rw_regions *host_rw)
|
||||
{
|
||||
struct host_flash_manager_single *single = (struct host_flash_manager_single*) manager;
|
||||
int status;
|
||||
|
||||
if ((single == NULL) || (pfm == NULL) || (hash == NULL) || (rsa == NULL) || (host_rw == NULL)) {
|
||||
return HOST_FLASH_MGR_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
if (good_pfm && !full_validation) {
|
||||
status = host_flash_manager_validate_pfm (pfm, good_pfm, hash, rsa, single->flash, host_rw);
|
||||
}
|
||||
else {
|
||||
status = host_flash_manager_validate_flash (pfm, hash, rsa, full_validation, single->flash,
|
||||
host_rw);
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
static int host_flash_manager_single_validate_read_write_flash (struct host_flash_manager *manager,
|
||||
struct pfm *pfm, struct hash_engine *hash, struct rsa_engine *rsa,
|
||||
struct host_flash_manager_rw_regions *host_rw)
|
||||
{
|
||||
struct host_flash_manager_single *single = (struct host_flash_manager_single*) manager;
|
||||
|
||||
if ((single == NULL) || (pfm == NULL) || (hash == NULL) || (rsa == NULL) || (host_rw == NULL)) {
|
||||
return HOST_FLASH_MGR_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
return host_flash_manager_validate_flash (pfm, hash, rsa, true, single->flash, host_rw);
|
||||
}
|
||||
|
||||
static int host_flash_manager_single_get_flash_read_write_regions (
|
||||
struct host_flash_manager *manager, struct pfm *pfm, bool rw_flash,
|
||||
struct host_flash_manager_rw_regions *host_rw)
|
||||
{
|
||||
struct host_flash_manager_single *single = (struct host_flash_manager_single*) manager;
|
||||
|
||||
if ((single == NULL) || (pfm == NULL) || (host_rw == NULL)) {
|
||||
return HOST_FLASH_MGR_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
return host_flash_manager_get_flash_read_write_regions (single->flash, pfm, host_rw);
|
||||
}
|
||||
|
||||
static int host_flash_manager_single_config_spi_filter_flash_type (
|
||||
struct host_flash_manager *manager)
|
||||
{
|
||||
struct host_flash_manager_single *single = (struct host_flash_manager_single*) manager;
|
||||
|
||||
if (single == NULL) {
|
||||
return HOST_FLASH_MGR_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
return host_flash_manager_config_spi_filter_flash_type (single->flash, NULL, single->filter,
|
||||
single->mfg_handler);
|
||||
}
|
||||
|
||||
static int host_flash_manager_single_config_spi_filter_flash_devices (
|
||||
struct host_flash_manager *manager)
|
||||
{
|
||||
struct host_flash_manager_single *single = (struct host_flash_manager_single*) manager;
|
||||
int status;
|
||||
|
||||
if (single == NULL) {
|
||||
return HOST_FLASH_MGR_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
status = single->filter->allow_all_single_flash_writes (single->filter, true);
|
||||
if (status != 0) {
|
||||
return status;
|
||||
}
|
||||
|
||||
return single->filter->set_filter_mode (single->filter, SPI_FILTER_FLASH_SINGLE_CS0);
|
||||
}
|
||||
|
||||
static int host_flash_manager_single_swap_flash_devices (struct host_flash_manager *manager,
|
||||
struct host_flash_manager_rw_regions *host_rw, struct pfm_manager *used_pending)
|
||||
{
|
||||
struct host_flash_manager_single *single = (struct host_flash_manager_single*) manager;
|
||||
int status;
|
||||
|
||||
if (single == NULL) {
|
||||
return HOST_FLASH_MGR_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
/* Clear the dirty bit in the SPI filter. */
|
||||
status = single->filter->clear_flash_dirty_state (single->filter);
|
||||
if (status != 0) {
|
||||
return status;
|
||||
}
|
||||
|
||||
/* Ensure proper configuration of the SPI filter. */
|
||||
status = single->filter->allow_all_single_flash_writes (single->filter, true);
|
||||
if (status != 0) {
|
||||
return status;
|
||||
}
|
||||
|
||||
status = single->filter->set_filter_mode (single->filter, SPI_FILTER_FLASH_SINGLE_CS0);
|
||||
|
||||
/* Save the current flash configuration. */
|
||||
if (status == 0) {
|
||||
state_manager_block_non_volatile_state_storage (&single->host_state->base, true);
|
||||
|
||||
host_state_manager_save_inactive_dirty (single->host_state, false);
|
||||
|
||||
if (used_pending) {
|
||||
used_pending->base.activate_pending_manifest (&used_pending->base);
|
||||
}
|
||||
|
||||
state_manager_block_non_volatile_state_storage (&single->host_state->base, false);
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
static int host_flash_manager_single_initialize_flash_protection (
|
||||
struct host_flash_manager *manager, struct host_flash_manager_rw_regions *host_rw)
|
||||
{
|
||||
struct host_flash_manager_single *single = (struct host_flash_manager_single*) manager;
|
||||
int status;
|
||||
int addr_4byte;
|
||||
|
||||
if ((single == NULL) || (host_rw == NULL)) {
|
||||
return HOST_FLASH_MGR_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
/* Protection is being initialized, so the flash can't be dirty yet. */
|
||||
status = single->filter->clear_flash_dirty_state (single->filter);
|
||||
if (status != 0) {
|
||||
return status;
|
||||
}
|
||||
|
||||
host_state_manager_save_inactive_dirty (single->host_state, false);
|
||||
|
||||
/* Make sure the SPI filter address mode matches the mode of the physical devices.
|
||||
*
|
||||
* If the device address mode is fixed, this was already configured during initial filter setup
|
||||
* and doesn't need to be done again. */
|
||||
if (!spi_flash_is_address_mode_fixed (single->flash)) {
|
||||
addr_4byte = spi_flash_is_4byte_address_mode (single->flash);
|
||||
|
||||
status = single->filter->set_addr_byte_mode (single->filter,
|
||||
(addr_4byte == 1) ? SPI_FILTER_ADDRESS_MODE_4 : SPI_FILTER_ADDRESS_MODE_3);
|
||||
if (status != 0) {
|
||||
return status;
|
||||
}
|
||||
}
|
||||
|
||||
/* Turn on the SPI filter. */
|
||||
status = single->filter->allow_all_single_flash_writes (single->filter, true);
|
||||
if (status != 0) {
|
||||
return status;
|
||||
}
|
||||
|
||||
return single->filter->set_filter_mode (single->filter, SPI_FILTER_FLASH_SINGLE_CS0);
|
||||
}
|
||||
|
||||
static int host_flash_manager_single_restore_flash_read_write_regions (
|
||||
struct host_flash_manager *manager, struct host_flash_manager_rw_regions *host_rw)
|
||||
{
|
||||
if ((manager == NULL) || (host_rw == NULL)) {
|
||||
return HOST_FLASH_MGR_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
return HOST_FLASH_MGR_UNSUPPORTED_OPERATION;
|
||||
}
|
||||
|
||||
static int host_flash_manager_single_set_flash_for_rot_access (struct host_flash_manager *manager,
|
||||
struct host_control *control)
|
||||
{
|
||||
struct host_flash_manager_single *single = (struct host_flash_manager_single*) manager;
|
||||
|
||||
if ((single == NULL) || (control == NULL)) {
|
||||
return HOST_FLASH_MGR_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
return host_flash_manager_set_flash_for_rot_access (control, single->filter, single->flash,
|
||||
NULL, single->flash_init);
|
||||
}
|
||||
|
||||
static int host_flash_manager_single_set_flash_for_host_access (struct host_flash_manager *manager,
|
||||
struct host_control *control)
|
||||
{
|
||||
struct host_flash_manager_single *single = (struct host_flash_manager_single*) manager;
|
||||
|
||||
if ((single == NULL) || (control == NULL)) {
|
||||
return HOST_FLASH_MGR_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
return host_flash_manager_set_flash_for_host_access (control, single->filter);
|
||||
}
|
||||
|
||||
static int host_flash_manager_single_host_has_flash_access (struct host_flash_manager *manager,
|
||||
struct host_control *control)
|
||||
{
|
||||
struct host_flash_manager_single *single = (struct host_flash_manager_single*) manager;
|
||||
|
||||
if ((single == NULL) || (control == NULL)) {
|
||||
return HOST_FLASH_MGR_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
return host_flash_manager_host_has_flash_access (control, single->filter);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize the manager for a single host flash device.
|
||||
*
|
||||
* @param manager The flash manager to initialize.
|
||||
* @param flash The host flash device.
|
||||
* @param host_state The manager for host state information.
|
||||
* @param filter The SPI filter for the protected flash.
|
||||
* @param mfg_handler The SPI filter handler for configuring the flash device manufacturer.
|
||||
*
|
||||
* @return 0 if the manager was successfully initialized or an error code.
|
||||
*/
|
||||
int host_flash_manager_single_init (struct host_flash_manager_single *manager,
|
||||
struct spi_flash *flash, struct host_state_manager *host_state,
|
||||
struct spi_filter_interface *filter, struct flash_mfg_filter_handler *mfg_handler)
|
||||
{
|
||||
if ((manager == NULL) || (flash == NULL) || (host_state == NULL) || (filter == NULL) ||
|
||||
(mfg_handler == NULL)) {
|
||||
return HOST_FLASH_MGR_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
memset (manager, 0, sizeof (struct host_flash_manager_single));
|
||||
|
||||
manager->base.get_read_only_flash = host_flash_manager_single_get_read_only_flash;
|
||||
manager->base.get_read_write_flash = host_flash_manager_single_get_read_write_flash;
|
||||
manager->base.validate_read_only_flash = host_flash_manager_single_validate_read_only_flash;
|
||||
manager->base.validate_read_write_flash = host_flash_manager_single_validate_read_write_flash;
|
||||
manager->base.get_flash_read_write_regions =
|
||||
host_flash_manager_single_get_flash_read_write_regions;
|
||||
manager->base.free_read_write_regions = host_flash_manager_free_read_write_regions;
|
||||
manager->base.config_spi_filter_flash_type =
|
||||
host_flash_manager_single_config_spi_filter_flash_type;
|
||||
manager->base.config_spi_filter_flash_devices =
|
||||
host_flash_manager_single_config_spi_filter_flash_devices;
|
||||
manager->base.swap_flash_devices = host_flash_manager_single_swap_flash_devices;
|
||||
manager->base.initialize_flash_protection =
|
||||
host_flash_manager_single_initialize_flash_protection;
|
||||
manager->base.restore_flash_read_write_regions =
|
||||
host_flash_manager_single_restore_flash_read_write_regions;
|
||||
manager->base.set_flash_for_rot_access = host_flash_manager_single_set_flash_for_rot_access;
|
||||
manager->base.set_flash_for_host_access = host_flash_manager_single_set_flash_for_host_access;
|
||||
manager->base.host_has_flash_access = host_flash_manager_single_host_has_flash_access;
|
||||
|
||||
manager->flash = flash;
|
||||
manager->host_state = host_state;
|
||||
manager->filter = filter;
|
||||
manager->mfg_handler = mfg_handler;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize the manager for a single host flash device. The interface to the flash device may be
|
||||
* uninitialized, but an initialization manager is provided to ensure it gets initialized prior to
|
||||
* use.
|
||||
*
|
||||
* @param manager The flash manager to initialize.
|
||||
* @param flash The host flash device.
|
||||
* @param host_state The manager for host state information.
|
||||
* @param filter The SPI filter for the protected flash.
|
||||
* @param mfg_handler The SPI filter handler for configuring the flash device manufacturer.
|
||||
* @param flash_init The initialization manager for SPI flash interfaces.
|
||||
*
|
||||
* @return 0 if the manager was successfully initialized or an error code.
|
||||
*/
|
||||
int host_flash_manager_single_init_with_managed_flash_initialization (
|
||||
struct host_flash_manager_single *manager, struct spi_flash *flash,
|
||||
struct host_state_manager *host_state, struct spi_filter_interface *filter,
|
||||
struct flash_mfg_filter_handler *mfg_handler, struct host_flash_initialization *flash_init)
|
||||
{
|
||||
int status;
|
||||
|
||||
if (flash_init == NULL) {
|
||||
return HOST_FLASH_MGR_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
status = host_flash_manager_single_init (manager, flash, host_state, filter, mfg_handler);
|
||||
if (status != 0) {
|
||||
return status;
|
||||
}
|
||||
|
||||
manager->flash_init = flash_init;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Release the resources used for single host flash management.
|
||||
*
|
||||
* @param manager The manager to release.
|
||||
*/
|
||||
void host_flash_manager_single_release (struct host_flash_manager_single *manager)
|
||||
{
|
||||
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
#ifndef HOST_FLASH_MANAGER_SINGLE_H_
|
||||
#define HOST_FLASH_MANAGER_SINGLE_H_
|
||||
|
||||
#include "host_flash_manager.h"
|
||||
#include "host_state_manager.h"
|
||||
#include "spi_filter/flash_mfg_filter_handler.h"
|
||||
|
||||
|
||||
/**
|
||||
* Manager for protected flash devices for a single host processor with a single flash
|
||||
* configuration.
|
||||
*/
|
||||
struct host_flash_manager_single {
|
||||
struct host_flash_manager base; /**< Base flash manager interface. */
|
||||
struct spi_flash *flash; /**< The host flash device. */
|
||||
struct host_state_manager *host_state; /**< State information for the host using the flash. */
|
||||
struct spi_filter_interface *filter; /**< The SPI filter connected to the flash devices. */
|
||||
struct flash_mfg_filter_handler *mfg_handler; /**< The filter handler for flash device types. */
|
||||
struct host_flash_initialization *flash_init; /**< Host flash initialization manager. */
|
||||
};
|
||||
|
||||
|
||||
int host_flash_manager_single_init (struct host_flash_manager_single *manager,
|
||||
struct spi_flash *flash, struct host_state_manager *host_state,
|
||||
struct spi_filter_interface *filter, struct flash_mfg_filter_handler *mfg_handler);
|
||||
int host_flash_manager_single_init_with_managed_flash_initialization (
|
||||
struct host_flash_manager_single *manager, struct spi_flash *flash,
|
||||
struct host_state_manager *host_state, struct spi_filter_interface *filter,
|
||||
struct flash_mfg_filter_handler *mfg_handler, struct host_flash_initialization *flash_init);
|
||||
void host_flash_manager_single_release (struct host_flash_manager_single *manager);
|
||||
|
||||
|
||||
#endif /* HOST_FLASH_MANAGER_SINGLE_H_ */
|
|
@ -4,28 +4,27 @@
|
|||
#include <stdlib.h>
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
#include "host_irq_handler_pfm_check.h"
|
||||
#include "host_irq_handler_auth_check.h"
|
||||
|
||||
|
||||
static void host_irq_handler_pfm_check_exit_reset (struct host_irq_handler *handler)
|
||||
static void host_irq_handler_auth_check_exit_reset (struct host_irq_handler *handler)
|
||||
{
|
||||
struct host_irq_handler_pfm_check *check = (struct host_irq_handler_pfm_check*) handler;
|
||||
struct pfm *pending;
|
||||
struct host_irq_handler_auth_check *check = (struct host_irq_handler_auth_check*) handler;
|
||||
int auth_action;
|
||||
|
||||
if (check) {
|
||||
host_irq_handler_exit_reset (handler);
|
||||
|
||||
pending = check->pfm->get_pending_pfm (check->pfm);
|
||||
if (pending) {
|
||||
check->pfm->free_pfm (check->pfm, pending);
|
||||
auth_action = check->base.host->get_next_reset_verification_actions (check->base.host);
|
||||
if (auth_action != HOST_PROCESSOR_ACTION_NONE) {
|
||||
check->control->hold_processor_in_reset (check->control, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize a handler for host interrupts. If there is a pending PFM on reset exit, the host
|
||||
* reset control signal will be asserted.
|
||||
* Initialize a handler for host interrupts. The host reset control signal will be asserted on
|
||||
* reset exit if firmware authentication is required on the next host reset.
|
||||
*
|
||||
* @param handler The handler instance to initialize.
|
||||
* @param host The host generating the interrupts.
|
||||
|
@ -34,22 +33,20 @@ static void host_irq_handler_pfm_check_exit_reset (struct host_irq_handler *hand
|
|||
* @param recovery An optional recovery manager for detecting BMC watchdog recovery boots.
|
||||
* @param control The interface for host control signals.
|
||||
* @param irq Interface to enable host interrupts.
|
||||
* @param pfm The PFM manager for the host.
|
||||
*
|
||||
* @return 0 if the IRQ handler was successfully initialized or an error code.
|
||||
*/
|
||||
int host_irq_handler_pfm_check_init (struct host_irq_handler_pfm_check *handler,
|
||||
int host_irq_handler_auth_check_init (struct host_irq_handler_auth_check *handler,
|
||||
struct host_processor *host, struct hash_engine *hash, struct rsa_engine *rsa,
|
||||
struct bmc_recovery *recovery, struct host_control *control, struct host_irq_control *irq,
|
||||
struct pfm_manager *pfm)
|
||||
struct bmc_recovery *recovery, struct host_control *control, struct host_irq_control *irq)
|
||||
{
|
||||
int status;
|
||||
|
||||
if ((handler == NULL) || (control == NULL) || (irq == NULL) || (pfm == NULL)) {
|
||||
if ((handler == NULL) || (control == NULL) || (irq == NULL)) {
|
||||
return HOST_IRQ_HANDLER_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
memset (handler, 0, sizeof (struct host_irq_handler_pfm_check));
|
||||
memset (handler, 0, sizeof (struct host_irq_handler_auth_check));
|
||||
|
||||
status = host_irq_handler_init (&handler->base, host, hash, rsa, recovery);
|
||||
if (status != 0) {
|
||||
|
@ -62,11 +59,10 @@ int host_irq_handler_pfm_check_init (struct host_irq_handler_pfm_check *handler,
|
|||
return status;
|
||||
}
|
||||
|
||||
handler->base.exit_reset = host_irq_handler_pfm_check_exit_reset;
|
||||
handler->base.exit_reset = host_irq_handler_auth_check_exit_reset;
|
||||
|
||||
handler->control = control;
|
||||
handler->irq = irq;
|
||||
handler->pfm = pfm;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -76,7 +72,7 @@ int host_irq_handler_pfm_check_init (struct host_irq_handler_pfm_check *handler,
|
|||
*
|
||||
* @param handler The IRQ handler to release.
|
||||
*/
|
||||
void host_irq_handler_pfm_check_release (struct host_irq_handler_pfm_check *handler)
|
||||
void host_irq_handler_auth_check_release (struct host_irq_handler_auth_check *handler)
|
||||
{
|
||||
if (handler) {
|
||||
handler->irq->enable_exit_reset (handler->irq, false);
|
|
@ -1,32 +1,29 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
#ifndef HOST_IRQ_HANDLER_PFM_CHECK_H_
|
||||
#define HOST_IRQ_HANDLER_PFM_CHECK_H_
|
||||
#ifndef HOST_IRQ_HANDLER_AUTH_CHECK_H_
|
||||
#define HOST_IRQ_HANDLER_AUTH_CHECK_H_
|
||||
|
||||
#include "host_irq_handler.h"
|
||||
#include "host_control.h"
|
||||
#include "host_irq_control.h"
|
||||
#include "manifest/pfm/pfm_manager.h"
|
||||
|
||||
|
||||
/**
|
||||
* A host IRQ handler that will assert the host reset control signal if there a pending PFM on reset
|
||||
* exit.
|
||||
* A host IRQ handler that will assert the host reset control signal on reset exit if firmware
|
||||
* authentication is required on the next host reset.
|
||||
*/
|
||||
struct host_irq_handler_pfm_check {
|
||||
struct host_irq_handler_auth_check {
|
||||
struct host_irq_handler base; /**< The base IRQ handler. */
|
||||
struct host_control *control; /**< The interface for host control signals. */
|
||||
struct host_irq_control *irq; /**< Interface for enabling host interrupts. */
|
||||
struct pfm_manager *pfm; /**< The PFM manager for the host. */
|
||||
};
|
||||
|
||||
|
||||
int host_irq_handler_pfm_check_init (struct host_irq_handler_pfm_check *handler,
|
||||
int host_irq_handler_auth_check_init (struct host_irq_handler_auth_check *handler,
|
||||
struct host_processor *host, struct hash_engine *hash, struct rsa_engine *rsa,
|
||||
struct bmc_recovery *recovery, struct host_control *control, struct host_irq_control *irq,
|
||||
struct pfm_manager *pfm);
|
||||
void host_irq_handler_pfm_check_release (struct host_irq_handler_pfm_check *handler);
|
||||
struct bmc_recovery *recovery, struct host_control *control, struct host_irq_control *irq);
|
||||
void host_irq_handler_auth_check_release (struct host_irq_handler_auth_check *handler);
|
||||
|
||||
|
||||
#endif /* HOST_IRQ_HANDLER_PFM_CHECK_H_ */
|
||||
#endif /* HOST_IRQ_HANDLER_AUTH_CHECK_H_ */
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -6,64 +6,33 @@
|
|||
|
||||
#include "platform.h"
|
||||
#include "host_processor.h"
|
||||
#include "host_control.h"
|
||||
#include "host_flash_manager.h"
|
||||
#include "state_manager/state_manager.h"
|
||||
#include "spi_filter/spi_filter_interface.h"
|
||||
#include "manifest/pfm/pfm_manager.h"
|
||||
#include "recovery/recovery_image_manager.h"
|
||||
#include "host_processor_filtered.h"
|
||||
#include "host_flash_manager_dual.h"
|
||||
|
||||
|
||||
/**
|
||||
* Defines the core interface for protecting the firmware of a single host processor. The host
|
||||
* has two flash devices available for storing firmware.
|
||||
*/
|
||||
struct host_processor_dual {
|
||||
struct host_processor base; /**< Base host processor interface. */
|
||||
struct host_control *control; /**< The interface for hardware control of the host. */
|
||||
struct host_flash_manager *flash; /**< The manager for host processor flash devices. */
|
||||
struct state_manager *state; /**< State information for the host processor. */
|
||||
struct spi_filter_interface *filter; /**< The SPI filter connected to host flash devices. */
|
||||
struct pfm_manager *pfm; /**< The manager for host processor PFMs. */
|
||||
struct recovery_image_manager *recovery; /**< The manager for recovery of the host processor. */
|
||||
int reset_pulse; /**< The length of the reset pulse for the host. */
|
||||
platform_mutex lock; /**< Synchronization for verification routines. */
|
||||
|
||||
/**
|
||||
* Private functions for customizing internal flows.
|
||||
*/
|
||||
struct {
|
||||
/**
|
||||
* Configure the SPI filter to run in bypass mode.
|
||||
*
|
||||
* @param host The instance for the processor to run in bypass mode.
|
||||
*
|
||||
* @return 0 if bypass mode was configured successfully or an error code.
|
||||
*/
|
||||
int (*enable_bypass_mode) (struct host_processor_dual *host);
|
||||
} internal;
|
||||
};
|
||||
/* Re-uses the common type of struct host_processor_filtered to allow for more efficient memory
|
||||
* allocation. */
|
||||
|
||||
|
||||
int host_processor_dual_init (struct host_processor_dual *host, struct host_control *control,
|
||||
struct host_flash_manager *flash, struct state_manager *state,
|
||||
int host_processor_dual_init (struct host_processor_filtered *host, struct host_control *control,
|
||||
struct host_flash_manager_dual *flash, struct host_state_manager *state,
|
||||
struct spi_filter_interface *filter, struct pfm_manager *pfm,
|
||||
struct recovery_image_manager *recovery);
|
||||
int host_processor_dual_init_pulse_reset (struct host_processor_dual *host,
|
||||
struct host_control *control, struct host_flash_manager *flash, struct state_manager *state,
|
||||
struct spi_filter_interface *filter, struct pfm_manager *pfm,
|
||||
struct recovery_image_manager *recovery);
|
||||
void host_processor_dual_release (struct host_processor_dual *host);
|
||||
int host_processor_dual_init_pulse_reset (struct host_processor_filtered *host,
|
||||
struct host_control *control, struct host_flash_manager_dual *flash,
|
||||
struct host_state_manager *state, struct spi_filter_interface *filter, struct pfm_manager *pfm,
|
||||
struct recovery_image_manager *recovery, int pulse_width);
|
||||
void host_processor_dual_release (struct host_processor_filtered *host);
|
||||
|
||||
/* Internal functions for use by derived types. */
|
||||
int host_processor_dual_init_internal (struct host_processor_dual *host,
|
||||
struct host_control *control, struct host_flash_manager *flash, struct state_manager *state,
|
||||
struct spi_filter_interface *filter, struct pfm_manager *pfm,
|
||||
struct recovery_image_manager *recovery);
|
||||
int host_processor_dual_init_pulse_reset_internal (struct host_processor_dual *host,
|
||||
struct host_control *control, struct host_flash_manager *flash, struct state_manager *state,
|
||||
struct spi_filter_interface *filter, struct pfm_manager *pfm,
|
||||
struct recovery_image_manager *recovery);
|
||||
int host_processor_dual_init_internal (struct host_processor_filtered *host,
|
||||
struct host_control *control, struct host_flash_manager_dual *flash,
|
||||
struct host_state_manager *state, struct spi_filter_interface *filter, struct pfm_manager *pfm,
|
||||
struct recovery_image_manager *recovery, int reset_pulse);
|
||||
|
||||
|
||||
#endif /* HOST_PROCESSOR_DUAL_H_ */
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
#include "host_state_manager.h"
|
||||
|
||||
|
||||
static int host_processor_dual_full_bypass_enable_bypass_mode (struct host_processor_dual *host)
|
||||
static int host_processor_dual_full_bypass_enable_bypass_mode (struct host_processor_filtered *host)
|
||||
{
|
||||
return host->filter->set_filter_mode (host->filter,
|
||||
(host_state_manager_get_read_only_flash (host->state) == SPI_FILTER_CS_0) ?
|
||||
|
@ -29,18 +29,18 @@ static int host_processor_dual_full_bypass_enable_bypass_mode (struct host_proce
|
|||
*
|
||||
* @return 0 if the host processor interface was successfully initialized or an error code.
|
||||
*/
|
||||
int host_processor_dual_full_bypass_init (struct host_processor_dual_full_bypass *host,
|
||||
struct host_control *control, struct host_flash_manager *flash, struct state_manager *state,
|
||||
struct spi_filter_interface *filter, struct pfm_manager *pfm,
|
||||
int host_processor_dual_full_bypass_init (struct host_processor_filtered *host,
|
||||
struct host_control *control, struct host_flash_manager_dual *flash,
|
||||
struct host_state_manager *state, struct spi_filter_interface *filter, struct pfm_manager *pfm,
|
||||
struct recovery_image_manager *recovery)
|
||||
{
|
||||
int status = host_processor_dual_init_internal (&host->base, control, flash, state, filter,
|
||||
pfm, recovery);
|
||||
int status = host_processor_dual_init_internal (host, control, flash, state, filter, pfm,
|
||||
recovery, 0);
|
||||
if (status != 0) {
|
||||
return status;
|
||||
}
|
||||
|
||||
host->base.internal.enable_bypass_mode = host_processor_dual_full_bypass_enable_bypass_mode;
|
||||
host->internal.enable_bypass_mode = host_processor_dual_full_bypass_enable_bypass_mode;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -50,7 +50,7 @@ int host_processor_dual_full_bypass_init (struct host_processor_dual_full_bypass
|
|||
* accessible in full bypass mode.
|
||||
*
|
||||
* While host flash is being accessed, the host processor will not be held in reset. After the host
|
||||
* flash accesses have been completed, the host processor reset will be pulsed for 100ms.
|
||||
* flash accesses have been completed, the host processor reset will be pulsed.
|
||||
*
|
||||
* @param host The host processor instance to initialize.
|
||||
* @param control The interface for controlling the host processor.
|
||||
|
@ -59,21 +59,28 @@ int host_processor_dual_full_bypass_init (struct host_processor_dual_full_bypass
|
|||
* @param filter The SPI filter controlling flash access for the host processor.
|
||||
* @param pfm The manager for PFMs for the host processor.
|
||||
* @param recovery The recovery image manager for the host processor.
|
||||
* @param pulse_width The width of the reset pulse, in milliseconds.
|
||||
*
|
||||
* @return 0 if the host processor interface was successfully initialized or an error code.
|
||||
*/
|
||||
int host_processor_dual_full_bypass_init_pulse_reset (struct host_processor_dual_full_bypass *host,
|
||||
struct host_control *control, struct host_flash_manager *flash, struct state_manager *state,
|
||||
struct spi_filter_interface *filter, struct pfm_manager *pfm,
|
||||
struct recovery_image_manager *recovery)
|
||||
int host_processor_dual_full_bypass_init_pulse_reset (struct host_processor_filtered *host,
|
||||
struct host_control *control, struct host_flash_manager_dual *flash,
|
||||
struct host_state_manager *state, struct spi_filter_interface *filter, struct pfm_manager *pfm,
|
||||
struct recovery_image_manager *recovery, int pulse_width)
|
||||
{
|
||||
int status = host_processor_dual_init_pulse_reset_internal (&host->base, control, flash, state,
|
||||
filter, pfm, recovery);
|
||||
int status;
|
||||
|
||||
if (pulse_width <= 0) {
|
||||
return HOST_PROCESSOR_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
status = host_processor_dual_init_internal (host, control, flash, state, filter, pfm,
|
||||
recovery, pulse_width);
|
||||
if (status != 0) {
|
||||
return status;
|
||||
}
|
||||
|
||||
host->base.internal.enable_bypass_mode = host_processor_dual_full_bypass_enable_bypass_mode;
|
||||
host->internal.enable_bypass_mode = host_processor_dual_full_bypass_enable_bypass_mode;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -83,9 +90,7 @@ int host_processor_dual_full_bypass_init_pulse_reset (struct host_processor_dual
|
|||
*
|
||||
* @param host The host processor instance to release.
|
||||
*/
|
||||
void host_processor_dual_full_bypass_release (struct host_processor_dual_full_bypass *host)
|
||||
void host_processor_dual_full_bypass_release (struct host_processor_filtered *host)
|
||||
{
|
||||
if (host) {
|
||||
host_processor_dual_release (&host->base);
|
||||
}
|
||||
host_processor_dual_release (host);
|
||||
}
|
||||
|
|
|
@ -11,20 +11,19 @@
|
|||
* Protection for firmware on a single host processor that uses two flash devices. When no
|
||||
* protection is enabled, bypass mode to the host flash uses full bypass (no commands are filtered).
|
||||
*/
|
||||
struct host_processor_dual_full_bypass {
|
||||
struct host_processor_dual base; /**< Base host management instance. */
|
||||
};
|
||||
/* Re-uses the common type of struct host_processor_filtered to allow for more efficient memory
|
||||
* allocation. */
|
||||
|
||||
|
||||
int host_processor_dual_full_bypass_init (struct host_processor_dual_full_bypass *host,
|
||||
struct host_control *control, struct host_flash_manager *flash, struct state_manager *state,
|
||||
struct spi_filter_interface *filter, struct pfm_manager *pfm,
|
||||
int host_processor_dual_full_bypass_init (struct host_processor_filtered *host,
|
||||
struct host_control *control, struct host_flash_manager_dual *flash,
|
||||
struct host_state_manager *state, struct spi_filter_interface *filter, struct pfm_manager *pfm,
|
||||
struct recovery_image_manager *recovery);
|
||||
int host_processor_dual_full_bypass_init_pulse_reset (struct host_processor_dual_full_bypass *host,
|
||||
struct host_control *control, struct host_flash_manager *flash, struct state_manager *state,
|
||||
struct spi_filter_interface *filter, struct pfm_manager *pfm,
|
||||
struct recovery_image_manager *recovery);
|
||||
void host_processor_dual_full_bypass_release (struct host_processor_dual_full_bypass *host);
|
||||
int host_processor_dual_full_bypass_init_pulse_reset (struct host_processor_filtered *host,
|
||||
struct host_control *control, struct host_flash_manager_dual *flash,
|
||||
struct host_state_manager *state, struct spi_filter_interface *filter, struct pfm_manager *pfm,
|
||||
struct recovery_image_manager *recovery, int pulse_width);
|
||||
void host_processor_dual_full_bypass_release (struct host_processor_filtered *host);
|
||||
|
||||
|
||||
#endif /* HOST_PROCESSOR_DUAL_FULL_BYPASS_H_ */
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -0,0 +1,75 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
#ifndef HOST_PROCESSOR_FILTERED_H_
|
||||
#define HOST_PROCESSOR_FILTERED_H_
|
||||
|
||||
#include "platform.h"
|
||||
#include "host_processor.h"
|
||||
#include "host_control.h"
|
||||
#include "host_flash_manager.h"
|
||||
#include "host_state_manager.h"
|
||||
#include "spi_filter/spi_filter_interface.h"
|
||||
#include "manifest/pfm/pfm_manager.h"
|
||||
#include "recovery/recovery_image_manager.h"
|
||||
|
||||
|
||||
/**
|
||||
* Defines the common components and handling used with a host connected to flash through a SPI
|
||||
* filter.
|
||||
*
|
||||
* This is not a stand-alone implementation of the host processor API. It provides common routines
|
||||
* that can be used by a complete implementation.
|
||||
*/
|
||||
struct host_processor_filtered {
|
||||
struct host_processor base; /**< Base host processor interface. */
|
||||
struct host_control *control; /**< The interface for hardware control of the host. */
|
||||
struct host_flash_manager *flash; /**< The manager for host processor flash devices. */
|
||||
struct host_state_manager *state; /**< State information for the host processor. */
|
||||
struct spi_filter_interface *filter; /**< The SPI filter connected to host flash devices. */
|
||||
struct pfm_manager *pfm; /**< The manager for host processor PFMs. */
|
||||
struct recovery_image_manager *recovery; /**< The manager for recovery of the host processor. */
|
||||
int reset_pulse; /**< The length of the reset pulse for the host. */
|
||||
platform_mutex lock; /**< Synchronization for verification routines. */
|
||||
|
||||
/**
|
||||
* Private functions for customizing internal flows.
|
||||
*/
|
||||
struct {
|
||||
/**
|
||||
* Configure the SPI filter to run in bypass mode.
|
||||
*
|
||||
* @param host The instance for the processor to run in bypass mode.
|
||||
*
|
||||
* @return 0 if bypass mode was configured successfully or an error code.
|
||||
*/
|
||||
int (*enable_bypass_mode) (struct host_processor_filtered *host);
|
||||
} internal;
|
||||
};
|
||||
|
||||
|
||||
/* Internal functions for use by derived types. */
|
||||
int host_processor_filtered_init (struct host_processor_filtered *host,
|
||||
struct host_control *control, struct host_flash_manager *flash,
|
||||
struct host_state_manager *state, struct spi_filter_interface *filter, struct pfm_manager *pfm,
|
||||
struct recovery_image_manager *recovery, int reset_pulse);
|
||||
void host_processor_filtered_release (struct host_processor_filtered *host);
|
||||
|
||||
void host_processor_filtered_set_host_flash_access (struct host_processor_filtered *host);
|
||||
void host_processor_filtered_config_bypass (struct host_processor_filtered *host);
|
||||
void host_processor_filtered_swap_flash (struct host_processor_filtered *host,
|
||||
struct host_flash_manager_rw_regions *rw_list, struct pfm_manager *pfm, bool no_migrate);
|
||||
int host_processor_filtered_restore_read_write_data (struct host_processor_filtered *host,
|
||||
struct host_flash_manager_rw_regions *rw_list, struct pfm *pfm);
|
||||
|
||||
int host_processor_filtered_power_on_reset (struct host_processor_filtered *host,
|
||||
struct hash_engine *hash, struct rsa_engine *rsa, bool single);
|
||||
int host_processor_filtered_update_verification (struct host_processor_filtered *host,
|
||||
struct hash_engine *hash, struct rsa_engine *rsa, bool single, bool reset, int bypass_status);
|
||||
|
||||
int host_processor_filtered_get_next_reset_verification_actions (struct host_processor *host);
|
||||
int host_processor_filtered_needs_config_recovery (struct host_processor *host);
|
||||
int host_processor_filtered_apply_recovery_image (struct host_processor *host, bool no_reset);
|
||||
|
||||
|
||||
#endif /* HOST_PROCESSOR_FILTERED_H_ */
|
|
@ -6,6 +6,7 @@
|
|||
#include <string.h>
|
||||
#include "host_processor_observer_pcr.h"
|
||||
#include "host_logging.h"
|
||||
#include "common/type_cast.h"
|
||||
|
||||
|
||||
/**
|
||||
|
@ -14,34 +15,46 @@
|
|||
* @param observer The observer context to update.
|
||||
* @param event The event state to update to.
|
||||
*/
|
||||
static void host_processor_observer_pcr_update (struct host_processor_observer *observer,
|
||||
static void host_processor_observer_pcr_update (struct host_processor_observer_pcr *observer,
|
||||
int event)
|
||||
{
|
||||
struct host_processor_observer_pcr *host = (struct host_processor_observer_pcr*) observer;
|
||||
int status;
|
||||
|
||||
*host->state = event;
|
||||
status = pcr_store_update_versioned_buffer (host->store, host->hash, host->pcr,
|
||||
(uint8_t*) host->state, sizeof (uint32_t), true, 0);
|
||||
*observer->state = event;
|
||||
status = pcr_store_update_versioned_buffer (observer->store, observer->hash, observer->pcr,
|
||||
(uint8_t*) observer->state, sizeof (uint32_t), true, 0);
|
||||
if (status != 0) {
|
||||
debug_log_create_entry (DEBUG_LOG_SEVERITY_ERROR, DEBUG_LOG_COMPONENT_HOST_FW,
|
||||
HOST_LOGGING_PCR_UPDATE_ERROR, host->pcr, status);
|
||||
HOST_LOGGING_PCR_UPDATE_ERROR, observer->pcr, status);
|
||||
}
|
||||
}
|
||||
|
||||
static void host_processor_observer_pcr_on_bypass_mode (struct host_processor_observer *observer)
|
||||
{
|
||||
host_processor_observer_pcr_update (observer, HOST_PROCESSOR_OBSERVER_PCR_BYPASS);
|
||||
host_processor_observer_pcr_update ((struct host_processor_observer_pcr*) observer,
|
||||
HOST_PROCESSOR_OBSERVER_PCR_BYPASS);
|
||||
}
|
||||
|
||||
static void host_processor_observer_pcr_on_active_mode (struct host_processor_observer *observer)
|
||||
{
|
||||
host_processor_observer_pcr_update (observer, HOST_PROCESSOR_OBSERVER_PCR_VALID);
|
||||
host_processor_observer_pcr_update ((struct host_processor_observer_pcr*) observer,
|
||||
HOST_PROCESSOR_OBSERVER_PCR_VALID);
|
||||
}
|
||||
|
||||
static void host_processor_observer_pcr_on_recovery (struct host_processor_observer *observer)
|
||||
{
|
||||
host_processor_observer_pcr_update (observer, HOST_PROCESSOR_OBSERVER_PCR_RECOVERY);
|
||||
host_processor_observer_pcr_update ((struct host_processor_observer_pcr*) observer,
|
||||
HOST_PROCESSOR_OBSERVER_PCR_RECOVERY);
|
||||
}
|
||||
|
||||
static void host_processor_observer_pcr_on_inactive_dirty (struct host_state_observer *observer,
|
||||
struct host_state_manager *manager)
|
||||
{
|
||||
if (host_state_manager_is_inactive_dirty (manager)) {
|
||||
host_processor_observer_pcr_update (
|
||||
TO_DERIVED_TYPE (observer, struct host_processor_observer_pcr, base_state),
|
||||
HOST_PROCESSOR_OBSERVER_PCR_NOT_VALIDATED);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -78,6 +91,8 @@ int host_processor_observer_pcr_init (struct host_processor_observer_pcr *host,
|
|||
host->base.on_active_mode = host_processor_observer_pcr_on_active_mode;
|
||||
host->base.on_recovery = host_processor_observer_pcr_on_recovery;
|
||||
|
||||
host->base_state.on_inactive_dirty = host_processor_observer_pcr_on_inactive_dirty;
|
||||
|
||||
host->hash = hash;
|
||||
host->store = store;
|
||||
host->pcr = pcr;
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
#include <stdint.h>
|
||||
#include "host_processor_observer.h"
|
||||
#include "host_state_observer.h"
|
||||
#include "attestation/pcr_store.h"
|
||||
#include "crypto/hash.h"
|
||||
|
||||
|
@ -17,7 +18,8 @@ enum {
|
|||
HOST_PROCESSOR_OBSERVER_PCR_INIT = 0xffffffff, /**< Initial state before any validation has happened. */
|
||||
HOST_PROCESSOR_OBSERVER_PCR_VALID = 0, /**< The FW has been validated and host is protected. */
|
||||
HOST_PROCESSOR_OBSERVER_PCR_BYPASS, /**< The host is running in bypass mode. */
|
||||
HOST_PROCESSOR_OBSERVER_PCR_RECOVERY /**< The host recovery image is running. */
|
||||
HOST_PROCESSOR_OBSERVER_PCR_RECOVERY, /**< The host recovery image is running. */
|
||||
HOST_PROCESSOR_OBSERVER_PCR_NOT_VALIDATED, /**< The host firmware is in an unknown state. */
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -25,6 +27,7 @@ enum {
|
|||
*/
|
||||
struct host_processor_observer_pcr {
|
||||
struct host_processor_observer base; /**< Base observer for receiving notifications. */
|
||||
struct host_state_observer base_state; /**< Base observer for host state notifications. */
|
||||
struct pcr_store *store; /**< Storage for the PCR to manage. */
|
||||
struct hash_engine *hash; /**< Hash engine for PCR calculation. */
|
||||
uint32_t *state; /**< Storage for the raw state value. */
|
||||
|
|
|
@ -0,0 +1,219 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
#include "host_processor_single.h"
|
||||
|
||||
|
||||
static int host_processor_single_power_on_reset (struct host_processor *host,
|
||||
struct hash_engine *hash, struct rsa_engine *rsa)
|
||||
{
|
||||
struct host_processor_filtered *single = (struct host_processor_filtered*) host;
|
||||
|
||||
if (single == NULL) {
|
||||
return HOST_PROCESSOR_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
return host_processor_filtered_power_on_reset (single, hash, rsa, true);
|
||||
}
|
||||
|
||||
static int host_processor_single_soft_reset (struct host_processor *host, struct hash_engine *hash,
|
||||
struct rsa_engine *rsa)
|
||||
{
|
||||
struct host_processor_filtered *single = (struct host_processor_filtered*) host;
|
||||
|
||||
if (single == NULL) {
|
||||
return HOST_PROCESSOR_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
return host_processor_filtered_update_verification (single, hash, rsa, true, true, 0);
|
||||
}
|
||||
|
||||
static int host_processor_single_run_time_verification (struct host_processor *host,
|
||||
struct hash_engine *hash, struct rsa_engine *rsa)
|
||||
{
|
||||
struct host_processor_filtered *single = (struct host_processor_filtered*) host;
|
||||
|
||||
if (single == NULL) {
|
||||
return HOST_PROCESSOR_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
return host_processor_filtered_update_verification (single, hash, rsa, true, false,
|
||||
HOST_PROCESSOR_NOTHING_TO_VERIFY);
|
||||
}
|
||||
|
||||
static int host_processor_single_flash_rollback (struct host_processor *host,
|
||||
struct hash_engine *hash, struct rsa_engine *rsa, bool disable_bypass, bool no_reset)
|
||||
{
|
||||
if ((host == NULL) || (hash == NULL) || (rsa == NULL)) {
|
||||
return HOST_PROCESSOR_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
return HOST_PROCESSOR_NO_ROLLBACK;
|
||||
}
|
||||
|
||||
static int host_processor_single_recover_active_read_write_data (struct host_processor *host)
|
||||
{
|
||||
if (host == NULL) {
|
||||
return HOST_PROCESSOR_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
return HOST_PROCESSOR_NO_ACTIVE_RW_DATA;
|
||||
}
|
||||
|
||||
static int host_processor_single_bypass_mode (struct host_processor *host, bool swap_flash)
|
||||
{
|
||||
struct host_processor_filtered *single = (struct host_processor_filtered*) host;
|
||||
|
||||
if (single == NULL) {
|
||||
return HOST_PROCESSOR_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
platform_mutex_lock (&single->lock);
|
||||
host_state_manager_save_read_only_flash (single->state, SPI_FILTER_CS_0);
|
||||
host_processor_filtered_config_bypass (single);
|
||||
host_processor_filtered_set_host_flash_access (single);
|
||||
platform_mutex_unlock (&single->lock);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Configure the SPI filter to allow full read/write access to the host flash. This is effectively
|
||||
* a bypass mode, but while blocking undesirable flash commands.
|
||||
*
|
||||
* @param host The host processor instance.
|
||||
*
|
||||
* @return 0 if the SPI filter was successfully configured or an error code.
|
||||
*/
|
||||
static int host_processor_single_full_read_write_flash (struct host_processor_filtered *host)
|
||||
{
|
||||
struct flash_region rw;
|
||||
struct pfm_read_write_regions writable;
|
||||
int status;
|
||||
|
||||
rw.start_addr = 0;
|
||||
rw.length = 0xffff0000;
|
||||
writable.regions = &rw;
|
||||
writable.count = 1;
|
||||
|
||||
status = host_fw_config_spi_filter_read_write_regions (host->filter, &writable);
|
||||
if (status != 0) {
|
||||
return status;
|
||||
}
|
||||
|
||||
return host->filter->set_filter_mode (host->filter, SPI_FILTER_FLASH_SINGLE_CS0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Internal function to initialize the core components for host processor actions using a single
|
||||
* flash.
|
||||
*
|
||||
* @param host The host processor instance to initialize.
|
||||
* @param control The interface for controlling the host processor.
|
||||
* @param flash The manager for the flash devices for the host processor.
|
||||
* @param state The state information for the host.
|
||||
* @param filter The SPI filter controlling flash access for the host processor.
|
||||
* @param pfm The manager for PFMs for the host processor.
|
||||
* @param recovery The manager for recovery of the host processor.
|
||||
* @param reset_pulse The length of the reset pulse to apply to the processor, in milliseconds. Set
|
||||
* this to 0 to hold the processor instead of using a pulse.
|
||||
*
|
||||
* @return 0 if the host processor interface was successfully initialized or an error code.
|
||||
*/
|
||||
int host_processor_single_init_internal (struct host_processor_filtered *host,
|
||||
struct host_control *control, struct host_flash_manager_single *flash,
|
||||
struct host_state_manager *state, struct spi_filter_interface *filter, struct pfm_manager *pfm,
|
||||
struct recovery_image_manager *recovery, int reset_pulse)
|
||||
{
|
||||
int status;
|
||||
|
||||
if (host == NULL) {
|
||||
return HOST_PROCESSOR_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
status = host_processor_filtered_init (host, control, &flash->base, state, filter, pfm,
|
||||
recovery, reset_pulse);
|
||||
if (status != 0) {
|
||||
return status;
|
||||
}
|
||||
|
||||
host->base.power_on_reset = host_processor_single_power_on_reset;
|
||||
host->base.soft_reset = host_processor_single_soft_reset;
|
||||
host->base.run_time_verification = host_processor_single_run_time_verification;
|
||||
host->base.flash_rollback = host_processor_single_flash_rollback;
|
||||
host->base.recover_active_read_write_data = host_processor_single_recover_active_read_write_data;
|
||||
host->base.get_next_reset_verification_actions =
|
||||
host_processor_filtered_get_next_reset_verification_actions;
|
||||
host->base.needs_config_recovery = host_processor_filtered_needs_config_recovery;
|
||||
host->base.apply_recovery_image = host_processor_filtered_apply_recovery_image;
|
||||
host->base.bypass_mode = host_processor_single_bypass_mode;
|
||||
|
||||
host->internal.enable_bypass_mode = host_processor_single_full_read_write_flash;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize the interface for executing host processor actions using a single flash device.
|
||||
*
|
||||
* @param host The host processor instance to initialize.
|
||||
* @param control The interface for controlling the host processor.
|
||||
* @param flash The manager for the flash device for the host processor.
|
||||
* @param state The state information for the host.
|
||||
* @param filter The SPI filter controlling flash access for the host processor.
|
||||
* @param pfm The manager for PFMs for the host processor.
|
||||
* @param recovery The manager for recovery of the host processor.
|
||||
*
|
||||
* @return 0 if the host processor interface was successfully initialized or an error code.
|
||||
*/
|
||||
int host_processor_single_init (struct host_processor_filtered *host, struct host_control *control,
|
||||
struct host_flash_manager_single *flash, struct host_state_manager *state,
|
||||
struct spi_filter_interface *filter, struct pfm_manager *pfm,
|
||||
struct recovery_image_manager *recovery)
|
||||
{
|
||||
return host_processor_single_init_internal (host, control, flash, state, filter, pfm, recovery,
|
||||
0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize the interface for executing host processor actions using a single flash device.
|
||||
*
|
||||
* While host flash is being accessed, the host processor will not be held in reset. After the host
|
||||
* flash accesses have been completed, the host processor reset will be pulsed.
|
||||
*
|
||||
* @param host The host processor instance to initialize.
|
||||
* @param control The interface for controlling the host processor.
|
||||
* @param flash The manager for the flash device for the host processor.
|
||||
* @param state The state information for the host.
|
||||
* @param filter The SPI filter controlling flash access for the host processor.
|
||||
* @param pfm The manager for PFMs for the host processor.
|
||||
* @param recovery The manager for recovery of the host processor.
|
||||
* @param pulse_width The width of the reset pulse, in milliseconds.
|
||||
*
|
||||
* @return 0 if the host processor interface was successfully initialized or an error code.
|
||||
*/
|
||||
int host_processor_single_init_pulse_reset (struct host_processor_filtered *host,
|
||||
struct host_control *control, struct host_flash_manager_single *flash,
|
||||
struct host_state_manager *state, struct spi_filter_interface *filter, struct pfm_manager *pfm,
|
||||
struct recovery_image_manager *recovery, int pulse_width)
|
||||
{
|
||||
if (pulse_width <= 0) {
|
||||
return HOST_PROCESSOR_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
return host_processor_single_init_internal (host, control, flash, state, filter, pfm, recovery,
|
||||
pulse_width);
|
||||
}
|
||||
|
||||
/**
|
||||
* Release the resources used by the host processor interface.
|
||||
*
|
||||
* @param host The host processor instance to release.
|
||||
*/
|
||||
void host_processor_single_release (struct host_processor_filtered *host)
|
||||
{
|
||||
host_processor_filtered_release (host);
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
#ifndef HOST_PROCESSOR_SINGLE_H_
|
||||
#define HOST_PROCESSOR_SINGLE_H_
|
||||
|
||||
#include "platform.h"
|
||||
#include "host_processor.h"
|
||||
#include "host_processor_filtered.h"
|
||||
#include "host_flash_manager_single.h"
|
||||
|
||||
|
||||
/**
|
||||
* Defines the core interface for protecting the firmware of a single host processor. The host
|
||||
* has a single flash devices available for storing firmware.
|
||||
*/
|
||||
/* Re-uses the common type of struct host_processor_filtered to allow for more efficient memory
|
||||
* allocation. */
|
||||
|
||||
|
||||
int host_processor_single_init (struct host_processor_filtered *host, struct host_control *control,
|
||||
struct host_flash_manager_single *flash, struct host_state_manager *state,
|
||||
struct spi_filter_interface *filter, struct pfm_manager *pfm,
|
||||
struct recovery_image_manager *recovery);
|
||||
int host_processor_single_init_pulse_reset (struct host_processor_filtered *host,
|
||||
struct host_control *control, struct host_flash_manager_single *flash,
|
||||
struct host_state_manager *state, struct spi_filter_interface *filter, struct pfm_manager *pfm,
|
||||
struct recovery_image_manager *recovery, int pulse_width);
|
||||
void host_processor_single_release (struct host_processor_filtered *host);
|
||||
|
||||
/* Internal functions for use by derived types. */
|
||||
int host_processor_single_init_internal (struct host_processor_filtered *host,
|
||||
struct host_control *control, struct host_flash_manager_single *flash,
|
||||
struct host_state_manager *state, struct spi_filter_interface *filter, struct pfm_manager *pfm,
|
||||
struct recovery_image_manager *recovery, int reset_pulse);
|
||||
|
||||
|
||||
#endif /* HOST_PROCESSOR_SINGLE_H_ */
|
|
@ -0,0 +1,95 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
#include "host_processor_single_full_bypass.h"
|
||||
#include "host_state_manager.h"
|
||||
|
||||
|
||||
static int host_processor_single_full_bypass_enable_bypass_mode (
|
||||
struct host_processor_filtered *host)
|
||||
{
|
||||
return host->filter->set_filter_mode (host->filter, SPI_FILTER_FLASH_BYPASS_CS0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize the interface for executing host processor actions. Unprotected flash will be
|
||||
* accessible in full bypass mode.
|
||||
*
|
||||
* @param host The host processor instance to initialize.
|
||||
* @param control The interface for controlling the host processor.
|
||||
* @param flash The manager for the flash devices for the host processor.
|
||||
* @param state The state information for the host.
|
||||
* @param filter The SPI filter controlling flash access for the host processor.
|
||||
* @param pfm The manager for PFMs for the host processor.
|
||||
* @param recovery The recovery image manager for the host processor.
|
||||
*
|
||||
* @return 0 if the host processor interface was successfully initialized or an error code.
|
||||
*/
|
||||
int host_processor_single_full_bypass_init (struct host_processor_filtered *host,
|
||||
struct host_control *control, struct host_flash_manager_single *flash,
|
||||
struct host_state_manager *state, struct spi_filter_interface *filter, struct pfm_manager *pfm,
|
||||
struct recovery_image_manager *recovery)
|
||||
{
|
||||
int status = host_processor_single_init_internal (host, control, flash, state, filter, pfm,
|
||||
recovery, 0);
|
||||
if (status != 0) {
|
||||
return status;
|
||||
}
|
||||
|
||||
host->internal.enable_bypass_mode = host_processor_single_full_bypass_enable_bypass_mode;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize the interface for executing host processor actions. Unprotected flash will be
|
||||
* accessible in full bypass mode.
|
||||
*
|
||||
* While host flash is being accessed, the host processor will not be held in reset. After the host
|
||||
* flash accesses have been completed, the host processor reset will be pulsed.
|
||||
*
|
||||
* @param host The host processor instance to initialize.
|
||||
* @param control The interface for controlling the host processor.
|
||||
* @param flash The manager for the flash devices for the host processor.
|
||||
* @param state The state information for the host.
|
||||
* @param filter The SPI filter controlling flash access for the host processor.
|
||||
* @param pfm The manager for PFMs for the host processor.
|
||||
* @param recovery The recovery image manager for the host processor.
|
||||
* @param pulse_width The width of the reset pulse, in milliseconds.
|
||||
*
|
||||
* @return 0 if the host processor interface was successfully initialized or an error code.
|
||||
*/
|
||||
int host_processor_single_full_bypass_init_pulse_reset (struct host_processor_filtered *host,
|
||||
struct host_control *control, struct host_flash_manager_single *flash,
|
||||
struct host_state_manager *state, struct spi_filter_interface *filter, struct pfm_manager *pfm,
|
||||
struct recovery_image_manager *recovery, int pulse_width)
|
||||
{
|
||||
int status;
|
||||
|
||||
if (pulse_width <= 0) {
|
||||
return HOST_PROCESSOR_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
status = host_processor_single_init_internal (host, control, flash, state, filter, pfm,
|
||||
recovery, pulse_width);
|
||||
if (status != 0) {
|
||||
return status;
|
||||
}
|
||||
|
||||
host->internal.enable_bypass_mode = host_processor_single_full_bypass_enable_bypass_mode;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Release the resources used by the host processor interface.
|
||||
*
|
||||
* @param host The host processor instance to release.
|
||||
*/
|
||||
void host_processor_single_full_bypass_release (struct host_processor_filtered *host)
|
||||
{
|
||||
host_processor_single_release (host);
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
#ifndef HOST_PROCESSOR_single_FULL_BYPASS_H_
|
||||
#define HOST_PROCESSOR_single_FULL_BYPASS_H_
|
||||
|
||||
#include "host_processor_single.h"
|
||||
|
||||
|
||||
/**
|
||||
* Protection for firmware on a single host processor that uses a single flash devices. When no
|
||||
* protection is enabled, bypass mode to the host flash uses full bypass (no commands are filtered).
|
||||
*/
|
||||
/* Re-uses the common type of struct host_processor_filtered to allow for more efficient memory
|
||||
* allocation. */
|
||||
|
||||
|
||||
int host_processor_single_full_bypass_init (struct host_processor_filtered *host,
|
||||
struct host_control *control, struct host_flash_manager_single *flash,
|
||||
struct host_state_manager *state, struct spi_filter_interface *filter, struct pfm_manager *pfm,
|
||||
struct recovery_image_manager *recovery);
|
||||
int host_processor_single_full_bypass_init_pulse_reset (struct host_processor_filtered *host,
|
||||
struct host_control *control, struct host_flash_manager_single *flash,
|
||||
struct host_state_manager *state, struct spi_filter_interface *filter, struct pfm_manager *pfm,
|
||||
struct recovery_image_manager *recovery, int pulse_width);
|
||||
void host_processor_single_full_bypass_release (struct host_processor_filtered *host);
|
||||
|
||||
|
||||
#endif /* HOST_PROCESSOR_single_FULL_BYPASS_H_ */
|
|
@ -5,6 +5,7 @@
|
|||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
#include "host_state_manager.h"
|
||||
#include "host_state_observer.h"
|
||||
#include "flash/flash_common.h"
|
||||
#include "flash/flash_util.h"
|
||||
|
||||
|
@ -16,16 +17,27 @@
|
|||
#define ACTIVE_RECOVERY_IMAGE_MASK (1U << 3)
|
||||
|
||||
/* Bitmasks for settings in volatile memory. */
|
||||
#define PFM_DIRTY_MASK (1U << 0)
|
||||
#define RUN_TIME_MASK (3U << 1)
|
||||
#define BYPASS_MASK (1U << 3)
|
||||
#define BAD_FLASH_MASK (1U << 4)
|
||||
#define PFM_DIRTY_MASK (1U << 0)
|
||||
#define RUN_TIME_MASK (3U << 1)
|
||||
#define BYPASS_MASK (1U << 3)
|
||||
#define BAD_FLASH_MASK (1U << 4)
|
||||
|
||||
|
||||
static int host_state_manager_save_active_manifest (struct state_manager *manager,
|
||||
uint8_t manifest_index, enum manifest_region active)
|
||||
{
|
||||
return state_manager_save_active_manifest (manager, active, ACTIVE_PFM_MASK);
|
||||
struct host_state_manager *host_state = (struct host_state_manager*) manager;
|
||||
int status;
|
||||
|
||||
status = state_manager_save_active_manifest (manager, active, ACTIVE_PFM_MASK);
|
||||
if (status == 0) {
|
||||
if (status == 0) {
|
||||
observable_notify_observers_with_ptr (&host_state->observable,
|
||||
offsetof (struct host_state_observer, on_active_pfm), host_state);
|
||||
}
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
static enum manifest_region host_state_manager_get_active_manifest (struct state_manager *manager,
|
||||
|
@ -36,7 +48,9 @@ static enum manifest_region host_state_manager_get_active_manifest (struct state
|
|||
|
||||
static int host_state_manager_restore_default_state (struct state_manager *manager)
|
||||
{
|
||||
if (manager == NULL) {
|
||||
struct host_state_manager *host_state = (struct host_state_manager*) manager;
|
||||
|
||||
if (host_state == NULL) {
|
||||
return STATE_MANAGER_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
|
@ -47,6 +61,24 @@ static int host_state_manager_restore_default_state (struct state_manager *manag
|
|||
manager->volatile_state |= PFM_DIRTY_MASK;
|
||||
|
||||
platform_mutex_unlock (&manager->state_lock);
|
||||
|
||||
observable_notify_observers_with_ptr (&host_state->observable,
|
||||
offsetof (struct host_state_observer, on_active_pfm), host_state);
|
||||
observable_notify_observers_with_ptr (&host_state->observable,
|
||||
offsetof (struct host_state_observer, on_read_only_flash), host_state);
|
||||
observable_notify_observers_with_ptr (&host_state->observable,
|
||||
offsetof (struct host_state_observer, on_inactive_dirty), host_state);
|
||||
observable_notify_observers_with_ptr (&host_state->observable,
|
||||
offsetof (struct host_state_observer, on_active_recovery_image), host_state);
|
||||
observable_notify_observers_with_ptr (&host_state->observable,
|
||||
offsetof (struct host_state_observer, on_pfm_dirty), host_state);
|
||||
observable_notify_observers_with_ptr (&host_state->observable,
|
||||
offsetof (struct host_state_observer, on_run_time_validation), host_state);
|
||||
observable_notify_observers_with_ptr (&host_state->observable,
|
||||
offsetof (struct host_state_observer, on_bypass_mode), host_state);
|
||||
observable_notify_observers_with_ptr (&host_state->observable,
|
||||
offsetof (struct host_state_observer, on_unsupported_flash), host_state);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -67,7 +99,7 @@ static int host_state_manager_is_manifest_valid (struct state_manager *manager,
|
|||
*
|
||||
* @return 0 if the state manager was successfully initialized or an error code.
|
||||
*/
|
||||
int host_state_manager_init (struct state_manager *manager, struct flash *state_flash,
|
||||
int host_state_manager_init (struct host_state_manager *manager, struct flash *state_flash,
|
||||
uint32_t store_addr)
|
||||
{
|
||||
int status;
|
||||
|
@ -76,17 +108,27 @@ int host_state_manager_init (struct state_manager *manager, struct flash *state_
|
|||
return STATE_MANAGER_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
status = state_manager_init (manager, state_flash, store_addr);
|
||||
if (status == 0) {
|
||||
manager->get_active_manifest = host_state_manager_get_active_manifest;
|
||||
manager->save_active_manifest = host_state_manager_save_active_manifest;
|
||||
manager->restore_default_state = host_state_manager_restore_default_state;
|
||||
manager->is_manifest_valid = host_state_manager_is_manifest_valid;
|
||||
memset (manager, 0, sizeof (struct host_state_manager));
|
||||
|
||||
manager->volatile_state |= PFM_DIRTY_MASK;
|
||||
status = state_manager_init (&manager->base, state_flash, store_addr);
|
||||
if (status != 0) {
|
||||
return status;
|
||||
}
|
||||
|
||||
return status;
|
||||
status = observable_init (&manager->observable);
|
||||
if (status != 0) {
|
||||
state_manager_release (&manager->base);
|
||||
return status;
|
||||
}
|
||||
|
||||
manager->base.get_active_manifest = host_state_manager_get_active_manifest;
|
||||
manager->base.save_active_manifest = host_state_manager_save_active_manifest;
|
||||
manager->base.restore_default_state = host_state_manager_restore_default_state;
|
||||
manager->base.is_manifest_valid = host_state_manager_is_manifest_valid;
|
||||
|
||||
manager->base.volatile_state |= PFM_DIRTY_MASK;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -94,9 +136,32 @@ int host_state_manager_init (struct state_manager *manager, struct flash *state_
|
|||
*
|
||||
* @param manager The state manager to release.
|
||||
*/
|
||||
void host_state_manager_release (struct state_manager *manager)
|
||||
void host_state_manager_release (struct host_state_manager *manager)
|
||||
{
|
||||
state_manager_release (manager);
|
||||
if (manager) {
|
||||
state_manager_release (&manager->base);
|
||||
observable_release (&manager->observable);
|
||||
}
|
||||
}
|
||||
|
||||
int host_state_manager_add_observer (struct host_state_manager *manager,
|
||||
struct host_state_observer *observer)
|
||||
{
|
||||
if (manager == NULL) {
|
||||
return STATE_MANAGER_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
return observable_add_observer (&manager->observable, observer);
|
||||
}
|
||||
|
||||
int host_state_manager_remove_observer (struct host_state_manager *manager,
|
||||
struct host_state_observer *observer)
|
||||
{
|
||||
if (manager == NULL) {
|
||||
return STATE_MANAGER_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
return observable_remove_observer (&manager->observable, observer);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -109,7 +174,7 @@ void host_state_manager_release (struct state_manager *manager)
|
|||
*
|
||||
* @return 0 if the setting was saved or an error code if the setting was invalid.
|
||||
*/
|
||||
int host_state_manager_save_read_only_flash (struct state_manager *manager, spi_filter_cs ro)
|
||||
int host_state_manager_save_read_only_flash (struct host_state_manager *manager, spi_filter_cs ro)
|
||||
{
|
||||
int status = 0;
|
||||
|
||||
|
@ -117,15 +182,15 @@ int host_state_manager_save_read_only_flash (struct state_manager *manager, spi_
|
|||
return STATE_MANAGER_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
platform_mutex_lock (&manager->state_lock);
|
||||
platform_mutex_lock (&manager->base.state_lock);
|
||||
|
||||
switch (ro) {
|
||||
case SPI_FILTER_CS_0:
|
||||
manager->nv_state = manager->nv_state | READ_ONLY_FLASH_MASK;
|
||||
manager->base.nv_state = manager->base.nv_state | READ_ONLY_FLASH_MASK;
|
||||
break;
|
||||
|
||||
case SPI_FILTER_CS_1:
|
||||
manager->nv_state = manager->nv_state & ~READ_ONLY_FLASH_MASK;
|
||||
manager->base.nv_state = manager->base.nv_state & ~READ_ONLY_FLASH_MASK;
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -133,7 +198,13 @@ int host_state_manager_save_read_only_flash (struct state_manager *manager, spi_
|
|||
break;
|
||||
}
|
||||
|
||||
platform_mutex_unlock (&manager->state_lock);
|
||||
platform_mutex_unlock (&manager->base.state_lock);
|
||||
|
||||
if (status == 0) {
|
||||
observable_notify_observers_with_ptr (&manager->observable,
|
||||
offsetof (struct host_state_observer, on_read_only_flash), manager);
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
|
@ -144,13 +215,13 @@ int host_state_manager_save_read_only_flash (struct state_manager *manager, spi_
|
|||
*
|
||||
* @return The read-only flash device.
|
||||
*/
|
||||
spi_filter_cs host_state_manager_get_read_only_flash (struct state_manager *manager)
|
||||
spi_filter_cs host_state_manager_get_read_only_flash (struct host_state_manager *manager)
|
||||
{
|
||||
if (manager == NULL) {
|
||||
return SPI_FILTER_CS_0;
|
||||
}
|
||||
|
||||
return (manager->nv_state & READ_ONLY_FLASH_MASK) ? SPI_FILTER_CS_0 : SPI_FILTER_CS_1;
|
||||
return (manager->base.nv_state & READ_ONLY_FLASH_MASK) ? SPI_FILTER_CS_0 : SPI_FILTER_CS_1;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -163,26 +234,36 @@ spi_filter_cs host_state_manager_get_read_only_flash (struct state_manager *mana
|
|||
*
|
||||
* @return 0 if the setting was saved or an error code if the manager instance is invalid.
|
||||
*/
|
||||
int host_state_manager_save_inactive_dirty (struct state_manager *manager, bool dirty)
|
||||
int host_state_manager_save_inactive_dirty (struct host_state_manager *manager, bool dirty)
|
||||
{
|
||||
int status = 0;
|
||||
bool run_time;
|
||||
|
||||
if (manager == NULL) {
|
||||
return STATE_MANAGER_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
platform_mutex_lock (&manager->state_lock);
|
||||
platform_mutex_lock (&manager->base.state_lock);
|
||||
|
||||
if (dirty) {
|
||||
manager->nv_state = manager->nv_state & ~INACTIVE_DIRTY_MASK;
|
||||
manager->volatile_state = manager->volatile_state & ~RUN_TIME_MASK;
|
||||
manager->base.nv_state = manager->base.nv_state & ~INACTIVE_DIRTY_MASK;
|
||||
|
||||
run_time = !!(manager->base.volatile_state & RUN_TIME_MASK);
|
||||
manager->base.volatile_state = manager->base.volatile_state & ~RUN_TIME_MASK;
|
||||
}
|
||||
else {
|
||||
manager->nv_state = manager->nv_state | INACTIVE_DIRTY_MASK;
|
||||
manager->base.nv_state = manager->base.nv_state | INACTIVE_DIRTY_MASK;
|
||||
}
|
||||
|
||||
platform_mutex_unlock (&manager->state_lock);
|
||||
return status;
|
||||
platform_mutex_unlock (&manager->base.state_lock);
|
||||
|
||||
observable_notify_observers_with_ptr (&manager->observable,
|
||||
offsetof (struct host_state_observer, on_inactive_dirty), manager);
|
||||
if (dirty && run_time) {
|
||||
observable_notify_observers_with_ptr (&manager->observable,
|
||||
offsetof (struct host_state_observer, on_run_time_validation), manager);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -192,13 +273,13 @@ int host_state_manager_save_inactive_dirty (struct state_manager *manager, bool
|
|||
*
|
||||
* @return true if the inactive flash has been written and not validated or false otherwise.
|
||||
*/
|
||||
bool host_state_manager_is_inactive_dirty (struct state_manager *manager)
|
||||
bool host_state_manager_is_inactive_dirty (struct host_state_manager *manager)
|
||||
{
|
||||
if (manager == NULL) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return !(manager->nv_state & INACTIVE_DIRTY_MASK);
|
||||
return !(manager->base.nv_state & INACTIVE_DIRTY_MASK);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -210,7 +291,7 @@ bool host_state_manager_is_inactive_dirty (struct state_manager *manager)
|
|||
|
||||
* @return 0 if the setting was saved or an error code.
|
||||
*/
|
||||
int host_state_manager_save_active_recovery_image (struct state_manager *manager,
|
||||
int host_state_manager_save_active_recovery_image (struct host_state_manager *manager,
|
||||
enum recovery_image_region active)
|
||||
{
|
||||
int status = 0;
|
||||
|
@ -219,15 +300,15 @@ int host_state_manager_save_active_recovery_image (struct state_manager *manager
|
|||
return STATE_MANAGER_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
platform_mutex_lock (&manager->state_lock);
|
||||
platform_mutex_lock (&manager->base.state_lock);
|
||||
|
||||
switch (active) {
|
||||
case RECOVERY_IMAGE_REGION_1:
|
||||
manager->nv_state = manager->nv_state | ACTIVE_RECOVERY_IMAGE_MASK;
|
||||
manager->base.nv_state = manager->base.nv_state | ACTIVE_RECOVERY_IMAGE_MASK;
|
||||
break;
|
||||
|
||||
case RECOVERY_IMAGE_REGION_2:
|
||||
manager->nv_state = manager->nv_state & ~ACTIVE_RECOVERY_IMAGE_MASK;
|
||||
manager->base.nv_state = manager->base.nv_state & ~ACTIVE_RECOVERY_IMAGE_MASK;
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -235,7 +316,12 @@ int host_state_manager_save_active_recovery_image (struct state_manager *manager
|
|||
break;
|
||||
}
|
||||
|
||||
platform_mutex_unlock (&manager->state_lock);
|
||||
platform_mutex_unlock (&manager->base.state_lock);
|
||||
|
||||
if (status == 0) {
|
||||
observable_notify_observers_with_ptr (&manager->observable,
|
||||
offsetof (struct host_state_observer, on_active_recovery_image), manager);
|
||||
}
|
||||
|
||||
return status;
|
||||
|
||||
|
@ -249,13 +335,13 @@ int host_state_manager_save_active_recovery_image (struct state_manager *manager
|
|||
* @return The active recovery image region.
|
||||
*/
|
||||
enum recovery_image_region host_state_manager_get_active_recovery_image (
|
||||
struct state_manager *manager)
|
||||
struct host_state_manager *manager)
|
||||
{
|
||||
if (manager == NULL) {
|
||||
return RECOVERY_IMAGE_REGION_1;
|
||||
}
|
||||
|
||||
return (manager->nv_state & ACTIVE_RECOVERY_IMAGE_MASK) ?
|
||||
return (manager->base.nv_state & ACTIVE_RECOVERY_IMAGE_MASK) ?
|
||||
RECOVERY_IMAGE_REGION_1 : RECOVERY_IMAGE_REGION_2;
|
||||
}
|
||||
|
||||
|
@ -266,21 +352,31 @@ enum recovery_image_region host_state_manager_get_active_recovery_image (
|
|||
* @param manager The host state to update.
|
||||
* @param dirty The dirty state of the PFM.
|
||||
*/
|
||||
void host_state_manager_set_pfm_dirty (struct state_manager *manager, bool dirty)
|
||||
void host_state_manager_set_pfm_dirty (struct host_state_manager *manager, bool dirty)
|
||||
{
|
||||
bool run_time = false;
|
||||
|
||||
if (manager != NULL) {
|
||||
platform_mutex_lock (&manager->state_lock);
|
||||
platform_mutex_lock (&manager->base.state_lock);
|
||||
if (dirty) {
|
||||
manager->volatile_state |= PFM_DIRTY_MASK;
|
||||
if ((manager->volatile_state & RUN_TIME_MASK) ==
|
||||
manager->base.volatile_state |= PFM_DIRTY_MASK;
|
||||
if ((manager->base.volatile_state & RUN_TIME_MASK) ==
|
||||
HOST_STATE_PREVALIDATED_FLASH_AND_PFM) {
|
||||
manager->volatile_state &= ~RUN_TIME_MASK;
|
||||
run_time = true;
|
||||
manager->base.volatile_state &= ~RUN_TIME_MASK;
|
||||
}
|
||||
}
|
||||
else {
|
||||
manager->volatile_state &= ~PFM_DIRTY_MASK;
|
||||
manager->base.volatile_state &= ~PFM_DIRTY_MASK;
|
||||
}
|
||||
platform_mutex_unlock (&manager->base.state_lock);
|
||||
|
||||
observable_notify_observers_with_ptr (&manager->observable,
|
||||
offsetof (struct host_state_observer, on_pfm_dirty), manager);
|
||||
if (run_time) {
|
||||
observable_notify_observers_with_ptr (&manager->observable,
|
||||
offsetof (struct host_state_observer, on_run_time_validation), manager);
|
||||
}
|
||||
platform_mutex_unlock (&manager->state_lock);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -292,13 +388,13 @@ void host_state_manager_set_pfm_dirty (struct state_manager *manager, bool dirty
|
|||
*
|
||||
* @return true if the pending PFM is dirty.
|
||||
*/
|
||||
bool host_state_manager_is_pfm_dirty (struct state_manager *manager)
|
||||
bool host_state_manager_is_pfm_dirty (struct host_state_manager *manager)
|
||||
{
|
||||
if (manager == NULL) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return !!(manager->volatile_state & PFM_DIRTY_MASK);
|
||||
return !!(manager->base.volatile_state & PFM_DIRTY_MASK);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -308,14 +404,17 @@ bool host_state_manager_is_pfm_dirty (struct state_manager *manager)
|
|||
* @param manager The host state to update.
|
||||
* @param state The run-time validation state for the host.
|
||||
*/
|
||||
void host_state_manager_set_run_time_validation (struct state_manager *manager,
|
||||
void host_state_manager_set_run_time_validation (struct host_state_manager *manager,
|
||||
enum host_state_prevalidated state)
|
||||
{
|
||||
if (manager != NULL) {
|
||||
platform_mutex_lock (&manager->state_lock);
|
||||
manager->volatile_state &= ~RUN_TIME_MASK;
|
||||
manager->volatile_state |= state;
|
||||
platform_mutex_unlock (&manager->state_lock);
|
||||
platform_mutex_lock (&manager->base.state_lock);
|
||||
manager->base.volatile_state &= ~RUN_TIME_MASK;
|
||||
manager->base.volatile_state |= state;
|
||||
platform_mutex_unlock (&manager->base.state_lock);
|
||||
|
||||
observable_notify_observers_with_ptr (&manager->observable,
|
||||
offsetof (struct host_state_observer, on_run_time_validation), manager);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -327,13 +426,13 @@ void host_state_manager_set_run_time_validation (struct state_manager *manager,
|
|||
* @return The run-time validation state for the host.
|
||||
*/
|
||||
enum host_state_prevalidated host_state_manager_get_run_time_validation (
|
||||
struct state_manager *manager)
|
||||
struct host_state_manager *manager)
|
||||
{
|
||||
if (manager == NULL) {
|
||||
return HOST_STATE_PREVALIDATED_NONE;
|
||||
}
|
||||
|
||||
return (enum host_state_prevalidated) (manager->volatile_state & RUN_TIME_MASK);
|
||||
return (enum host_state_prevalidated) (manager->base.volatile_state & RUN_TIME_MASK);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -342,17 +441,20 @@ enum host_state_prevalidated host_state_manager_get_run_time_validation (
|
|||
* @param manager The host state to update.
|
||||
* @param bypass The bypass state of the host.
|
||||
*/
|
||||
void host_state_manager_set_bypass_mode (struct state_manager *manager, bool bypass)
|
||||
void host_state_manager_set_bypass_mode (struct host_state_manager *manager, bool bypass)
|
||||
{
|
||||
if (manager != NULL) {
|
||||
platform_mutex_lock (&manager->state_lock);
|
||||
platform_mutex_lock (&manager->base.state_lock);
|
||||
if (bypass) {
|
||||
manager->volatile_state |= BYPASS_MASK;
|
||||
manager->base.volatile_state |= BYPASS_MASK;
|
||||
}
|
||||
else {
|
||||
manager->volatile_state &= ~BYPASS_MASK;
|
||||
manager->base.volatile_state &= ~BYPASS_MASK;
|
||||
}
|
||||
platform_mutex_unlock (&manager->state_lock);
|
||||
platform_mutex_unlock (&manager->base.state_lock);
|
||||
|
||||
observable_notify_observers_with_ptr (&manager->observable,
|
||||
offsetof (struct host_state_observer, on_bypass_mode), manager);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -363,13 +465,13 @@ void host_state_manager_set_bypass_mode (struct state_manager *manager, bool byp
|
|||
*
|
||||
* @return true if the host is running in bypass mode.
|
||||
*/
|
||||
bool host_state_manager_is_bypass_mode (struct state_manager *manager)
|
||||
bool host_state_manager_is_bypass_mode (struct host_state_manager *manager)
|
||||
{
|
||||
if (manager == NULL) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return !!(manager->volatile_state & BYPASS_MASK);
|
||||
return !!(manager->base.volatile_state & BYPASS_MASK);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -378,17 +480,20 @@ bool host_state_manager_is_bypass_mode (struct state_manager *manager)
|
|||
* @param manager The host state to update.
|
||||
* @param unsupported true to indicate an unsupported configuration.
|
||||
*/
|
||||
void host_state_manager_set_unsupported_flash (struct state_manager *manager, bool unsupported)
|
||||
void host_state_manager_set_unsupported_flash (struct host_state_manager *manager, bool unsupported)
|
||||
{
|
||||
if (manager != NULL) {
|
||||
platform_mutex_lock (&manager->state_lock);
|
||||
platform_mutex_lock (&manager->base.state_lock);
|
||||
if (unsupported) {
|
||||
manager->volatile_state |= BAD_FLASH_MASK;
|
||||
manager->base.volatile_state |= BAD_FLASH_MASK;
|
||||
}
|
||||
else {
|
||||
manager->volatile_state &= ~BAD_FLASH_MASK;
|
||||
manager->base.volatile_state &= ~BAD_FLASH_MASK;
|
||||
}
|
||||
platform_mutex_unlock (&manager->state_lock);
|
||||
platform_mutex_unlock (&manager->base.state_lock);
|
||||
|
||||
observable_notify_observers_with_ptr (&manager->observable,
|
||||
offsetof (struct host_state_observer, on_unsupported_flash), manager);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -399,11 +504,11 @@ void host_state_manager_set_unsupported_flash (struct state_manager *manager, bo
|
|||
*
|
||||
* @return true if the flash configuration is supported.
|
||||
*/
|
||||
bool host_state_manager_is_flash_supported (struct state_manager *manager)
|
||||
bool host_state_manager_is_flash_supported (struct host_state_manager *manager)
|
||||
{
|
||||
if (manager == NULL) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return !(manager->volatile_state & BAD_FLASH_MASK);
|
||||
return !(manager->base.volatile_state & BAD_FLASH_MASK);
|
||||
}
|
||||
|
|
|
@ -6,22 +6,35 @@
|
|||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "flash/flash.h"
|
||||
#include "spi_filter/spi_filter_interface.h"
|
||||
#include "state_manager/state_manager.h"
|
||||
#include "common/observable.h"
|
||||
#include "spi_filter/spi_filter_interface.h"
|
||||
|
||||
|
||||
int host_state_manager_init (struct state_manager *manager, struct flash *state_flash,
|
||||
struct host_state_observer;
|
||||
|
||||
struct host_state_manager {
|
||||
struct state_manager base; /**< The base state manager. */
|
||||
struct observable observable; /**< Observer manager for the state manager. */
|
||||
};
|
||||
|
||||
|
||||
int host_state_manager_init (struct host_state_manager *manager, struct flash *state_flash,
|
||||
uint32_t store_addr);
|
||||
void host_state_manager_release (struct state_manager *manager);
|
||||
void host_state_manager_release (struct host_state_manager *manager);
|
||||
|
||||
int host_state_manager_add_observer (struct host_state_manager *manager,
|
||||
struct host_state_observer *observer);
|
||||
int host_state_manager_remove_observer (struct host_state_manager *manager,
|
||||
struct host_state_observer *observer);
|
||||
|
||||
/* Non-volatile state. */
|
||||
|
||||
int host_state_manager_save_read_only_flash (struct state_manager *manager, spi_filter_cs ro);
|
||||
spi_filter_cs host_state_manager_get_read_only_flash (struct state_manager *manager);
|
||||
int host_state_manager_save_read_only_flash (struct host_state_manager *manager, spi_filter_cs ro);
|
||||
spi_filter_cs host_state_manager_get_read_only_flash (struct host_state_manager *manager);
|
||||
|
||||
int host_state_manager_save_inactive_dirty (struct state_manager *manager, bool dirty);
|
||||
bool host_state_manager_is_inactive_dirty (struct state_manager *manager);
|
||||
int host_state_manager_save_inactive_dirty (struct host_state_manager *manager, bool dirty);
|
||||
bool host_state_manager_is_inactive_dirty (struct host_state_manager *manager);
|
||||
|
||||
/**
|
||||
* Definitions to indicate which region of flash holds the active recovery image.
|
||||
|
@ -31,15 +44,15 @@ enum recovery_image_region {
|
|||
RECOVERY_IMAGE_REGION_2, /**< The secondary recovery image region contains the active image. */
|
||||
};
|
||||
|
||||
int host_state_manager_save_active_recovery_image (struct state_manager *manager,
|
||||
int host_state_manager_save_active_recovery_image (struct host_state_manager *manager,
|
||||
enum recovery_image_region active);
|
||||
enum recovery_image_region host_state_manager_get_active_recovery_image (
|
||||
struct state_manager *manager);
|
||||
struct host_state_manager *manager);
|
||||
|
||||
/* Volatile state */
|
||||
|
||||
void host_state_manager_set_pfm_dirty (struct state_manager *manager, bool dirty);
|
||||
bool host_state_manager_is_pfm_dirty (struct state_manager *manager);
|
||||
void host_state_manager_set_pfm_dirty (struct host_state_manager *manager, bool dirty);
|
||||
bool host_state_manager_is_pfm_dirty (struct host_state_manager *manager);
|
||||
|
||||
/**
|
||||
* States to indicate the level of run-time validation done for host flash.
|
||||
|
@ -50,16 +63,17 @@ enum host_state_prevalidated {
|
|||
HOST_STATE_PREVALIDATED_FLASH_AND_PFM = 6, /**< The R/W flash has been validated against the pending PFM. */
|
||||
};
|
||||
|
||||
void host_state_manager_set_run_time_validation (struct state_manager *manager,
|
||||
void host_state_manager_set_run_time_validation (struct host_state_manager *manager,
|
||||
enum host_state_prevalidated state);
|
||||
enum host_state_prevalidated host_state_manager_get_run_time_validation (
|
||||
struct state_manager *manager);
|
||||
struct host_state_manager *manager);
|
||||
|
||||
void host_state_manager_set_bypass_mode (struct state_manager *manager, bool bypass);
|
||||
bool host_state_manager_is_bypass_mode (struct state_manager *manager);
|
||||
void host_state_manager_set_bypass_mode (struct host_state_manager *manager, bool bypass);
|
||||
bool host_state_manager_is_bypass_mode (struct host_state_manager *manager);
|
||||
|
||||
void host_state_manager_set_unsupported_flash (struct state_manager *manager, bool unsupported);
|
||||
bool host_state_manager_is_flash_supported (struct state_manager *manager);
|
||||
void host_state_manager_set_unsupported_flash (struct host_state_manager *manager,
|
||||
bool unsupported);
|
||||
bool host_state_manager_is_flash_supported (struct host_state_manager *manager);
|
||||
|
||||
|
||||
#endif /* HOST_STATE_MANAGER_H_ */
|
||||
|
|
|
@ -0,0 +1,115 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
#ifndef HOST_STATE_OBSERVER_H_
|
||||
#define HOST_STATE_OBSERVER_H_
|
||||
|
||||
#include "status/rot_status.h"
|
||||
#include "host_state_manager.h"
|
||||
|
||||
|
||||
/**
|
||||
* Observer interface for handling host state events.
|
||||
*/
|
||||
struct host_state_observer {
|
||||
/**
|
||||
* Notification that the active PFM region has changed.
|
||||
*
|
||||
* Arguments passed with the notification will never be null.
|
||||
*
|
||||
* @param observer The observer instance being notified.
|
||||
* @param manager The manager generating the event.
|
||||
*/
|
||||
void (*on_active_pfm) (struct host_state_observer *observer,
|
||||
struct host_state_manager *manager);
|
||||
|
||||
/**
|
||||
* Notification that the read only flash device has changed.
|
||||
*
|
||||
* Arguments passed with the notification will never be null.
|
||||
*
|
||||
* @param observer The observer instance being notified.
|
||||
* @param manager The manager generating the event.
|
||||
*/
|
||||
void (*on_read_only_flash) (struct host_state_observer *observer,
|
||||
struct host_state_manager *manager);
|
||||
|
||||
/**
|
||||
* Notification that the dirty state of flash has changed.
|
||||
*
|
||||
* Arguments passed with the notification will never be null.
|
||||
*
|
||||
* @param observer The observer instance being notified.
|
||||
* @param manager The manager generating the event.
|
||||
*/
|
||||
void (*on_inactive_dirty) (struct host_state_observer *observer,
|
||||
struct host_state_manager *manager);
|
||||
|
||||
/**
|
||||
* Notification that the active recovery image has changed.
|
||||
*
|
||||
* Arguments passed with the notification will never be null.
|
||||
*
|
||||
* @param observer The observer instance being notified.
|
||||
* @param manager The manager generating the event.
|
||||
*/
|
||||
void (*on_active_recovery_image) (struct host_state_observer *observer,
|
||||
struct host_state_manager *manager);
|
||||
|
||||
/**
|
||||
* Notification that the dirty state of a PFM has changed.
|
||||
*
|
||||
* Arguments passed with the notification will never be null.
|
||||
*
|
||||
* @param observer The observer instance being notified.
|
||||
* @param manager The manager generating the event.
|
||||
*/
|
||||
void (*on_pfm_dirty) (struct host_state_observer *observer,
|
||||
struct host_state_manager *manager);
|
||||
|
||||
/**
|
||||
* Notification that the run-time validation status has changed.
|
||||
*
|
||||
* Arguments passed with the notification will never be null.
|
||||
*
|
||||
* @param observer The observer instance being notified.
|
||||
* @param manager The manager generating the event.
|
||||
*/
|
||||
void (*on_run_time_validation) (struct host_state_observer *observer,
|
||||
struct host_state_manager *manager);
|
||||
|
||||
/**
|
||||
* Notification that the bypass mode state has changed.
|
||||
*
|
||||
* Arguments passed with the notification will never be null.
|
||||
*
|
||||
* @param observer The observer instance being notified.v
|
||||
*/
|
||||
void (*on_bypass_mode) (struct host_state_observer *observer,
|
||||
struct host_state_manager *manager);
|
||||
|
||||
/**
|
||||
* Notification that the unsupported flash state has changed.
|
||||
*
|
||||
* Arguments passed with the notification will never be null.
|
||||
*
|
||||
* @param observer The observer instance being notified.
|
||||
* @param manager The manager generating the event.
|
||||
*/
|
||||
void (*on_unsupported_flash) (struct host_state_observer *observer,
|
||||
struct host_state_manager *manager);
|
||||
};
|
||||
|
||||
|
||||
#define HOST_STATE_OBSERVER_ERROR(code) ROT_ERROR (ROT_MODULE_HOST_STATE_OBSERVER, code)
|
||||
|
||||
/**
|
||||
* Error codes that can be generated by a host processor observer.
|
||||
*/
|
||||
enum {
|
||||
HOST_STATE_OBSERVER_INVALID_ARGUMENT = HOST_STATE_OBSERVER_ERROR (0x00), /**< Input parameter is null or not valid. */
|
||||
HOST_STATE_OBSERVER_NO_MEMORY = HOST_STATE_OBSERVER_ERROR (0x01), /**< Memory allocation failed. */
|
||||
};
|
||||
|
||||
|
||||
#endif /* HOST_STATE_OBSERVER_H_ */
|
|
@ -0,0 +1,53 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
#include "host_state_observer_dirty_reset.h"
|
||||
|
||||
|
||||
static void host_state_observer_dirty_reset_on_inactive_dirty (struct host_state_observer *observer,
|
||||
struct host_state_manager *manager)
|
||||
{
|
||||
struct host_state_observer_dirty_reset *reset =
|
||||
(struct host_state_observer_dirty_reset*) observer;
|
||||
|
||||
if (host_state_manager_is_inactive_dirty (manager)) {
|
||||
reset->control->hold_processor_in_reset (reset->control, true);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize a host state observer to assert the host reset control when the flash is dirty.
|
||||
*
|
||||
* @param observer The observer to initialize.
|
||||
* @param control The interface for host processor control signals.
|
||||
*
|
||||
* @return 0 if the observer was successfully initialized or an error code.
|
||||
*/
|
||||
int host_state_observer_dirty_reset_init (struct host_state_observer_dirty_reset *observer,
|
||||
struct host_control *control)
|
||||
{
|
||||
if ((observer == NULL) || (control == NULL)) {
|
||||
return HOST_STATE_OBSERVER_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
memset (observer, 0, sizeof (struct host_state_observer_dirty_reset));
|
||||
|
||||
observer->base.on_inactive_dirty = host_state_observer_dirty_reset_on_inactive_dirty;
|
||||
|
||||
observer->control = control;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Release the resources used by the pending PFM reset observer.
|
||||
*
|
||||
* @param observer The observer to release.
|
||||
*/
|
||||
void host_state_observer_dirty_reset_release (struct host_state_observer_dirty_reset *observer)
|
||||
{
|
||||
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
#ifndef HOST_STATE_OBSERVER_DIRTY_RESET_H_
|
||||
#define HOST_STATE_OBSERVER_DIRTY_RESET_H_
|
||||
|
||||
#include "host_state_observer.h"
|
||||
#include "host_control.h"
|
||||
|
||||
|
||||
struct host_state_observer_dirty_reset {
|
||||
struct host_state_observer base;
|
||||
struct host_control *control;
|
||||
};
|
||||
|
||||
|
||||
int host_state_observer_dirty_reset_init (struct host_state_observer_dirty_reset *observer,
|
||||
struct host_control *control);
|
||||
void host_state_observer_dirty_reset_release (struct host_state_observer_dirty_reset *observer);
|
||||
|
||||
|
||||
#endif /* HOST_STATE_OBSERVER_DIRTY_RESET_H_ */
|
|
@ -8,148 +8,135 @@
|
|||
#include "manifest/manifest_format.h"
|
||||
|
||||
|
||||
/**
|
||||
* Type identifiers for PCD v2 elements.
|
||||
*/
|
||||
enum pcd_element_type {
|
||||
PCD_ROT = 0x40, /**< Information about the RoT configuration. */
|
||||
PCD_CPLD = 0x41, /**< Information about CPLD utilized by RoT. */
|
||||
PCD_COMPONENT_DIRECT = 0x42, /**< A single component connected directly to RoT. */
|
||||
PCD_COMPONENT_MCTP_BRIDGE = 0x43, /**< A components connected to RoT through an MCTP bridge. */
|
||||
};
|
||||
#define PCD_ROT_HDR_IS_PA_ROT_SHIFT 0
|
||||
#define PCD_ROT_HDR_IS_PA_ROT_SET_MASK (1U << PCD_ROT_HDR_IS_PA_ROT_SHIFT)
|
||||
#define PCD_ROT_HDR_IS_PA_ROT_CLR_MASK (~PCD_ROT_HDR_IS_PA_ROT_SET_MASK)
|
||||
|
||||
#define PCD_COMPONENT_HDR_I2C_MODE_SHIFT 0
|
||||
#define PCD_COMPONENT_HDR_I2C_MODE_SET_MASK (1U << PCD_COMPONENT_HDR_I2C_MODE_SHIFT)
|
||||
#define PCD_COMPONENT_HDR_I2C_MODE_CLR_MASK (~PCD_COMPONENT_HDR_I2C_MODE_SET_MASK)
|
||||
|
||||
|
||||
/**
|
||||
* Flags for policy failure action.
|
||||
*/
|
||||
enum pcd_policy_failure_action {
|
||||
PCD_POLICY_FAILURE_ACTION_PASSIVE = 0x0,/**< Report policy failure through attestation. */
|
||||
PCD_POLICY_FAILURE_ACTION_ACTIVE = 0x1, /**< Prevent failed device from booting. */
|
||||
};
|
||||
|
||||
/**
|
||||
* Flags for I2C mode.
|
||||
*/
|
||||
enum pcd_i2c_mode {
|
||||
PCD_I2C_MODE_MULTIMASTER = 0x0, /**< MultiMaster I2C communication scheme. */
|
||||
PCD_I2C_MODE_MASTER_SLAVE = 0x1, /**< Master/Slave I2C communication scheme. */
|
||||
};
|
||||
|
||||
/**
|
||||
* Flags for RoT configuration.
|
||||
*/
|
||||
enum pcd_rot_type_flags {
|
||||
PCD_ROT_TYPE_PA_ROT = 0x0, /**< PA-ROT. */
|
||||
PCD_ROT_TYPE_AC_ROT = 0x1, /**< AC-ROT. */
|
||||
};
|
||||
|
||||
/**
|
||||
* Flags for port flash mode.
|
||||
*/
|
||||
enum pcd_port_flash_mode {
|
||||
PCD_PORT_FLASH_MODE_DUAL = 0x0, /**< Dual flash mode. */
|
||||
PCD_PORT_FLASH_MODE_SINGLE = 0x1, /**< Single flash mode. */
|
||||
};
|
||||
|
||||
/**
|
||||
* Flags for port reset control.
|
||||
*/
|
||||
enum pcd_port_reset_control {
|
||||
PCD_PORT_RESET_CTRL_NOTIFY = 0x0, /**< Notify when port reset pin toggled. */
|
||||
PCD_PORT_RESET_CTRL_RESET = 0x1, /**< Reset port when port reset pin toggled. */
|
||||
};
|
||||
|
||||
#pragma pack(push, 1)
|
||||
/**
|
||||
* The PCD RoT element structure.
|
||||
*/
|
||||
struct pcd_rot_element {
|
||||
uint8_t rot_flags; /**< Flags pertaining to RoT configuration. */
|
||||
uint8_t port_count; /**< The number of ports protected by RoT. */
|
||||
uint8_t components_count; /**< The number of components attested by RoT. */
|
||||
uint8_t rot_address; /**< RoT slave address to utilize. */
|
||||
uint8_t rot_eid; /**< Default RoT MCTP EID to utilize. */
|
||||
uint8_t bridge_address; /**< MCTP bridge slave address. */
|
||||
uint8_t bridge_eid; /**< MCTP bridge EID. */
|
||||
uint8_t reserved; /**< Unused. */
|
||||
};
|
||||
|
||||
/**
|
||||
* A port section defined in PCD as part of RoT element.
|
||||
*/
|
||||
struct pcd_port {
|
||||
uint8_t port_id; /**< Port ID. */
|
||||
uint8_t port_flags; /**< Flags with port configuration. */
|
||||
uint8_t policy; /**< Port attestation policy. */
|
||||
uint8_t reserved; /**< Unused. */
|
||||
uint32_t spi_frequency_hz; /**< Flash SPI frequency in Hz. */
|
||||
};
|
||||
|
||||
/**
|
||||
* A single I2C mux section.
|
||||
*/
|
||||
struct pcd_mux {
|
||||
uint8_t mux_address; /**< I2C slave address of mux. */
|
||||
uint8_t mux_channel; /**< Channel to activate on mux. */
|
||||
uint16_t reserved; /**< Unused. */
|
||||
};
|
||||
|
||||
/**
|
||||
* Container for fields common to I2C interface sections in elements.
|
||||
*/
|
||||
struct pcd_i2c_interface {
|
||||
uint8_t mux_count:4; /**< Number of muxes in I2C path from RoT to device. */
|
||||
uint8_t i2c_flags:4; /**< Flags with I2C configuration. */
|
||||
uint8_t bus; /**< I2C bus device is on. */
|
||||
uint8_t address; /**< Device I2C slave address. */
|
||||
uint8_t eid; /**< Device MCTP EID, 0x00 if not utilizing MCTP. */
|
||||
};
|
||||
|
||||
/**
|
||||
* An I2C CPLD element.
|
||||
*/
|
||||
struct pcd_cpld_element {
|
||||
struct pcd_i2c_interface interface; /**< CPLD I2C interface. */
|
||||
};
|
||||
|
||||
/**
|
||||
* Container for fields common to component elements.
|
||||
*/
|
||||
struct pcd_component_common {
|
||||
uint8_t policy; /**< Component attestation policy. */
|
||||
uint8_t power_ctrl_reg; /**< Power control register. */
|
||||
uint8_t power_ctrl_mask; /**< Power control mask. */
|
||||
uint8_t type_len; /**< Component type length. */
|
||||
uint8_t type[MANIFEST_MAX_STRING]; /**< Component type. */
|
||||
};
|
||||
|
||||
/**
|
||||
* Element for a component with direct I2C connection to RoT.
|
||||
*/
|
||||
struct pcd_direct_i2c_component_element {
|
||||
struct pcd_component_common component; /**< Common component configuration. */
|
||||
struct pcd_i2c_interface interface; /**< Component I2C interface. */
|
||||
};
|
||||
|
||||
/**
|
||||
* Element for a component with connection to RoT through MCTP bridge.
|
||||
*/
|
||||
struct pcd_mctp_bridge_component_element {
|
||||
struct pcd_component_common component; /**< Common component configuration. */
|
||||
uint16_t device_id; /**< Device ID. */
|
||||
uint16_t vendor_id; /**< Vendor ID. */
|
||||
uint16_t subsystem_device_id; /**< Subsystem device ID. */
|
||||
uint16_t subsystem_vendor_id; /**< Subsystem vendor ID. */
|
||||
uint8_t components_count; /**< Number of identical components this element describes. */
|
||||
uint8_t eid; /**< Default EID to use if cannot retrieve EID table from MCTP bridge. */
|
||||
uint16_t reserved; /**< Unused. */
|
||||
};
|
||||
#pragma pack(pop)
|
||||
|
||||
/**
|
||||
* Get the operation to perform on a read/write region after an authentication failure.
|
||||
* The PCD is a variable length structure that has the following format:
|
||||
*
|
||||
* @param rw Pointer to a R/W region structure.
|
||||
* struct {
|
||||
* struct manifest_header
|
||||
* struct pcd_header
|
||||
* struct pcd_rot_header
|
||||
* <struct pcd_port_header> [pcd_rot_header.num_ports]
|
||||
* struct pcd_components_header
|
||||
* <components> [pcd_components_header.num_components]
|
||||
* struct pcd_platform_header
|
||||
* char platform_id[pcd_platform_header.id_len]
|
||||
* uint8_t signature[manifest_header.sig_length]
|
||||
* }
|
||||
*
|
||||
* Each component is a variable length structure that has the following format:
|
||||
*
|
||||
* struct {
|
||||
* struct pcd_component_header
|
||||
* <struct pcd_mux_header> [pcd_component_header.num_muxes]
|
||||
* }
|
||||
*/
|
||||
#define pfm_get_rw_operation_on_failure(rw) (enum pfm_read_write_management) (((rw)->flags) & 0x3)
|
||||
|
||||
/**
|
||||
* The header information for the PCD.
|
||||
*/
|
||||
struct pcd_header {
|
||||
uint16_t length; /**< Total length of PCD without manifest header and signature. */
|
||||
uint16_t header_len; /**< PCD header length. */
|
||||
uint8_t format_id; /**< PCD format ID. */
|
||||
uint8_t reserved1; /**< Reserved. */
|
||||
uint8_t reserved2; /**< Reserved. */
|
||||
uint8_t reserved3; /**< Reserved. */
|
||||
};
|
||||
|
||||
/**
|
||||
* The header information for the PCD RoT.
|
||||
*/
|
||||
struct pcd_rot_header {
|
||||
uint16_t length; /**< Total length of PCD RoT section including header. */
|
||||
uint16_t header_len; /**< Length of PCD RoT header. */
|
||||
uint8_t format_id; /**< PCD RoT format ID. */
|
||||
uint8_t num_ports; /**< Number of ports in RoT. */
|
||||
uint8_t addr; /**< I2C slave address */
|
||||
uint8_t bmc_i2c_addr; /**< BMC I2C address */
|
||||
uint8_t cpld_addr; /**< CPLD I2C slave address */
|
||||
uint8_t cpld_channel; /**< CPLD I2C bus channel */
|
||||
uint8_t active; /**< Policy active */
|
||||
uint8_t default_failure_action; /**< Default action on attestation failure */
|
||||
uint8_t flags; /**< Field for flags */
|
||||
uint8_t reserved1; /**< Reserved. */
|
||||
uint8_t reserved2; /**< Reserved. */
|
||||
uint8_t reserved3; /**< Reserved. */
|
||||
};
|
||||
|
||||
/**
|
||||
* The header information for a RoT port section.
|
||||
*/
|
||||
struct pcd_port_header {
|
||||
uint16_t length; /**< Total length of RoT ports section. */
|
||||
uint16_t header_len; /**< Length of PCD port header. */
|
||||
uint8_t format_id; /**< RoT ports format ID. */
|
||||
uint8_t id; /**< Port ID */
|
||||
uint8_t reserverd1; /**< Reserved. */
|
||||
uint8_t reserverd2; /**< Reserved. */
|
||||
uint32_t frequency; /**< Bus frequency */
|
||||
};
|
||||
|
||||
/**
|
||||
* The header information for the PCD components section.
|
||||
*/
|
||||
struct pcd_components_header {
|
||||
uint16_t length; /**< Total length of PCD components section. */
|
||||
uint16_t header_len; /**< Length of PCD components header. */
|
||||
uint8_t format_id; /**< PCD components format ID. */
|
||||
uint8_t num_components; /**< Number of components in PCD. */
|
||||
uint8_t reserved1; /**< Reserved. */
|
||||
uint8_t reserved2; /**< Reserved. */
|
||||
};
|
||||
|
||||
/**
|
||||
* The header information for a PCD component.
|
||||
*/
|
||||
struct pcd_component_header {
|
||||
uint16_t length; /**< Total length of PCD component. */
|
||||
uint16_t header_len; /**< Length of PCD component header. */
|
||||
uint8_t format_id; /**< PCD component format ID. */
|
||||
uint8_t num_muxes; /**< Number of muxes in component. */
|
||||
uint8_t addr; /**< I2C slave address */
|
||||
uint8_t channel; /**< I2C bus channel */
|
||||
uint8_t flags; /**< Field for flags */
|
||||
uint8_t eid; /**< MCTP EID */
|
||||
uint8_t power_ctrl_reg; /**< Power control register */
|
||||
uint8_t power_ctrl_mask; /**< Power control bitmask */
|
||||
uint32_t id; /**< Component ID. */
|
||||
};
|
||||
|
||||
/**
|
||||
* The header information for a mux section.
|
||||
*/
|
||||
struct pcd_mux_header {
|
||||
uint16_t length; /**< Total length of component mux section. */
|
||||
uint16_t header_len; /**< Length of PCD mux header */
|
||||
uint8_t format_id; /**< Component mux format ID. */
|
||||
uint8_t addr; /**< I2C slave address */
|
||||
uint8_t channel; /**< I2C bus channel */
|
||||
uint8_t mux_level; /**< Mux level */
|
||||
};
|
||||
|
||||
/**
|
||||
* The header information for the platform information.
|
||||
*/
|
||||
struct pcd_platform_header {
|
||||
uint16_t length; /**< The total length of the platform descriptor. */
|
||||
uint16_t header_len; /**< Length of PCD platform header. */
|
||||
uint8_t format_id; /**< PCD platform header format ID. */
|
||||
uint8_t id_len; /**< Platform ID length. */
|
||||
uint8_t reserved1; /**< Reserved. */
|
||||
uint8_t reserved2; /**< Reserved. */
|
||||
};
|
||||
|
||||
|
||||
#endif /* PCD_FORMAT_H_ */
|
||||
|
|
|
@ -64,7 +64,7 @@ static int pfm_manager_flash_activate_pending_pfm (struct manifest_manager *mana
|
|||
|
||||
status = manifest_manager_flash_activate_pending_manifest (&pfm_mgr->manifest_manager);
|
||||
if (status == 0) {
|
||||
host_state_manager_set_pfm_dirty (pfm_mgr->manifest_manager.state, false);
|
||||
host_state_manager_set_pfm_dirty (pfm_mgr->host_state, false);
|
||||
pfm_manager_on_pfm_activated (&pfm_mgr->base);
|
||||
}
|
||||
|
||||
|
@ -105,7 +105,7 @@ int pfm_manager_flash_verify_pending_pfm (struct manifest_manager *manager)
|
|||
|
||||
status = manifest_manager_flash_verify_pending_manifest (&pfm_mgr->manifest_manager);
|
||||
if (status == 0) {
|
||||
host_state_manager_set_pfm_dirty (pfm_mgr->manifest_manager.state, true);
|
||||
host_state_manager_set_pfm_dirty (pfm_mgr->host_state, true);
|
||||
pfm_manager_on_pfm_verified (&pfm_mgr->base);
|
||||
}
|
||||
|
||||
|
@ -179,7 +179,7 @@ static int pfm_manager_flash_check_supported_versions (struct pfm_manager_flash
|
|||
* @return 0 if the PFM manager was successfully initialized or an error code.
|
||||
*/
|
||||
int pfm_manager_flash_init (struct pfm_manager_flash *manager, struct pfm_flash *pfm_region1,
|
||||
struct pfm_flash *pfm_region2, struct state_manager *state, struct hash_engine *hash,
|
||||
struct pfm_flash *pfm_region2, struct host_state_manager *state, struct hash_engine *hash,
|
||||
struct signature_verification *verification)
|
||||
{
|
||||
return pfm_manager_flash_init_port (manager, pfm_region1, pfm_region2, state, hash,
|
||||
|
@ -205,7 +205,7 @@ int pfm_manager_flash_init (struct pfm_manager_flash *manager, struct pfm_flash
|
|||
* @return 0 if the PFM manager was successfully initialized or an error code.
|
||||
*/
|
||||
int pfm_manager_flash_init_port (struct pfm_manager_flash *manager, struct pfm_flash *pfm_region1,
|
||||
struct pfm_flash *pfm_region2, struct state_manager *state, struct hash_engine *hash,
|
||||
struct pfm_flash *pfm_region2, struct host_state_manager *state, struct hash_engine *hash,
|
||||
struct signature_verification *verification, int port)
|
||||
{
|
||||
int status;
|
||||
|
@ -222,8 +222,8 @@ int pfm_manager_flash_init_port (struct pfm_manager_flash *manager, struct pfm_f
|
|||
}
|
||||
|
||||
status = manifest_manager_flash_init (&manager->manifest_manager, &pfm_region1->base.base,
|
||||
&pfm_region2->base.base, &pfm_region1->base_flash, &pfm_region2->base_flash, state, hash,
|
||||
verification, 0);
|
||||
&pfm_region2->base.base, &pfm_region1->base_flash, &pfm_region2->base_flash, &state->base,
|
||||
hash, verification, 0);
|
||||
if (status != 0) {
|
||||
goto manifest_base_error;
|
||||
}
|
||||
|
@ -243,6 +243,8 @@ int pfm_manager_flash_init_port (struct pfm_manager_flash *manager, struct pfm_f
|
|||
manager->base.base.verify_pending_manifest = pfm_manager_flash_verify_pending_pfm;
|
||||
manager->base.base.clear_all_manifests = pfm_manager_flash_clear_all_manifests;
|
||||
|
||||
manager->host_state = state;
|
||||
|
||||
return 0;
|
||||
|
||||
platform_id_error:
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
#include "pfm_manager.h"
|
||||
#include "pfm_flash.h"
|
||||
#include "manifest/manifest_manager_flash.h"
|
||||
#include "host_fw/host_state_manager.h"
|
||||
|
||||
|
||||
/**
|
||||
|
@ -16,14 +17,15 @@
|
|||
struct pfm_manager_flash {
|
||||
struct pfm_manager base; /**< The base PFM manager instance. */
|
||||
struct manifest_manager_flash manifest_manager; /**< Common manifest manager flash members. */
|
||||
struct host_state_manager *host_state; /**< Manager for host state. */
|
||||
};
|
||||
|
||||
|
||||
int pfm_manager_flash_init (struct pfm_manager_flash *manager, struct pfm_flash *pfm_region1,
|
||||
struct pfm_flash *pfm_region2, struct state_manager *state, struct hash_engine *hash,
|
||||
struct pfm_flash *pfm_region2, struct host_state_manager *state, struct hash_engine *hash,
|
||||
struct signature_verification *verification);
|
||||
int pfm_manager_flash_init_port (struct pfm_manager_flash *manager, struct pfm_flash *pfm_region1,
|
||||
struct pfm_flash *pfm_region2, struct state_manager *state, struct hash_engine *hash,
|
||||
struct pfm_flash *pfm_region2, struct host_state_manager *state, struct hash_engine *hash,
|
||||
struct signature_verification *verification, int port);
|
||||
void pfm_manager_flash_release (struct pfm_manager_flash *manager);
|
||||
|
||||
|
|
|
@ -475,7 +475,7 @@ release_observer:
|
|||
* @return 0 if the recovery image manager was initialized successfully or an error code.
|
||||
*/
|
||||
int recovery_image_manager_init_two_region (struct recovery_image_manager *manager,
|
||||
struct recovery_image *image1, struct recovery_image *image2, struct state_manager *state,
|
||||
struct recovery_image *image1, struct recovery_image *image2, struct host_state_manager *state,
|
||||
struct hash_engine *hash, struct signature_verification *verification, struct pfm_manager *pfm,
|
||||
size_t max_size)
|
||||
{
|
||||
|
|
|
@ -4,16 +4,15 @@
|
|||
#ifndef RECOVERY_IMAGE_MANAGER_H_
|
||||
#define RECOVERY_IMAGE_MANAGER_H_
|
||||
|
||||
#include "platform.h"
|
||||
#include "recovery_image.h"
|
||||
#include "common/observable.h"
|
||||
#include "common/signature_verification.h"
|
||||
#include "recovery_image_observer.h"
|
||||
#include "flash/flash.h"
|
||||
#include "recovery_image.h"
|
||||
#include "crypto/hash.h"
|
||||
#include "common/signature_verification.h"
|
||||
#include "platform.h"
|
||||
#include "host_fw/host_state_manager.h"
|
||||
#include "flash/flash_updater.h"
|
||||
#include "crypto/hash.h"
|
||||
#include "host_fw/host_state_manager.h"
|
||||
|
||||
|
||||
/**
|
||||
|
@ -129,7 +128,7 @@ struct recovery_image_manager {
|
|||
struct pfm_manager *pfm; /**< The PFM manager for recovery image verification. */
|
||||
platform_mutex lock; /**< Synchronization for recovery image manager state. */
|
||||
int port; /**< Port identifier for the manager. */
|
||||
struct state_manager *state; /**< State manager interface. */
|
||||
struct host_state_manager *state; /**< State manager interface. */
|
||||
struct flash_updater *updating; /**< The update manager being used to write
|
||||
new recovery image data. */
|
||||
};
|
||||
|
@ -139,7 +138,7 @@ int recovery_image_manager_init (struct recovery_image_manager *manager,
|
|||
struct recovery_image *image, struct hash_engine *hash,
|
||||
struct signature_verification *verification, struct pfm_manager *pfm, size_t max_size);
|
||||
int recovery_image_manager_init_two_region (struct recovery_image_manager *manager,
|
||||
struct recovery_image *image1, struct recovery_image *image2, struct state_manager *state,
|
||||
struct recovery_image *image1, struct recovery_image *image2, struct host_state_manager *state,
|
||||
struct hash_engine *hash, struct signature_verification *verification, struct pfm_manager *pfm,
|
||||
size_t max_size);
|
||||
void recovery_image_manager_release (struct recovery_image_manager *manager);
|
||||
|
|
|
@ -24,7 +24,7 @@ void spi_filter_irq_handler_ro_flash_dirty (struct spi_filter_irq_handler *handl
|
|||
* @return 0 if the handler was initialized successfully or an error code.
|
||||
*/
|
||||
int spi_filter_irq_handler_init (struct spi_filter_irq_handler *handler,
|
||||
struct state_manager *host_state)
|
||||
struct host_state_manager *host_state)
|
||||
{
|
||||
if ((handler == NULL) || (host_state == NULL)) {
|
||||
return SPI_FILTER_IRQ_INVALID_ARGUMENT;
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
#define SPI_FILTER_IRQ_HANDLER_H_
|
||||
|
||||
#include "status/rot_status.h"
|
||||
#include "state_manager/state_manager.h"
|
||||
#include "host_fw/host_state_manager.h"
|
||||
|
||||
|
||||
/**
|
||||
|
@ -19,12 +19,12 @@ struct spi_filter_irq_handler {
|
|||
*/
|
||||
void (*ro_flash_dirty) (struct spi_filter_irq_handler *handler);
|
||||
|
||||
struct state_manager *host_state; /**< State of the host for the SPI filter. */
|
||||
struct host_state_manager *host_state; /**< State of the host for the SPI filter. */
|
||||
};
|
||||
|
||||
|
||||
int spi_filter_irq_handler_init (struct spi_filter_irq_handler *handler,
|
||||
struct state_manager *host_state);
|
||||
struct host_state_manager *host_state);
|
||||
void spi_filter_irq_handler_release (struct spi_filter_irq_handler *handler);
|
||||
|
||||
/* Internal functions for use by derived types. */
|
||||
|
|
|
@ -29,7 +29,7 @@ static void spi_filter_irq_handler_dirty_ro_flash_dirty (struct spi_filter_irq_h
|
|||
* @return 0 if the handler was successfully initialized or an error code.
|
||||
*/
|
||||
int spi_filter_irq_handler_dirty_init (struct spi_filter_irq_handler_dirty *handler,
|
||||
struct state_manager *host_state, struct host_control *control)
|
||||
struct host_state_manager *host_state, struct host_control *control)
|
||||
{
|
||||
int status;
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ struct spi_filter_irq_handler_dirty {
|
|||
|
||||
|
||||
int spi_filter_irq_handler_dirty_init (struct spi_filter_irq_handler_dirty *handler,
|
||||
struct state_manager *host_state, struct host_control *control);
|
||||
struct host_state_manager *host_state, struct host_control *control);
|
||||
void spi_filter_irq_handler_dirty_release (struct spi_filter_irq_handler_dirty *handler);
|
||||
|
||||
|
||||
|
|
|
@ -15,8 +15,8 @@
|
|||
* Definitions to indicate which region of flash holds the active manifest.
|
||||
*/
|
||||
enum manifest_region {
|
||||
MANIFEST_REGION_1, /**< The primary manifest region contains the active manifest. */
|
||||
MANIFEST_REGION_2, /**< The secondary manifest region contains the active manifest. */
|
||||
MANIFEST_REGION_1, /**< The primary manifest region contains the active manifest. */
|
||||
MANIFEST_REGION_2, /**< The secondary manifest region contains the active manifest. */
|
||||
};
|
||||
|
||||
|
||||
|
@ -24,14 +24,14 @@ enum manifest_region {
|
|||
* Manager for state information.
|
||||
*/
|
||||
struct state_manager {
|
||||
struct flash *nv_store; /**< The flash that contains the stored state. */
|
||||
uint32_t base_addr; /**< The first address of the state storage. */
|
||||
uint32_t store_addr; /**< The address of the last storage location used. */
|
||||
uint16_t nv_state; /**< The current non-volatile state. */
|
||||
uint16_t last_nv_stored; /**< The last state value stored in flash. */
|
||||
uint8_t volatile_state; /**< The current volatile state. */
|
||||
platform_mutex state_lock; /**< Synchronization lock for state. */
|
||||
platform_mutex store_lock; /**< Synchronization lock for store actions. */
|
||||
struct flash *nv_store; /**< The flash that contains the stored state. */
|
||||
uint32_t base_addr; /**< The first address of the state storage. */
|
||||
uint32_t store_addr; /**< The address of the last storage location used. */
|
||||
uint16_t nv_state; /**< The current non-volatile state. */
|
||||
uint16_t last_nv_stored; /**< The last state value stored in flash. */
|
||||
uint8_t volatile_state; /**< The current volatile state. */
|
||||
platform_mutex state_lock; /**< Synchronization lock for state. */
|
||||
platform_mutex store_lock; /**< Synchronization lock for store actions. */
|
||||
|
||||
/**
|
||||
* Save the setting for the manifest region that contains the active manifest.
|
||||
|
@ -54,7 +54,8 @@ struct state_manager {
|
|||
*
|
||||
* @return The active manifest region.
|
||||
*/
|
||||
enum manifest_region (*get_active_manifest) (struct state_manager *manager, uint8_t manifest_index);
|
||||
enum manifest_region (*get_active_manifest) (struct state_manager *manager,
|
||||
uint8_t manifest_index);
|
||||
|
||||
/**
|
||||
* Restore all state information to the default values. This does not erase non-volatile state,
|
||||
|
|
|
@ -94,6 +94,7 @@ enum {
|
|||
ROT_MODULE_SESSION_MANAGER = 0x0052, /**< Encrypted session management. */
|
||||
ROT_MODULE_FLASH_STORE = 0x0053, /**< Block data storage in flash. */
|
||||
ROT_MODULE_KDF = 0x0054, /**< Key derivation function. */
|
||||
ROT_MODULE_HOST_STATE_OBSERVER = 0x0055, /**< Observers for host state changes. */
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -32,11 +32,13 @@
|
|||
//#define TESTING_RUN_STATE_MANAGER_SUITE
|
||||
//#define TESTING_RUN_HOST_STATE_MANAGER_SUITE
|
||||
//#define TESTING_RUN_SYSTEM_STATE_MANAGER_SUITE
|
||||
//#define TESTING_RUN_HOST_FLASH_MANAGER_SUITE
|
||||
//#define TESTING_RUN_HOST_FLASH_MANAGER_DUAL_SUITE
|
||||
//#define TESTING_RUN_HOST_FLASH_MANAGER_SINGLE_SUITE
|
||||
//#define TESTING_RUN_PFM_MANAGER_FLASH_SUITE
|
||||
//#define TESTING_RUN_CFM_MANAGER_FLASH_SUITE
|
||||
//#define TESTING_RUN_HOST_PROCESSOR_SUITE
|
||||
//#define TESTING_RUN_HOST_PROCESSOR_DUAL_SUITE
|
||||
//#define TESTING_RUN_HOST_PROCESSOR_SINGLE_SUITE
|
||||
//#define TESTING_RUN_HOST_IRQ_HANDLER_SUITE
|
||||
//#define TESTING_RUN_SPI_FILTER_IRQ_HANDLER_SUITE
|
||||
//#define TESTING_RUN_PLATFORM_TIMER_SUITE
|
||||
|
@ -56,7 +58,7 @@
|
|||
//#define TESTING_RUN_AUX_ATTESTATION_SUITE
|
||||
//#define TESTING_RUN_FIRMWARE_HEADER_SUITE
|
||||
//#define TESTING_RUN_SPI_FILTER_IRQ_HANDLER_DIRTY_SUITE
|
||||
//#define TESTING_RUN_HOST_IRQ_HANDLER_PFM_CHECK_SUITE
|
||||
//#define TESTING_RUN_HOST_IRQ_HANDLER_AUTH_CHECK_SUITE
|
||||
//#define TESTING_RUN_ATTESTATION_MASTER_SUITE
|
||||
//#define TESTING_RUN_ATTESTATION_SLAVE_SUITE
|
||||
//#define TESTING_RUN_RNG_MBEDTLS_SUITE
|
||||
|
@ -68,6 +70,7 @@
|
|||
//#define TESTING_RUN_PCR_STORE_SUITE
|
||||
//#define TESTING_RUN_HOST_IRQ_HANDLER_MASK_IRQS_SUITE
|
||||
//#define TESTING_RUN_HOST_PROCESSOR_DUAL_FULL_BYPASS_SUITE
|
||||
//#define TESTING_RUN_HOST_PROCESSOR_SINGLE_FULL_BYPASS_SUITE
|
||||
//#define TESTING_RUN_OBSERVABLE_SUITE
|
||||
//#define TESTING_RUN_PFM_MANAGER_SUITE
|
||||
//#define TESTING_RUN_CFM_MANAGER_SUITE
|
||||
|
@ -116,6 +119,7 @@
|
|||
//#define TESTING_RUN_FLASH_STORE_ENCRYPTED_SUITE
|
||||
//#define TESTING_RUN_KDF_SUITE
|
||||
//#define TESTING_RUN_BUFFER_UTIL_SUITE
|
||||
//#define TESTING_RUN_HOST_STATE_OBSERVER_DIRTY_RESET_SUITE
|
||||
|
||||
|
||||
CuSuite* get_flash_common_suite (void);
|
||||
|
@ -144,7 +148,8 @@ CuSuite* get_mctp_protocol_suite (void);
|
|||
CuSuite* get_state_manager_suite (void);
|
||||
CuSuite* get_host_state_manager_suite (void);
|
||||
CuSuite* get_system_state_manager_suite (void);
|
||||
CuSuite* get_host_flash_manager_suite (void);
|
||||
CuSuite* get_host_flash_manager_dual_suite (void);
|
||||
CuSuite* get_host_flash_manager_single_suite (void);
|
||||
CuSuite* get_pfm_manager_flash_suite (void);
|
||||
CuSuite* get_cfm_manager_flash_suite (void);
|
||||
CuSuite* get_host_processor_suite (void);
|
||||
|
@ -156,6 +161,14 @@ CuSuite* get_host_processor_dual_flash_rollback_suite (void);
|
|||
CuSuite* get_host_processor_dual_recover_active_read_write_data_suite (void);
|
||||
CuSuite* get_host_processor_dual_apply_recovery_image_suite (void);
|
||||
CuSuite* get_host_processor_dual_bypass_mode_suite (void);
|
||||
CuSuite* get_host_processor_single_suite (void);
|
||||
CuSuite* get_host_processor_single_power_on_reset_suite (void);
|
||||
CuSuite* get_host_processor_single_soft_reset_suite (void);
|
||||
CuSuite* get_host_processor_single_run_time_verification_suite (void);
|
||||
CuSuite* get_host_processor_single_flash_rollback_suite (void);
|
||||
CuSuite* get_host_processor_single_recover_active_read_write_data_suite (void);
|
||||
CuSuite* get_host_processor_single_apply_recovery_image_suite (void);
|
||||
CuSuite* get_host_processor_single_bypass_mode_suite (void);
|
||||
CuSuite* get_host_irq_handler_suite (void);
|
||||
CuSuite* get_spi_filter_irq_handler_suite (void);
|
||||
CuSuite* get_platform_timer_suite (void);
|
||||
|
@ -175,7 +188,7 @@ CuSuite* get_riot_key_manager_suite (void);
|
|||
CuSuite* get_aux_attestation_suite (void);
|
||||
CuSuite* get_firmware_header_suite (void);
|
||||
CuSuite* get_spi_filter_irq_handler_dirty_suite (void);
|
||||
CuSuite* get_host_irq_handler_pfm_check_suite (void);
|
||||
CuSuite* get_host_irq_handler_auth_check_suite (void);
|
||||
CuSuite* get_attestation_master_suite (void);
|
||||
CuSuite* get_attestation_slave_suite (void);
|
||||
CuSuite* get_rng_mbedtls_suite (void);
|
||||
|
@ -187,6 +200,7 @@ CuSuite* get_pcr_suite (void);
|
|||
CuSuite* get_pcr_store_suite (void);
|
||||
CuSuite* get_host_irq_handler_mask_irqs_suite (void);
|
||||
CuSuite* get_host_processor_dual_full_bypass_suite (void);
|
||||
CuSuite* get_host_processor_single_full_bypass_suite (void);
|
||||
CuSuite* get_observable_suite (void);
|
||||
CuSuite* get_pfm_manager_suite (void);
|
||||
CuSuite* get_cfm_manager_suite (void);
|
||||
|
@ -235,6 +249,7 @@ CuSuite* get_flash_store_suite (void);
|
|||
CuSuite* get_flash_store_encrypted_suite (void);
|
||||
CuSuite* get_kdf_suite (void);
|
||||
CuSuite* get_buffer_util_suite (void);
|
||||
CuSuite* get_host_state_observer_dirty_reset_suite (void);
|
||||
|
||||
void add_all_tests (CuSuite *suite)
|
||||
{
|
||||
|
@ -312,8 +327,11 @@ void add_all_tests (CuSuite *suite)
|
|||
#ifdef TESTING_RUN_SYSTEM_STATE_MANAGER_SUITE
|
||||
CuSuiteAddSuite (suite, get_system_state_manager_suite ());
|
||||
#endif
|
||||
#ifdef TESTING_RUN_HOST_FLASH_MANAGER_SUITE
|
||||
CuSuiteAddSuite (suite, get_host_flash_manager_suite ());
|
||||
#ifdef TESTING_RUN_HOST_FLASH_MANAGER_DUAL_SUITE
|
||||
CuSuiteAddSuite (suite, get_host_flash_manager_dual_suite ());
|
||||
#endif
|
||||
#ifdef TESTING_RUN_HOST_FLASH_MANAGER_SINGLE_SUITE
|
||||
CuSuiteAddSuite (suite, get_host_flash_manager_single_suite ());
|
||||
#endif
|
||||
#ifdef TESTING_RUN_PFM_MANAGER_FLASH_SUITE
|
||||
CuSuiteAddSuite (suite, get_pfm_manager_flash_suite ());
|
||||
|
@ -334,6 +352,16 @@ void add_all_tests (CuSuite *suite)
|
|||
CuSuiteAddSuite (suite, get_host_processor_dual_apply_recovery_image_suite ());
|
||||
CuSuiteAddSuite (suite, get_host_processor_dual_bypass_mode_suite ());
|
||||
#endif
|
||||
#ifdef TESTING_RUN_HOST_PROCESSOR_SINGLE_SUITE
|
||||
CuSuiteAddSuite (suite, get_host_processor_single_suite ());
|
||||
CuSuiteAddSuite (suite, get_host_processor_single_power_on_reset_suite ());
|
||||
CuSuiteAddSuite (suite, get_host_processor_single_soft_reset_suite ());
|
||||
CuSuiteAddSuite (suite, get_host_processor_single_run_time_verification_suite ());
|
||||
CuSuiteAddSuite (suite, get_host_processor_single_flash_rollback_suite ());
|
||||
CuSuiteAddSuite (suite, get_host_processor_single_recover_active_read_write_data_suite ());
|
||||
CuSuiteAddSuite (suite, get_host_processor_single_apply_recovery_image_suite ());
|
||||
CuSuiteAddSuite (suite, get_host_processor_single_bypass_mode_suite ());
|
||||
#endif
|
||||
#ifdef TESTING_RUN_HOST_IRQ_HANDLER_SUITE
|
||||
CuSuiteAddSuite (suite, get_host_irq_handler_suite ());
|
||||
#endif
|
||||
|
@ -391,8 +419,8 @@ void add_all_tests (CuSuite *suite)
|
|||
#ifdef TESTING_RUN_SPI_FILTER_IRQ_HANDLER_DIRTY_SUITE
|
||||
CuSuiteAddSuite (suite, get_spi_filter_irq_handler_dirty_suite ());
|
||||
#endif
|
||||
#ifdef TESTING_RUN_HOST_IRQ_HANDLER_PFM_CHECK_SUITE
|
||||
CuSuiteAddSuite (suite, get_host_irq_handler_pfm_check_suite ());
|
||||
#ifdef TESTING_RUN_HOST_IRQ_HANDLER_AUTH_CHECK_SUITE
|
||||
CuSuiteAddSuite (suite, get_host_irq_handler_auth_check_suite ());
|
||||
#endif
|
||||
#ifdef TESTING_RUN_ATTESTATION_MASTER_SUITE
|
||||
CuSuiteAddSuite (suite, get_attestation_master_suite ());
|
||||
|
@ -427,6 +455,9 @@ void add_all_tests (CuSuite *suite)
|
|||
#ifdef TESTING_RUN_HOST_PROCESSOR_DUAL_FULL_BYPASS_SUITE
|
||||
CuSuiteAddSuite (suite, get_host_processor_dual_full_bypass_suite ());
|
||||
#endif
|
||||
#ifdef TESTING_RUN_HOST_PROCESSOR_SINGLE_FULL_BYPASS_SUITE
|
||||
CuSuiteAddSuite (suite, get_host_processor_single_full_bypass_suite ());
|
||||
#endif
|
||||
#ifdef TESTING_RUN_OBSERVABLE_SUITE
|
||||
CuSuiteAddSuite (suite, get_observable_suite ());
|
||||
#endif
|
||||
|
@ -571,6 +602,9 @@ void add_all_tests (CuSuite *suite)
|
|||
#ifdef TESTING_RUN_BUFFER_UTIL_SUITE
|
||||
CuSuiteAddSuite (suite, get_buffer_util_suite ());
|
||||
#endif
|
||||
#ifdef TESTING_RUN_HOST_STATE_OBSERVER_DIRTY_RESET_SUITE
|
||||
CuSuiteAddSuite (suite, get_host_state_observer_dirty_reset_suite ());
|
||||
#endif
|
||||
|
||||
add_all_platform_tests (suite);
|
||||
}
|
||||
|
|
|
@ -119,7 +119,7 @@ struct cmd_interface_system_testing {
|
|||
struct x509_engine_mock x509_mock; /**< The X.509 engine mock for the RIoT keys. */
|
||||
X509_TESTING_ENGINE x509; /**< X.509 engine for the RIoT keys. */
|
||||
struct flash_mock flash; /**< The flash mock to set expectations on. */
|
||||
struct state_manager state; /**< The state manager. */
|
||||
struct host_state_manager state; /**< The state manager. */
|
||||
struct flash_mock flash_state; /**< The mock for the flash state storage. */
|
||||
struct cmd_background_mock background; /**< The background command interface mock. */
|
||||
struct pcr_store store; /**< PCR storage. */
|
||||
|
@ -156,7 +156,7 @@ static struct riot_keys keys = {
|
|||
* @param flash The mock for the flash state storage.
|
||||
*/
|
||||
static void cmd_interface_system_testing_init_host_state (CuTest *test,
|
||||
struct state_manager *state, struct flash_mock *flash)
|
||||
struct host_state_manager *state, struct flash_mock *flash)
|
||||
{
|
||||
int status;
|
||||
uint16_t end[4] = {0xffff, 0xffff, 0xffff, 0xffff};
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -5,7 +5,7 @@
|
|||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include "testing.h"
|
||||
#include "host_fw/host_irq_handler_pfm_check.h"
|
||||
#include "host_fw/host_irq_handler_auth_check.h"
|
||||
#include "host_fw/host_state_manager.h"
|
||||
#include "mock/host_processor_mock.h"
|
||||
#include "mock/bmc_recovery_mock.h"
|
||||
|
@ -13,20 +13,18 @@
|
|||
#include "mock/flash_master_mock.h"
|
||||
#include "mock/host_control_mock.h"
|
||||
#include "mock/host_irq_control_mock.h"
|
||||
#include "mock/pfm_manager_mock.h"
|
||||
#include "mock/pfm_mock.h"
|
||||
#include "engines/hash_testing_engine.h"
|
||||
#include "engines/rsa_testing_engine.h"
|
||||
|
||||
|
||||
static const char *SUITE = "host_irq_handler_pfm_check";
|
||||
static const char *SUITE = "host_irq_handler_auth_check";
|
||||
|
||||
|
||||
/*******************
|
||||
* Test cases
|
||||
*******************/
|
||||
|
||||
static void host_irq_handler_pfm_check_test_init (CuTest *test)
|
||||
static void host_irq_handler_auth_check_test_init (CuTest *test)
|
||||
{
|
||||
HASH_TESTING_ENGINE hash;
|
||||
RSA_TESTING_ENGINE rsa;
|
||||
|
@ -34,8 +32,7 @@ static void host_irq_handler_pfm_check_test_init (CuTest *test)
|
|||
struct bmc_recovery_mock recovery;
|
||||
struct host_control_mock control;
|
||||
struct host_irq_control_mock irq;
|
||||
struct pfm_manager_mock pfm_mgr;
|
||||
struct host_irq_handler_pfm_check handler;
|
||||
struct host_irq_handler_auth_check handler;
|
||||
int status;
|
||||
|
||||
TEST_START;
|
||||
|
@ -58,14 +55,11 @@ static void host_irq_handler_pfm_check_test_init (CuTest *test)
|
|||
status = host_irq_control_mock_init (&irq);
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
status = pfm_manager_mock_init (&pfm_mgr);
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
status = mock_expect (&irq.mock, irq.base.enable_exit_reset, &irq, 0, MOCK_ARG (true));
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
status = host_irq_handler_pfm_check_init (&handler, &host.base, &hash.base, &rsa.base,
|
||||
&recovery.base, &control.base, &irq.base, &pfm_mgr.base);
|
||||
status = host_irq_handler_auth_check_init (&handler, &host.base, &hash.base, &rsa.base,
|
||||
&recovery.base, &control.base, &irq.base);
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
CuAssertPtrNotNull (test, handler.base.power_on);
|
||||
|
@ -86,13 +80,10 @@ static void host_irq_handler_pfm_check_test_init (CuTest *test)
|
|||
status = mock_validate (&irq.mock);
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
status = pfm_manager_mock_validate_and_release (&pfm_mgr);
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
status = mock_expect (&irq.mock, irq.base.enable_exit_reset, &irq, 0, MOCK_ARG (false));
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
host_irq_handler_pfm_check_release (&handler);
|
||||
host_irq_handler_auth_check_release (&handler);
|
||||
|
||||
status = host_irq_control_mock_validate_and_release (&irq);
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
@ -101,15 +92,14 @@ static void host_irq_handler_pfm_check_test_init (CuTest *test)
|
|||
RSA_TESTING_ENGINE_RELEASE (&rsa);
|
||||
}
|
||||
|
||||
static void host_irq_handler_pfm_check_test_init_no_recovery (CuTest *test)
|
||||
static void host_irq_handler_auth_check_test_init_no_recovery (CuTest *test)
|
||||
{
|
||||
HASH_TESTING_ENGINE hash;
|
||||
RSA_TESTING_ENGINE rsa;
|
||||
struct host_processor_mock host;
|
||||
struct host_control_mock control;
|
||||
struct host_irq_control_mock irq;
|
||||
struct pfm_manager_mock pfm_mgr;
|
||||
struct host_irq_handler_pfm_check handler;
|
||||
struct host_irq_handler_auth_check handler;
|
||||
int status;
|
||||
|
||||
TEST_START;
|
||||
|
@ -129,14 +119,11 @@ static void host_irq_handler_pfm_check_test_init_no_recovery (CuTest *test)
|
|||
status = host_irq_control_mock_init (&irq);
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
status = pfm_manager_mock_init (&pfm_mgr);
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
status = mock_expect (&irq.mock, irq.base.enable_exit_reset, &irq, 0, MOCK_ARG (true));
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
status = host_irq_handler_pfm_check_init (&handler, &host.base, &hash.base, &rsa.base,
|
||||
NULL, &control.base, &irq.base, &pfm_mgr.base);
|
||||
status = host_irq_handler_auth_check_init (&handler, &host.base, &hash.base, &rsa.base,
|
||||
NULL, &control.base, &irq.base);
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
status = host_processor_mock_validate_and_release (&host);
|
||||
|
@ -148,13 +135,10 @@ static void host_irq_handler_pfm_check_test_init_no_recovery (CuTest *test)
|
|||
status = mock_validate (&irq.mock);
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
status = pfm_manager_mock_validate_and_release (&pfm_mgr);
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
status = mock_expect (&irq.mock, irq.base.enable_exit_reset, &irq, 0, MOCK_ARG (false));
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
host_irq_handler_pfm_check_release (&handler);
|
||||
host_irq_handler_auth_check_release (&handler);
|
||||
|
||||
status = host_irq_control_mock_validate_and_release (&irq);
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
@ -163,7 +147,7 @@ static void host_irq_handler_pfm_check_test_init_no_recovery (CuTest *test)
|
|||
RSA_TESTING_ENGINE_RELEASE (&rsa);
|
||||
}
|
||||
|
||||
static void host_irq_handler_pfm_check_test_init_null (CuTest *test)
|
||||
static void host_irq_handler_auth_check_test_init_null (CuTest *test)
|
||||
{
|
||||
HASH_TESTING_ENGINE hash;
|
||||
RSA_TESTING_ENGINE rsa;
|
||||
|
@ -171,8 +155,7 @@ static void host_irq_handler_pfm_check_test_init_null (CuTest *test)
|
|||
struct bmc_recovery_mock recovery;
|
||||
struct host_control_mock control;
|
||||
struct host_irq_control_mock irq;
|
||||
struct pfm_manager_mock pfm_mgr;
|
||||
struct host_irq_handler_pfm_check handler;
|
||||
struct host_irq_handler_auth_check handler;
|
||||
int status;
|
||||
|
||||
TEST_START;
|
||||
|
@ -195,35 +178,28 @@ static void host_irq_handler_pfm_check_test_init_null (CuTest *test)
|
|||
status = host_irq_control_mock_init (&irq);
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
status = pfm_manager_mock_init (&pfm_mgr);
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
status = host_irq_handler_pfm_check_init (NULL, &host.base, &hash.base, &rsa.base,
|
||||
&recovery.base, &control.base, &irq.base, &pfm_mgr.base);
|
||||
status = host_irq_handler_auth_check_init (NULL, &host.base, &hash.base, &rsa.base,
|
||||
&recovery.base, &control.base, &irq.base);
|
||||
CuAssertIntEquals (test, HOST_IRQ_HANDLER_INVALID_ARGUMENT, status);
|
||||
|
||||
status = host_irq_handler_pfm_check_init (&handler, NULL, &hash.base, &rsa.base,
|
||||
&recovery.base, &control.base, &irq.base, &pfm_mgr.base);
|
||||
status = host_irq_handler_auth_check_init (&handler, NULL, &hash.base, &rsa.base,
|
||||
&recovery.base, &control.base, &irq.base);
|
||||
CuAssertIntEquals (test, HOST_IRQ_HANDLER_INVALID_ARGUMENT, status);
|
||||
|
||||
status = host_irq_handler_pfm_check_init (&handler, &host.base, NULL, &rsa.base,
|
||||
&recovery.base, &control.base, &irq.base, &pfm_mgr.base);
|
||||
status = host_irq_handler_auth_check_init (&handler, &host.base, NULL, &rsa.base,
|
||||
&recovery.base, &control.base, &irq.base);
|
||||
CuAssertIntEquals (test, HOST_IRQ_HANDLER_INVALID_ARGUMENT, status);
|
||||
|
||||
status = host_irq_handler_pfm_check_init (&handler, &host.base, &hash.base, NULL,
|
||||
&recovery.base, &control.base, &irq.base, &pfm_mgr.base);
|
||||
status = host_irq_handler_auth_check_init (&handler, &host.base, &hash.base, NULL,
|
||||
&recovery.base, &control.base, &irq.base);
|
||||
CuAssertIntEquals (test, HOST_IRQ_HANDLER_INVALID_ARGUMENT, status);
|
||||
|
||||
status = host_irq_handler_pfm_check_init (&handler, &host.base, &hash.base, &rsa.base,
|
||||
&recovery.base, NULL, &irq.base, &pfm_mgr.base);
|
||||
status = host_irq_handler_auth_check_init (&handler, &host.base, &hash.base, &rsa.base,
|
||||
&recovery.base, NULL, &irq.base);
|
||||
CuAssertIntEquals (test, HOST_IRQ_HANDLER_INVALID_ARGUMENT, status);
|
||||
|
||||
status = host_irq_handler_pfm_check_init (&handler, &host.base, &hash.base, &rsa.base,
|
||||
&recovery.base, &control.base, NULL, &pfm_mgr.base);
|
||||
CuAssertIntEquals (test, HOST_IRQ_HANDLER_INVALID_ARGUMENT, status);
|
||||
|
||||
status = host_irq_handler_pfm_check_init (&handler, &host.base, &hash.base, &rsa.base,
|
||||
&recovery.base, &control.base, &irq.base, NULL);
|
||||
status = host_irq_handler_auth_check_init (&handler, &host.base, &hash.base, &rsa.base,
|
||||
&recovery.base, &control.base, NULL);
|
||||
CuAssertIntEquals (test, HOST_IRQ_HANDLER_INVALID_ARGUMENT, status);
|
||||
|
||||
status = host_processor_mock_validate_and_release (&host);
|
||||
|
@ -238,15 +214,12 @@ static void host_irq_handler_pfm_check_test_init_null (CuTest *test)
|
|||
status = mock_validate (&irq.mock);
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
status = pfm_manager_mock_validate_and_release (&pfm_mgr);
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
host_irq_control_mock_release (&irq);
|
||||
HASH_TESTING_ENGINE_RELEASE (&hash);
|
||||
RSA_TESTING_ENGINE_RELEASE (&rsa);
|
||||
}
|
||||
|
||||
static void host_irq_handler_pfm_check_test_init_error_irq (CuTest *test)
|
||||
static void host_irq_handler_auth_check_test_init_error_irq (CuTest *test)
|
||||
{
|
||||
HASH_TESTING_ENGINE hash;
|
||||
RSA_TESTING_ENGINE rsa;
|
||||
|
@ -254,8 +227,7 @@ static void host_irq_handler_pfm_check_test_init_error_irq (CuTest *test)
|
|||
struct bmc_recovery_mock recovery;
|
||||
struct host_control_mock control;
|
||||
struct host_irq_control_mock irq;
|
||||
struct pfm_manager_mock pfm_mgr;
|
||||
struct host_irq_handler_pfm_check handler;
|
||||
struct host_irq_handler_auth_check handler;
|
||||
int status;
|
||||
|
||||
TEST_START;
|
||||
|
@ -278,15 +250,12 @@ static void host_irq_handler_pfm_check_test_init_error_irq (CuTest *test)
|
|||
status = host_irq_control_mock_init (&irq);
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
status = pfm_manager_mock_init (&pfm_mgr);
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
status = mock_expect (&irq.mock, irq.base.enable_exit_reset, &irq,
|
||||
HOST_IRQ_HANDLER_EXIT_RESET_FAILED, MOCK_ARG (true));
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
status = host_irq_handler_pfm_check_init (&handler, &host.base, &hash.base, &rsa.base,
|
||||
&recovery.base, &control.base, &irq.base, &pfm_mgr.base);
|
||||
status = host_irq_handler_auth_check_init (&handler, &host.base, &hash.base, &rsa.base,
|
||||
&recovery.base, &control.base, &irq.base);
|
||||
CuAssertIntEquals (test, HOST_IRQ_HANDLER_EXIT_RESET_FAILED, status);
|
||||
|
||||
status = host_processor_mock_validate_and_release (&host);
|
||||
|
@ -301,22 +270,19 @@ static void host_irq_handler_pfm_check_test_init_error_irq (CuTest *test)
|
|||
status = mock_validate (&irq.mock);
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
status = pfm_manager_mock_validate_and_release (&pfm_mgr);
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
host_irq_control_mock_release (&irq);
|
||||
HASH_TESTING_ENGINE_RELEASE (&hash);
|
||||
RSA_TESTING_ENGINE_RELEASE (&rsa);
|
||||
}
|
||||
|
||||
static void host_irq_handler_pfm_check_test_release_null (CuTest *test)
|
||||
static void host_irq_handler_auth_check_test_release_null (CuTest *test)
|
||||
{
|
||||
TEST_START;
|
||||
|
||||
host_irq_handler_pfm_check_release (NULL);
|
||||
host_irq_handler_auth_check_release (NULL);
|
||||
}
|
||||
|
||||
static void host_irq_handler_pfm_check_test_release_error_irq (CuTest *test)
|
||||
static void host_irq_handler_auth_check_test_release_error_irq (CuTest *test)
|
||||
{
|
||||
HASH_TESTING_ENGINE hash;
|
||||
RSA_TESTING_ENGINE rsa;
|
||||
|
@ -324,8 +290,7 @@ static void host_irq_handler_pfm_check_test_release_error_irq (CuTest *test)
|
|||
struct bmc_recovery_mock recovery;
|
||||
struct host_control_mock control;
|
||||
struct host_irq_control_mock irq;
|
||||
struct pfm_manager_mock pfm_mgr;
|
||||
struct host_irq_handler_pfm_check handler;
|
||||
struct host_irq_handler_auth_check handler;
|
||||
int status;
|
||||
|
||||
TEST_START;
|
||||
|
@ -348,14 +313,11 @@ static void host_irq_handler_pfm_check_test_release_error_irq (CuTest *test)
|
|||
status = host_irq_control_mock_init (&irq);
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
status = pfm_manager_mock_init (&pfm_mgr);
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
status = mock_expect (&irq.mock, irq.base.enable_exit_reset, &irq, 0, MOCK_ARG (true));
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
status = host_irq_handler_pfm_check_init (&handler, &host.base, &hash.base, &rsa.base,
|
||||
&recovery.base, &control.base, &irq.base, &pfm_mgr.base);
|
||||
status = host_irq_handler_auth_check_init (&handler, &host.base, &hash.base, &rsa.base,
|
||||
&recovery.base, &control.base, &irq.base);
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
status = host_processor_mock_validate_and_release (&host);
|
||||
|
@ -370,14 +332,11 @@ static void host_irq_handler_pfm_check_test_release_error_irq (CuTest *test)
|
|||
status = mock_validate (&irq.mock);
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
status = pfm_manager_mock_validate_and_release (&pfm_mgr);
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
status = mock_expect (&irq.mock, irq.base.enable_exit_reset, &irq,
|
||||
HOST_IRQ_HANDLER_EXIT_RESET_FAILED, MOCK_ARG (false));
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
host_irq_handler_pfm_check_release (&handler);
|
||||
host_irq_handler_auth_check_release (&handler);
|
||||
|
||||
status = host_irq_control_mock_validate_and_release (&irq);
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
@ -386,7 +345,7 @@ static void host_irq_handler_pfm_check_test_release_error_irq (CuTest *test)
|
|||
RSA_TESTING_ENGINE_RELEASE (&rsa);
|
||||
}
|
||||
|
||||
static void host_irq_handler_pfm_check_test_exit_reset_no_pending_pfm (CuTest *test)
|
||||
static void host_irq_handler_auth_check_test_exit_reset_no_pending_auth (CuTest *test)
|
||||
{
|
||||
HASH_TESTING_ENGINE hash;
|
||||
RSA_TESTING_ENGINE rsa;
|
||||
|
@ -394,8 +353,7 @@ static void host_irq_handler_pfm_check_test_exit_reset_no_pending_pfm (CuTest *t
|
|||
struct bmc_recovery_mock recovery;
|
||||
struct host_control_mock control;
|
||||
struct host_irq_control_mock irq;
|
||||
struct pfm_manager_mock pfm_mgr;
|
||||
struct host_irq_handler_pfm_check handler;
|
||||
struct host_irq_handler_auth_check handler;
|
||||
int status;
|
||||
|
||||
TEST_START;
|
||||
|
@ -418,18 +376,16 @@ static void host_irq_handler_pfm_check_test_exit_reset_no_pending_pfm (CuTest *t
|
|||
status = host_irq_control_mock_init (&irq);
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
status = pfm_manager_mock_init (&pfm_mgr);
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
status = mock_expect (&irq.mock, irq.base.enable_exit_reset, &irq, 0, MOCK_ARG (true));
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
status = host_irq_handler_pfm_check_init (&handler, &host.base, &hash.base, &rsa.base,
|
||||
&recovery.base, &control.base, &irq.base, &pfm_mgr.base);
|
||||
status = host_irq_handler_auth_check_init (&handler, &host.base, &hash.base, &rsa.base,
|
||||
&recovery.base, &control.base, &irq.base);
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
status = mock_expect (&recovery.mock, recovery.base.on_host_out_of_reset, &recovery, 0);
|
||||
status |= mock_expect (&pfm_mgr.mock, pfm_mgr.base.get_pending_pfm, &pfm_mgr, (intptr_t) NULL);
|
||||
status |= mock_expect (&host.mock, host.base.get_next_reset_verification_actions, &host,
|
||||
HOST_PROCESSOR_ACTION_NONE);
|
||||
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
|
@ -447,17 +403,14 @@ static void host_irq_handler_pfm_check_test_exit_reset_no_pending_pfm (CuTest *t
|
|||
status = mock_validate (&irq.mock);
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
status = pfm_manager_mock_validate_and_release (&pfm_mgr);
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
host_irq_handler_pfm_check_release (&handler);
|
||||
host_irq_handler_auth_check_release (&handler);
|
||||
|
||||
host_irq_control_mock_release (&irq);
|
||||
HASH_TESTING_ENGINE_RELEASE (&hash);
|
||||
RSA_TESTING_ENGINE_RELEASE (&rsa);
|
||||
}
|
||||
|
||||
static void host_irq_handler_pfm_check_test_exit_reset_with_pending_pfm (CuTest *test)
|
||||
static void host_irq_handler_auth_check_test_exit_reset_with_pending_auth (CuTest *test)
|
||||
{
|
||||
HASH_TESTING_ENGINE hash;
|
||||
RSA_TESTING_ENGINE rsa;
|
||||
|
@ -465,10 +418,8 @@ static void host_irq_handler_pfm_check_test_exit_reset_with_pending_pfm (CuTest
|
|||
struct bmc_recovery_mock recovery;
|
||||
struct host_control_mock control;
|
||||
struct host_irq_control_mock irq;
|
||||
struct pfm_manager_mock pfm_mgr;
|
||||
struct host_irq_handler_pfm_check handler;
|
||||
struct host_irq_handler_auth_check handler;
|
||||
int status;
|
||||
struct pfm_mock pfm;
|
||||
|
||||
TEST_START;
|
||||
|
||||
|
@ -490,23 +441,16 @@ static void host_irq_handler_pfm_check_test_exit_reset_with_pending_pfm (CuTest
|
|||
status = host_irq_control_mock_init (&irq);
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
status = pfm_manager_mock_init (&pfm_mgr);
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
status = pfm_mock_init (&pfm);
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
status = mock_expect (&irq.mock, irq.base.enable_exit_reset, &irq, 0, MOCK_ARG (true));
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
status = host_irq_handler_pfm_check_init (&handler, &host.base, &hash.base, &rsa.base,
|
||||
&recovery.base, &control.base, &irq.base, &pfm_mgr.base);
|
||||
status = host_irq_handler_auth_check_init (&handler, &host.base, &hash.base, &rsa.base,
|
||||
&recovery.base, &control.base, &irq.base);
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
status = mock_expect (&recovery.mock, recovery.base.on_host_out_of_reset, &recovery, 0);
|
||||
|
||||
status |= mock_expect (&pfm_mgr.mock, pfm_mgr.base.get_pending_pfm, &pfm_mgr, (intptr_t) &pfm);
|
||||
status |= mock_expect (&pfm_mgr.mock, pfm_mgr.base.free_pfm, &pfm_mgr, 0, MOCK_ARG (&pfm));
|
||||
status |= mock_expect (&host.mock, host.base.get_next_reset_verification_actions, &host,
|
||||
HOST_PROCESSOR_ACTION_VERIFY_UPDATE);
|
||||
|
||||
status |= mock_expect (&control.mock, control.base.hold_processor_in_reset, &control, 0,
|
||||
MOCK_ARG (true));
|
||||
|
@ -527,20 +471,14 @@ static void host_irq_handler_pfm_check_test_exit_reset_with_pending_pfm (CuTest
|
|||
status = mock_validate (&irq.mock);
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
status = pfm_manager_mock_validate_and_release (&pfm_mgr);
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
status = pfm_mock_validate_and_release (&pfm);
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
host_irq_handler_pfm_check_release (&handler);
|
||||
host_irq_handler_auth_check_release (&handler);
|
||||
|
||||
host_irq_control_mock_release (&irq);
|
||||
HASH_TESTING_ENGINE_RELEASE (&hash);
|
||||
RSA_TESTING_ENGINE_RELEASE (&rsa);
|
||||
}
|
||||
|
||||
static void host_irq_handler_pfm_check_test_exit_reset_null (CuTest *test)
|
||||
static void host_irq_handler_auth_check_test_exit_reset_null (CuTest *test)
|
||||
{
|
||||
HASH_TESTING_ENGINE hash;
|
||||
RSA_TESTING_ENGINE rsa;
|
||||
|
@ -548,8 +486,7 @@ static void host_irq_handler_pfm_check_test_exit_reset_null (CuTest *test)
|
|||
struct bmc_recovery_mock recovery;
|
||||
struct host_control_mock control;
|
||||
struct host_irq_control_mock irq;
|
||||
struct pfm_manager_mock pfm_mgr;
|
||||
struct host_irq_handler_pfm_check handler;
|
||||
struct host_irq_handler_auth_check handler;
|
||||
int status;
|
||||
|
||||
TEST_START;
|
||||
|
@ -572,14 +509,11 @@ static void host_irq_handler_pfm_check_test_exit_reset_null (CuTest *test)
|
|||
status = host_irq_control_mock_init (&irq);
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
status = pfm_manager_mock_init (&pfm_mgr);
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
status = mock_expect (&irq.mock, irq.base.enable_exit_reset, &irq, 0, MOCK_ARG (true));
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
status = host_irq_handler_pfm_check_init (&handler, &host.base, &hash.base, &rsa.base,
|
||||
&recovery.base, &control.base, &irq.base, &pfm_mgr.base);
|
||||
status = host_irq_handler_auth_check_init (&handler, &host.base, &hash.base, &rsa.base,
|
||||
&recovery.base, &control.base, &irq.base);
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
handler.base.exit_reset (NULL);
|
||||
|
@ -596,10 +530,7 @@ static void host_irq_handler_pfm_check_test_exit_reset_null (CuTest *test)
|
|||
status = mock_validate (&irq.mock);
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
status = pfm_manager_mock_validate_and_release (&pfm_mgr);
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
host_irq_handler_pfm_check_release (&handler);
|
||||
host_irq_handler_auth_check_release (&handler);
|
||||
|
||||
host_irq_control_mock_release (&irq);
|
||||
HASH_TESTING_ENGINE_RELEASE (&hash);
|
||||
|
@ -607,19 +538,19 @@ static void host_irq_handler_pfm_check_test_exit_reset_null (CuTest *test)
|
|||
}
|
||||
|
||||
|
||||
CuSuite* get_host_irq_handler_pfm_check_suite ()
|
||||
CuSuite* get_host_irq_handler_auth_check_suite ()
|
||||
{
|
||||
CuSuite *suite = CuSuiteNew ();
|
||||
|
||||
SUITE_ADD_TEST (suite, host_irq_handler_pfm_check_test_init);
|
||||
SUITE_ADD_TEST (suite, host_irq_handler_pfm_check_test_init_no_recovery);
|
||||
SUITE_ADD_TEST (suite, host_irq_handler_pfm_check_test_init_null);
|
||||
SUITE_ADD_TEST (suite, host_irq_handler_pfm_check_test_init_error_irq);
|
||||
SUITE_ADD_TEST (suite, host_irq_handler_pfm_check_test_release_null);
|
||||
SUITE_ADD_TEST (suite, host_irq_handler_pfm_check_test_release_error_irq);
|
||||
SUITE_ADD_TEST (suite, host_irq_handler_pfm_check_test_exit_reset_no_pending_pfm);
|
||||
SUITE_ADD_TEST (suite, host_irq_handler_pfm_check_test_exit_reset_with_pending_pfm);
|
||||
SUITE_ADD_TEST (suite, host_irq_handler_pfm_check_test_exit_reset_null);
|
||||
SUITE_ADD_TEST (suite, host_irq_handler_auth_check_test_init);
|
||||
SUITE_ADD_TEST (suite, host_irq_handler_auth_check_test_init_no_recovery);
|
||||
SUITE_ADD_TEST (suite, host_irq_handler_auth_check_test_init_null);
|
||||
SUITE_ADD_TEST (suite, host_irq_handler_auth_check_test_init_error_irq);
|
||||
SUITE_ADD_TEST (suite, host_irq_handler_auth_check_test_release_null);
|
||||
SUITE_ADD_TEST (suite, host_irq_handler_auth_check_test_release_error_irq);
|
||||
SUITE_ADD_TEST (suite, host_irq_handler_auth_check_test_exit_reset_no_pending_auth);
|
||||
SUITE_ADD_TEST (suite, host_irq_handler_auth_check_test_exit_reset_with_pending_auth);
|
||||
SUITE_ADD_TEST (suite, host_irq_handler_auth_check_test_exit_reset_null);
|
||||
|
||||
return suite;
|
||||
}
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -43,7 +43,7 @@ static void host_processor_dual_testing_init_dependencies (CuTest *test,
|
|||
status = pfm_mock_init (&host->pfm_next);
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
status = host_flash_manager_mock_init (&host->flash_mgr);
|
||||
status = host_flash_manager_dual_mock_init (&host->flash_mgr);
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
status = recovery_image_manager_mock_init (&host->recovery_manager);
|
||||
|
@ -95,7 +95,7 @@ void host_processor_dual_testing_init_pulse_reset (CuTest *test,
|
|||
|
||||
status = host_processor_dual_init_pulse_reset (&host->test, &host->control.base,
|
||||
&host->flash_mgr.base, &host->host_state, &host->filter.base, &host->pfm_mgr.base,
|
||||
&host->recovery_manager.base);
|
||||
&host->recovery_manager.base, 100);
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
status = host_processor_add_observer (&host->test.base, &host->observer.base);
|
||||
|
@ -137,7 +137,8 @@ void host_processor_dual_testing_init_no_recovery_pulse_reset (CuTest *test,
|
|||
host_processor_dual_testing_init_dependencies (test, host);
|
||||
|
||||
status = host_processor_dual_init_pulse_reset (&host->test, &host->control.base,
|
||||
&host->flash_mgr.base, &host->host_state, &host->filter.base, &host->pfm_mgr.base, NULL);
|
||||
&host->flash_mgr.base, &host->host_state, &host->filter.base, &host->pfm_mgr.base, NULL,
|
||||
100);
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
status = host_processor_add_observer (&host->test.base, &host->observer.base);
|
||||
|
@ -173,7 +174,7 @@ void host_processor_dual_testing_validate_and_release (CuTest *test,
|
|||
status = pfm_mock_validate_and_release (&host->pfm_next);
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
status = host_flash_manager_mock_validate_and_release (&host->flash_mgr);
|
||||
status = host_flash_manager_dual_mock_validate_and_release (&host->flash_mgr);
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
status = recovery_image_manager_mock_validate_and_release (&host->recovery_manager);
|
||||
|
@ -201,7 +202,7 @@ void host_processor_dual_testing_validate_and_release (CuTest *test,
|
|||
* @param flash_mock The mock for the flash state storage.
|
||||
* @param flash The flash device to initialize for state.
|
||||
*/
|
||||
void host_processor_dual_testing_init_host_state (CuTest *test, struct state_manager *state,
|
||||
void host_processor_dual_testing_init_host_state (CuTest *test, struct host_state_manager *state,
|
||||
struct flash_master_mock *flash_mock, struct spi_flash *flash)
|
||||
{
|
||||
int status;
|
||||
|
@ -243,12 +244,12 @@ static void host_processor_dual_test_init (CuTest *test)
|
|||
{
|
||||
struct flash_master_mock flash_mock_state;
|
||||
struct spi_flash flash_state;
|
||||
struct state_manager host_state;
|
||||
struct host_state_manager host_state;
|
||||
struct spi_filter_interface_mock filter;
|
||||
struct host_flash_manager_mock flash_mgr;
|
||||
struct host_flash_manager_dual_mock flash_mgr;
|
||||
struct host_control_mock control;
|
||||
struct pfm_manager_mock pfm_mgr;
|
||||
struct host_processor_dual host;
|
||||
struct host_processor_filtered host;
|
||||
int status;
|
||||
|
||||
TEST_START;
|
||||
|
@ -262,7 +263,7 @@ static void host_processor_dual_test_init (CuTest *test)
|
|||
status = pfm_manager_mock_init (&pfm_mgr);
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
status = host_flash_manager_mock_init (&flash_mgr);
|
||||
status = host_flash_manager_dual_mock_init (&flash_mgr);
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
host_processor_dual_testing_init_host_state (test, &host_state, &flash_mock_state,
|
||||
|
@ -295,7 +296,7 @@ static void host_processor_dual_test_init (CuTest *test)
|
|||
status = pfm_manager_mock_validate_and_release (&pfm_mgr);
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
status = host_flash_manager_mock_validate_and_release (&flash_mgr);
|
||||
status = host_flash_manager_dual_mock_validate_and_release (&flash_mgr);
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
host_processor_dual_release (&host);
|
||||
|
@ -308,12 +309,12 @@ static void host_processor_dual_test_init_null (CuTest *test)
|
|||
{
|
||||
struct flash_master_mock flash_mock_state;
|
||||
struct spi_flash flash_state;
|
||||
struct state_manager host_state;
|
||||
struct host_state_manager host_state;
|
||||
struct spi_filter_interface_mock filter;
|
||||
struct host_flash_manager_mock flash_mgr;
|
||||
struct host_flash_manager_dual_mock flash_mgr;
|
||||
struct host_control_mock control;
|
||||
struct pfm_manager_mock pfm_mgr;
|
||||
struct host_processor_dual host;
|
||||
struct host_processor_filtered host;
|
||||
int status;
|
||||
|
||||
TEST_START;
|
||||
|
@ -327,7 +328,7 @@ static void host_processor_dual_test_init_null (CuTest *test)
|
|||
status = pfm_manager_mock_init (&pfm_mgr);
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
status = host_flash_manager_mock_init (&flash_mgr);
|
||||
status = host_flash_manager_dual_mock_init (&flash_mgr);
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
host_processor_dual_testing_init_host_state (test, &host_state, &flash_mock_state,
|
||||
|
@ -369,7 +370,7 @@ static void host_processor_dual_test_init_null (CuTest *test)
|
|||
status = pfm_manager_mock_validate_and_release (&pfm_mgr);
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
status = host_flash_manager_mock_validate_and_release (&flash_mgr);
|
||||
status = host_flash_manager_dual_mock_validate_and_release (&flash_mgr);
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
host_state_manager_release (&host_state);
|
||||
|
@ -380,12 +381,12 @@ static void host_processor_dual_test_init_pulse_reset (CuTest *test)
|
|||
{
|
||||
struct flash_master_mock flash_mock_state;
|
||||
struct spi_flash flash_state;
|
||||
struct state_manager host_state;
|
||||
struct host_state_manager host_state;
|
||||
struct spi_filter_interface_mock filter;
|
||||
struct host_flash_manager_mock flash_mgr;
|
||||
struct host_flash_manager_dual_mock flash_mgr;
|
||||
struct host_control_mock control;
|
||||
struct pfm_manager_mock pfm_mgr;
|
||||
struct host_processor_dual host;
|
||||
struct host_processor_filtered host;
|
||||
int status;
|
||||
|
||||
TEST_START;
|
||||
|
@ -399,14 +400,14 @@ static void host_processor_dual_test_init_pulse_reset (CuTest *test)
|
|||
status = pfm_manager_mock_init (&pfm_mgr);
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
status = host_flash_manager_mock_init (&flash_mgr);
|
||||
status = host_flash_manager_dual_mock_init (&flash_mgr);
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
host_processor_dual_testing_init_host_state (test, &host_state, &flash_mock_state,
|
||||
&flash_state);
|
||||
|
||||
status = host_processor_dual_init_pulse_reset (&host, &control.base, &flash_mgr.base,
|
||||
&host_state, &filter.base, &pfm_mgr.base, NULL);
|
||||
&host_state, &filter.base, &pfm_mgr.base, NULL, 100);
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
CuAssertIntEquals (test, 0, host_processor_get_port (&host.base));
|
||||
|
||||
|
@ -432,7 +433,7 @@ static void host_processor_dual_test_init_pulse_reset (CuTest *test)
|
|||
status = pfm_manager_mock_validate_and_release (&pfm_mgr);
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
status = host_flash_manager_mock_validate_and_release (&flash_mgr);
|
||||
status = host_flash_manager_dual_mock_validate_and_release (&flash_mgr);
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
host_processor_dual_release (&host);
|
||||
|
@ -445,12 +446,12 @@ static void host_processor_dual_test_init_pulse_reset_null (CuTest *test)
|
|||
{
|
||||
struct flash_master_mock flash_mock_state;
|
||||
struct spi_flash flash_state;
|
||||
struct state_manager host_state;
|
||||
struct host_state_manager host_state;
|
||||
struct spi_filter_interface_mock filter;
|
||||
struct host_flash_manager_mock flash_mgr;
|
||||
struct host_flash_manager_dual_mock flash_mgr;
|
||||
struct host_control_mock control;
|
||||
struct pfm_manager_mock pfm_mgr;
|
||||
struct host_processor_dual host;
|
||||
struct host_processor_filtered host;
|
||||
int status;
|
||||
|
||||
TEST_START;
|
||||
|
@ -464,34 +465,34 @@ static void host_processor_dual_test_init_pulse_reset_null (CuTest *test)
|
|||
status = pfm_manager_mock_init (&pfm_mgr);
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
status = host_flash_manager_mock_init (&flash_mgr);
|
||||
status = host_flash_manager_dual_mock_init (&flash_mgr);
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
host_processor_dual_testing_init_host_state (test, &host_state, &flash_mock_state,
|
||||
&flash_state);
|
||||
|
||||
status = host_processor_dual_init_pulse_reset (NULL, &control.base, &flash_mgr.base,
|
||||
&host_state, &filter.base, &pfm_mgr.base, NULL);
|
||||
&host_state, &filter.base, &pfm_mgr.base, NULL, 100);
|
||||
CuAssertIntEquals (test, HOST_PROCESSOR_INVALID_ARGUMENT, status);
|
||||
|
||||
status = host_processor_dual_init_pulse_reset (&host, NULL, &flash_mgr.base,
|
||||
&host_state, &filter.base, &pfm_mgr.base, NULL);
|
||||
&host_state, &filter.base, &pfm_mgr.base, NULL, 100);
|
||||
CuAssertIntEquals (test, HOST_PROCESSOR_INVALID_ARGUMENT, status);
|
||||
|
||||
status = host_processor_dual_init_pulse_reset (&host, &control.base, NULL,
|
||||
&host_state, &filter.base, &pfm_mgr.base, NULL);
|
||||
&host_state, &filter.base, &pfm_mgr.base, NULL, 100);
|
||||
CuAssertIntEquals (test, HOST_PROCESSOR_INVALID_ARGUMENT, status);
|
||||
|
||||
status = host_processor_dual_init_pulse_reset (&host, &control.base, &flash_mgr.base,
|
||||
NULL, &filter.base, &pfm_mgr.base, NULL);
|
||||
NULL, &filter.base, &pfm_mgr.base, NULL, 100);
|
||||
CuAssertIntEquals (test, HOST_PROCESSOR_INVALID_ARGUMENT, status);
|
||||
|
||||
status = host_processor_dual_init_pulse_reset (&host, &control.base, &flash_mgr.base,
|
||||
&host_state, NULL, &pfm_mgr.base, NULL);
|
||||
&host_state, NULL, &pfm_mgr.base, NULL, 100);
|
||||
CuAssertIntEquals (test, HOST_PROCESSOR_INVALID_ARGUMENT, status);
|
||||
|
||||
status = host_processor_dual_init_pulse_reset (&host, &control.base, &flash_mgr.base,
|
||||
&host_state, &filter.base, NULL, NULL);
|
||||
&host_state, &filter.base, NULL, NULL, 100);
|
||||
CuAssertIntEquals (test, HOST_PROCESSOR_INVALID_ARGUMENT, status);
|
||||
|
||||
status = flash_master_mock_validate_and_release (&flash_mock_state);
|
||||
|
@ -506,7 +507,63 @@ static void host_processor_dual_test_init_pulse_reset_null (CuTest *test)
|
|||
status = pfm_manager_mock_validate_and_release (&pfm_mgr);
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
status = host_flash_manager_mock_validate_and_release (&flash_mgr);
|
||||
status = host_flash_manager_dual_mock_validate_and_release (&flash_mgr);
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
host_state_manager_release (&host_state);
|
||||
spi_flash_release (&flash_state);
|
||||
}
|
||||
|
||||
static void host_processor_dual_test_init_pulse_reset_invalid_pulse_width (CuTest *test)
|
||||
{
|
||||
struct flash_master_mock flash_mock_state;
|
||||
struct spi_flash flash_state;
|
||||
struct host_state_manager host_state;
|
||||
struct spi_filter_interface_mock filter;
|
||||
struct host_flash_manager_dual_mock flash_mgr;
|
||||
struct host_control_mock control;
|
||||
struct pfm_manager_mock pfm_mgr;
|
||||
struct host_processor_filtered host;
|
||||
int status;
|
||||
|
||||
TEST_START;
|
||||
|
||||
status = spi_filter_interface_mock_init (&filter);
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
status = host_control_mock_init (&control);
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
status = pfm_manager_mock_init (&pfm_mgr);
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
status = host_flash_manager_dual_mock_init (&flash_mgr);
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
host_processor_dual_testing_init_host_state (test, &host_state, &flash_mock_state,
|
||||
&flash_state);
|
||||
|
||||
status = host_processor_dual_init_pulse_reset (&host, &control.base, &flash_mgr.base,
|
||||
&host_state, &filter.base, &pfm_mgr.base, NULL, 0);
|
||||
CuAssertIntEquals (test, HOST_PROCESSOR_INVALID_ARGUMENT, status);
|
||||
|
||||
status = host_processor_dual_init_pulse_reset (&host, &control.base, &flash_mgr.base,
|
||||
&host_state, &filter.base, &pfm_mgr.base, NULL, -1);
|
||||
CuAssertIntEquals (test, HOST_PROCESSOR_INVALID_ARGUMENT, status);
|
||||
|
||||
status = flash_master_mock_validate_and_release (&flash_mock_state);
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
status = spi_filter_interface_mock_validate_and_release (&filter);
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
status = host_control_mock_validate_and_release (&control);
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
status = pfm_manager_mock_validate_and_release (&pfm_mgr);
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
status = host_flash_manager_dual_mock_validate_and_release (&flash_mgr);
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
host_state_manager_release (&host_state);
|
||||
|
@ -529,7 +586,7 @@ static void host_processor_dual_test_needs_config_recovery (CuTest *test)
|
|||
|
||||
host_processor_dual_testing_init (test, &host);
|
||||
|
||||
status = mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.host_has_flash_access,
|
||||
status = mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.base.host_has_flash_access,
|
||||
&host.flash_mgr, 1, MOCK_ARG(&host.control));
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
|
@ -548,7 +605,7 @@ static void host_processor_dual_test_needs_config_recovery_no_host_access (CuTes
|
|||
|
||||
host_processor_dual_testing_init (test, &host);
|
||||
|
||||
status = mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.host_has_flash_access,
|
||||
status = mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.base.host_has_flash_access,
|
||||
&host.flash_mgr, 0, MOCK_ARG(&host.control));
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
|
@ -582,7 +639,7 @@ static void host_processor_dual_test_needs_config_recovery_check_access_error (C
|
|||
|
||||
host_processor_dual_testing_init (test, &host);
|
||||
|
||||
status = mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.host_has_flash_access,
|
||||
status = mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.base.host_has_flash_access,
|
||||
&host.flash_mgr, HOST_FLASH_MGR_CHECK_ACCESS_FAILED, MOCK_ARG(&host.control));
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
|
@ -2142,6 +2199,7 @@ CuSuite* get_host_processor_dual_suite ()
|
|||
SUITE_ADD_TEST (suite, host_processor_dual_test_init_null);
|
||||
SUITE_ADD_TEST (suite, host_processor_dual_test_init_pulse_reset);
|
||||
SUITE_ADD_TEST (suite, host_processor_dual_test_init_pulse_reset_null);
|
||||
SUITE_ADD_TEST (suite, host_processor_dual_test_init_pulse_reset_invalid_pulse_width);
|
||||
SUITE_ADD_TEST (suite, host_processor_dual_test_release_null);
|
||||
SUITE_ADD_TEST (suite, host_processor_dual_test_needs_config_recovery);
|
||||
SUITE_ADD_TEST (suite, host_processor_dual_test_needs_config_recovery_no_host_access);
|
||||
|
|
|
@ -33,11 +33,11 @@ static void host_processor_dual_test_apply_recovery_image (CuTest *test)
|
|||
status = mock_expect (&host.control.mock, host.control.base.hold_processor_in_reset,
|
||||
&host.control, 0, MOCK_ARG (true));
|
||||
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.set_flash_for_rot_access,
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.base.set_flash_for_rot_access,
|
||||
&host.flash_mgr, 0, MOCK_ARG (&host.control));
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
status = mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.get_read_only_flash,
|
||||
status = mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.base.get_read_only_flash,
|
||||
&host.flash_mgr, (intptr_t) &host.flash_state);
|
||||
|
||||
status |= mock_expect (&host.observer.mock, host.observer.base.on_recovery, &host.observer, 0);
|
||||
|
@ -51,9 +51,9 @@ static void host_processor_dual_test_apply_recovery_image (CuTest *test)
|
|||
&host.filter, 0);
|
||||
|
||||
status |= mock_expect (&host.flash_mgr.mock,
|
||||
host.flash_mgr.base.config_spi_filter_flash_devices, &host.flash_mgr, 0);
|
||||
host.flash_mgr.base.base.config_spi_filter_flash_devices, &host.flash_mgr, 0);
|
||||
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.set_flash_for_host_access,
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.base.set_flash_for_host_access,
|
||||
&host.flash_mgr, 0, MOCK_ARG (&host.control));
|
||||
|
||||
status |= mock_expect (&host.control.mock, host.control.base.hold_processor_in_reset,
|
||||
|
@ -88,11 +88,11 @@ static void host_processor_dual_test_apply_recovery_image_pulse_reset (CuTest *t
|
|||
(intptr_t) &host.image.base);
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
status = mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.set_flash_for_rot_access,
|
||||
status = mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.base.set_flash_for_rot_access,
|
||||
&host.flash_mgr, 0, MOCK_ARG (&host.control));
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
status = mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.get_read_only_flash,
|
||||
status = mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.base.get_read_only_flash,
|
||||
&host.flash_mgr, (intptr_t) &host.flash_state);
|
||||
|
||||
status |= mock_expect (&host.observer.mock, host.observer.base.on_recovery, &host.observer, 0);
|
||||
|
@ -106,9 +106,9 @@ static void host_processor_dual_test_apply_recovery_image_pulse_reset (CuTest *t
|
|||
&host.filter, 0);
|
||||
|
||||
status |= mock_expect (&host.flash_mgr.mock,
|
||||
host.flash_mgr.base.config_spi_filter_flash_devices, &host.flash_mgr, 0);
|
||||
host.flash_mgr.base.base.config_spi_filter_flash_devices, &host.flash_mgr, 0);
|
||||
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.set_flash_for_host_access,
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.base.set_flash_for_host_access,
|
||||
&host.flash_mgr, 0, MOCK_ARG (&host.control));
|
||||
|
||||
status |= mock_expect (&host.control.mock, host.control.base.hold_processor_in_reset,
|
||||
|
@ -151,11 +151,11 @@ static void host_processor_dual_test_apply_recovery_image_no_observer (CuTest *t
|
|||
status = mock_expect (&host.control.mock, host.control.base.hold_processor_in_reset,
|
||||
&host.control, 0, MOCK_ARG (true));
|
||||
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.set_flash_for_rot_access,
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.base.set_flash_for_rot_access,
|
||||
&host.flash_mgr, 0, MOCK_ARG (&host.control));
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
status = mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.get_read_only_flash,
|
||||
status = mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.base.get_read_only_flash,
|
||||
&host.flash_mgr, (intptr_t) &host.flash_state);
|
||||
|
||||
status |= flash_master_mock_expect_chip_erase (&host.flash_mock_state);
|
||||
|
@ -167,9 +167,9 @@ static void host_processor_dual_test_apply_recovery_image_no_observer (CuTest *t
|
|||
&host.filter, 0);
|
||||
|
||||
status |= mock_expect (&host.flash_mgr.mock,
|
||||
host.flash_mgr.base.config_spi_filter_flash_devices, &host.flash_mgr, 0);
|
||||
host.flash_mgr.base.base.config_spi_filter_flash_devices, &host.flash_mgr, 0);
|
||||
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.set_flash_for_host_access,
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.base.set_flash_for_host_access,
|
||||
&host.flash_mgr, 0, MOCK_ARG (&host.control));
|
||||
|
||||
status |= mock_expect (&host.control.mock, host.control.base.hold_processor_in_reset,
|
||||
|
@ -209,11 +209,11 @@ static void host_processor_dual_test_apply_recovery_image_bypass (CuTest *test)
|
|||
status = mock_expect (&host.control.mock, host.control.base.hold_processor_in_reset,
|
||||
&host.control, 0, MOCK_ARG (true));
|
||||
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.set_flash_for_rot_access,
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.base.set_flash_for_rot_access,
|
||||
&host.flash_mgr, 0, MOCK_ARG (&host.control));
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
status = mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.get_read_only_flash,
|
||||
status = mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.base.get_read_only_flash,
|
||||
&host.flash_mgr, (intptr_t) &host.flash_state);
|
||||
|
||||
status |= mock_expect (&host.observer.mock, host.observer.base.on_recovery, &host.observer, 0);
|
||||
|
@ -223,7 +223,7 @@ static void host_processor_dual_test_apply_recovery_image_bypass (CuTest *test)
|
|||
status |= mock_expect (&host.image.mock, host.image.base.apply_to_flash, &host.image, 0,
|
||||
MOCK_ARG_NOT_NULL);
|
||||
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.set_flash_for_host_access,
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.base.set_flash_for_host_access,
|
||||
&host.flash_mgr, 0, MOCK_ARG (&host.control));
|
||||
|
||||
status |= mock_expect (&host.control.mock, host.control.base.hold_processor_in_reset,
|
||||
|
@ -258,11 +258,11 @@ static void host_processor_dual_test_apply_recovery_image_no_reset (CuTest *test
|
|||
(intptr_t) &host.image.base);
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.set_flash_for_rot_access,
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.base.set_flash_for_rot_access,
|
||||
&host.flash_mgr, 0, MOCK_ARG (&host.control));
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
status = mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.get_read_only_flash,
|
||||
status = mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.base.get_read_only_flash,
|
||||
&host.flash_mgr, (intptr_t) &host.flash_state);
|
||||
|
||||
status |= mock_expect (&host.observer.mock, host.observer.base.on_recovery, &host.observer, 0);
|
||||
|
@ -276,9 +276,9 @@ static void host_processor_dual_test_apply_recovery_image_no_reset (CuTest *test
|
|||
&host.filter, 0);
|
||||
|
||||
status |= mock_expect (&host.flash_mgr.mock,
|
||||
host.flash_mgr.base.config_spi_filter_flash_devices, &host.flash_mgr, 0);
|
||||
host.flash_mgr.base.base.config_spi_filter_flash_devices, &host.flash_mgr, 0);
|
||||
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.set_flash_for_host_access,
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.base.set_flash_for_host_access,
|
||||
&host.flash_mgr, 0, MOCK_ARG (&host.control));
|
||||
|
||||
status |= mock_expect (&host.recovery_manager.mock,
|
||||
|
@ -310,11 +310,11 @@ static void host_processor_dual_test_apply_recovery_image_no_reset_pulse_reset (
|
|||
(intptr_t) &host.image.base);
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.set_flash_for_rot_access,
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.base.set_flash_for_rot_access,
|
||||
&host.flash_mgr, 0, MOCK_ARG (&host.control));
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
status = mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.get_read_only_flash,
|
||||
status = mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.base.get_read_only_flash,
|
||||
&host.flash_mgr, (intptr_t) &host.flash_state);
|
||||
|
||||
status |= mock_expect (&host.observer.mock, host.observer.base.on_recovery, &host.observer, 0);
|
||||
|
@ -328,9 +328,9 @@ static void host_processor_dual_test_apply_recovery_image_no_reset_pulse_reset (
|
|||
&host.filter, 0);
|
||||
|
||||
status |= mock_expect (&host.flash_mgr.mock,
|
||||
host.flash_mgr.base.config_spi_filter_flash_devices, &host.flash_mgr, 0);
|
||||
host.flash_mgr.base.base.config_spi_filter_flash_devices, &host.flash_mgr, 0);
|
||||
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.set_flash_for_host_access,
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.base.set_flash_for_host_access,
|
||||
&host.flash_mgr, 0, MOCK_ARG (&host.control));
|
||||
|
||||
status |= mock_expect (&host.recovery_manager.mock,
|
||||
|
@ -471,11 +471,11 @@ static void host_processor_dual_test_apply_recovery_image_bypass_unsupported_fla
|
|||
status = mock_expect (&host.control.mock, host.control.base.hold_processor_in_reset,
|
||||
&host.control, 0, MOCK_ARG (true));
|
||||
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.set_flash_for_rot_access,
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.base.set_flash_for_rot_access,
|
||||
&host.flash_mgr, 0, MOCK_ARG (&host.control));
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
status = mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.get_read_only_flash,
|
||||
status = mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.base.get_read_only_flash,
|
||||
&host.flash_mgr, (intptr_t) &host.flash_state);
|
||||
|
||||
status |= mock_expect (&host.observer.mock, host.observer.base.on_recovery, &host.observer, 0);
|
||||
|
@ -485,7 +485,7 @@ static void host_processor_dual_test_apply_recovery_image_bypass_unsupported_fla
|
|||
status |= mock_expect (&host.image.mock, host.image.base.apply_to_flash, &host.image, 0,
|
||||
MOCK_ARG_NOT_NULL);
|
||||
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.set_flash_for_host_access,
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.base.set_flash_for_host_access,
|
||||
&host.flash_mgr, 0, MOCK_ARG (&host.control));
|
||||
|
||||
status |= mock_expect (&host.control.mock, host.control.base.hold_processor_in_reset,
|
||||
|
@ -539,10 +539,10 @@ static void host_processor_dual_test_apply_recovery_image_set_flash_for_rot_acce
|
|||
status = mock_expect (&host.control.mock, host.control.base.hold_processor_in_reset,
|
||||
&host.control, 0, MOCK_ARG (true));
|
||||
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.set_flash_for_rot_access,
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.base.set_flash_for_rot_access,
|
||||
&host.flash_mgr, HOST_CONTROL_FLASH_ACCESS_FAILED, MOCK_ARG (&host.control));
|
||||
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.set_flash_for_host_access,
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.base.set_flash_for_host_access,
|
||||
&host.flash_mgr, 0, MOCK_ARG (&host.control));
|
||||
|
||||
status |= mock_expect (&host.control.mock, host.control.base.hold_processor_in_reset,
|
||||
|
@ -578,10 +578,10 @@ static void host_processor_dual_test_apply_recovery_image_set_flash_for_rot_acce
|
|||
(intptr_t) &host.image.base);
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
status = mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.set_flash_for_rot_access,
|
||||
status = mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.base.set_flash_for_rot_access,
|
||||
&host.flash_mgr, HOST_CONTROL_FLASH_ACCESS_FAILED, MOCK_ARG (&host.control));
|
||||
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.set_flash_for_host_access,
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.base.set_flash_for_host_access,
|
||||
&host.flash_mgr, 0, MOCK_ARG (&host.control));
|
||||
|
||||
status = mock_expect (&host.control.mock, host.control.base.hold_processor_in_reset,
|
||||
|
@ -622,18 +622,18 @@ static void host_processor_dual_test_apply_recovery_image_set_flash_for_rot_acce
|
|||
status = mock_expect (&host.control.mock, host.control.base.hold_processor_in_reset,
|
||||
&host.control, 0, MOCK_ARG (true));
|
||||
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.set_flash_for_rot_access,
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.base.set_flash_for_rot_access,
|
||||
&host.flash_mgr, HOST_CONTROL_FLASH_ACCESS_FAILED, MOCK_ARG (&host.control));
|
||||
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.set_flash_for_host_access,
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.base.set_flash_for_host_access,
|
||||
&host.flash_mgr, HOST_FLASH_MGR_HOST_ACCESS_FAILED, MOCK_ARG (&host.control));
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.set_flash_for_host_access,
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.base.set_flash_for_host_access,
|
||||
&host.flash_mgr, HOST_FLASH_MGR_HOST_ACCESS_FAILED, MOCK_ARG (&host.control));
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.set_flash_for_host_access,
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.base.set_flash_for_host_access,
|
||||
&host.flash_mgr, HOST_FLASH_MGR_HOST_ACCESS_FAILED, MOCK_ARG (&host.control));
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.set_flash_for_host_access,
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.base.set_flash_for_host_access,
|
||||
&host.flash_mgr, HOST_FLASH_MGR_HOST_ACCESS_FAILED, MOCK_ARG (&host.control));
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.set_flash_for_host_access,
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.base.set_flash_for_host_access,
|
||||
&host.flash_mgr, 0, MOCK_ARG (&host.control));
|
||||
|
||||
status |= mock_expect (&host.control.mock, host.control.base.hold_processor_in_reset,
|
||||
|
@ -672,11 +672,11 @@ static void host_processor_dual_test_apply_recovery_image_chip_erase_error (
|
|||
status = mock_expect (&host.control.mock, host.control.base.hold_processor_in_reset,
|
||||
&host.control, 0, MOCK_ARG (true));
|
||||
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.set_flash_for_rot_access,
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.base.set_flash_for_rot_access,
|
||||
&host.flash_mgr, 0, MOCK_ARG (&host.control));
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
status = mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.get_read_only_flash,
|
||||
status = mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.base.get_read_only_flash,
|
||||
&host.flash_mgr, (intptr_t) &host.flash_state);
|
||||
|
||||
status |= mock_expect (&host.observer.mock, host.observer.base.on_recovery, &host.observer, 0);
|
||||
|
@ -687,7 +687,7 @@ static void host_processor_dual_test_apply_recovery_image_chip_erase_error (
|
|||
status |= flash_master_mock_expect_xfer (&host.flash_mock_state, FLASH_MASTER_XFER_FAILED,
|
||||
FLASH_EXP_OPCODE(0xc7));
|
||||
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.set_flash_for_host_access,
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.base.set_flash_for_host_access,
|
||||
&host.flash_mgr, 0, MOCK_ARG (&host.control));
|
||||
|
||||
status |= mock_expect (&host.control.mock, host.control.base.hold_processor_in_reset,
|
||||
|
@ -723,11 +723,11 @@ static void host_processor_dual_test_apply_recovery_image_chip_erase_error_pulse
|
|||
(intptr_t) &host.image.base);
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
status = mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.set_flash_for_rot_access,
|
||||
status = mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.base.set_flash_for_rot_access,
|
||||
&host.flash_mgr, 0, MOCK_ARG (&host.control));
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
status = mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.get_read_only_flash,
|
||||
status = mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.base.get_read_only_flash,
|
||||
&host.flash_mgr, (intptr_t) &host.flash_state);
|
||||
|
||||
status |= mock_expect (&host.observer.mock, host.observer.base.on_recovery, &host.observer, 0);
|
||||
|
@ -738,7 +738,7 @@ static void host_processor_dual_test_apply_recovery_image_chip_erase_error_pulse
|
|||
status |= flash_master_mock_expect_xfer (&host.flash_mock_state, FLASH_MASTER_XFER_FAILED,
|
||||
FLASH_EXP_OPCODE(0xc7));
|
||||
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.set_flash_for_host_access,
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.base.set_flash_for_host_access,
|
||||
&host.flash_mgr, 0, MOCK_ARG (&host.control));
|
||||
|
||||
status |= mock_expect (&host.control.mock, host.control.base.hold_processor_in_reset,
|
||||
|
@ -778,11 +778,11 @@ static void host_processor_dual_test_apply_recovery_image_bad_image (CuTest *tes
|
|||
status = mock_expect (&host.control.mock, host.control.base.hold_processor_in_reset,
|
||||
&host.control, 0, MOCK_ARG (true));
|
||||
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.set_flash_for_rot_access,
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.base.set_flash_for_rot_access,
|
||||
&host.flash_mgr, 0, MOCK_ARG (&host.control));
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
status = mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.get_read_only_flash,
|
||||
status = mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.base.get_read_only_flash,
|
||||
&host.flash_mgr, (intptr_t) &host.flash_state);
|
||||
|
||||
status |= mock_expect (&host.observer.mock, host.observer.base.on_recovery, &host.observer, 0);
|
||||
|
@ -792,7 +792,7 @@ static void host_processor_dual_test_apply_recovery_image_bad_image (CuTest *tes
|
|||
status |= mock_expect (&host.image.mock, host.image.base.apply_to_flash, &host.image,
|
||||
RECOVERY_IMAGE_HEADER_BAD_FORMAT_LENGTH, MOCK_ARG_NOT_NULL);
|
||||
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.set_flash_for_host_access,
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.base.set_flash_for_host_access,
|
||||
&host.flash_mgr, 0, MOCK_ARG (&host.control));
|
||||
|
||||
status |= mock_expect (&host.control.mock, host.control.base.hold_processor_in_reset,
|
||||
|
@ -827,11 +827,11 @@ static void host_processor_dual_test_apply_recovery_image_bad_image_pulse_reset
|
|||
(intptr_t) &host.image.base);
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
status = mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.set_flash_for_rot_access,
|
||||
status = mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.base.set_flash_for_rot_access,
|
||||
&host.flash_mgr, 0, MOCK_ARG (&host.control));
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
status = mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.get_read_only_flash,
|
||||
status = mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.base.get_read_only_flash,
|
||||
&host.flash_mgr, (intptr_t) &host.flash_state);
|
||||
|
||||
status |= mock_expect (&host.observer.mock, host.observer.base.on_recovery, &host.observer, 0);
|
||||
|
@ -841,7 +841,7 @@ static void host_processor_dual_test_apply_recovery_image_bad_image_pulse_reset
|
|||
status |= mock_expect (&host.image.mock, host.image.base.apply_to_flash, &host.image,
|
||||
RECOVERY_IMAGE_HEADER_BAD_FORMAT_LENGTH, MOCK_ARG_NOT_NULL);
|
||||
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.set_flash_for_host_access,
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.base.set_flash_for_host_access,
|
||||
&host.flash_mgr, 0, MOCK_ARG (&host.control));
|
||||
|
||||
status |= mock_expect (&host.control.mock, host.control.base.hold_processor_in_reset,
|
||||
|
@ -881,11 +881,11 @@ static void host_processor_dual_test_apply_recovery_image_clear_rw_region_error
|
|||
status = mock_expect (&host.control.mock, host.control.base.hold_processor_in_reset,
|
||||
&host.control, 0, MOCK_ARG (true));
|
||||
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.set_flash_for_rot_access,
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.base.set_flash_for_rot_access,
|
||||
&host.flash_mgr, 0, MOCK_ARG (&host.control));
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
status = mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.get_read_only_flash,
|
||||
status = mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.base.get_read_only_flash,
|
||||
&host.flash_mgr, (intptr_t) &host.flash_state);
|
||||
|
||||
status |= mock_expect (&host.observer.mock, host.observer.base.on_recovery, &host.observer, 0);
|
||||
|
@ -907,9 +907,9 @@ static void host_processor_dual_test_apply_recovery_image_clear_rw_region_error
|
|||
&host.filter, 0);
|
||||
|
||||
status |= mock_expect (&host.flash_mgr.mock,
|
||||
host.flash_mgr.base.config_spi_filter_flash_devices, &host.flash_mgr, 0);
|
||||
host.flash_mgr.base.base.config_spi_filter_flash_devices, &host.flash_mgr, 0);
|
||||
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.set_flash_for_host_access,
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.base.set_flash_for_host_access,
|
||||
&host.flash_mgr, 0, MOCK_ARG (&host.control));
|
||||
|
||||
status |= mock_expect (&host.control.mock, host.control.base.hold_processor_in_reset,
|
||||
|
@ -945,11 +945,11 @@ static void host_processor_dual_test_apply_recovery_image_clear_rw_region_error_
|
|||
(intptr_t) &host.image.base);
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
status = mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.set_flash_for_rot_access,
|
||||
status = mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.base.set_flash_for_rot_access,
|
||||
&host.flash_mgr, 0, MOCK_ARG (&host.control));
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
status = mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.get_read_only_flash,
|
||||
status = mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.base.get_read_only_flash,
|
||||
&host.flash_mgr, (intptr_t) &host.flash_state);
|
||||
|
||||
status |= mock_expect (&host.observer.mock, host.observer.base.on_recovery, &host.observer, 0);
|
||||
|
@ -971,9 +971,9 @@ static void host_processor_dual_test_apply_recovery_image_clear_rw_region_error_
|
|||
&host.filter, 0);
|
||||
|
||||
status |= mock_expect (&host.flash_mgr.mock,
|
||||
host.flash_mgr.base.config_spi_filter_flash_devices, &host.flash_mgr, 0);
|
||||
host.flash_mgr.base.base.config_spi_filter_flash_devices, &host.flash_mgr, 0);
|
||||
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.set_flash_for_host_access,
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.base.set_flash_for_host_access,
|
||||
&host.flash_mgr, 0, MOCK_ARG (&host.control));
|
||||
|
||||
status |= mock_expect (&host.control.mock, host.control.base.hold_processor_in_reset,
|
||||
|
@ -1013,11 +1013,11 @@ static void host_processor_dual_test_apply_recovery_image_spi_filter_config_erro
|
|||
status = mock_expect (&host.control.mock, host.control.base.hold_processor_in_reset,
|
||||
&host.control, 0, MOCK_ARG (true));
|
||||
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.set_flash_for_rot_access,
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.base.set_flash_for_rot_access,
|
||||
&host.flash_mgr, 0, MOCK_ARG (&host.control));
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
status = mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.get_read_only_flash,
|
||||
status = mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.base.get_read_only_flash,
|
||||
&host.flash_mgr, (intptr_t) &host.flash_state);
|
||||
|
||||
status |= mock_expect (&host.observer.mock, host.observer.base.on_recovery, &host.observer, 0);
|
||||
|
@ -1031,21 +1031,21 @@ static void host_processor_dual_test_apply_recovery_image_spi_filter_config_erro
|
|||
&host.filter, 0);
|
||||
|
||||
status |= mock_expect (&host.flash_mgr.mock,
|
||||
host.flash_mgr.base.config_spi_filter_flash_devices, &host.flash_mgr,
|
||||
host.flash_mgr.base.base.config_spi_filter_flash_devices, &host.flash_mgr,
|
||||
HOST_FLASH_MGR_CONFIG_FILTER_FAILED);
|
||||
status |= mock_expect (&host.flash_mgr.mock,
|
||||
host.flash_mgr.base.config_spi_filter_flash_devices, &host.flash_mgr,
|
||||
host.flash_mgr.base.base.config_spi_filter_flash_devices, &host.flash_mgr,
|
||||
HOST_FLASH_MGR_CONFIG_FILTER_FAILED);
|
||||
status |= mock_expect (&host.flash_mgr.mock,
|
||||
host.flash_mgr.base.config_spi_filter_flash_devices, &host.flash_mgr,
|
||||
host.flash_mgr.base.base.config_spi_filter_flash_devices, &host.flash_mgr,
|
||||
HOST_FLASH_MGR_CONFIG_FILTER_FAILED);
|
||||
status |= mock_expect (&host.flash_mgr.mock,
|
||||
host.flash_mgr.base.config_spi_filter_flash_devices, &host.flash_mgr,
|
||||
host.flash_mgr.base.base.config_spi_filter_flash_devices, &host.flash_mgr,
|
||||
HOST_FLASH_MGR_CONFIG_FILTER_FAILED);
|
||||
status |= mock_expect (&host.flash_mgr.mock,
|
||||
host.flash_mgr.base.config_spi_filter_flash_devices, &host.flash_mgr, 0);
|
||||
host.flash_mgr.base.base.config_spi_filter_flash_devices, &host.flash_mgr, 0);
|
||||
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.set_flash_for_host_access,
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.base.set_flash_for_host_access,
|
||||
&host.flash_mgr, 0, MOCK_ARG (&host.control));
|
||||
|
||||
status |= mock_expect (&host.control.mock, host.control.base.hold_processor_in_reset,
|
||||
|
@ -1081,11 +1081,11 @@ static void host_processor_dual_test_apply_recovery_image_spi_filter_config_erro
|
|||
(intptr_t) &host.image.base);
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
status = mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.set_flash_for_rot_access,
|
||||
status = mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.base.set_flash_for_rot_access,
|
||||
&host.flash_mgr, 0, MOCK_ARG (&host.control));
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
status = mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.get_read_only_flash,
|
||||
status = mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.base.get_read_only_flash,
|
||||
&host.flash_mgr, (intptr_t) &host.flash_state);
|
||||
|
||||
status |= mock_expect (&host.observer.mock, host.observer.base.on_recovery, &host.observer, 0);
|
||||
|
@ -1099,21 +1099,21 @@ static void host_processor_dual_test_apply_recovery_image_spi_filter_config_erro
|
|||
&host.filter, 0);
|
||||
|
||||
status |= mock_expect (&host.flash_mgr.mock,
|
||||
host.flash_mgr.base.config_spi_filter_flash_devices, &host.flash_mgr,
|
||||
host.flash_mgr.base.base.config_spi_filter_flash_devices, &host.flash_mgr,
|
||||
HOST_FLASH_MGR_CONFIG_FILTER_FAILED);
|
||||
status |= mock_expect (&host.flash_mgr.mock,
|
||||
host.flash_mgr.base.config_spi_filter_flash_devices, &host.flash_mgr,
|
||||
host.flash_mgr.base.base.config_spi_filter_flash_devices, &host.flash_mgr,
|
||||
HOST_FLASH_MGR_CONFIG_FILTER_FAILED);
|
||||
status |= mock_expect (&host.flash_mgr.mock,
|
||||
host.flash_mgr.base.config_spi_filter_flash_devices, &host.flash_mgr,
|
||||
host.flash_mgr.base.base.config_spi_filter_flash_devices, &host.flash_mgr,
|
||||
HOST_FLASH_MGR_CONFIG_FILTER_FAILED);
|
||||
status |= mock_expect (&host.flash_mgr.mock,
|
||||
host.flash_mgr.base.config_spi_filter_flash_devices, &host.flash_mgr,
|
||||
host.flash_mgr.base.base.config_spi_filter_flash_devices, &host.flash_mgr,
|
||||
HOST_FLASH_MGR_CONFIG_FILTER_FAILED);
|
||||
status |= mock_expect (&host.flash_mgr.mock,
|
||||
host.flash_mgr.base.config_spi_filter_flash_devices, &host.flash_mgr, 0);
|
||||
host.flash_mgr.base.base.config_spi_filter_flash_devices, &host.flash_mgr, 0);
|
||||
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.set_flash_for_host_access,
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.base.set_flash_for_host_access,
|
||||
&host.flash_mgr, 0, MOCK_ARG (&host.control));
|
||||
|
||||
status |= mock_expect (&host.control.mock, host.control.base.hold_processor_in_reset,
|
||||
|
@ -1154,11 +1154,11 @@ static void host_processor_dual_test_apply_recovery_image_set_flash_for_host_acc
|
|||
status = mock_expect (&host.control.mock, host.control.base.hold_processor_in_reset,
|
||||
&host.control, 0, MOCK_ARG (true));
|
||||
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.set_flash_for_rot_access,
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.base.set_flash_for_rot_access,
|
||||
&host.flash_mgr, 0, MOCK_ARG (&host.control));
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
status = mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.get_read_only_flash,
|
||||
status = mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.base.get_read_only_flash,
|
||||
&host.flash_mgr, (intptr_t) &host.flash_state);
|
||||
|
||||
status |= mock_expect (&host.observer.mock, host.observer.base.on_recovery, &host.observer, 0);
|
||||
|
@ -1172,17 +1172,17 @@ static void host_processor_dual_test_apply_recovery_image_set_flash_for_host_acc
|
|||
&host.filter, 0);
|
||||
|
||||
status |= mock_expect (&host.flash_mgr.mock,
|
||||
host.flash_mgr.base.config_spi_filter_flash_devices, &host.flash_mgr, 0);
|
||||
host.flash_mgr.base.base.config_spi_filter_flash_devices, &host.flash_mgr, 0);
|
||||
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.set_flash_for_host_access,
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.base.set_flash_for_host_access,
|
||||
&host.flash_mgr, HOST_FLASH_MGR_HOST_ACCESS_FAILED, MOCK_ARG (&host.control));
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.set_flash_for_host_access,
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.base.set_flash_for_host_access,
|
||||
&host.flash_mgr, HOST_FLASH_MGR_HOST_ACCESS_FAILED, MOCK_ARG (&host.control));
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.set_flash_for_host_access,
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.base.set_flash_for_host_access,
|
||||
&host.flash_mgr, HOST_FLASH_MGR_HOST_ACCESS_FAILED, MOCK_ARG (&host.control));
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.set_flash_for_host_access,
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.base.set_flash_for_host_access,
|
||||
&host.flash_mgr, HOST_FLASH_MGR_HOST_ACCESS_FAILED, MOCK_ARG (&host.control));
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.set_flash_for_host_access,
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.base.set_flash_for_host_access,
|
||||
&host.flash_mgr, 0, MOCK_ARG (&host.control));
|
||||
|
||||
status |= mock_expect (&host.control.mock, host.control.base.hold_processor_in_reset,
|
||||
|
@ -1218,11 +1218,11 @@ static void host_processor_dual_test_apply_recovery_image_set_flash_for_host_acc
|
|||
(intptr_t) &host.image.base);
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
status = mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.set_flash_for_rot_access,
|
||||
status = mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.base.set_flash_for_rot_access,
|
||||
&host.flash_mgr, 0, MOCK_ARG (&host.control));
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
status = mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.get_read_only_flash,
|
||||
status = mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.base.get_read_only_flash,
|
||||
&host.flash_mgr, (intptr_t) &host.flash_state);
|
||||
|
||||
status |= mock_expect (&host.observer.mock, host.observer.base.on_recovery, &host.observer, 0);
|
||||
|
@ -1236,17 +1236,17 @@ static void host_processor_dual_test_apply_recovery_image_set_flash_for_host_acc
|
|||
&host.filter, 0);
|
||||
|
||||
status |= mock_expect (&host.flash_mgr.mock,
|
||||
host.flash_mgr.base.config_spi_filter_flash_devices, &host.flash_mgr, 0);
|
||||
host.flash_mgr.base.base.config_spi_filter_flash_devices, &host.flash_mgr, 0);
|
||||
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.set_flash_for_host_access,
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.base.set_flash_for_host_access,
|
||||
&host.flash_mgr, HOST_FLASH_MGR_HOST_ACCESS_FAILED, MOCK_ARG (&host.control));
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.set_flash_for_host_access,
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.base.set_flash_for_host_access,
|
||||
&host.flash_mgr, HOST_FLASH_MGR_HOST_ACCESS_FAILED, MOCK_ARG (&host.control));
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.set_flash_for_host_access,
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.base.set_flash_for_host_access,
|
||||
&host.flash_mgr, HOST_FLASH_MGR_HOST_ACCESS_FAILED, MOCK_ARG (&host.control));
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.set_flash_for_host_access,
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.base.set_flash_for_host_access,
|
||||
&host.flash_mgr, HOST_FLASH_MGR_HOST_ACCESS_FAILED, MOCK_ARG (&host.control));
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.set_flash_for_host_access,
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.base.set_flash_for_host_access,
|
||||
&host.flash_mgr, 0, MOCK_ARG (&host.control));
|
||||
|
||||
status |= mock_expect (&host.control.mock, host.control.base.hold_processor_in_reset,
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
#include "mock/flash_master_mock.h"
|
||||
#include "mock/spi_filter_interface_mock.h"
|
||||
#include "mock/host_control_mock.h"
|
||||
#include "mock/host_flash_manager_mock.h"
|
||||
#include "mock/host_flash_manager_dual_mock.h"
|
||||
#include "mock/pfm_manager_mock.h"
|
||||
#include "engines/hash_testing_engine.h"
|
||||
#include "engines/rsa_testing_engine.h"
|
||||
|
@ -45,7 +45,7 @@ static void host_processor_dual_test_bypass_mode_ro_flash (CuTest *test)
|
|||
status |= mock_expect (&host.observer.mock, host.observer.base.on_bypass_mode, &host.observer,
|
||||
0);
|
||||
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.set_flash_for_host_access,
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.base.set_flash_for_host_access,
|
||||
&host.flash_mgr, 0, MOCK_ARG (&host.control));
|
||||
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
@ -85,7 +85,7 @@ static void host_processor_dual_test_bypass_mode_ro_flash_cs1 (CuTest *test)
|
|||
status |= mock_expect (&host.observer.mock, host.observer.base.on_bypass_mode, &host.observer,
|
||||
0);
|
||||
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.set_flash_for_host_access,
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.base.set_flash_for_host_access,
|
||||
&host.flash_mgr, 0, MOCK_ARG (&host.control));
|
||||
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
@ -122,7 +122,7 @@ static void host_processor_dual_test_bypass_mode_rw_flash (CuTest *test)
|
|||
status |= mock_expect (&host.observer.mock, host.observer.base.on_bypass_mode, &host.observer,
|
||||
0);
|
||||
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.set_flash_for_host_access,
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.base.set_flash_for_host_access,
|
||||
&host.flash_mgr, 0, MOCK_ARG (&host.control));
|
||||
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
@ -165,7 +165,7 @@ static void host_processor_dual_test_bypass_mode_rw_flash_cs0 (CuTest *test)
|
|||
status |= mock_expect (&host.observer.mock, host.observer.base.on_bypass_mode, &host.observer,
|
||||
0);
|
||||
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.set_flash_for_host_access,
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.base.set_flash_for_host_access,
|
||||
&host.flash_mgr, 0, MOCK_ARG (&host.control));
|
||||
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
@ -205,7 +205,7 @@ static void host_processor_dual_test_bypass_mode_no_observer (CuTest *test)
|
|||
status |= mock_expect (&host.filter.mock, host.filter.base.set_ro_cs, &host.filter, 0,
|
||||
MOCK_ARG (SPI_FILTER_CS_1));
|
||||
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.set_flash_for_host_access,
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.base.set_flash_for_host_access,
|
||||
&host.flash_mgr, 0, MOCK_ARG (&host.control));
|
||||
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
@ -244,7 +244,7 @@ static void host_processor_dual_test_bypass_mode_unsupported_flash (CuTest *test
|
|||
status |= mock_expect (&host.observer.mock, host.observer.base.on_bypass_mode, &host.observer,
|
||||
0);
|
||||
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.set_flash_for_host_access,
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.base.set_flash_for_host_access,
|
||||
&host.flash_mgr, 0, MOCK_ARG (&host.control));
|
||||
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
@ -310,7 +310,7 @@ static void host_processor_dual_test_bypass_mode_filter_error (CuTest *test)
|
|||
status |= mock_expect (&host.observer.mock, host.observer.base.on_bypass_mode, &host.observer,
|
||||
0);
|
||||
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.set_flash_for_host_access,
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.base.set_flash_for_host_access,
|
||||
&host.flash_mgr, 0, MOCK_ARG (&host.control));
|
||||
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
@ -347,15 +347,15 @@ static void host_processor_dual_test_bypass_mode_host_access_error (CuTest *test
|
|||
status |= mock_expect (&host.observer.mock, host.observer.base.on_bypass_mode, &host.observer,
|
||||
0);
|
||||
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.set_flash_for_host_access,
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.base.set_flash_for_host_access,
|
||||
&host.flash_mgr, HOST_FLASH_MGR_HOST_ACCESS_FAILED, MOCK_ARG (&host.control));
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.set_flash_for_host_access,
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.base.set_flash_for_host_access,
|
||||
&host.flash_mgr, HOST_FLASH_MGR_HOST_ACCESS_FAILED, MOCK_ARG (&host.control));
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.set_flash_for_host_access,
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.base.set_flash_for_host_access,
|
||||
&host.flash_mgr, HOST_FLASH_MGR_HOST_ACCESS_FAILED, MOCK_ARG (&host.control));
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.set_flash_for_host_access,
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.base.set_flash_for_host_access,
|
||||
&host.flash_mgr, HOST_FLASH_MGR_HOST_ACCESS_FAILED, MOCK_ARG (&host.control));
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.set_flash_for_host_access,
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.base.set_flash_for_host_access,
|
||||
&host.flash_mgr, 0, MOCK_ARG (&host.control));
|
||||
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -74,25 +74,26 @@ static void host_processor_dual_test_recover_active_read_write_data_active_pfm_n
|
|||
status |= mock_expect (&host.control.mock, host.control.base.hold_processor_in_reset,
|
||||
&host.control, 0, MOCK_ARG (true));
|
||||
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.set_flash_for_rot_access,
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.base.set_flash_for_rot_access,
|
||||
&host.flash_mgr, 0, MOCK_ARG (&host.control));
|
||||
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.get_flash_read_write_regions,
|
||||
&host.flash_mgr, 0, MOCK_ARG (&host.pfm), MOCK_ARG (false), MOCK_ARG_NOT_NULL);
|
||||
status |= mock_expect (&host.flash_mgr.mock,
|
||||
host.flash_mgr.base.base.get_flash_read_write_regions, &host.flash_mgr, 0,
|
||||
MOCK_ARG (&host.pfm), MOCK_ARG (false), MOCK_ARG_NOT_NULL);
|
||||
status |= mock_expect_output (&host.flash_mgr.mock, 2, &rw_host, sizeof (rw_host), -1);
|
||||
status |= mock_expect_save_arg (&host.flash_mgr.mock, 2, 0);
|
||||
|
||||
status |= mock_expect (&host.flash_mgr.mock,
|
||||
host.flash_mgr.base.restore_flash_read_write_regions, &host.flash_mgr, 0,
|
||||
host.flash_mgr.base.base.restore_flash_read_write_regions, &host.flash_mgr, 0,
|
||||
MOCK_ARG_SAVED_ARG (0));
|
||||
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.free_read_write_regions,
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.base.free_read_write_regions,
|
||||
&host.flash_mgr, 0, MOCK_ARG_SAVED_ARG (0));
|
||||
|
||||
status |= mock_expect (&host.pfm_mgr.mock, host.pfm_mgr.base.free_pfm, &host.pfm_mgr, 0,
|
||||
MOCK_ARG (&host.pfm));
|
||||
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.set_flash_for_host_access,
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.base.set_flash_for_host_access,
|
||||
&host.flash_mgr, 0, MOCK_ARG (&host.control));
|
||||
status |= mock_expect (&host.control.mock, host.control.base.hold_processor_in_reset,
|
||||
&host.control, 0, MOCK_ARG (false));
|
||||
|
@ -170,25 +171,26 @@ static void host_processor_dual_test_recover_active_read_write_data_active_pfm_n
|
|||
status |= mock_expect (&host.control.mock, host.control.base.hold_processor_in_reset,
|
||||
&host.control, 0, MOCK_ARG (true));
|
||||
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.set_flash_for_rot_access,
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.base.set_flash_for_rot_access,
|
||||
&host.flash_mgr, 0, MOCK_ARG (&host.control));
|
||||
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.get_flash_read_write_regions,
|
||||
&host.flash_mgr, 0, MOCK_ARG (&host.pfm), MOCK_ARG (false), MOCK_ARG_NOT_NULL);
|
||||
status |= mock_expect (&host.flash_mgr.mock,
|
||||
host.flash_mgr.base.base.get_flash_read_write_regions, &host.flash_mgr, 0,
|
||||
MOCK_ARG (&host.pfm), MOCK_ARG (false), MOCK_ARG_NOT_NULL);
|
||||
status |= mock_expect_output (&host.flash_mgr.mock, 2, &rw_host, sizeof (rw_host), -1);
|
||||
status |= mock_expect_save_arg (&host.flash_mgr.mock, 2, 0);
|
||||
|
||||
status |= mock_expect (&host.flash_mgr.mock,
|
||||
host.flash_mgr.base.restore_flash_read_write_regions, &host.flash_mgr, 0,
|
||||
host.flash_mgr.base.base.restore_flash_read_write_regions, &host.flash_mgr, 0,
|
||||
MOCK_ARG_SAVED_ARG (0));
|
||||
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.free_read_write_regions,
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.base.free_read_write_regions,
|
||||
&host.flash_mgr, 0, MOCK_ARG_SAVED_ARG (0));
|
||||
|
||||
status |= mock_expect (&host.pfm_mgr.mock, host.pfm_mgr.base.free_pfm, &host.pfm_mgr, 0,
|
||||
MOCK_ARG (&host.pfm));
|
||||
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.set_flash_for_host_access,
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.base.set_flash_for_host_access,
|
||||
&host.flash_mgr, 0, MOCK_ARG (&host.control));
|
||||
status |= mock_expect (&host.control.mock, host.control.base.hold_processor_in_reset,
|
||||
&host.control, 0, MOCK_ARG (false));
|
||||
|
@ -262,25 +264,26 @@ static void host_processor_dual_test_recover_active_read_write_data_active_pfm_n
|
|||
status = mock_expect (&host.pfm_mgr.mock, host.pfm_mgr.base.get_active_pfm, &host.pfm_mgr,
|
||||
(intptr_t) &host.pfm);
|
||||
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.set_flash_for_rot_access,
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.base.set_flash_for_rot_access,
|
||||
&host.flash_mgr, 0, MOCK_ARG (&host.control));
|
||||
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.get_flash_read_write_regions,
|
||||
&host.flash_mgr, 0, MOCK_ARG (&host.pfm), MOCK_ARG (false), MOCK_ARG_NOT_NULL);
|
||||
status |= mock_expect (&host.flash_mgr.mock,
|
||||
host.flash_mgr.base.base.get_flash_read_write_regions, &host.flash_mgr, 0,
|
||||
MOCK_ARG (&host.pfm), MOCK_ARG (false), MOCK_ARG_NOT_NULL);
|
||||
status |= mock_expect_output (&host.flash_mgr.mock, 2, &rw_host, sizeof (rw_host), -1);
|
||||
status |= mock_expect_save_arg (&host.flash_mgr.mock, 2, 0);
|
||||
|
||||
status |= mock_expect (&host.flash_mgr.mock,
|
||||
host.flash_mgr.base.restore_flash_read_write_regions, &host.flash_mgr, 0,
|
||||
host.flash_mgr.base.base.restore_flash_read_write_regions, &host.flash_mgr, 0,
|
||||
MOCK_ARG_SAVED_ARG (0));
|
||||
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.free_read_write_regions,
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.base.free_read_write_regions,
|
||||
&host.flash_mgr, 0, MOCK_ARG_SAVED_ARG (0));
|
||||
|
||||
status |= mock_expect (&host.pfm_mgr.mock, host.pfm_mgr.base.free_pfm, &host.pfm_mgr, 0,
|
||||
MOCK_ARG (&host.pfm));
|
||||
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.set_flash_for_host_access,
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.base.set_flash_for_host_access,
|
||||
&host.flash_mgr, 0, MOCK_ARG (&host.control));
|
||||
|
||||
status |= mock_expect (&host.control.mock, host.control.base.hold_processor_in_reset,
|
||||
|
@ -338,25 +341,26 @@ static void host_processor_dual_test_recover_active_read_write_data_active_pfm_d
|
|||
status |= mock_expect (&host.control.mock, host.control.base.hold_processor_in_reset,
|
||||
&host.control, 0, MOCK_ARG (true));
|
||||
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.set_flash_for_rot_access,
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.base.set_flash_for_rot_access,
|
||||
&host.flash_mgr, 0, MOCK_ARG (&host.control));
|
||||
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.get_flash_read_write_regions,
|
||||
&host.flash_mgr, 0, MOCK_ARG (&host.pfm), MOCK_ARG (false), MOCK_ARG_NOT_NULL);
|
||||
status |= mock_expect (&host.flash_mgr.mock,
|
||||
host.flash_mgr.base.base.get_flash_read_write_regions, &host.flash_mgr, 0,
|
||||
MOCK_ARG (&host.pfm), MOCK_ARG (false), MOCK_ARG_NOT_NULL);
|
||||
status |= mock_expect_output (&host.flash_mgr.mock, 2, &rw_host, sizeof (rw_host), -1);
|
||||
status |= mock_expect_save_arg (&host.flash_mgr.mock, 2, 0);
|
||||
|
||||
status |= mock_expect (&host.flash_mgr.mock,
|
||||
host.flash_mgr.base.restore_flash_read_write_regions, &host.flash_mgr, 0,
|
||||
host.flash_mgr.base.base.restore_flash_read_write_regions, &host.flash_mgr, 0,
|
||||
MOCK_ARG_SAVED_ARG (0));
|
||||
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.free_read_write_regions,
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.base.free_read_write_regions,
|
||||
&host.flash_mgr, 0, MOCK_ARG_SAVED_ARG (0));
|
||||
|
||||
status |= mock_expect (&host.pfm_mgr.mock, host.pfm_mgr.base.free_pfm, &host.pfm_mgr, 0,
|
||||
MOCK_ARG (&host.pfm));
|
||||
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.set_flash_for_host_access,
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.base.set_flash_for_host_access,
|
||||
&host.flash_mgr, 0, MOCK_ARG (&host.control));
|
||||
status |= mock_expect (&host.control.mock, host.control.base.hold_processor_in_reset,
|
||||
&host.control, 0, MOCK_ARG (false));
|
||||
|
@ -446,25 +450,26 @@ static void host_processor_dual_test_recover_active_read_write_data_active_pfm_d
|
|||
status |= mock_expect (&host.control.mock, host.control.base.hold_processor_in_reset,
|
||||
&host.control, 0, MOCK_ARG (true));
|
||||
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.set_flash_for_rot_access,
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.base.set_flash_for_rot_access,
|
||||
&host.flash_mgr, 0, MOCK_ARG (&host.control));
|
||||
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.get_flash_read_write_regions,
|
||||
&host.flash_mgr, 0, MOCK_ARG (&host.pfm), MOCK_ARG (false), MOCK_ARG_NOT_NULL);
|
||||
status |= mock_expect (&host.flash_mgr.mock,
|
||||
host.flash_mgr.base.base.get_flash_read_write_regions, &host.flash_mgr, 0,
|
||||
MOCK_ARG (&host.pfm), MOCK_ARG (false), MOCK_ARG_NOT_NULL);
|
||||
status |= mock_expect_output (&host.flash_mgr.mock, 2, &rw_host, sizeof (rw_host), -1);
|
||||
status |= mock_expect_save_arg (&host.flash_mgr.mock, 2, 0);
|
||||
|
||||
status |= mock_expect (&host.flash_mgr.mock,
|
||||
host.flash_mgr.base.restore_flash_read_write_regions, &host.flash_mgr, 0,
|
||||
host.flash_mgr.base.base.restore_flash_read_write_regions, &host.flash_mgr, 0,
|
||||
MOCK_ARG_SAVED_ARG (0));
|
||||
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.free_read_write_regions,
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.base.free_read_write_regions,
|
||||
&host.flash_mgr, 0, MOCK_ARG_SAVED_ARG (0));
|
||||
|
||||
status |= mock_expect (&host.pfm_mgr.mock, host.pfm_mgr.base.free_pfm, &host.pfm_mgr, 0,
|
||||
MOCK_ARG (&host.pfm));
|
||||
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.set_flash_for_host_access,
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.base.set_flash_for_host_access,
|
||||
&host.flash_mgr, 0, MOCK_ARG (&host.control));
|
||||
status |= mock_expect (&host.control.mock, host.control.base.hold_processor_in_reset,
|
||||
&host.control, 0, MOCK_ARG (false));
|
||||
|
@ -573,25 +578,26 @@ static void host_processor_dual_test_recover_active_read_write_data_active_pfm_d
|
|||
status |= mock_expect (&host.control.mock, host.control.base.hold_processor_in_reset,
|
||||
&host.control, 0, MOCK_ARG (true));
|
||||
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.set_flash_for_rot_access,
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.base.set_flash_for_rot_access,
|
||||
&host.flash_mgr, 0, MOCK_ARG (&host.control));
|
||||
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.get_flash_read_write_regions,
|
||||
&host.flash_mgr, 0, MOCK_ARG (&host.pfm), MOCK_ARG (false), MOCK_ARG_NOT_NULL);
|
||||
status |= mock_expect (&host.flash_mgr.mock,
|
||||
host.flash_mgr.base.base.get_flash_read_write_regions, &host.flash_mgr, 0,
|
||||
MOCK_ARG (&host.pfm), MOCK_ARG (false), MOCK_ARG_NOT_NULL);
|
||||
status |= mock_expect_output (&host.flash_mgr.mock, 2, &rw_host, sizeof (rw_host), -1);
|
||||
status |= mock_expect_save_arg (&host.flash_mgr.mock, 2, 0);
|
||||
|
||||
status |= mock_expect (&host.flash_mgr.mock,
|
||||
host.flash_mgr.base.restore_flash_read_write_regions, &host.flash_mgr, 0,
|
||||
host.flash_mgr.base.base.restore_flash_read_write_regions, &host.flash_mgr, 0,
|
||||
MOCK_ARG_SAVED_ARG (0));
|
||||
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.free_read_write_regions,
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.base.free_read_write_regions,
|
||||
&host.flash_mgr, 0, MOCK_ARG_SAVED_ARG (0));
|
||||
|
||||
status |= mock_expect (&host.pfm_mgr.mock, host.pfm_mgr.base.free_pfm, &host.pfm_mgr, 0,
|
||||
MOCK_ARG (&host.pfm));
|
||||
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.set_flash_for_host_access,
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.base.set_flash_for_host_access,
|
||||
&host.flash_mgr, 0, MOCK_ARG (&host.control));
|
||||
status |= mock_expect (&host.control.mock, host.control.base.hold_processor_in_reset,
|
||||
&host.control, 0, MOCK_ARG (false));
|
||||
|
@ -694,25 +700,26 @@ static void host_processor_dual_test_recover_active_read_write_data_active_pfm_d
|
|||
status |= mock_expect (&host.control.mock, host.control.base.hold_processor_in_reset,
|
||||
&host.control, 0, MOCK_ARG (true));
|
||||
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.set_flash_for_rot_access,
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.base.set_flash_for_rot_access,
|
||||
&host.flash_mgr, 0, MOCK_ARG (&host.control));
|
||||
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.get_flash_read_write_regions,
|
||||
&host.flash_mgr, 0, MOCK_ARG (&host.pfm), MOCK_ARG (false), MOCK_ARG_NOT_NULL);
|
||||
status |= mock_expect (&host.flash_mgr.mock,
|
||||
host.flash_mgr.base.base.get_flash_read_write_regions, &host.flash_mgr, 0,
|
||||
MOCK_ARG (&host.pfm), MOCK_ARG (false), MOCK_ARG_NOT_NULL);
|
||||
status |= mock_expect_output (&host.flash_mgr.mock, 2, &rw_host, sizeof (rw_host), -1);
|
||||
status |= mock_expect_save_arg (&host.flash_mgr.mock, 2, 0);
|
||||
|
||||
status |= mock_expect (&host.flash_mgr.mock,
|
||||
host.flash_mgr.base.restore_flash_read_write_regions, &host.flash_mgr, 0,
|
||||
host.flash_mgr.base.base.restore_flash_read_write_regions, &host.flash_mgr, 0,
|
||||
MOCK_ARG_SAVED_ARG (0));
|
||||
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.free_read_write_regions,
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.base.free_read_write_regions,
|
||||
&host.flash_mgr, 0, MOCK_ARG_SAVED_ARG (0));
|
||||
|
||||
status |= mock_expect (&host.pfm_mgr.mock, host.pfm_mgr.base.free_pfm, &host.pfm_mgr, 0,
|
||||
MOCK_ARG (&host.pfm));
|
||||
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.set_flash_for_host_access,
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.base.set_flash_for_host_access,
|
||||
&host.flash_mgr, 0, MOCK_ARG (&host.control));
|
||||
status |= mock_expect (&host.control.mock, host.control.base.hold_processor_in_reset,
|
||||
&host.control, 0, MOCK_ARG (false));
|
||||
|
@ -804,25 +811,26 @@ static void host_processor_dual_test_recover_active_read_write_data_active_pfm_d
|
|||
status |= mock_expect (&host.control.mock, host.control.base.hold_processor_in_reset,
|
||||
&host.control, 0, MOCK_ARG (true));
|
||||
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.set_flash_for_rot_access,
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.base.set_flash_for_rot_access,
|
||||
&host.flash_mgr, 0, MOCK_ARG (&host.control));
|
||||
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.get_flash_read_write_regions,
|
||||
&host.flash_mgr, 0, MOCK_ARG (&host.pfm), MOCK_ARG (false), MOCK_ARG_NOT_NULL);
|
||||
status |= mock_expect (&host.flash_mgr.mock,
|
||||
host.flash_mgr.base.base.get_flash_read_write_regions, &host.flash_mgr, 0,
|
||||
MOCK_ARG (&host.pfm), MOCK_ARG (false), MOCK_ARG_NOT_NULL);
|
||||
status |= mock_expect_output (&host.flash_mgr.mock, 2, &rw_host, sizeof (rw_host), -1);
|
||||
status |= mock_expect_save_arg (&host.flash_mgr.mock, 2, 0);
|
||||
|
||||
status |= mock_expect (&host.flash_mgr.mock,
|
||||
host.flash_mgr.base.restore_flash_read_write_regions, &host.flash_mgr, 0,
|
||||
host.flash_mgr.base.base.restore_flash_read_write_regions, &host.flash_mgr, 0,
|
||||
MOCK_ARG_SAVED_ARG (0));
|
||||
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.free_read_write_regions,
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.base.free_read_write_regions,
|
||||
&host.flash_mgr, 0, MOCK_ARG_SAVED_ARG (0));
|
||||
|
||||
status |= mock_expect (&host.pfm_mgr.mock, host.pfm_mgr.base.free_pfm, &host.pfm_mgr, 0,
|
||||
MOCK_ARG (&host.pfm));
|
||||
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.set_flash_for_host_access,
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.base.set_flash_for_host_access,
|
||||
&host.flash_mgr, 0, MOCK_ARG (&host.control));
|
||||
status |= mock_expect (&host.control.mock, host.control.base.hold_processor_in_reset,
|
||||
&host.control, 0, MOCK_ARG (false));
|
||||
|
@ -927,25 +935,26 @@ static void host_processor_dual_test_recover_active_read_write_data_active_pfm_d
|
|||
status |= mock_expect (&host.control.mock, host.control.base.hold_processor_in_reset,
|
||||
&host.control, 0, MOCK_ARG (true));
|
||||
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.set_flash_for_rot_access,
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.base.set_flash_for_rot_access,
|
||||
&host.flash_mgr, 0, MOCK_ARG (&host.control));
|
||||
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.get_flash_read_write_regions,
|
||||
&host.flash_mgr, 0, MOCK_ARG (&host.pfm), MOCK_ARG (false), MOCK_ARG_NOT_NULL);
|
||||
status |= mock_expect (&host.flash_mgr.mock,
|
||||
host.flash_mgr.base.base.get_flash_read_write_regions, &host.flash_mgr, 0,
|
||||
MOCK_ARG (&host.pfm), MOCK_ARG (false), MOCK_ARG_NOT_NULL);
|
||||
status |= mock_expect_output (&host.flash_mgr.mock, 2, &rw_host, sizeof (rw_host), -1);
|
||||
status |= mock_expect_save_arg (&host.flash_mgr.mock, 2, 0);
|
||||
|
||||
status |= mock_expect (&host.flash_mgr.mock,
|
||||
host.flash_mgr.base.restore_flash_read_write_regions, &host.flash_mgr, 0,
|
||||
host.flash_mgr.base.base.restore_flash_read_write_regions, &host.flash_mgr, 0,
|
||||
MOCK_ARG_SAVED_ARG (0));
|
||||
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.free_read_write_regions,
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.base.free_read_write_regions,
|
||||
&host.flash_mgr, 0, MOCK_ARG_SAVED_ARG (0));
|
||||
|
||||
status |= mock_expect (&host.pfm_mgr.mock, host.pfm_mgr.base.free_pfm, &host.pfm_mgr, 0,
|
||||
MOCK_ARG (&host.pfm));
|
||||
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.set_flash_for_host_access,
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.base.set_flash_for_host_access,
|
||||
&host.flash_mgr, 0, MOCK_ARG (&host.control));
|
||||
status |= mock_expect (&host.control.mock, host.control.base.hold_processor_in_reset,
|
||||
&host.control, 0, MOCK_ARG (false));
|
||||
|
@ -1046,25 +1055,26 @@ static void host_processor_dual_test_recover_active_read_write_data_active_pfm_d
|
|||
status = mock_expect (&host.pfm_mgr.mock, host.pfm_mgr.base.get_active_pfm, &host.pfm_mgr,
|
||||
(intptr_t) &host.pfm);
|
||||
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.set_flash_for_rot_access,
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.base.set_flash_for_rot_access,
|
||||
&host.flash_mgr, 0, MOCK_ARG (&host.control));
|
||||
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.get_flash_read_write_regions,
|
||||
&host.flash_mgr, 0, MOCK_ARG (&host.pfm), MOCK_ARG (false), MOCK_ARG_NOT_NULL);
|
||||
status |= mock_expect (&host.flash_mgr.mock,
|
||||
host.flash_mgr.base.base.get_flash_read_write_regions, &host.flash_mgr, 0,
|
||||
MOCK_ARG (&host.pfm), MOCK_ARG (false), MOCK_ARG_NOT_NULL);
|
||||
status |= mock_expect_output (&host.flash_mgr.mock, 2, &rw_host, sizeof (rw_host), -1);
|
||||
status |= mock_expect_save_arg (&host.flash_mgr.mock, 2, 0);
|
||||
|
||||
status |= mock_expect (&host.flash_mgr.mock,
|
||||
host.flash_mgr.base.restore_flash_read_write_regions, &host.flash_mgr, 0,
|
||||
host.flash_mgr.base.base.restore_flash_read_write_regions, &host.flash_mgr, 0,
|
||||
MOCK_ARG_SAVED_ARG (0));
|
||||
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.free_read_write_regions,
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.base.free_read_write_regions,
|
||||
&host.flash_mgr, 0, MOCK_ARG_SAVED_ARG (0));
|
||||
|
||||
status |= mock_expect (&host.pfm_mgr.mock, host.pfm_mgr.base.free_pfm, &host.pfm_mgr, 0,
|
||||
MOCK_ARG (&host.pfm));
|
||||
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.set_flash_for_host_access,
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.base.set_flash_for_host_access,
|
||||
&host.flash_mgr, 0, MOCK_ARG (&host.control));
|
||||
|
||||
status |= mock_expect (&host.control.mock, host.control.base.hold_processor_in_reset,
|
||||
|
@ -1120,13 +1130,13 @@ static void host_processor_dual_test_recover_active_read_write_data_rot_access_e
|
|||
status |= mock_expect (&host.control.mock, host.control.base.hold_processor_in_reset,
|
||||
&host.control, 0, MOCK_ARG (true));
|
||||
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.set_flash_for_rot_access,
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.base.set_flash_for_rot_access,
|
||||
&host.flash_mgr, HOST_FLASH_MGR_ROT_ACCESS_FAILED, MOCK_ARG (&host.control));
|
||||
|
||||
status |= mock_expect (&host.pfm_mgr.mock, host.pfm_mgr.base.free_pfm, &host.pfm_mgr, 0,
|
||||
MOCK_ARG (&host.pfm));
|
||||
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.set_flash_for_host_access,
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.base.set_flash_for_host_access,
|
||||
&host.flash_mgr, 0, MOCK_ARG (&host.control));
|
||||
status |= mock_expect (&host.control.mock, host.control.base.hold_processor_in_reset,
|
||||
&host.control, 0, MOCK_ARG (false));
|
||||
|
@ -1164,13 +1174,13 @@ static void host_processor_dual_test_recover_active_read_write_data_rot_access_e
|
|||
status = mock_expect (&host.pfm_mgr.mock, host.pfm_mgr.base.get_active_pfm, &host.pfm_mgr,
|
||||
(intptr_t) &host.pfm);
|
||||
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.set_flash_for_rot_access,
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.base.set_flash_for_rot_access,
|
||||
&host.flash_mgr, HOST_FLASH_MGR_ROT_ACCESS_FAILED, MOCK_ARG (&host.control));
|
||||
|
||||
status |= mock_expect (&host.pfm_mgr.mock, host.pfm_mgr.base.free_pfm, &host.pfm_mgr, 0,
|
||||
MOCK_ARG (&host.pfm));
|
||||
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.set_flash_for_host_access,
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.base.set_flash_for_host_access,
|
||||
&host.flash_mgr, 0, MOCK_ARG (&host.control));
|
||||
|
||||
status |= mock_expect (&host.control.mock, host.control.base.hold_processor_in_reset,
|
||||
|
@ -1231,33 +1241,34 @@ static void host_processor_dual_test_recover_active_read_write_data_host_access_
|
|||
status |= mock_expect (&host.control.mock, host.control.base.hold_processor_in_reset,
|
||||
&host.control, 0, MOCK_ARG (true));
|
||||
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.set_flash_for_rot_access,
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.base.set_flash_for_rot_access,
|
||||
&host.flash_mgr, 0, MOCK_ARG (&host.control));
|
||||
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.get_flash_read_write_regions,
|
||||
&host.flash_mgr, 0, MOCK_ARG (&host.pfm), MOCK_ARG (false), MOCK_ARG_NOT_NULL);
|
||||
status |= mock_expect (&host.flash_mgr.mock,
|
||||
host.flash_mgr.base.base.get_flash_read_write_regions, &host.flash_mgr, 0,
|
||||
MOCK_ARG (&host.pfm), MOCK_ARG (false), MOCK_ARG_NOT_NULL);
|
||||
status |= mock_expect_output (&host.flash_mgr.mock, 2, &rw_host, sizeof (rw_host), -1);
|
||||
status |= mock_expect_save_arg (&host.flash_mgr.mock, 2, 0);
|
||||
|
||||
status |= mock_expect (&host.flash_mgr.mock,
|
||||
host.flash_mgr.base.restore_flash_read_write_regions, &host.flash_mgr, 0,
|
||||
host.flash_mgr.base.base.restore_flash_read_write_regions, &host.flash_mgr, 0,
|
||||
MOCK_ARG_SAVED_ARG (0));
|
||||
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.free_read_write_regions,
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.base.free_read_write_regions,
|
||||
&host.flash_mgr, 0, MOCK_ARG_SAVED_ARG (0));
|
||||
|
||||
status |= mock_expect (&host.pfm_mgr.mock, host.pfm_mgr.base.free_pfm, &host.pfm_mgr, 0,
|
||||
MOCK_ARG (&host.pfm));
|
||||
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.set_flash_for_host_access,
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.base.set_flash_for_host_access,
|
||||
&host.flash_mgr, HOST_FLASH_MGR_HOST_ACCESS_FAILED, MOCK_ARG (&host.control));
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.set_flash_for_host_access,
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.base.set_flash_for_host_access,
|
||||
&host.flash_mgr, HOST_FLASH_MGR_HOST_ACCESS_FAILED, MOCK_ARG (&host.control));
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.set_flash_for_host_access,
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.base.set_flash_for_host_access,
|
||||
&host.flash_mgr, HOST_FLASH_MGR_HOST_ACCESS_FAILED, MOCK_ARG (&host.control));
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.set_flash_for_host_access,
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.base.set_flash_for_host_access,
|
||||
&host.flash_mgr, HOST_FLASH_MGR_HOST_ACCESS_FAILED, MOCK_ARG (&host.control));
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.set_flash_for_host_access,
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.base.set_flash_for_host_access,
|
||||
&host.flash_mgr, 0, MOCK_ARG (&host.control));
|
||||
|
||||
status |= mock_expect (&host.control.mock, host.control.base.hold_processor_in_reset,
|
||||
|
@ -1313,33 +1324,34 @@ static void host_processor_dual_test_recover_active_read_write_data_host_access_
|
|||
status = mock_expect (&host.pfm_mgr.mock, host.pfm_mgr.base.get_active_pfm, &host.pfm_mgr,
|
||||
(intptr_t) &host.pfm);
|
||||
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.set_flash_for_rot_access,
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.base.set_flash_for_rot_access,
|
||||
&host.flash_mgr, 0, MOCK_ARG (&host.control));
|
||||
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.get_flash_read_write_regions,
|
||||
&host.flash_mgr, 0, MOCK_ARG (&host.pfm), MOCK_ARG (false), MOCK_ARG_NOT_NULL);
|
||||
status |= mock_expect (&host.flash_mgr.mock,
|
||||
host.flash_mgr.base.base.get_flash_read_write_regions, &host.flash_mgr, 0,
|
||||
MOCK_ARG (&host.pfm), MOCK_ARG (false), MOCK_ARG_NOT_NULL);
|
||||
status |= mock_expect_output (&host.flash_mgr.mock, 2, &rw_host, sizeof (rw_host), -1);
|
||||
status |= mock_expect_save_arg (&host.flash_mgr.mock, 2, 0);
|
||||
|
||||
status |= mock_expect (&host.flash_mgr.mock,
|
||||
host.flash_mgr.base.restore_flash_read_write_regions, &host.flash_mgr, 0,
|
||||
host.flash_mgr.base.base.restore_flash_read_write_regions, &host.flash_mgr, 0,
|
||||
MOCK_ARG_SAVED_ARG (0));
|
||||
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.free_read_write_regions,
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.base.free_read_write_regions,
|
||||
&host.flash_mgr, 0, MOCK_ARG_SAVED_ARG (0));
|
||||
|
||||
status |= mock_expect (&host.pfm_mgr.mock, host.pfm_mgr.base.free_pfm, &host.pfm_mgr, 0,
|
||||
MOCK_ARG (&host.pfm));
|
||||
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.set_flash_for_host_access,
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.base.set_flash_for_host_access,
|
||||
&host.flash_mgr, HOST_FLASH_MGR_HOST_ACCESS_FAILED, MOCK_ARG (&host.control));
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.set_flash_for_host_access,
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.base.set_flash_for_host_access,
|
||||
&host.flash_mgr, HOST_FLASH_MGR_HOST_ACCESS_FAILED, MOCK_ARG (&host.control));
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.set_flash_for_host_access,
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.base.set_flash_for_host_access,
|
||||
&host.flash_mgr, HOST_FLASH_MGR_HOST_ACCESS_FAILED, MOCK_ARG (&host.control));
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.set_flash_for_host_access,
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.base.set_flash_for_host_access,
|
||||
&host.flash_mgr, HOST_FLASH_MGR_HOST_ACCESS_FAILED, MOCK_ARG (&host.control));
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.set_flash_for_host_access,
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.base.set_flash_for_host_access,
|
||||
&host.flash_mgr, 0, MOCK_ARG (&host.control));
|
||||
|
||||
status |= mock_expect (&host.control.mock, host.control.base.hold_processor_in_reset,
|
||||
|
@ -1383,17 +1395,17 @@ static void host_processor_dual_test_recover_active_read_write_data_active_pfm_d
|
|||
status |= mock_expect (&host.control.mock, host.control.base.hold_processor_in_reset,
|
||||
&host.control, 0, MOCK_ARG (true));
|
||||
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.set_flash_for_rot_access,
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.base.set_flash_for_rot_access,
|
||||
&host.flash_mgr, 0, MOCK_ARG (&host.control));
|
||||
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.get_flash_read_write_regions,
|
||||
&host.flash_mgr, HOST_FLASH_MGR_GET_RW_FAILED, MOCK_ARG (&host.pfm), MOCK_ARG (false),
|
||||
MOCK_ARG_NOT_NULL);
|
||||
status |= mock_expect (&host.flash_mgr.mock,
|
||||
host.flash_mgr.base.base.get_flash_read_write_regions, &host.flash_mgr,
|
||||
HOST_FLASH_MGR_GET_RW_FAILED, MOCK_ARG (&host.pfm), MOCK_ARG (false), MOCK_ARG_NOT_NULL);
|
||||
|
||||
status |= mock_expect (&host.pfm_mgr.mock, host.pfm_mgr.base.free_pfm, &host.pfm_mgr, 0,
|
||||
MOCK_ARG (&host.pfm));
|
||||
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.set_flash_for_host_access,
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.base.set_flash_for_host_access,
|
||||
&host.flash_mgr, 0, MOCK_ARG (&host.control));
|
||||
status |= mock_expect (&host.control.mock, host.control.base.hold_processor_in_reset,
|
||||
&host.control, 0, MOCK_ARG (false));
|
||||
|
@ -1451,31 +1463,32 @@ static void host_processor_dual_test_recover_active_read_write_data_active_pfm_d
|
|||
status |= mock_expect (&host.control.mock, host.control.base.hold_processor_in_reset,
|
||||
&host.control, 0, MOCK_ARG (true));
|
||||
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.set_flash_for_rot_access,
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.base.set_flash_for_rot_access,
|
||||
&host.flash_mgr, 0, MOCK_ARG (&host.control));
|
||||
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.get_flash_read_write_regions,
|
||||
&host.flash_mgr, 0, MOCK_ARG (&host.pfm), MOCK_ARG (false), MOCK_ARG_NOT_NULL);
|
||||
status |= mock_expect (&host.flash_mgr.mock,
|
||||
host.flash_mgr.base.base.get_flash_read_write_regions, &host.flash_mgr, 0,
|
||||
MOCK_ARG (&host.pfm), MOCK_ARG (false), MOCK_ARG_NOT_NULL);
|
||||
status |= mock_expect_output (&host.flash_mgr.mock, 2, &rw_host, sizeof (rw_host), -1);
|
||||
status |= mock_expect_save_arg (&host.flash_mgr.mock, 2, 0);
|
||||
|
||||
status |= mock_expect (&host.flash_mgr.mock,
|
||||
host.flash_mgr.base.restore_flash_read_write_regions, &host.flash_mgr,
|
||||
host.flash_mgr.base.base.restore_flash_read_write_regions, &host.flash_mgr,
|
||||
HOST_FLASH_MGR_RESTORE_RW_FAILED, MOCK_ARG_SAVED_ARG (0));
|
||||
status |= mock_expect (&host.flash_mgr.mock,
|
||||
host.flash_mgr.base.restore_flash_read_write_regions, &host.flash_mgr,
|
||||
host.flash_mgr.base.base.restore_flash_read_write_regions, &host.flash_mgr,
|
||||
HOST_FLASH_MGR_RESTORE_RW_FAILED, MOCK_ARG_SAVED_ARG (0));
|
||||
status |= mock_expect (&host.flash_mgr.mock,
|
||||
host.flash_mgr.base.restore_flash_read_write_regions, &host.flash_mgr,
|
||||
host.flash_mgr.base.base.restore_flash_read_write_regions, &host.flash_mgr,
|
||||
HOST_FLASH_MGR_RESTORE_RW_FAILED, MOCK_ARG_SAVED_ARG (0));
|
||||
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.free_read_write_regions,
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.base.free_read_write_regions,
|
||||
&host.flash_mgr, 0, MOCK_ARG_SAVED_ARG (0));
|
||||
|
||||
status |= mock_expect (&host.pfm_mgr.mock, host.pfm_mgr.base.free_pfm, &host.pfm_mgr, 0,
|
||||
MOCK_ARG (&host.pfm));
|
||||
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.set_flash_for_host_access,
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.base.set_flash_for_host_access,
|
||||
&host.flash_mgr, 0, MOCK_ARG (&host.control));
|
||||
status |= mock_expect (&host.control.mock, host.control.base.hold_processor_in_reset,
|
||||
&host.control, 0, MOCK_ARG (false));
|
||||
|
@ -1518,17 +1531,17 @@ static void host_processor_dual_test_recover_active_read_write_data_active_pfm_d
|
|||
status |= mock_expect (&host.control.mock, host.control.base.hold_processor_in_reset,
|
||||
&host.control, 0, MOCK_ARG (true));
|
||||
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.set_flash_for_rot_access,
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.base.set_flash_for_rot_access,
|
||||
&host.flash_mgr, 0, MOCK_ARG (&host.control));
|
||||
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.get_flash_read_write_regions,
|
||||
&host.flash_mgr, HOST_FLASH_MGR_GET_RW_FAILED, MOCK_ARG (&host.pfm), MOCK_ARG (false),
|
||||
MOCK_ARG_NOT_NULL);
|
||||
status |= mock_expect (&host.flash_mgr.mock,
|
||||
host.flash_mgr.base.base.get_flash_read_write_regions, &host.flash_mgr,
|
||||
HOST_FLASH_MGR_GET_RW_FAILED, MOCK_ARG (&host.pfm), MOCK_ARG (false), MOCK_ARG_NOT_NULL);
|
||||
|
||||
status |= mock_expect (&host.pfm_mgr.mock, host.pfm_mgr.base.free_pfm, &host.pfm_mgr, 0,
|
||||
MOCK_ARG (&host.pfm));
|
||||
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.set_flash_for_host_access,
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.base.set_flash_for_host_access,
|
||||
&host.flash_mgr, 0, MOCK_ARG (&host.control));
|
||||
status |= mock_expect (&host.control.mock, host.control.base.hold_processor_in_reset,
|
||||
&host.control, 0, MOCK_ARG (false));
|
||||
|
@ -1591,31 +1604,32 @@ static void host_processor_dual_test_recover_active_read_write_data_active_pfm_d
|
|||
status |= mock_expect (&host.control.mock, host.control.base.hold_processor_in_reset,
|
||||
&host.control, 0, MOCK_ARG (true));
|
||||
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.set_flash_for_rot_access,
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.base.set_flash_for_rot_access,
|
||||
&host.flash_mgr, 0, MOCK_ARG (&host.control));
|
||||
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.get_flash_read_write_regions,
|
||||
&host.flash_mgr, 0, MOCK_ARG (&host.pfm), MOCK_ARG (false), MOCK_ARG_NOT_NULL);
|
||||
status |= mock_expect (&host.flash_mgr.mock,
|
||||
host.flash_mgr.base.base.get_flash_read_write_regions, &host.flash_mgr, 0,
|
||||
MOCK_ARG (&host.pfm), MOCK_ARG (false), MOCK_ARG_NOT_NULL);
|
||||
status |= mock_expect_output (&host.flash_mgr.mock, 2, &rw_host, sizeof (rw_host), -1);
|
||||
status |= mock_expect_save_arg (&host.flash_mgr.mock, 2, 0);
|
||||
|
||||
status |= mock_expect (&host.flash_mgr.mock,
|
||||
host.flash_mgr.base.restore_flash_read_write_regions, &host.flash_mgr,
|
||||
host.flash_mgr.base.base.restore_flash_read_write_regions, &host.flash_mgr,
|
||||
HOST_FLASH_MGR_RESTORE_RW_FAILED, MOCK_ARG_SAVED_ARG (0));
|
||||
status |= mock_expect (&host.flash_mgr.mock,
|
||||
host.flash_mgr.base.restore_flash_read_write_regions, &host.flash_mgr,
|
||||
host.flash_mgr.base.base.restore_flash_read_write_regions, &host.flash_mgr,
|
||||
HOST_FLASH_MGR_RESTORE_RW_FAILED, MOCK_ARG_SAVED_ARG (0));
|
||||
status |= mock_expect (&host.flash_mgr.mock,
|
||||
host.flash_mgr.base.restore_flash_read_write_regions, &host.flash_mgr,
|
||||
host.flash_mgr.base.base.restore_flash_read_write_regions, &host.flash_mgr,
|
||||
HOST_FLASH_MGR_RESTORE_RW_FAILED, MOCK_ARG_SAVED_ARG (0));
|
||||
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.free_read_write_regions,
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.base.free_read_write_regions,
|
||||
&host.flash_mgr, 0, MOCK_ARG_SAVED_ARG (0));
|
||||
|
||||
status |= mock_expect (&host.pfm_mgr.mock, host.pfm_mgr.base.free_pfm, &host.pfm_mgr, 0,
|
||||
MOCK_ARG (&host.pfm));
|
||||
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.set_flash_for_host_access,
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.base.set_flash_for_host_access,
|
||||
&host.flash_mgr, 0, MOCK_ARG (&host.control));
|
||||
status |= mock_expect (&host.control.mock, host.control.base.hold_processor_in_reset,
|
||||
&host.control, 0, MOCK_ARG (false));
|
||||
|
@ -1662,17 +1676,17 @@ static void host_processor_dual_test_recover_active_read_write_data_active_pfm_d
|
|||
status |= mock_expect (&host.control.mock, host.control.base.hold_processor_in_reset,
|
||||
&host.control, 0, MOCK_ARG (true));
|
||||
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.set_flash_for_rot_access,
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.base.set_flash_for_rot_access,
|
||||
&host.flash_mgr, 0, MOCK_ARG (&host.control));
|
||||
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.get_flash_read_write_regions,
|
||||
&host.flash_mgr, HOST_FLASH_MGR_GET_RW_FAILED, MOCK_ARG (&host.pfm), MOCK_ARG (false),
|
||||
MOCK_ARG_NOT_NULL);
|
||||
status |= mock_expect (&host.flash_mgr.mock,
|
||||
host.flash_mgr.base.base.get_flash_read_write_regions, &host.flash_mgr,
|
||||
HOST_FLASH_MGR_GET_RW_FAILED, MOCK_ARG (&host.pfm), MOCK_ARG (false), MOCK_ARG_NOT_NULL);
|
||||
|
||||
status |= mock_expect (&host.pfm_mgr.mock, host.pfm_mgr.base.free_pfm, &host.pfm_mgr, 0,
|
||||
MOCK_ARG (&host.pfm));
|
||||
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.set_flash_for_host_access,
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.base.set_flash_for_host_access,
|
||||
&host.flash_mgr, 0, MOCK_ARG (&host.control));
|
||||
status |= mock_expect (&host.control.mock, host.control.base.hold_processor_in_reset,
|
||||
&host.control, 0, MOCK_ARG (false));
|
||||
|
@ -1736,31 +1750,32 @@ static void host_processor_dual_test_recover_active_read_write_data_active_pfm_d
|
|||
status |= mock_expect (&host.control.mock, host.control.base.hold_processor_in_reset,
|
||||
&host.control, 0, MOCK_ARG (true));
|
||||
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.set_flash_for_rot_access,
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.base.set_flash_for_rot_access,
|
||||
&host.flash_mgr, 0, MOCK_ARG (&host.control));
|
||||
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.get_flash_read_write_regions,
|
||||
&host.flash_mgr, 0, MOCK_ARG (&host.pfm), MOCK_ARG (false), MOCK_ARG_NOT_NULL);
|
||||
status |= mock_expect (&host.flash_mgr.mock,
|
||||
host.flash_mgr.base.base.get_flash_read_write_regions, &host.flash_mgr, 0,
|
||||
MOCK_ARG (&host.pfm), MOCK_ARG (false), MOCK_ARG_NOT_NULL);
|
||||
status |= mock_expect_output (&host.flash_mgr.mock, 2, &rw_host, sizeof (rw_host), -1);
|
||||
status |= mock_expect_save_arg (&host.flash_mgr.mock, 2, 0);
|
||||
|
||||
status |= mock_expect (&host.flash_mgr.mock,
|
||||
host.flash_mgr.base.restore_flash_read_write_regions, &host.flash_mgr,
|
||||
host.flash_mgr.base.base.restore_flash_read_write_regions, &host.flash_mgr,
|
||||
HOST_FLASH_MGR_RESTORE_RW_FAILED, MOCK_ARG_SAVED_ARG (0));
|
||||
status |= mock_expect (&host.flash_mgr.mock,
|
||||
host.flash_mgr.base.restore_flash_read_write_regions, &host.flash_mgr,
|
||||
host.flash_mgr.base.base.restore_flash_read_write_regions, &host.flash_mgr,
|
||||
HOST_FLASH_MGR_RESTORE_RW_FAILED, MOCK_ARG_SAVED_ARG (0));
|
||||
status |= mock_expect (&host.flash_mgr.mock,
|
||||
host.flash_mgr.base.restore_flash_read_write_regions, &host.flash_mgr,
|
||||
host.flash_mgr.base.base.restore_flash_read_write_regions, &host.flash_mgr,
|
||||
HOST_FLASH_MGR_RESTORE_RW_FAILED, MOCK_ARG_SAVED_ARG (0));
|
||||
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.free_read_write_regions,
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.base.free_read_write_regions,
|
||||
&host.flash_mgr, 0, MOCK_ARG_SAVED_ARG (0));
|
||||
|
||||
status |= mock_expect (&host.pfm_mgr.mock, host.pfm_mgr.base.free_pfm, &host.pfm_mgr, 0,
|
||||
MOCK_ARG (&host.pfm));
|
||||
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.set_flash_for_host_access,
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.base.set_flash_for_host_access,
|
||||
&host.flash_mgr, 0, MOCK_ARG (&host.control));
|
||||
status |= mock_expect (&host.control.mock, host.control.base.hold_processor_in_reset,
|
||||
&host.control, 0, MOCK_ARG (false));
|
||||
|
@ -1808,17 +1823,17 @@ static void host_processor_dual_test_recover_active_read_write_data_active_pfm_d
|
|||
status |= mock_expect (&host.control.mock, host.control.base.hold_processor_in_reset,
|
||||
&host.control, 0, MOCK_ARG (true));
|
||||
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.set_flash_for_rot_access,
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.base.set_flash_for_rot_access,
|
||||
&host.flash_mgr, 0, MOCK_ARG (&host.control));
|
||||
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.get_flash_read_write_regions,
|
||||
&host.flash_mgr, HOST_FLASH_MGR_GET_RW_FAILED, MOCK_ARG (&host.pfm), MOCK_ARG (false),
|
||||
MOCK_ARG_NOT_NULL);
|
||||
status |= mock_expect (&host.flash_mgr.mock,
|
||||
host.flash_mgr.base.base.get_flash_read_write_regions, &host.flash_mgr,
|
||||
HOST_FLASH_MGR_GET_RW_FAILED, MOCK_ARG (&host.pfm), MOCK_ARG (false), MOCK_ARG_NOT_NULL);
|
||||
|
||||
status |= mock_expect (&host.pfm_mgr.mock, host.pfm_mgr.base.free_pfm, &host.pfm_mgr, 0,
|
||||
MOCK_ARG (&host.pfm));
|
||||
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.set_flash_for_host_access,
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.base.set_flash_for_host_access,
|
||||
&host.flash_mgr, 0, MOCK_ARG (&host.control));
|
||||
status |= mock_expect (&host.control.mock, host.control.base.hold_processor_in_reset,
|
||||
&host.control, 0, MOCK_ARG (false));
|
||||
|
@ -1883,31 +1898,32 @@ static void host_processor_dual_test_recover_active_read_write_data_active_pfm_d
|
|||
status |= mock_expect (&host.control.mock, host.control.base.hold_processor_in_reset,
|
||||
&host.control, 0, MOCK_ARG (true));
|
||||
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.set_flash_for_rot_access,
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.base.set_flash_for_rot_access,
|
||||
&host.flash_mgr, 0, MOCK_ARG (&host.control));
|
||||
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.get_flash_read_write_regions,
|
||||
&host.flash_mgr, 0, MOCK_ARG (&host.pfm), MOCK_ARG (false), MOCK_ARG_NOT_NULL);
|
||||
status |= mock_expect (&host.flash_mgr.mock,
|
||||
host.flash_mgr.base.base.get_flash_read_write_regions, &host.flash_mgr, 0,
|
||||
MOCK_ARG (&host.pfm), MOCK_ARG (false), MOCK_ARG_NOT_NULL);
|
||||
status |= mock_expect_output (&host.flash_mgr.mock, 2, &rw_host, sizeof (rw_host), -1);
|
||||
status |= mock_expect_save_arg (&host.flash_mgr.mock, 2, 0);
|
||||
|
||||
status |= mock_expect (&host.flash_mgr.mock,
|
||||
host.flash_mgr.base.restore_flash_read_write_regions, &host.flash_mgr,
|
||||
host.flash_mgr.base.base.restore_flash_read_write_regions, &host.flash_mgr,
|
||||
HOST_FLASH_MGR_RESTORE_RW_FAILED, MOCK_ARG_SAVED_ARG (0));
|
||||
status |= mock_expect (&host.flash_mgr.mock,
|
||||
host.flash_mgr.base.restore_flash_read_write_regions, &host.flash_mgr,
|
||||
host.flash_mgr.base.base.restore_flash_read_write_regions, &host.flash_mgr,
|
||||
HOST_FLASH_MGR_RESTORE_RW_FAILED, MOCK_ARG_SAVED_ARG (0));
|
||||
status |= mock_expect (&host.flash_mgr.mock,
|
||||
host.flash_mgr.base.restore_flash_read_write_regions, &host.flash_mgr,
|
||||
host.flash_mgr.base.base.restore_flash_read_write_regions, &host.flash_mgr,
|
||||
HOST_FLASH_MGR_RESTORE_RW_FAILED, MOCK_ARG_SAVED_ARG (0));
|
||||
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.free_read_write_regions,
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.base.free_read_write_regions,
|
||||
&host.flash_mgr, 0, MOCK_ARG_SAVED_ARG (0));
|
||||
|
||||
status |= mock_expect (&host.pfm_mgr.mock, host.pfm_mgr.base.free_pfm, &host.pfm_mgr, 0,
|
||||
MOCK_ARG (&host.pfm));
|
||||
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.set_flash_for_host_access,
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.base.set_flash_for_host_access,
|
||||
&host.flash_mgr, 0, MOCK_ARG (&host.control));
|
||||
status |= mock_expect (&host.control.mock, host.control.base.hold_processor_in_reset,
|
||||
&host.control, 0, MOCK_ARG (false));
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -11,7 +11,7 @@
|
|||
#include "mock/flash_master_mock.h"
|
||||
#include "mock/spi_filter_interface_mock.h"
|
||||
#include "mock/host_control_mock.h"
|
||||
#include "mock/host_flash_manager_mock.h"
|
||||
#include "mock/host_flash_manager_dual_mock.h"
|
||||
#include "mock/pfm_manager_mock.h"
|
||||
#include "mock/pfm_mock.h"
|
||||
#include "mock/recovery_image_manager_mock.h"
|
||||
|
@ -29,9 +29,9 @@ struct host_processor_dual_testing {
|
|||
RSA_TESTING_ENGINE rsa; /**< RSA engine for API arguments. */
|
||||
struct flash_master_mock flash_mock_state; /**< Flash mock for host state information. */
|
||||
struct spi_flash flash_state; /**< Host state flash. */
|
||||
struct state_manager host_state; /**< Host state manager. */
|
||||
struct host_state_manager host_state; /**< Host state manager. */
|
||||
struct spi_filter_interface_mock filter; /**< Mock for the SPI filter. */
|
||||
struct host_flash_manager_mock flash_mgr; /**< Mock for flash management. */
|
||||
struct host_flash_manager_dual_mock flash_mgr; /**< Mock for flash management. */
|
||||
struct host_control_mock control; /**< Mock for host control. */
|
||||
struct pfm_manager_mock pfm_mgr; /**< Mock for PFM management. */
|
||||
struct pfm_mock pfm; /**< Mock for a valid PFM. */
|
||||
|
@ -39,7 +39,7 @@ struct host_processor_dual_testing {
|
|||
struct recovery_image_manager_mock recovery_manager; /**< Mock for recovery image management. */
|
||||
struct recovery_image_mock image; /**< Mock for a valid recovery image. */
|
||||
struct host_processor_observer_mock observer; /**< Mock for host notifications. */
|
||||
struct host_processor_dual test; /**< Host instance being tested. */
|
||||
struct host_processor_filtered test; /**< Host instance being tested. */
|
||||
};
|
||||
|
||||
|
||||
|
@ -55,7 +55,7 @@ void host_processor_dual_testing_init_no_recovery_pulse_reset (CuTest *test,
|
|||
void host_processor_dual_testing_validate_and_release (CuTest *test,
|
||||
struct host_processor_dual_testing *host);
|
||||
|
||||
void host_processor_dual_testing_init_host_state (CuTest *test, struct state_manager *state,
|
||||
void host_processor_dual_testing_init_host_state (CuTest *test, struct host_state_manager *state,
|
||||
struct flash_master_mock *flash_mock, struct spi_flash *flash);
|
||||
|
||||
|
||||
|
|
|
@ -7,9 +7,11 @@
|
|||
#include "testing.h"
|
||||
#include "host_fw/host_processor_observer_pcr.h"
|
||||
#include "host_fw/host_logging.h"
|
||||
#include "host_fw/host_state_manager.h"
|
||||
#include "attestation/pcr_store.h"
|
||||
#include "mock/hash_mock.h"
|
||||
#include "mock/logging_mock.h"
|
||||
#include "mock/flash_mock.h"
|
||||
#include "engines/hash_testing_engine.h"
|
||||
|
||||
|
||||
|
@ -40,6 +42,14 @@ static const uint8_t DIGEST_RECOVERY[] = {
|
|||
0x8f,0x39,0x12,0x06,0x44,0xc3,0x07,0x84,0xf4,0xd0,0x13,0x2f,0x8b,0x1d,0xfb,0xc6
|
||||
};
|
||||
|
||||
/**
|
||||
* Digest of the state indicating unvalidated flash with event type 0xaabbccdd and version 0x0.
|
||||
*/
|
||||
static const uint8_t DIGEST_NOT_VALIDATED[] = {
|
||||
0x2d,0x89,0xc3,0x8b,0xe5,0x2a,0x9b,0xf8,0xec,0xfd,0xb7,0xe4,0x73,0x5b,0xec,0xbb,
|
||||
0x81,0x77,0xb1,0xfb,0x63,0xf4,0x02,0x27,0x9f,0xce,0xb6,0x42,0x25,0xf7,0xb1,0xa1
|
||||
};
|
||||
|
||||
/**
|
||||
* Digest of the initial state with event type 0xaabbccdd and version 0x0 for testing.
|
||||
*/
|
||||
|
@ -49,6 +59,42 @@ static const uint8_t DIGEST_INIT[] = {
|
|||
};
|
||||
|
||||
|
||||
/**
|
||||
* Initialize the host state manager for testing.
|
||||
*
|
||||
* @param test The testing framework.
|
||||
* @param state The host state instance to initialize.
|
||||
* @param flash The flash device to initialize for state.
|
||||
*/
|
||||
void host_processor_observer_pcr_testing_init_host_state (CuTest *test,
|
||||
struct host_state_manager *state, struct flash_mock *flash)
|
||||
{
|
||||
int status;
|
||||
uint32_t sector_size = 0x1000;
|
||||
uint16_t end[4] = {0xffff, 0xffff, 0xffff, 0xffff};
|
||||
|
||||
status = flash_mock_init (flash);
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
status = mock_expect (&flash->mock, flash->base.get_sector_size, flash, 0, MOCK_ARG_NOT_NULL);
|
||||
status |= mock_expect_output (&flash->mock, 0, §or_size, sizeof (sector_size), -1);
|
||||
|
||||
status |= mock_expect (&flash->mock, flash->base.read, flash, 0, MOCK_ARG (0x10000),
|
||||
MOCK_ARG_NOT_NULL, MOCK_ARG (8));
|
||||
status |= mock_expect_output (&flash->mock, 1, end, sizeof (end), 2);
|
||||
|
||||
status |= mock_expect (&flash->mock, flash->base.read, flash, 0, MOCK_ARG (0x11000),
|
||||
MOCK_ARG_NOT_NULL, MOCK_ARG (8));
|
||||
status |= mock_expect_output (&flash->mock, 1, end, sizeof (end), 2);
|
||||
|
||||
status |= flash_mock_expect_erase_flash_sector_verify (flash, 0x10000, 0x1000);
|
||||
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
status = host_state_manager_init (state, &flash->base, 0x10000);
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tear down the test suite.
|
||||
*
|
||||
|
@ -94,6 +140,14 @@ static void host_processor_observer_pcr_test_init (CuTest *test)
|
|||
CuAssertPtrNotNull (test, observer.base.on_active_mode);
|
||||
CuAssertPtrNotNull (test, observer.base.on_recovery);
|
||||
|
||||
CuAssertPtrEquals (test, NULL, observer.base_state.on_active_pfm);
|
||||
CuAssertPtrEquals (test, NULL, observer.base_state.on_read_only_flash);
|
||||
CuAssertPtrNotNull (test, observer.base_state.on_inactive_dirty);
|
||||
CuAssertPtrEquals (test, NULL, observer.base_state.on_active_recovery_image);
|
||||
CuAssertPtrEquals (test, NULL, observer.base_state.on_pfm_dirty);
|
||||
CuAssertPtrEquals (test, NULL, observer.base_state.on_run_time_validation);
|
||||
CuAssertPtrEquals (test, NULL, observer.base_state.on_unsupported_flash);
|
||||
|
||||
status = pcr_store_get_measurement (&store, PCR_MEASUREMENT (0, 0), &measurement);
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
|
@ -265,7 +319,6 @@ static void host_processor_observer_pcr_test_on_bypass_mode_error (CuTest *test)
|
|||
uint32_t state = HOST_PROCESSOR_OBSERVER_PCR_INIT;
|
||||
struct host_processor_observer_pcr observer;
|
||||
int status;
|
||||
struct pcr_measurement measurement;
|
||||
struct debug_log_entry_info entry = {
|
||||
.format = DEBUG_LOG_ENTRY_FORMAT,
|
||||
.severity = DEBUG_LOG_SEVERITY_ERROR,
|
||||
|
@ -326,9 +379,6 @@ static void host_processor_observer_pcr_test_on_bypass_mode_error (CuTest *test)
|
|||
|
||||
debug_log = NULL;
|
||||
|
||||
status = pcr_store_get_measurement (&store, PCR_MEASUREMENT (0, 0), &measurement);
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
status = hash_mock_validate_and_release (&hash);
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
|
@ -390,7 +440,6 @@ static void host_processor_observer_pcr_test_on_active_mode_error (CuTest *test)
|
|||
uint32_t state = HOST_PROCESSOR_OBSERVER_PCR_INIT;
|
||||
struct host_processor_observer_pcr observer;
|
||||
int status;
|
||||
struct pcr_measurement measurement;
|
||||
struct debug_log_entry_info entry = {
|
||||
.format = DEBUG_LOG_ENTRY_FORMAT,
|
||||
.severity = DEBUG_LOG_SEVERITY_ERROR,
|
||||
|
@ -451,9 +500,6 @@ static void host_processor_observer_pcr_test_on_active_mode_error (CuTest *test)
|
|||
|
||||
debug_log = NULL;
|
||||
|
||||
status = pcr_store_get_measurement (&store, PCR_MEASUREMENT (0, 0), &measurement);
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
status = hash_mock_validate_and_release (&hash);
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
|
@ -515,7 +561,6 @@ static void host_processor_observer_pcr_test_on_recovery_error (CuTest *test)
|
|||
uint32_t state = HOST_PROCESSOR_OBSERVER_PCR_INIT;
|
||||
struct host_processor_observer_pcr observer;
|
||||
int status;
|
||||
struct pcr_measurement measurement;
|
||||
struct debug_log_entry_info entry = {
|
||||
.format = DEBUG_LOG_ENTRY_FORMAT,
|
||||
.severity = DEBUG_LOG_SEVERITY_ERROR,
|
||||
|
@ -576,15 +621,201 @@ static void host_processor_observer_pcr_test_on_recovery_error (CuTest *test)
|
|||
|
||||
debug_log = NULL;
|
||||
|
||||
status = hash_mock_validate_and_release (&hash);
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
status = logging_mock_validate_and_release (&logger);
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
host_processor_observer_pcr_release (&observer);
|
||||
|
||||
pcr_store_release (&store);
|
||||
}
|
||||
|
||||
static void host_processor_observer_pcr_test_on_inactive_dirty_dirty (CuTest *test)
|
||||
{
|
||||
HASH_TESTING_ENGINE hash;
|
||||
struct pcr_store store;
|
||||
uint8_t num_pcr_measurements[] = {6, 6};
|
||||
uint32_t state = HOST_PROCESSOR_OBSERVER_PCR_INIT;
|
||||
struct host_processor_observer_pcr observer;
|
||||
int status;
|
||||
struct flash_mock flash;
|
||||
struct host_state_manager host_state;
|
||||
struct pcr_measurement measurement;
|
||||
uint32_t event = 0xaabbccdd;
|
||||
|
||||
TEST_START;
|
||||
|
||||
status = HASH_TESTING_ENGINE_INIT (&hash);
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
host_processor_observer_pcr_testing_init_host_state (test, &host_state, &flash);
|
||||
|
||||
host_state_manager_save_inactive_dirty (&host_state, true);
|
||||
|
||||
status = pcr_store_init (&store, num_pcr_measurements, sizeof (num_pcr_measurements));
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
status = pcr_update_event_type (&store.banks[0], 0, event);
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
status = host_processor_observer_pcr_init (&observer, &hash.base, &store,
|
||||
PCR_MEASUREMENT (0, 0), &state);
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
observer.base_state.on_inactive_dirty (&observer.base_state, &host_state);
|
||||
CuAssertIntEquals (test, HOST_PROCESSOR_OBSERVER_PCR_NOT_VALIDATED, state);
|
||||
|
||||
status = pcr_store_get_measurement (&store, PCR_MEASUREMENT (0, 0), &measurement);
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
status = testing_validate_array (DIGEST_NOT_VALIDATED, measurement.digest, SHA256_HASH_LENGTH);
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
status = flash_mock_validate_and_release (&flash);
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
host_processor_observer_pcr_release (&observer);
|
||||
|
||||
pcr_store_release (&store);
|
||||
HASH_TESTING_ENGINE_RELEASE (&hash);
|
||||
}
|
||||
|
||||
static void host_processor_observer_pcr_test_on_inactive_dirty_not_dirty (CuTest *test)
|
||||
{
|
||||
HASH_TESTING_ENGINE hash;
|
||||
struct pcr_store store;
|
||||
uint8_t num_pcr_measurements[] = {6, 6};
|
||||
uint32_t state = HOST_PROCESSOR_OBSERVER_PCR_INIT;
|
||||
struct host_processor_observer_pcr observer;
|
||||
int status;
|
||||
struct flash_mock flash;
|
||||
struct host_state_manager host_state;
|
||||
struct pcr_measurement measurement;
|
||||
uint32_t event = 0xaabbccdd;
|
||||
|
||||
TEST_START;
|
||||
|
||||
status = HASH_TESTING_ENGINE_INIT (&hash);
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
host_processor_observer_pcr_testing_init_host_state (test, &host_state, &flash);
|
||||
|
||||
host_state_manager_save_inactive_dirty (&host_state, false);
|
||||
|
||||
status = pcr_store_init (&store, num_pcr_measurements, sizeof (num_pcr_measurements));
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
status = pcr_update_event_type (&store.banks[0], 0, event);
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
status = host_processor_observer_pcr_init (&observer, &hash.base, &store,
|
||||
PCR_MEASUREMENT (0, 0), &state);
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
observer.base_state.on_inactive_dirty (&observer.base_state, &host_state);
|
||||
CuAssertIntEquals (test, HOST_PROCESSOR_OBSERVER_PCR_INIT, state);
|
||||
|
||||
status = pcr_store_get_measurement (&store, PCR_MEASUREMENT (0, 0), &measurement);
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
status = testing_validate_array (DIGEST_INIT, measurement.digest, SHA256_HASH_LENGTH);
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
status = flash_mock_validate_and_release (&flash);
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
host_processor_observer_pcr_release (&observer);
|
||||
|
||||
pcr_store_release (&store);
|
||||
HASH_TESTING_ENGINE_RELEASE (&hash);
|
||||
}
|
||||
|
||||
static void host_processor_observer_pcr_test_on_inactive_dirty_error (CuTest *test)
|
||||
{
|
||||
struct hash_engine_mock hash;
|
||||
struct logging_mock logger;
|
||||
struct pcr_store store;
|
||||
uint8_t num_pcr_measurements[] = {6, 6};
|
||||
uint32_t state = HOST_PROCESSOR_OBSERVER_PCR_INIT;
|
||||
struct host_processor_observer_pcr observer;
|
||||
int status;
|
||||
struct flash_mock flash;
|
||||
struct host_state_manager host_state;
|
||||
struct debug_log_entry_info entry = {
|
||||
.format = DEBUG_LOG_ENTRY_FORMAT,
|
||||
.severity = DEBUG_LOG_SEVERITY_ERROR,
|
||||
.component = DEBUG_LOG_COMPONENT_HOST_FW,
|
||||
.msg_index = HOST_LOGGING_PCR_UPDATE_ERROR,
|
||||
.arg1 = PCR_MEASUREMENT (0, 0),
|
||||
.arg2 = HASH_ENGINE_UPDATE_FAILED
|
||||
};
|
||||
uint32_t event = 0xaabbccdd;
|
||||
uint8_t version = 0;
|
||||
|
||||
TEST_START;
|
||||
|
||||
status = hash_mock_init (&hash);
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
status = logging_mock_init (&logger);
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
host_processor_observer_pcr_testing_init_host_state (test, &host_state, &flash);
|
||||
|
||||
host_state_manager_save_inactive_dirty (&host_state, true);
|
||||
|
||||
status = pcr_store_init (&store, num_pcr_measurements, sizeof (num_pcr_measurements));
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
status = pcr_update_event_type (&store.banks[0], 0, event);
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
status = mock_expect (&hash.mock, hash.base.start_sha256, &hash, 0);
|
||||
status |= mock_expect (&hash.mock, hash.base.update, &hash, 0,
|
||||
MOCK_ARG_PTR_CONTAINS (&event, sizeof (event)), MOCK_ARG (sizeof (event)));
|
||||
status |= mock_expect (&hash.mock, hash.base.update, &hash, 0,
|
||||
MOCK_ARG_PTR_CONTAINS (&version, sizeof (version)), MOCK_ARG (sizeof (version)));
|
||||
status |= mock_expect (&hash.mock, hash.base.update, &hash, 0, MOCK_ARG_NOT_NULL,
|
||||
MOCK_ARG (sizeof (uint32_t)));
|
||||
status |= mock_expect (&hash.mock, hash.base.finish, &hash, 0, MOCK_ARG_NOT_NULL,
|
||||
MOCK_ARG (SHA256_HASH_LENGTH));
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
status = host_processor_observer_pcr_init (&observer, &hash.base, &store,
|
||||
PCR_MEASUREMENT (0, 0), &state);
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
status = mock_validate (&hash.mock);
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
status = mock_expect (&hash.mock, hash.base.start_sha256, &hash, 0);
|
||||
status |= mock_expect (&hash.mock, hash.base.update, &hash, HASH_ENGINE_UPDATE_FAILED,
|
||||
MOCK_ARG_NOT_NULL, MOCK_ARG (sizeof (uint32_t)));
|
||||
status |= mock_expect (&hash.mock, hash.base.cancel, &hash, 0);
|
||||
|
||||
status |= mock_expect (&logger.mock, logger.base.create_entry, &logger, 0,
|
||||
MOCK_ARG_PTR_CONTAINS ((uint8_t*) &entry, sizeof (entry)), MOCK_ARG (sizeof (entry)));
|
||||
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
debug_log = &logger.base;
|
||||
|
||||
observer.base_state.on_inactive_dirty (&observer.base_state, &host_state);
|
||||
CuAssertIntEquals (test, HOST_PROCESSOR_OBSERVER_PCR_NOT_VALIDATED, state);
|
||||
|
||||
debug_log = NULL;
|
||||
|
||||
status = hash_mock_validate_and_release (&hash);
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
status = logging_mock_validate_and_release (&logger);
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
status = flash_mock_validate_and_release (&flash);
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
host_processor_observer_pcr_release (&observer);
|
||||
|
||||
pcr_store_release (&store);
|
||||
|
@ -605,6 +836,9 @@ CuSuite* get_host_processor_observer_pcr_suite ()
|
|||
SUITE_ADD_TEST (suite, host_processor_observer_pcr_test_on_active_mode_error);
|
||||
SUITE_ADD_TEST (suite, host_processor_observer_pcr_test_on_recovery);
|
||||
SUITE_ADD_TEST (suite, host_processor_observer_pcr_test_on_recovery_error);
|
||||
SUITE_ADD_TEST (suite, host_processor_observer_pcr_test_on_inactive_dirty_dirty);
|
||||
SUITE_ADD_TEST (suite, host_processor_observer_pcr_test_on_inactive_dirty_not_dirty);
|
||||
SUITE_ADD_TEST (suite, host_processor_observer_pcr_test_on_inactive_dirty_error);
|
||||
|
||||
/* Tear down after the tests in this suite have run. */
|
||||
SUITE_ADD_TEST (suite, host_processor_observer_pcr_testing_suite_tear_down);
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -0,0 +1,403 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include "testing.h"
|
||||
#include "host_fw/host_processor_single.h"
|
||||
#include "host_fw/host_state_manager.h"
|
||||
#include "mock/flash_master_mock.h"
|
||||
#include "mock/spi_filter_interface_mock.h"
|
||||
#include "mock/host_control_mock.h"
|
||||
#include "mock/host_flash_manager_single_mock.h"
|
||||
#include "mock/pfm_manager_mock.h"
|
||||
#include "engines/hash_testing_engine.h"
|
||||
#include "engines/rsa_testing_engine.h"
|
||||
#include "host_processor_single_testing.h"
|
||||
#include "rsa_testing.h"
|
||||
|
||||
|
||||
static const char *SUITE = "host_processor_single";
|
||||
|
||||
|
||||
/*******************
|
||||
* Test cases
|
||||
*******************/
|
||||
|
||||
static void host_processor_single_test_bypass_mode_ro_flash (CuTest *test)
|
||||
{
|
||||
struct host_processor_single_testing host;
|
||||
int status;
|
||||
|
||||
TEST_START;
|
||||
|
||||
host_processor_single_testing_init (test, &host);
|
||||
|
||||
status = mock_expect (&host.filter.mock, host.filter.base.clear_filter_rw_regions,
|
||||
&host.filter, 0);
|
||||
status |= mock_expect (&host.filter.mock, host.filter.base.set_filter_rw_region, &host.filter,
|
||||
0, MOCK_ARG (1), MOCK_ARG (0), MOCK_ARG (0xffff0000));
|
||||
|
||||
status |= mock_expect (&host.filter.mock, host.filter.base.set_filter_mode, &host.filter, 0,
|
||||
MOCK_ARG (SPI_FILTER_FLASH_SINGLE_CS0));
|
||||
|
||||
status |= mock_expect (&host.observer.mock, host.observer.base.on_bypass_mode, &host.observer,
|
||||
0);
|
||||
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.base.set_flash_for_host_access,
|
||||
&host.flash_mgr, 0, MOCK_ARG (&host.control));
|
||||
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
status = host.test.base.bypass_mode (&host.test.base, false);
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
status = host_state_manager_is_pfm_dirty (&host.host_state);
|
||||
CuAssertIntEquals (test, true, status);
|
||||
|
||||
status = host_state_manager_get_read_only_flash (&host.host_state);
|
||||
CuAssertIntEquals (test, SPI_FILTER_CS_0, status);
|
||||
|
||||
status = host_state_manager_is_bypass_mode (&host.host_state);
|
||||
CuAssertIntEquals (test, true, status);
|
||||
|
||||
host_processor_single_testing_validate_and_release (test, &host);
|
||||
}
|
||||
|
||||
static void host_processor_single_test_bypass_mode_ro_flash_cs1 (CuTest *test)
|
||||
{
|
||||
struct host_processor_single_testing host;
|
||||
int status;
|
||||
|
||||
TEST_START;
|
||||
|
||||
host_processor_single_testing_init (test, &host);
|
||||
|
||||
status = host_state_manager_save_read_only_flash (&host.host_state, SPI_FILTER_CS_1);
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
status = mock_expect (&host.filter.mock, host.filter.base.clear_filter_rw_regions,
|
||||
&host.filter, 0);
|
||||
status |= mock_expect (&host.filter.mock, host.filter.base.set_filter_rw_region, &host.filter,
|
||||
0, MOCK_ARG (1), MOCK_ARG (0), MOCK_ARG (0xffff0000));
|
||||
|
||||
status |= mock_expect (&host.filter.mock, host.filter.base.set_filter_mode, &host.filter, 0,
|
||||
MOCK_ARG (SPI_FILTER_FLASH_SINGLE_CS0));
|
||||
|
||||
status |= mock_expect (&host.observer.mock, host.observer.base.on_bypass_mode, &host.observer,
|
||||
0);
|
||||
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.base.set_flash_for_host_access,
|
||||
&host.flash_mgr, 0, MOCK_ARG (&host.control));
|
||||
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
status = host.test.base.bypass_mode (&host.test.base, false);
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
status = host_state_manager_is_pfm_dirty (&host.host_state);
|
||||
CuAssertIntEquals (test, true, status);
|
||||
|
||||
status = host_state_manager_get_read_only_flash (&host.host_state);
|
||||
CuAssertIntEquals (test, SPI_FILTER_CS_0, status);
|
||||
|
||||
status = host_state_manager_is_bypass_mode (&host.host_state);
|
||||
CuAssertIntEquals (test, true, status);
|
||||
|
||||
host_processor_single_testing_validate_and_release (test, &host);
|
||||
}
|
||||
|
||||
static void host_processor_single_test_bypass_mode_rw_flash (CuTest *test)
|
||||
{
|
||||
struct host_processor_single_testing host;
|
||||
int status;
|
||||
|
||||
TEST_START;
|
||||
|
||||
host_processor_single_testing_init (test, &host);
|
||||
|
||||
status = mock_expect (&host.filter.mock, host.filter.base.clear_filter_rw_regions,
|
||||
&host.filter, 0);
|
||||
status |= mock_expect (&host.filter.mock, host.filter.base.set_filter_rw_region, &host.filter,
|
||||
0, MOCK_ARG (1), MOCK_ARG (0), MOCK_ARG (0xffff0000));
|
||||
|
||||
status |= mock_expect (&host.filter.mock, host.filter.base.set_filter_mode, &host.filter, 0,
|
||||
MOCK_ARG (SPI_FILTER_FLASH_SINGLE_CS0));
|
||||
|
||||
status |= mock_expect (&host.observer.mock, host.observer.base.on_bypass_mode, &host.observer,
|
||||
0);
|
||||
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.base.set_flash_for_host_access,
|
||||
&host.flash_mgr, 0, MOCK_ARG (&host.control));
|
||||
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
status = host.test.base.bypass_mode (&host.test.base, true);
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
status = host_state_manager_is_pfm_dirty (&host.host_state);
|
||||
CuAssertIntEquals (test, true, status);
|
||||
|
||||
status = host_state_manager_get_read_only_flash (&host.host_state);
|
||||
CuAssertIntEquals (test, SPI_FILTER_CS_0, status);
|
||||
|
||||
status = host_state_manager_is_bypass_mode (&host.host_state);
|
||||
CuAssertIntEquals (test, true, status);
|
||||
|
||||
host_processor_single_testing_validate_and_release (test, &host);
|
||||
}
|
||||
|
||||
static void host_processor_single_test_bypass_mode_rw_flash_cs0 (CuTest *test)
|
||||
{
|
||||
struct host_processor_single_testing host;
|
||||
int status;
|
||||
|
||||
TEST_START;
|
||||
|
||||
host_processor_single_testing_init (test, &host);
|
||||
|
||||
status = host_state_manager_save_read_only_flash (&host.host_state, SPI_FILTER_CS_1);
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
status = mock_expect (&host.filter.mock, host.filter.base.clear_filter_rw_regions,
|
||||
&host.filter, 0);
|
||||
status |= mock_expect (&host.filter.mock, host.filter.base.set_filter_rw_region, &host.filter,
|
||||
0, MOCK_ARG (1), MOCK_ARG (0), MOCK_ARG (0xffff0000));
|
||||
|
||||
status |= mock_expect (&host.filter.mock, host.filter.base.set_filter_mode, &host.filter, 0,
|
||||
MOCK_ARG (SPI_FILTER_FLASH_SINGLE_CS0));
|
||||
|
||||
status |= mock_expect (&host.observer.mock, host.observer.base.on_bypass_mode, &host.observer,
|
||||
0);
|
||||
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.base.set_flash_for_host_access,
|
||||
&host.flash_mgr, 0, MOCK_ARG (&host.control));
|
||||
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
status = host.test.base.bypass_mode (&host.test.base, true);
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
status = host_state_manager_is_pfm_dirty (&host.host_state);
|
||||
CuAssertIntEquals (test, true, status);
|
||||
|
||||
status = host_state_manager_get_read_only_flash (&host.host_state);
|
||||
CuAssertIntEquals (test, SPI_FILTER_CS_0, status);
|
||||
|
||||
status = host_state_manager_is_bypass_mode (&host.host_state);
|
||||
CuAssertIntEquals (test, true, status);
|
||||
|
||||
host_processor_single_testing_validate_and_release (test, &host);
|
||||
}
|
||||
|
||||
static void host_processor_single_test_bypass_mode_no_observer (CuTest *test)
|
||||
{
|
||||
struct host_processor_single_testing host;
|
||||
int status;
|
||||
|
||||
TEST_START;
|
||||
|
||||
host_processor_single_testing_init (test, &host);
|
||||
|
||||
status = host_processor_remove_observer (&host.test.base, &host.observer.base);
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
status = mock_expect (&host.filter.mock, host.filter.base.clear_filter_rw_regions,
|
||||
&host.filter, 0);
|
||||
status |= mock_expect (&host.filter.mock, host.filter.base.set_filter_rw_region, &host.filter,
|
||||
0, MOCK_ARG (1), MOCK_ARG (0), MOCK_ARG (0xffff0000));
|
||||
|
||||
status |= mock_expect (&host.filter.mock, host.filter.base.set_filter_mode, &host.filter, 0,
|
||||
MOCK_ARG (SPI_FILTER_FLASH_SINGLE_CS0));
|
||||
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.base.set_flash_for_host_access,
|
||||
&host.flash_mgr, 0, MOCK_ARG (&host.control));
|
||||
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
status = host.test.base.bypass_mode (&host.test.base, false);
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
status = host_state_manager_is_pfm_dirty (&host.host_state);
|
||||
CuAssertIntEquals (test, true, status);
|
||||
|
||||
status = host_state_manager_get_read_only_flash (&host.host_state);
|
||||
CuAssertIntEquals (test, SPI_FILTER_CS_0, status);
|
||||
|
||||
status = host_state_manager_is_bypass_mode (&host.host_state);
|
||||
CuAssertIntEquals (test, true, status);
|
||||
|
||||
host_processor_single_testing_validate_and_release (test, &host);
|
||||
}
|
||||
|
||||
static void host_processor_single_test_bypass_mode_unsupported_flash (CuTest *test)
|
||||
{
|
||||
struct host_processor_single_testing host;
|
||||
int status;
|
||||
|
||||
TEST_START;
|
||||
|
||||
host_processor_single_testing_init (test, &host);
|
||||
|
||||
host_state_manager_set_unsupported_flash (&host.host_state, true);
|
||||
|
||||
status = mock_expect (&host.filter.mock, host.filter.base.clear_filter_rw_regions,
|
||||
&host.filter, 0);
|
||||
status |= mock_expect (&host.filter.mock, host.filter.base.set_filter_rw_region, &host.filter,
|
||||
0, MOCK_ARG (1), MOCK_ARG (0), MOCK_ARG (0xffff0000));
|
||||
|
||||
status |= mock_expect (&host.filter.mock, host.filter.base.set_filter_mode, &host.filter, 0,
|
||||
MOCK_ARG (SPI_FILTER_FLASH_SINGLE_CS0));
|
||||
|
||||
status |= mock_expect (&host.observer.mock, host.observer.base.on_bypass_mode, &host.observer,
|
||||
0);
|
||||
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.base.set_flash_for_host_access,
|
||||
&host.flash_mgr, 0, MOCK_ARG (&host.control));
|
||||
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
status = host.test.base.bypass_mode (&host.test.base, false);
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
status = host_state_manager_is_pfm_dirty (&host.host_state);
|
||||
CuAssertIntEquals (test, true, status);
|
||||
|
||||
status = host_state_manager_get_read_only_flash (&host.host_state);
|
||||
CuAssertIntEquals (test, SPI_FILTER_CS_0, status);
|
||||
|
||||
status = host_state_manager_is_bypass_mode (&host.host_state);
|
||||
CuAssertIntEquals (test, true, status);
|
||||
|
||||
host_processor_single_testing_validate_and_release (test, &host);
|
||||
}
|
||||
|
||||
static void host_processor_single_test_bypass_mode_null (CuTest *test)
|
||||
{
|
||||
struct host_processor_single_testing host;
|
||||
int status;
|
||||
|
||||
TEST_START;
|
||||
|
||||
host_processor_single_testing_init (test, &host);
|
||||
|
||||
status = host.test.base.bypass_mode (NULL, false);
|
||||
CuAssertIntEquals (test, HOST_PROCESSOR_INVALID_ARGUMENT, status);
|
||||
|
||||
status = host_state_manager_is_pfm_dirty (&host.host_state);
|
||||
CuAssertIntEquals (test, true, status);
|
||||
|
||||
status = host_state_manager_is_bypass_mode (&host.host_state);
|
||||
CuAssertIntEquals (test, false, status);
|
||||
|
||||
host_processor_single_testing_validate_and_release (test, &host);
|
||||
}
|
||||
|
||||
static void host_processor_single_test_bypass_mode_filter_error (CuTest *test)
|
||||
{
|
||||
struct host_processor_single_testing host;
|
||||
int status;
|
||||
|
||||
TEST_START;
|
||||
|
||||
host_processor_single_testing_init (test, &host);
|
||||
|
||||
status = mock_expect (&host.filter.mock, host.filter.base.clear_filter_rw_regions,
|
||||
&host.filter, SPI_FILTER_CLEAR_RW_FAILED);
|
||||
status |= mock_expect (&host.filter.mock, host.filter.base.clear_filter_rw_regions,
|
||||
&host.filter, SPI_FILTER_CLEAR_RW_FAILED);
|
||||
status |= mock_expect (&host.filter.mock, host.filter.base.clear_filter_rw_regions,
|
||||
&host.filter, SPI_FILTER_CLEAR_RW_FAILED);
|
||||
status |= mock_expect (&host.filter.mock, host.filter.base.clear_filter_rw_regions,
|
||||
&host.filter, SPI_FILTER_CLEAR_RW_FAILED);
|
||||
status |= mock_expect (&host.filter.mock, host.filter.base.clear_filter_rw_regions,
|
||||
&host.filter, 0);
|
||||
status |= mock_expect (&host.filter.mock, host.filter.base.set_filter_rw_region, &host.filter,
|
||||
0, MOCK_ARG (1), MOCK_ARG (0), MOCK_ARG (0xffff0000));
|
||||
|
||||
status |= mock_expect (&host.filter.mock, host.filter.base.set_filter_mode, &host.filter, 0,
|
||||
MOCK_ARG (SPI_FILTER_FLASH_SINGLE_CS0));
|
||||
|
||||
status |= mock_expect (&host.observer.mock, host.observer.base.on_bypass_mode, &host.observer,
|
||||
0);
|
||||
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.base.set_flash_for_host_access,
|
||||
&host.flash_mgr, 0, MOCK_ARG (&host.control));
|
||||
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
status = host.test.base.bypass_mode (&host.test.base, false);
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
status = host_state_manager_is_pfm_dirty (&host.host_state);
|
||||
CuAssertIntEquals (test, true, status);
|
||||
|
||||
status = host_state_manager_is_bypass_mode (&host.host_state);
|
||||
CuAssertIntEquals (test, true, status);
|
||||
|
||||
host_processor_single_testing_validate_and_release (test, &host);
|
||||
}
|
||||
|
||||
static void host_processor_single_test_bypass_mode_host_access_error (CuTest *test)
|
||||
{
|
||||
struct host_processor_single_testing host;
|
||||
int status;
|
||||
|
||||
TEST_START;
|
||||
|
||||
host_processor_single_testing_init (test, &host);
|
||||
|
||||
status = mock_expect (&host.filter.mock, host.filter.base.clear_filter_rw_regions,
|
||||
&host.filter, 0);
|
||||
status |= mock_expect (&host.filter.mock, host.filter.base.set_filter_rw_region, &host.filter,
|
||||
0, MOCK_ARG (1), MOCK_ARG (0), MOCK_ARG (0xffff0000));
|
||||
|
||||
status |= mock_expect (&host.filter.mock, host.filter.base.set_filter_mode, &host.filter, 0,
|
||||
MOCK_ARG (SPI_FILTER_FLASH_SINGLE_CS0));
|
||||
|
||||
status |= mock_expect (&host.observer.mock, host.observer.base.on_bypass_mode, &host.observer,
|
||||
0);
|
||||
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.base.set_flash_for_host_access,
|
||||
&host.flash_mgr, HOST_FLASH_MGR_HOST_ACCESS_FAILED, MOCK_ARG (&host.control));
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.base.set_flash_for_host_access,
|
||||
&host.flash_mgr, HOST_FLASH_MGR_HOST_ACCESS_FAILED, MOCK_ARG (&host.control));
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.base.set_flash_for_host_access,
|
||||
&host.flash_mgr, HOST_FLASH_MGR_HOST_ACCESS_FAILED, MOCK_ARG (&host.control));
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.base.set_flash_for_host_access,
|
||||
&host.flash_mgr, HOST_FLASH_MGR_HOST_ACCESS_FAILED, MOCK_ARG (&host.control));
|
||||
status |= mock_expect (&host.flash_mgr.mock, host.flash_mgr.base.base.set_flash_for_host_access,
|
||||
&host.flash_mgr, 0, MOCK_ARG (&host.control));
|
||||
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
status = host.test.base.bypass_mode (&host.test.base, false);
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
status = host_state_manager_is_pfm_dirty (&host.host_state);
|
||||
CuAssertIntEquals (test, true, status);
|
||||
|
||||
status = host_state_manager_is_bypass_mode (&host.host_state);
|
||||
CuAssertIntEquals (test, true, status);
|
||||
|
||||
host_processor_single_testing_validate_and_release (test, &host);
|
||||
}
|
||||
|
||||
|
||||
CuSuite* get_host_processor_single_bypass_mode_suite ()
|
||||
{
|
||||
CuSuite *suite = CuSuiteNew ();
|
||||
|
||||
SUITE_ADD_TEST (suite, host_processor_single_test_bypass_mode_ro_flash);
|
||||
SUITE_ADD_TEST (suite, host_processor_single_test_bypass_mode_ro_flash_cs1);
|
||||
SUITE_ADD_TEST (suite, host_processor_single_test_bypass_mode_rw_flash);
|
||||
SUITE_ADD_TEST (suite, host_processor_single_test_bypass_mode_rw_flash_cs0);
|
||||
SUITE_ADD_TEST (suite, host_processor_single_test_bypass_mode_no_observer);
|
||||
SUITE_ADD_TEST (suite, host_processor_single_test_bypass_mode_unsupported_flash);
|
||||
SUITE_ADD_TEST (suite, host_processor_single_test_bypass_mode_null);
|
||||
SUITE_ADD_TEST (suite, host_processor_single_test_bypass_mode_filter_error);
|
||||
SUITE_ADD_TEST (suite, host_processor_single_test_bypass_mode_host_access_error);
|
||||
|
||||
return suite;
|
||||
}
|
|
@ -0,0 +1,312 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include "testing.h"
|
||||
#include "host_processor_single_testing.h"
|
||||
#include "rsa_testing.h"
|
||||
|
||||
|
||||
static const char *SUITE = "host_processor_single";
|
||||
|
||||
|
||||
/*******************
|
||||
* Test cases
|
||||
*******************/
|
||||
|
||||
static void host_processor_single_test_flash_rollback_not_dirty (CuTest *test)
|
||||
{
|
||||
struct host_processor_single_testing host;
|
||||
int status;
|
||||
|
||||
TEST_START;
|
||||
|
||||
host_processor_single_testing_init (test, &host);
|
||||
|
||||
status = host.test.base.flash_rollback (&host.test.base, &host.hash.base, &host.rsa.base,
|
||||
false, false);
|
||||
CuAssertIntEquals (test, HOST_PROCESSOR_NO_ROLLBACK, status);
|
||||
|
||||
status = host_state_manager_is_inactive_dirty (&host.host_state);
|
||||
CuAssertIntEquals (test, false, status);
|
||||
|
||||
status = host_state_manager_is_pfm_dirty (&host.host_state);
|
||||
CuAssertIntEquals (test, true, status);
|
||||
|
||||
CuAssertIntEquals (test, HOST_STATE_PREVALIDATED_NONE,
|
||||
host_state_manager_get_run_time_validation (&host.host_state));
|
||||
|
||||
status = host_state_manager_is_bypass_mode (&host.host_state);
|
||||
CuAssertIntEquals (test, false, status);
|
||||
|
||||
host_processor_single_testing_validate_and_release (test, &host);
|
||||
}
|
||||
|
||||
static void host_processor_single_test_flash_rollback_not_dirty_bypass (CuTest *test)
|
||||
{
|
||||
struct host_processor_single_testing host;
|
||||
int status;
|
||||
|
||||
TEST_START;
|
||||
|
||||
host_processor_single_testing_init (test, &host);
|
||||
|
||||
host_state_manager_set_bypass_mode (&host.host_state, true);
|
||||
|
||||
status = host.test.base.flash_rollback (&host.test.base, &host.hash.base, &host.rsa.base,
|
||||
false, false);
|
||||
CuAssertIntEquals (test, HOST_PROCESSOR_NO_ROLLBACK, status);
|
||||
|
||||
status = host_state_manager_is_inactive_dirty (&host.host_state);
|
||||
CuAssertIntEquals (test, false, status);
|
||||
|
||||
status = host_state_manager_is_pfm_dirty (&host.host_state);
|
||||
CuAssertIntEquals (test, true, status);
|
||||
|
||||
CuAssertIntEquals (test, HOST_STATE_PREVALIDATED_NONE,
|
||||
host_state_manager_get_run_time_validation (&host.host_state));
|
||||
|
||||
status = host_state_manager_is_bypass_mode (&host.host_state);
|
||||
CuAssertIntEquals (test, true, status);
|
||||
|
||||
host_processor_single_testing_validate_and_release (test, &host);
|
||||
}
|
||||
|
||||
static void host_processor_single_test_flash_rollback_not_dirty_checked (CuTest *test)
|
||||
{
|
||||
struct host_processor_single_testing host;
|
||||
int status;
|
||||
|
||||
TEST_START;
|
||||
|
||||
host_processor_single_testing_init (test, &host);
|
||||
|
||||
host_state_manager_set_pfm_dirty (&host.host_state, false);
|
||||
|
||||
status = host.test.base.flash_rollback (&host.test.base, &host.hash.base, &host.rsa.base,
|
||||
false, false);
|
||||
CuAssertIntEquals (test, HOST_PROCESSOR_NO_ROLLBACK, status);
|
||||
|
||||
status = host_state_manager_is_inactive_dirty (&host.host_state);
|
||||
CuAssertIntEquals (test, false, status);
|
||||
|
||||
status = host_state_manager_is_pfm_dirty (&host.host_state);
|
||||
CuAssertIntEquals (test, false, status);
|
||||
|
||||
CuAssertIntEquals (test, HOST_STATE_PREVALIDATED_NONE,
|
||||
host_state_manager_get_run_time_validation (&host.host_state));
|
||||
|
||||
status = host_state_manager_is_bypass_mode (&host.host_state);
|
||||
CuAssertIntEquals (test, false, status);
|
||||
|
||||
host_processor_single_testing_validate_and_release (test, &host);
|
||||
}
|
||||
|
||||
static void host_processor_single_test_flash_rollback_not_dirty_checked_bypass (CuTest *test)
|
||||
{
|
||||
struct host_processor_single_testing host;
|
||||
int status;
|
||||
|
||||
TEST_START;
|
||||
|
||||
host_processor_single_testing_init (test, &host);
|
||||
|
||||
host_state_manager_set_pfm_dirty (&host.host_state, false);
|
||||
host_state_manager_set_bypass_mode (&host.host_state, true);
|
||||
|
||||
status = host.test.base.flash_rollback (&host.test.base, &host.hash.base, &host.rsa.base,
|
||||
false, false);
|
||||
CuAssertIntEquals (test, HOST_PROCESSOR_NO_ROLLBACK, status);
|
||||
|
||||
status = host_state_manager_is_inactive_dirty (&host.host_state);
|
||||
CuAssertIntEquals (test, false, status);
|
||||
|
||||
status = host_state_manager_is_pfm_dirty (&host.host_state);
|
||||
CuAssertIntEquals (test, false, status);
|
||||
|
||||
CuAssertIntEquals (test, HOST_STATE_PREVALIDATED_NONE,
|
||||
host_state_manager_get_run_time_validation (&host.host_state));
|
||||
|
||||
status = host_state_manager_is_bypass_mode (&host.host_state);
|
||||
CuAssertIntEquals (test, true, status);
|
||||
|
||||
host_processor_single_testing_validate_and_release (test, &host);
|
||||
}
|
||||
|
||||
static void host_processor_single_test_flash_rollback_dirty (CuTest *test)
|
||||
{
|
||||
struct host_processor_single_testing host;
|
||||
int status;
|
||||
|
||||
TEST_START;
|
||||
|
||||
host_processor_single_testing_init (test, &host);
|
||||
|
||||
status = host_state_manager_save_inactive_dirty (&host.host_state, true);
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
status = host.test.base.flash_rollback (&host.test.base, &host.hash.base, &host.rsa.base,
|
||||
false, false);
|
||||
CuAssertIntEquals (test, HOST_PROCESSOR_NO_ROLLBACK, status);
|
||||
|
||||
status = host_state_manager_is_inactive_dirty (&host.host_state);
|
||||
CuAssertIntEquals (test, true, status);
|
||||
|
||||
status = host_state_manager_is_pfm_dirty (&host.host_state);
|
||||
CuAssertIntEquals (test, true, status);
|
||||
|
||||
CuAssertIntEquals (test, HOST_STATE_PREVALIDATED_NONE,
|
||||
host_state_manager_get_run_time_validation (&host.host_state));
|
||||
|
||||
status = host_state_manager_is_bypass_mode (&host.host_state);
|
||||
CuAssertIntEquals (test, false, status);
|
||||
|
||||
host_processor_single_testing_validate_and_release (test, &host);
|
||||
}
|
||||
|
||||
static void host_processor_single_test_flash_rollback_dirty_bypass (CuTest *test)
|
||||
{
|
||||
struct host_processor_single_testing host;
|
||||
int status;
|
||||
|
||||
TEST_START;
|
||||
|
||||
host_processor_single_testing_init (test, &host);
|
||||
|
||||
status = host_state_manager_save_inactive_dirty (&host.host_state, true);
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
host_state_manager_set_bypass_mode (&host.host_state, true);
|
||||
|
||||
status = host.test.base.flash_rollback (&host.test.base, &host.hash.base, &host.rsa.base,
|
||||
false, false);
|
||||
CuAssertIntEquals (test, HOST_PROCESSOR_NO_ROLLBACK, status);
|
||||
|
||||
status = host_state_manager_is_inactive_dirty (&host.host_state);
|
||||
CuAssertIntEquals (test, true, status);
|
||||
|
||||
status = host_state_manager_is_pfm_dirty (&host.host_state);
|
||||
CuAssertIntEquals (test, true, status);
|
||||
|
||||
CuAssertIntEquals (test, HOST_STATE_PREVALIDATED_NONE,
|
||||
host_state_manager_get_run_time_validation (&host.host_state));
|
||||
|
||||
status = host_state_manager_is_bypass_mode (&host.host_state);
|
||||
CuAssertIntEquals (test, true, status);
|
||||
|
||||
host_processor_single_testing_validate_and_release (test, &host);
|
||||
}
|
||||
|
||||
static void host_processor_single_test_flash_rollback_dirty_checked (CuTest *test)
|
||||
{
|
||||
struct host_processor_single_testing host;
|
||||
int status;
|
||||
|
||||
TEST_START;
|
||||
|
||||
host_processor_single_testing_init (test, &host);
|
||||
|
||||
status = host_state_manager_save_inactive_dirty (&host.host_state, true);
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
host_state_manager_set_pfm_dirty (&host.host_state, false);
|
||||
|
||||
status = host.test.base.flash_rollback (&host.test.base, &host.hash.base, &host.rsa.base,
|
||||
false, false);
|
||||
CuAssertIntEquals (test, HOST_PROCESSOR_NO_ROLLBACK, status);
|
||||
|
||||
status = host_state_manager_is_inactive_dirty (&host.host_state);
|
||||
CuAssertIntEquals (test, true, status);
|
||||
|
||||
status = host_state_manager_is_pfm_dirty (&host.host_state);
|
||||
CuAssertIntEquals (test, false, status);
|
||||
|
||||
CuAssertIntEquals (test, HOST_STATE_PREVALIDATED_NONE,
|
||||
host_state_manager_get_run_time_validation (&host.host_state));
|
||||
|
||||
status = host_state_manager_is_bypass_mode (&host.host_state);
|
||||
CuAssertIntEquals (test, false, status);
|
||||
|
||||
host_processor_single_testing_validate_and_release (test, &host);
|
||||
}
|
||||
|
||||
static void host_processor_single_test_flash_rollback_dirty_checked_bypass (CuTest *test)
|
||||
{
|
||||
struct host_processor_single_testing host;
|
||||
int status;
|
||||
|
||||
TEST_START;
|
||||
|
||||
host_processor_single_testing_init (test, &host);
|
||||
|
||||
status = host_state_manager_save_inactive_dirty (&host.host_state, true);
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
host_state_manager_set_pfm_dirty (&host.host_state, false);
|
||||
host_state_manager_set_bypass_mode (&host.host_state, true);
|
||||
|
||||
status = host.test.base.flash_rollback (&host.test.base, &host.hash.base, &host.rsa.base,
|
||||
false, false);
|
||||
CuAssertIntEquals (test, HOST_PROCESSOR_NO_ROLLBACK, status);
|
||||
|
||||
status = host_state_manager_is_inactive_dirty (&host.host_state);
|
||||
CuAssertIntEquals (test, true, status);
|
||||
|
||||
status = host_state_manager_is_pfm_dirty (&host.host_state);
|
||||
CuAssertIntEquals (test, false, status);
|
||||
|
||||
CuAssertIntEquals (test, HOST_STATE_PREVALIDATED_NONE,
|
||||
host_state_manager_get_run_time_validation (&host.host_state));
|
||||
|
||||
status = host_state_manager_is_bypass_mode (&host.host_state);
|
||||
CuAssertIntEquals (test, true, status);
|
||||
|
||||
host_processor_single_testing_validate_and_release (test, &host);
|
||||
}
|
||||
|
||||
static void host_processor_single_test_flash_rollback_null (CuTest *test)
|
||||
{
|
||||
struct host_processor_single_testing host;
|
||||
int status;
|
||||
|
||||
TEST_START;
|
||||
|
||||
host_processor_single_testing_init (test, &host);
|
||||
|
||||
status = host.test.base.flash_rollback (NULL, &host.hash.base, &host.rsa.base, false, false);
|
||||
CuAssertIntEquals (test, HOST_PROCESSOR_INVALID_ARGUMENT, status);
|
||||
|
||||
status = host.test.base.flash_rollback (&host.test.base, NULL, &host.rsa.base, false, false);
|
||||
CuAssertIntEquals (test, HOST_PROCESSOR_INVALID_ARGUMENT, status);
|
||||
|
||||
status = host.test.base.flash_rollback (&host.test.base, &host.hash.base, NULL, false, false);
|
||||
CuAssertIntEquals (test, HOST_PROCESSOR_INVALID_ARGUMENT, status);
|
||||
|
||||
status = host_state_manager_is_pfm_dirty (&host.host_state);
|
||||
CuAssertIntEquals (test, true, status);
|
||||
|
||||
status = host_state_manager_is_bypass_mode (&host.host_state);
|
||||
CuAssertIntEquals (test, false, status);
|
||||
|
||||
host_processor_single_testing_validate_and_release (test, &host);
|
||||
}
|
||||
|
||||
|
||||
CuSuite* get_host_processor_single_flash_rollback_suite ()
|
||||
{
|
||||
CuSuite *suite = CuSuiteNew ();
|
||||
|
||||
SUITE_ADD_TEST (suite, host_processor_single_test_flash_rollback_not_dirty);
|
||||
SUITE_ADD_TEST (suite, host_processor_single_test_flash_rollback_not_dirty_bypass);
|
||||
SUITE_ADD_TEST (suite, host_processor_single_test_flash_rollback_not_dirty_checked);
|
||||
SUITE_ADD_TEST (suite, host_processor_single_test_flash_rollback_not_dirty_checked_bypass);
|
||||
SUITE_ADD_TEST (suite, host_processor_single_test_flash_rollback_dirty);
|
||||
SUITE_ADD_TEST (suite, host_processor_single_test_flash_rollback_dirty_bypass);
|
||||
SUITE_ADD_TEST (suite, host_processor_single_test_flash_rollback_dirty_checked);
|
||||
SUITE_ADD_TEST (suite, host_processor_single_test_flash_rollback_dirty_checked_bypass);
|
||||
SUITE_ADD_TEST (suite, host_processor_single_test_flash_rollback_null);
|
||||
|
||||
return suite;
|
||||
}
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -0,0 +1,299 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include "testing.h"
|
||||
#include "host_processor_single_testing.h"
|
||||
|
||||
|
||||
static const char *SUITE = "host_processor_single";
|
||||
|
||||
|
||||
/*******************
|
||||
* Test cases
|
||||
*******************/
|
||||
|
||||
static void host_processor_single_test_recover_active_read_write_data_not_dirty (CuTest *test)
|
||||
{
|
||||
struct host_processor_single_testing host;
|
||||
int status;
|
||||
|
||||
TEST_START;
|
||||
|
||||
host_processor_single_testing_init (test, &host);
|
||||
|
||||
status = host.test.base.recover_active_read_write_data (&host.test.base);
|
||||
CuAssertIntEquals (test, HOST_PROCESSOR_NO_ACTIVE_RW_DATA, status);
|
||||
|
||||
status = host_state_manager_is_inactive_dirty (&host.host_state);
|
||||
CuAssertIntEquals (test, false, status);
|
||||
|
||||
status = host_state_manager_is_pfm_dirty (&host.host_state);
|
||||
CuAssertIntEquals (test, true, status);
|
||||
|
||||
CuAssertIntEquals (test, HOST_STATE_PREVALIDATED_NONE,
|
||||
host_state_manager_get_run_time_validation (&host.host_state));
|
||||
|
||||
status = host_state_manager_is_bypass_mode (&host.host_state);
|
||||
CuAssertIntEquals (test, false, status);
|
||||
|
||||
host_processor_single_testing_validate_and_release (test, &host);
|
||||
}
|
||||
|
||||
static void host_processor_single_test_recover_active_read_write_data_not_dirty_bypass (
|
||||
CuTest *test)
|
||||
{
|
||||
struct host_processor_single_testing host;
|
||||
int status;
|
||||
|
||||
TEST_START;
|
||||
|
||||
host_processor_single_testing_init (test, &host);
|
||||
|
||||
host_state_manager_set_bypass_mode (&host.host_state, true);
|
||||
|
||||
status = host.test.base.recover_active_read_write_data (&host.test.base);
|
||||
CuAssertIntEquals (test, HOST_PROCESSOR_NO_ACTIVE_RW_DATA, status);
|
||||
|
||||
status = host_state_manager_is_inactive_dirty (&host.host_state);
|
||||
CuAssertIntEquals (test, false, status);
|
||||
|
||||
status = host_state_manager_is_pfm_dirty (&host.host_state);
|
||||
CuAssertIntEquals (test, true, status);
|
||||
|
||||
CuAssertIntEquals (test, HOST_STATE_PREVALIDATED_NONE,
|
||||
host_state_manager_get_run_time_validation (&host.host_state));
|
||||
|
||||
status = host_state_manager_is_bypass_mode (&host.host_state);
|
||||
CuAssertIntEquals (test, true, status);
|
||||
|
||||
host_processor_single_testing_validate_and_release (test, &host);
|
||||
}
|
||||
|
||||
static void host_processor_single_test_recover_active_read_write_data_not_dirty_checked (
|
||||
CuTest *test)
|
||||
{
|
||||
struct host_processor_single_testing host;
|
||||
int status;
|
||||
|
||||
TEST_START;
|
||||
|
||||
host_processor_single_testing_init (test, &host);
|
||||
|
||||
host_state_manager_set_pfm_dirty (&host.host_state, false);
|
||||
|
||||
status = host.test.base.recover_active_read_write_data (&host.test.base);
|
||||
CuAssertIntEquals (test, HOST_PROCESSOR_NO_ACTIVE_RW_DATA, status);
|
||||
|
||||
status = host_state_manager_is_inactive_dirty (&host.host_state);
|
||||
CuAssertIntEquals (test, false, status);
|
||||
|
||||
status = host_state_manager_is_pfm_dirty (&host.host_state);
|
||||
CuAssertIntEquals (test, false, status);
|
||||
|
||||
CuAssertIntEquals (test, HOST_STATE_PREVALIDATED_NONE,
|
||||
host_state_manager_get_run_time_validation (&host.host_state));
|
||||
|
||||
status = host_state_manager_is_bypass_mode (&host.host_state);
|
||||
CuAssertIntEquals (test, false, status);
|
||||
|
||||
host_processor_single_testing_validate_and_release (test, &host);
|
||||
}
|
||||
|
||||
static void host_processor_single_test_recover_active_read_write_data_not_dirty_checked_bypass (
|
||||
CuTest *test)
|
||||
{
|
||||
struct host_processor_single_testing host;
|
||||
int status;
|
||||
|
||||
TEST_START;
|
||||
|
||||
host_processor_single_testing_init (test, &host);
|
||||
|
||||
host_state_manager_set_pfm_dirty (&host.host_state, false);
|
||||
host_state_manager_set_bypass_mode (&host.host_state, true);
|
||||
|
||||
status = host.test.base.recover_active_read_write_data (&host.test.base);
|
||||
CuAssertIntEquals (test, HOST_PROCESSOR_NO_ACTIVE_RW_DATA, status);
|
||||
|
||||
status = host_state_manager_is_inactive_dirty (&host.host_state);
|
||||
CuAssertIntEquals (test, false, status);
|
||||
|
||||
status = host_state_manager_is_pfm_dirty (&host.host_state);
|
||||
CuAssertIntEquals (test, false, status);
|
||||
|
||||
CuAssertIntEquals (test, HOST_STATE_PREVALIDATED_NONE,
|
||||
host_state_manager_get_run_time_validation (&host.host_state));
|
||||
|
||||
status = host_state_manager_is_bypass_mode (&host.host_state);
|
||||
CuAssertIntEquals (test, true, status);
|
||||
|
||||
host_processor_single_testing_validate_and_release (test, &host);
|
||||
}
|
||||
|
||||
static void host_processor_single_test_recover_active_read_write_data_dirty (CuTest *test)
|
||||
{
|
||||
struct host_processor_single_testing host;
|
||||
int status;
|
||||
|
||||
TEST_START;
|
||||
|
||||
host_processor_single_testing_init (test, &host);
|
||||
|
||||
status = host_state_manager_save_inactive_dirty (&host.host_state, true);
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
status = host.test.base.recover_active_read_write_data (&host.test.base);
|
||||
CuAssertIntEquals (test, HOST_PROCESSOR_NO_ACTIVE_RW_DATA, status);
|
||||
|
||||
status = host_state_manager_is_inactive_dirty (&host.host_state);
|
||||
CuAssertIntEquals (test, true, status);
|
||||
|
||||
status = host_state_manager_is_pfm_dirty (&host.host_state);
|
||||
CuAssertIntEquals (test, true, status);
|
||||
|
||||
CuAssertIntEquals (test, HOST_STATE_PREVALIDATED_NONE,
|
||||
host_state_manager_get_run_time_validation (&host.host_state));
|
||||
|
||||
status = host_state_manager_is_bypass_mode (&host.host_state);
|
||||
CuAssertIntEquals (test, false, status);
|
||||
|
||||
host_processor_single_testing_validate_and_release (test, &host);
|
||||
}
|
||||
|
||||
static void host_processor_single_test_recover_active_read_write_data_dirty_bypass (CuTest *test)
|
||||
{
|
||||
struct host_processor_single_testing host;
|
||||
int status;
|
||||
|
||||
TEST_START;
|
||||
|
||||
host_processor_single_testing_init (test, &host);
|
||||
|
||||
status = host_state_manager_save_inactive_dirty (&host.host_state, true);
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
host_state_manager_set_bypass_mode (&host.host_state, true);
|
||||
|
||||
status = host.test.base.recover_active_read_write_data (&host.test.base);
|
||||
CuAssertIntEquals (test, HOST_PROCESSOR_NO_ACTIVE_RW_DATA, status);
|
||||
|
||||
status = host_state_manager_is_inactive_dirty (&host.host_state);
|
||||
CuAssertIntEquals (test, true, status);
|
||||
|
||||
status = host_state_manager_is_pfm_dirty (&host.host_state);
|
||||
CuAssertIntEquals (test, true, status);
|
||||
|
||||
CuAssertIntEquals (test, HOST_STATE_PREVALIDATED_NONE,
|
||||
host_state_manager_get_run_time_validation (&host.host_state));
|
||||
|
||||
status = host_state_manager_is_bypass_mode (&host.host_state);
|
||||
CuAssertIntEquals (test, true, status);
|
||||
|
||||
host_processor_single_testing_validate_and_release (test, &host);
|
||||
}
|
||||
|
||||
static void host_processor_single_test_recover_active_read_write_data_dirty_checked (CuTest *test)
|
||||
{
|
||||
struct host_processor_single_testing host;
|
||||
int status;
|
||||
|
||||
TEST_START;
|
||||
|
||||
host_processor_single_testing_init (test, &host);
|
||||
|
||||
status = host_state_manager_save_inactive_dirty (&host.host_state, true);
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
host_state_manager_set_pfm_dirty (&host.host_state, false);
|
||||
|
||||
status = host.test.base.recover_active_read_write_data (&host.test.base);
|
||||
CuAssertIntEquals (test, HOST_PROCESSOR_NO_ACTIVE_RW_DATA, status);
|
||||
|
||||
status = host_state_manager_is_inactive_dirty (&host.host_state);
|
||||
CuAssertIntEquals (test, true, status);
|
||||
|
||||
status = host_state_manager_is_pfm_dirty (&host.host_state);
|
||||
CuAssertIntEquals (test, false, status);
|
||||
|
||||
CuAssertIntEquals (test, HOST_STATE_PREVALIDATED_NONE,
|
||||
host_state_manager_get_run_time_validation (&host.host_state));
|
||||
|
||||
status = host_state_manager_is_bypass_mode (&host.host_state);
|
||||
CuAssertIntEquals (test, false, status);
|
||||
|
||||
host_processor_single_testing_validate_and_release (test, &host);
|
||||
}
|
||||
|
||||
static void host_processor_single_test_recover_active_read_write_data_dirty_checked_bypass (
|
||||
CuTest *test)
|
||||
{
|
||||
struct host_processor_single_testing host;
|
||||
int status;
|
||||
|
||||
TEST_START;
|
||||
|
||||
host_processor_single_testing_init (test, &host);
|
||||
|
||||
status = host_state_manager_save_inactive_dirty (&host.host_state, true);
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
host_state_manager_set_pfm_dirty (&host.host_state, false);
|
||||
host_state_manager_set_bypass_mode (&host.host_state, true);
|
||||
|
||||
status = host.test.base.recover_active_read_write_data (&host.test.base);
|
||||
CuAssertIntEquals (test, HOST_PROCESSOR_NO_ACTIVE_RW_DATA, status);
|
||||
|
||||
status = host_state_manager_is_inactive_dirty (&host.host_state);
|
||||
CuAssertIntEquals (test, true, status);
|
||||
|
||||
status = host_state_manager_is_pfm_dirty (&host.host_state);
|
||||
CuAssertIntEquals (test, false, status);
|
||||
|
||||
CuAssertIntEquals (test, HOST_STATE_PREVALIDATED_NONE,
|
||||
host_state_manager_get_run_time_validation (&host.host_state));
|
||||
|
||||
status = host_state_manager_is_bypass_mode (&host.host_state);
|
||||
CuAssertIntEquals (test, true, status);
|
||||
|
||||
host_processor_single_testing_validate_and_release (test, &host);
|
||||
}
|
||||
|
||||
static void host_processor_single_test_recover_active_read_write_data_null (CuTest *test)
|
||||
{
|
||||
struct host_processor_single_testing host;
|
||||
int status;
|
||||
|
||||
TEST_START;
|
||||
|
||||
host_processor_single_testing_init (test, &host);
|
||||
|
||||
status = host.test.base.recover_active_read_write_data (NULL);
|
||||
CuAssertIntEquals (test, HOST_PROCESSOR_INVALID_ARGUMENT, status);
|
||||
|
||||
host_processor_single_testing_validate_and_release (test, &host);
|
||||
}
|
||||
|
||||
|
||||
CuSuite* get_host_processor_single_recover_active_read_write_data_suite ()
|
||||
{
|
||||
CuSuite *suite = CuSuiteNew ();
|
||||
|
||||
SUITE_ADD_TEST (suite, host_processor_single_test_recover_active_read_write_data_not_dirty);
|
||||
SUITE_ADD_TEST (suite,
|
||||
host_processor_single_test_recover_active_read_write_data_not_dirty_bypass);
|
||||
SUITE_ADD_TEST (suite,
|
||||
host_processor_single_test_recover_active_read_write_data_not_dirty_checked);
|
||||
SUITE_ADD_TEST (suite,
|
||||
host_processor_single_test_recover_active_read_write_data_not_dirty_checked_bypass);
|
||||
SUITE_ADD_TEST (suite, host_processor_single_test_recover_active_read_write_data_dirty);
|
||||
SUITE_ADD_TEST (suite, host_processor_single_test_recover_active_read_write_data_dirty_bypass);
|
||||
SUITE_ADD_TEST (suite, host_processor_single_test_recover_active_read_write_data_dirty_checked);
|
||||
SUITE_ADD_TEST (suite,
|
||||
host_processor_single_test_recover_active_read_write_data_dirty_checked_bypass);
|
||||
SUITE_ADD_TEST (suite, host_processor_single_test_recover_active_read_write_data_null);
|
||||
|
||||
return suite;
|
||||
}
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -0,0 +1,62 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
#ifndef HOST_PROCESSOR_SINGLE_TESTING_H_
|
||||
#define HOST_PROCESSOR_SINGLE_TESTING_H_
|
||||
|
||||
#include "testing.h"
|
||||
#include "host_fw/host_processor_single.h"
|
||||
#include "host_fw/host_state_manager.h"
|
||||
#include "flash/spi_flash.h"
|
||||
#include "mock/flash_master_mock.h"
|
||||
#include "mock/spi_filter_interface_mock.h"
|
||||
#include "mock/host_control_mock.h"
|
||||
#include "mock/host_flash_manager_single_mock.h"
|
||||
#include "mock/pfm_manager_mock.h"
|
||||
#include "mock/pfm_mock.h"
|
||||
#include "mock/recovery_image_manager_mock.h"
|
||||
#include "mock/recovery_image_mock.h"
|
||||
#include "mock/host_processor_observer_mock.h"
|
||||
#include "engines/hash_testing_engine.h"
|
||||
#include "engines/rsa_testing_engine.h"
|
||||
|
||||
|
||||
/**
|
||||
* Dependencies for testing.
|
||||
*/
|
||||
struct host_processor_single_testing {
|
||||
HASH_TESTING_ENGINE hash; /**< Hash engine for API arguments. */
|
||||
RSA_TESTING_ENGINE rsa; /**< RSA engine for API arguments. */
|
||||
struct flash_master_mock flash_mock_state; /**< Flash mock for host state information. */
|
||||
struct spi_flash flash_state; /**< Host state flash. */
|
||||
struct host_state_manager host_state; /**< Host state manager. */
|
||||
struct spi_filter_interface_mock filter; /**< Mock for the SPI filter. */
|
||||
struct host_flash_manager_single_mock flash_mgr; /**< Mock for flash management. */
|
||||
struct host_control_mock control; /**< Mock for host control. */
|
||||
struct pfm_manager_mock pfm_mgr; /**< Mock for PFM management. */
|
||||
struct pfm_mock pfm; /**< Mock for a valid PFM. */
|
||||
struct pfm_mock pfm_next; /**< Mock for a valid pending PFM. */
|
||||
struct recovery_image_manager_mock recovery_manager; /**< Mock for recovery image management. */
|
||||
struct recovery_image_mock image; /**< Mock for a valid recovery image. */
|
||||
struct host_processor_observer_mock observer; /**< Mock for host notifications. */
|
||||
struct host_processor_filtered test; /**< Host instance being tested. */
|
||||
};
|
||||
|
||||
|
||||
void host_processor_single_testing_init (CuTest *test,
|
||||
struct host_processor_single_testing *host);
|
||||
void host_processor_single_testing_init_pulse_reset (CuTest *test,
|
||||
struct host_processor_single_testing *host);
|
||||
void host_processor_single_testing_init_no_recovery (CuTest *test,
|
||||
struct host_processor_single_testing *host);
|
||||
void host_processor_single_testing_init_no_recovery_pulse_reset (CuTest *test,
|
||||
struct host_processor_single_testing *host);
|
||||
|
||||
void host_processor_single_testing_validate_and_release (CuTest *test,
|
||||
struct host_processor_single_testing *host);
|
||||
|
||||
void host_processor_single_testing_init_host_state (CuTest *test, struct host_state_manager *state,
|
||||
struct flash_master_mock *flash_mock, struct spi_flash *flash);
|
||||
|
||||
|
||||
#endif /* HOST_PROCESSOR_SINGLE_TESTING_H_ */
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -0,0 +1,234 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include "testing.h"
|
||||
#include "host_fw/host_state_observer_dirty_reset.h"
|
||||
#include "host_fw/host_state_manager.h"
|
||||
#include "mock/host_control_mock.h"
|
||||
#include "mock/flash_mock.h"
|
||||
|
||||
|
||||
static const char *SUITE = "host_state_observer_dirty_reset";
|
||||
|
||||
|
||||
/**
|
||||
* Initialize the host state manager for testing.
|
||||
*
|
||||
* @param test The testing framework.
|
||||
* @param state The host state instance to initialize.
|
||||
* @param flash The flash device to initialize for state.
|
||||
*/
|
||||
void host_state_observer_dirty_reset_testing_init_host_state (CuTest *test,
|
||||
struct host_state_manager *state, struct flash_mock *flash)
|
||||
{
|
||||
int status;
|
||||
uint32_t sector_size = 0x1000;
|
||||
uint16_t end[4] = {0xffff, 0xffff, 0xffff, 0xffff};
|
||||
|
||||
status = flash_mock_init (flash);
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
status = mock_expect (&flash->mock, flash->base.get_sector_size, flash, 0, MOCK_ARG_NOT_NULL);
|
||||
status |= mock_expect_output (&flash->mock, 0, §or_size, sizeof (sector_size), -1);
|
||||
|
||||
status |= mock_expect (&flash->mock, flash->base.read, flash, 0, MOCK_ARG (0x10000),
|
||||
MOCK_ARG_NOT_NULL, MOCK_ARG (8));
|
||||
status |= mock_expect_output (&flash->mock, 1, end, sizeof (end), 2);
|
||||
|
||||
status |= mock_expect (&flash->mock, flash->base.read, flash, 0, MOCK_ARG (0x11000),
|
||||
MOCK_ARG_NOT_NULL, MOCK_ARG (8));
|
||||
status |= mock_expect_output (&flash->mock, 1, end, sizeof (end), 2);
|
||||
|
||||
status |= flash_mock_expect_erase_flash_sector_verify (flash, 0x10000, 0x1000);
|
||||
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
status = host_state_manager_init (state, &flash->base, 0x10000);
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
}
|
||||
|
||||
/*******************
|
||||
* Test cases
|
||||
*******************/
|
||||
|
||||
static void host_state_observer_dirty_reset_test_init (CuTest *test)
|
||||
{
|
||||
struct host_control_mock control;
|
||||
struct host_state_observer_dirty_reset observer;
|
||||
int status;
|
||||
|
||||
TEST_START;
|
||||
|
||||
status = host_control_mock_init (&control);
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
status = host_state_observer_dirty_reset_init (&observer, &control.base);
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
CuAssertPtrEquals (test, NULL, observer.base.on_active_pfm);
|
||||
CuAssertPtrEquals (test, NULL, observer.base.on_read_only_flash);
|
||||
CuAssertPtrNotNull (test, observer.base.on_inactive_dirty);
|
||||
CuAssertPtrEquals (test, NULL, observer.base.on_active_recovery_image);
|
||||
CuAssertPtrEquals (test, NULL, observer.base.on_pfm_dirty);
|
||||
CuAssertPtrEquals (test, NULL, observer.base.on_run_time_validation);
|
||||
CuAssertPtrEquals (test, NULL, observer.base.on_bypass_mode);
|
||||
CuAssertPtrEquals (test, NULL, observer.base.on_unsupported_flash);
|
||||
|
||||
status = host_control_mock_validate_and_release (&control);
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
host_state_observer_dirty_reset_release (&observer);
|
||||
}
|
||||
|
||||
static void host_state_observer_dirty_reset_test_init_null (CuTest *test)
|
||||
{
|
||||
struct host_control_mock control;
|
||||
struct host_state_observer_dirty_reset observer;
|
||||
int status;
|
||||
|
||||
TEST_START;
|
||||
|
||||
status = host_control_mock_init (&control);
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
status = host_state_observer_dirty_reset_init (NULL, &control.base);
|
||||
CuAssertIntEquals (test, HOST_STATE_OBSERVER_INVALID_ARGUMENT, status);
|
||||
|
||||
status = host_state_observer_dirty_reset_init (&observer, NULL);
|
||||
CuAssertIntEquals (test, HOST_STATE_OBSERVER_INVALID_ARGUMENT, status);
|
||||
|
||||
status = host_control_mock_validate_and_release (&control);
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
}
|
||||
|
||||
static void host_state_observer_dirty_reset_test_release_null (CuTest *test)
|
||||
{
|
||||
TEST_START;
|
||||
|
||||
host_state_observer_dirty_reset_release (NULL);
|
||||
}
|
||||
|
||||
static void host_state_observer_dirty_reset_test_on_inactive_dirty_dirty (CuTest *test)
|
||||
{
|
||||
struct host_control_mock control;
|
||||
struct host_state_observer_dirty_reset observer;
|
||||
int status;
|
||||
struct flash_mock flash;
|
||||
struct host_state_manager state;
|
||||
|
||||
TEST_START;
|
||||
|
||||
status = host_control_mock_init (&control);
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
host_state_observer_dirty_reset_testing_init_host_state (test, &state, &flash);
|
||||
|
||||
host_state_manager_save_inactive_dirty (&state, true);
|
||||
|
||||
status = host_state_observer_dirty_reset_init (&observer, &control.base);
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
status = mock_expect (&control.mock, control.base.hold_processor_in_reset, &control, 0,
|
||||
MOCK_ARG (true));
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
observer.base.on_inactive_dirty (&observer.base, &state);
|
||||
|
||||
status = host_control_mock_validate_and_release (&control);
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
status = flash_mock_validate_and_release (&flash);
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
host_state_observer_dirty_reset_release (&observer);
|
||||
|
||||
host_state_manager_release (&state);
|
||||
}
|
||||
|
||||
static void host_state_observer_dirty_reset_test_on_inactive_dirty_not_dirty (CuTest *test)
|
||||
{
|
||||
struct host_control_mock control;
|
||||
struct host_state_observer_dirty_reset observer;
|
||||
int status;
|
||||
struct flash_mock flash;
|
||||
struct host_state_manager state;
|
||||
|
||||
TEST_START;
|
||||
|
||||
status = host_control_mock_init (&control);
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
host_state_observer_dirty_reset_testing_init_host_state (test, &state, &flash);
|
||||
|
||||
host_state_manager_save_inactive_dirty (&state, false);
|
||||
|
||||
status = host_state_observer_dirty_reset_init (&observer, &control.base);
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
observer.base.on_inactive_dirty (&observer.base, &state);
|
||||
|
||||
status = host_control_mock_validate_and_release (&control);
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
status = flash_mock_validate_and_release (&flash);
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
host_state_observer_dirty_reset_release (&observer);
|
||||
|
||||
host_state_manager_release (&state);
|
||||
}
|
||||
|
||||
static void host_state_observer_dirty_reset_test_on_inactive_dirty_control_error (CuTest *test)
|
||||
{
|
||||
struct host_control_mock control;
|
||||
struct host_state_observer_dirty_reset observer;
|
||||
int status;
|
||||
struct flash_mock flash;
|
||||
struct host_state_manager state;
|
||||
|
||||
TEST_START;
|
||||
|
||||
status = host_control_mock_init (&control);
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
host_state_observer_dirty_reset_testing_init_host_state (test, &state, &flash);
|
||||
|
||||
host_state_manager_save_inactive_dirty (&state, true);
|
||||
|
||||
status = host_state_observer_dirty_reset_init (&observer, &control.base);
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
status = mock_expect (&control.mock, control.base.hold_processor_in_reset, &control,
|
||||
HOST_CONTROL_HOLD_RESET_FAILED, MOCK_ARG (true));
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
observer.base.on_inactive_dirty (&observer.base, &state);
|
||||
|
||||
status = host_control_mock_validate_and_release (&control);
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
status = flash_mock_validate_and_release (&flash);
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
host_state_observer_dirty_reset_release (&observer);
|
||||
|
||||
host_state_manager_release (&state);
|
||||
}
|
||||
|
||||
|
||||
CuSuite* get_host_state_observer_dirty_reset_suite ()
|
||||
{
|
||||
CuSuite *suite = CuSuiteNew ();
|
||||
|
||||
SUITE_ADD_TEST (suite, host_state_observer_dirty_reset_test_init);
|
||||
SUITE_ADD_TEST (suite, host_state_observer_dirty_reset_test_init_null);
|
||||
SUITE_ADD_TEST (suite, host_state_observer_dirty_reset_test_release_null);
|
||||
SUITE_ADD_TEST (suite, host_state_observer_dirty_reset_test_on_inactive_dirty_dirty);
|
||||
SUITE_ADD_TEST (suite, host_state_observer_dirty_reset_test_on_inactive_dirty_not_dirty);
|
||||
SUITE_ADD_TEST (suite, host_state_observer_dirty_reset_test_on_inactive_dirty_control_error);
|
||||
|
||||
return suite;
|
||||
}
|
|
@ -578,6 +578,7 @@ void manifest_flash_v2_testing_read_element_mocked_hash (CuTest *test,
|
|||
break;
|
||||
|
||||
default:
|
||||
status = 0;
|
||||
break;
|
||||
}
|
||||
status |= mock_expect (&manifest->hash_mock.mock, manifest->hash_mock.base.update,
|
||||
|
|
|
@ -0,0 +1,456 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
#include "host_flash_manager_dual_mock.h"
|
||||
|
||||
|
||||
static struct spi_flash* host_flash_manager_dual_mock_get_read_only_flash (
|
||||
struct host_flash_manager *manager)
|
||||
{
|
||||
struct host_flash_manager_dual_mock *mock = (struct host_flash_manager_dual_mock*) manager;
|
||||
|
||||
if (mock == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
MOCK_RETURN_NO_ARGS_CAST (&mock->mock, struct spi_flash*,
|
||||
host_flash_manager_dual_mock_get_read_only_flash, manager);
|
||||
}
|
||||
|
||||
static struct spi_flash* host_flash_manager_dual_mock_get_read_write_flash (
|
||||
struct host_flash_manager *manager)
|
||||
{
|
||||
struct host_flash_manager_dual_mock *mock = (struct host_flash_manager_dual_mock*) manager;
|
||||
|
||||
if (mock == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
MOCK_RETURN_NO_ARGS_CAST (&mock->mock, struct spi_flash*,
|
||||
host_flash_manager_dual_mock_get_read_write_flash, manager);
|
||||
}
|
||||
|
||||
static int host_flash_manager_dual_mock_validate_read_only_flash (
|
||||
struct host_flash_manager *manager, struct pfm *pfm, struct pfm *good_pfm,
|
||||
struct hash_engine *hash, struct rsa_engine *rsa, bool full_validation,
|
||||
struct host_flash_manager_rw_regions *host_rw)
|
||||
{
|
||||
struct host_flash_manager_dual_mock *mock = (struct host_flash_manager_dual_mock*) manager;
|
||||
|
||||
if (mock == NULL) {
|
||||
return MOCK_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
MOCK_RETURN (&mock->mock, host_flash_manager_dual_mock_validate_read_only_flash, manager,
|
||||
MOCK_ARG_CALL (pfm), MOCK_ARG_CALL (good_pfm), MOCK_ARG_CALL (hash), MOCK_ARG_CALL (rsa),
|
||||
MOCK_ARG_CALL (full_validation), MOCK_ARG_CALL (host_rw));
|
||||
}
|
||||
|
||||
static int host_flash_manager_dual_mock_validate_read_write_flash (
|
||||
struct host_flash_manager *manager, struct pfm *pfm, struct hash_engine *hash,
|
||||
struct rsa_engine *rsa, struct host_flash_manager_rw_regions *host_rw)
|
||||
{
|
||||
struct host_flash_manager_dual_mock *mock = (struct host_flash_manager_dual_mock*) manager;
|
||||
|
||||
if (mock == NULL) {
|
||||
return MOCK_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
MOCK_RETURN (&mock->mock, host_flash_manager_dual_mock_validate_read_write_flash, manager,
|
||||
MOCK_ARG_CALL (pfm), MOCK_ARG_CALL (hash), MOCK_ARG_CALL (rsa), MOCK_ARG_CALL (host_rw));
|
||||
}
|
||||
|
||||
static int host_flash_manager_dual_mock_get_flash_read_write_regions (
|
||||
struct host_flash_manager *manager, struct pfm *pfm, bool rw_flash,
|
||||
struct host_flash_manager_rw_regions *host_rw)
|
||||
{
|
||||
struct host_flash_manager_dual_mock *mock = (struct host_flash_manager_dual_mock*) manager;
|
||||
|
||||
if (mock == NULL) {
|
||||
return MOCK_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
MOCK_RETURN (&mock->mock, host_flash_manager_dual_mock_get_flash_read_write_regions, manager,
|
||||
MOCK_ARG_CALL (pfm), MOCK_ARG_CALL (rw_flash), MOCK_ARG_CALL (host_rw));
|
||||
}
|
||||
|
||||
static void host_flash_manager_dual_mock_free_read_write_regions (
|
||||
struct host_flash_manager *manager, struct host_flash_manager_rw_regions *host_rw)
|
||||
{
|
||||
struct host_flash_manager_dual_mock *mock = (struct host_flash_manager_dual_mock*) manager;
|
||||
|
||||
if (mock == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
MOCK_VOID_RETURN (&mock->mock, host_flash_manager_dual_mock_free_read_write_regions, manager,
|
||||
MOCK_ARG_CALL (host_rw));
|
||||
}
|
||||
|
||||
static int host_flash_manager_dual_mock_config_spi_filter_flash_type (
|
||||
struct host_flash_manager *manager)
|
||||
{
|
||||
struct host_flash_manager_dual_mock *mock = (struct host_flash_manager_dual_mock*) manager;
|
||||
|
||||
if (mock == NULL) {
|
||||
return MOCK_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
MOCK_RETURN_NO_ARGS (&mock->mock, host_flash_manager_dual_mock_config_spi_filter_flash_type,
|
||||
manager);
|
||||
}
|
||||
|
||||
static int host_flash_manager_dual_mock_config_spi_filter_flash_devices (
|
||||
struct host_flash_manager *manager)
|
||||
{
|
||||
struct host_flash_manager_dual_mock *mock = (struct host_flash_manager_dual_mock*) manager;
|
||||
|
||||
if (mock == NULL) {
|
||||
return MOCK_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
MOCK_RETURN_NO_ARGS (&mock->mock, host_flash_manager_dual_mock_config_spi_filter_flash_devices,
|
||||
manager);
|
||||
}
|
||||
|
||||
static int host_flash_manager_dual_mock_swap_flash_devices (struct host_flash_manager *manager,
|
||||
struct host_flash_manager_rw_regions *host_rw, struct pfm_manager *used_pending)
|
||||
{
|
||||
struct host_flash_manager_dual_mock *mock = (struct host_flash_manager_dual_mock*) manager;
|
||||
|
||||
if (mock == NULL) {
|
||||
return MOCK_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
MOCK_RETURN (&mock->mock, host_flash_manager_dual_mock_swap_flash_devices, manager,
|
||||
MOCK_ARG_CALL (host_rw), MOCK_ARG_CALL (used_pending));
|
||||
}
|
||||
|
||||
static int host_flash_manager_dual_mock_initialize_flash_protection (
|
||||
struct host_flash_manager *manager, struct host_flash_manager_rw_regions *host_rw)
|
||||
{
|
||||
struct host_flash_manager_dual_mock *mock = (struct host_flash_manager_dual_mock*) manager;
|
||||
|
||||
if (mock == NULL) {
|
||||
return MOCK_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
MOCK_RETURN (&mock->mock, host_flash_manager_dual_mock_initialize_flash_protection, manager,
|
||||
MOCK_ARG_CALL (host_rw));
|
||||
}
|
||||
|
||||
static int host_flash_manager_dual_mock_restore_flash_read_write_regions (
|
||||
struct host_flash_manager *manager, struct host_flash_manager_rw_regions *host_rw)
|
||||
{
|
||||
struct host_flash_manager_dual_mock *mock = (struct host_flash_manager_dual_mock*) manager;
|
||||
|
||||
if (mock == NULL) {
|
||||
return MOCK_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
MOCK_RETURN (&mock->mock, host_flash_manager_dual_mock_restore_flash_read_write_regions,
|
||||
manager, MOCK_ARG_CALL (host_rw));
|
||||
}
|
||||
|
||||
static int host_flash_manager_dual_mock_set_flash_for_rot_access (
|
||||
struct host_flash_manager *manager, struct host_control *control)
|
||||
{
|
||||
struct host_flash_manager_dual_mock *mock = (struct host_flash_manager_dual_mock*) manager;
|
||||
|
||||
if (mock == NULL) {
|
||||
return MOCK_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
MOCK_RETURN (&mock->mock, host_flash_manager_dual_mock_set_flash_for_rot_access, manager,
|
||||
MOCK_ARG_CALL (control));
|
||||
}
|
||||
|
||||
static int host_flash_manager_dual_mock_set_flash_for_host_access (
|
||||
struct host_flash_manager *manager, struct host_control *control)
|
||||
{
|
||||
struct host_flash_manager_dual_mock *mock = (struct host_flash_manager_dual_mock*) manager;
|
||||
|
||||
if (mock == NULL) {
|
||||
return MOCK_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
MOCK_RETURN (&mock->mock, host_flash_manager_dual_mock_set_flash_for_host_access, manager,
|
||||
MOCK_ARG_CALL (control));
|
||||
}
|
||||
|
||||
static int host_flash_manager_dual_mock_host_has_flash_access (struct host_flash_manager *manager,
|
||||
struct host_control *control)
|
||||
{
|
||||
struct host_flash_manager_dual_mock *mock = (struct host_flash_manager_dual_mock*) manager;
|
||||
|
||||
if (mock == NULL) {
|
||||
return MOCK_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
MOCK_RETURN (&mock->mock, host_flash_manager_dual_mock_host_has_flash_access, manager,
|
||||
MOCK_ARG_CALL (control));
|
||||
}
|
||||
|
||||
static int host_flash_manager_dual_mock_func_arg_count (void *func)
|
||||
{
|
||||
if (func == host_flash_manager_dual_mock_validate_read_only_flash) {
|
||||
return 6;
|
||||
}
|
||||
else if (func == host_flash_manager_dual_mock_validate_read_write_flash) {
|
||||
return 4;
|
||||
}
|
||||
else if (func == host_flash_manager_dual_mock_get_flash_read_write_regions) {
|
||||
return 3;
|
||||
}
|
||||
else if (func == host_flash_manager_dual_mock_swap_flash_devices) {
|
||||
return 2;
|
||||
}
|
||||
else if ((func == host_flash_manager_dual_mock_initialize_flash_protection) ||
|
||||
(func == host_flash_manager_dual_mock_set_flash_for_rot_access) ||
|
||||
(func == host_flash_manager_dual_mock_set_flash_for_host_access) ||
|
||||
(func == host_flash_manager_dual_mock_host_has_flash_access) ||
|
||||
(func == host_flash_manager_dual_mock_restore_flash_read_write_regions) ||
|
||||
(func == host_flash_manager_dual_mock_free_read_write_regions)) {
|
||||
return 1;
|
||||
}
|
||||
else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
static const char* host_flash_manager_dual_mock_func_name_map (void *func)
|
||||
{
|
||||
if (func == host_flash_manager_dual_mock_get_read_only_flash) {
|
||||
return "get_read_only_flash";
|
||||
}
|
||||
else if (func == host_flash_manager_dual_mock_get_read_write_flash) {
|
||||
return "get_read_write_flash";
|
||||
}
|
||||
else if (func == host_flash_manager_dual_mock_validate_read_only_flash) {
|
||||
return "validate_read_only_flash";
|
||||
}
|
||||
else if (func == host_flash_manager_dual_mock_validate_read_write_flash) {
|
||||
return "validate_read_write_flash";
|
||||
}
|
||||
else if (func == host_flash_manager_dual_mock_get_flash_read_write_regions) {
|
||||
return "get_flash_read_write_regions";
|
||||
}
|
||||
else if (func == host_flash_manager_dual_mock_free_read_write_regions) {
|
||||
return "free_read_write_regions";
|
||||
}
|
||||
else if (func == host_flash_manager_dual_mock_config_spi_filter_flash_type) {
|
||||
return "config_spi_filter_flash_type";
|
||||
}
|
||||
else if (func == host_flash_manager_dual_mock_config_spi_filter_flash_devices) {
|
||||
return "config_spi_filter_flash_devices";
|
||||
}
|
||||
else if (func == host_flash_manager_dual_mock_swap_flash_devices) {
|
||||
return "swap_flash_devices";
|
||||
}
|
||||
else if (func == host_flash_manager_dual_mock_initialize_flash_protection) {
|
||||
return "initialize_flash_protection";
|
||||
}
|
||||
else if (func == host_flash_manager_dual_mock_restore_flash_read_write_regions) {
|
||||
return "restore_flash_read_write_regions";
|
||||
}
|
||||
else if (func == host_flash_manager_dual_mock_set_flash_for_rot_access) {
|
||||
return "set_flash_for_rot_access";
|
||||
}
|
||||
else if (func == host_flash_manager_dual_mock_set_flash_for_host_access) {
|
||||
return "set_flash_for_host_access";
|
||||
}
|
||||
else if (func == host_flash_manager_dual_mock_host_has_flash_access) {
|
||||
return "host_has_flash_access";
|
||||
}
|
||||
else {
|
||||
return "unknown";
|
||||
}
|
||||
}
|
||||
|
||||
static const char* host_flash_manager_dual_mock_arg_name_map (void *func, int arg)
|
||||
{
|
||||
if (func == host_flash_manager_dual_mock_validate_read_only_flash) {
|
||||
switch (arg) {
|
||||
case 0:
|
||||
return "pfm";
|
||||
|
||||
case 1:
|
||||
return "good_pfm";
|
||||
|
||||
case 2:
|
||||
return "hash";
|
||||
|
||||
case 3:
|
||||
return "rsa";
|
||||
|
||||
case 4:
|
||||
return "full_validation";
|
||||
|
||||
case 5:
|
||||
return "host_rw";
|
||||
}
|
||||
}
|
||||
else if (func == host_flash_manager_dual_mock_validate_read_write_flash) {
|
||||
switch (arg) {
|
||||
case 0:
|
||||
return "pfm";
|
||||
|
||||
case 1:
|
||||
return "hash";
|
||||
|
||||
case 2:
|
||||
return "rsa";
|
||||
|
||||
case 3:
|
||||
return "host_rw";
|
||||
}
|
||||
}
|
||||
else if (func == host_flash_manager_dual_mock_get_flash_read_write_regions) {
|
||||
switch (arg) {
|
||||
case 0:
|
||||
return "pfm";
|
||||
|
||||
case 1:
|
||||
return "rw_flash";
|
||||
|
||||
case 2:
|
||||
return "host_rw";
|
||||
}
|
||||
}
|
||||
else if (func == host_flash_manager_dual_mock_free_read_write_regions) {
|
||||
switch (arg) {
|
||||
case 0:
|
||||
return "host_rw";
|
||||
}
|
||||
}
|
||||
else if (func == host_flash_manager_dual_mock_swap_flash_devices) {
|
||||
switch (arg) {
|
||||
case 0:
|
||||
return "host_rw";
|
||||
|
||||
case 1:
|
||||
return "used_pending";
|
||||
}
|
||||
}
|
||||
else if (func == host_flash_manager_dual_mock_initialize_flash_protection) {
|
||||
switch (arg) {
|
||||
case 0:
|
||||
return "host_rw";
|
||||
}
|
||||
}
|
||||
else if (func == host_flash_manager_dual_mock_restore_flash_read_write_regions) {
|
||||
switch (arg) {
|
||||
case 0:
|
||||
return "host_rw";
|
||||
}
|
||||
}
|
||||
else if (func == host_flash_manager_dual_mock_set_flash_for_rot_access) {
|
||||
switch (arg) {
|
||||
case 0:
|
||||
return "control";
|
||||
}
|
||||
}
|
||||
else if (func == host_flash_manager_dual_mock_set_flash_for_host_access) {
|
||||
switch (arg) {
|
||||
case 0:
|
||||
return "control";
|
||||
}
|
||||
}
|
||||
else if (func == host_flash_manager_dual_mock_host_has_flash_access) {
|
||||
switch (arg) {
|
||||
case 0:
|
||||
return "control";
|
||||
}
|
||||
}
|
||||
|
||||
return "unknown";
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize a mock instance for a manager of protected dual flash.
|
||||
*
|
||||
* @param mock The mock to initialize.
|
||||
*
|
||||
* @return 0 if the mock was successfully initialized or an error code.
|
||||
*/
|
||||
int host_flash_manager_dual_mock_init (struct host_flash_manager_dual_mock *mock)
|
||||
{
|
||||
int status;
|
||||
|
||||
if (mock == NULL) {
|
||||
return MOCK_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
memset (mock, 0, sizeof (struct host_flash_manager_dual_mock));
|
||||
|
||||
status = mock_init (&mock->mock);
|
||||
if (status != 0) {
|
||||
return status;
|
||||
}
|
||||
|
||||
mock_set_name (&mock->mock, "host_flash_manager_dual");
|
||||
|
||||
mock->base.base.get_read_only_flash = host_flash_manager_dual_mock_get_read_only_flash;
|
||||
mock->base.base.get_read_write_flash = host_flash_manager_dual_mock_get_read_write_flash;
|
||||
mock->base.base.validate_read_only_flash =
|
||||
host_flash_manager_dual_mock_validate_read_only_flash;
|
||||
mock->base.base.validate_read_write_flash =
|
||||
host_flash_manager_dual_mock_validate_read_write_flash;
|
||||
mock->base.base.get_flash_read_write_regions =
|
||||
host_flash_manager_dual_mock_get_flash_read_write_regions;
|
||||
mock->base.base.free_read_write_regions = host_flash_manager_dual_mock_free_read_write_regions;
|
||||
mock->base.base.config_spi_filter_flash_type =
|
||||
host_flash_manager_dual_mock_config_spi_filter_flash_type;
|
||||
mock->base.base.config_spi_filter_flash_devices =
|
||||
host_flash_manager_dual_mock_config_spi_filter_flash_devices;
|
||||
mock->base.base.swap_flash_devices = host_flash_manager_dual_mock_swap_flash_devices;
|
||||
mock->base.base.initialize_flash_protection =
|
||||
host_flash_manager_dual_mock_initialize_flash_protection;
|
||||
mock->base.base.restore_flash_read_write_regions =
|
||||
host_flash_manager_dual_mock_restore_flash_read_write_regions;
|
||||
mock->base.base.set_flash_for_rot_access =
|
||||
host_flash_manager_dual_mock_set_flash_for_rot_access;
|
||||
mock->base.base.set_flash_for_host_access =
|
||||
host_flash_manager_dual_mock_set_flash_for_host_access;
|
||||
mock->base.base.host_has_flash_access = host_flash_manager_dual_mock_host_has_flash_access;
|
||||
|
||||
mock->mock.func_arg_count = host_flash_manager_dual_mock_func_arg_count;
|
||||
mock->mock.func_name_map = host_flash_manager_dual_mock_func_name_map;
|
||||
mock->mock.arg_name_map = host_flash_manager_dual_mock_arg_name_map;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Release the resources used by flash manager mock instance.
|
||||
*
|
||||
* @param mock The mock to release.
|
||||
*/
|
||||
void host_flash_manager_dual_mock_release (struct host_flash_manager_dual_mock *mock)
|
||||
{
|
||||
if (mock) {
|
||||
mock_release (&mock->mock);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate that the flash manager mock was called as expected and release the instance.
|
||||
*
|
||||
* @param mock The mock instance to validate.
|
||||
*
|
||||
* @return 0 if the expectations were met or 1 if not.
|
||||
*/
|
||||
int host_flash_manager_dual_mock_validate_and_release (struct host_flash_manager_dual_mock *mock)
|
||||
{
|
||||
int status = 1;
|
||||
|
||||
if (mock != NULL) {
|
||||
status = mock_validate (&mock->mock);
|
||||
host_flash_manager_dual_mock_release (mock);
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
#ifndef HOST_FLASH_MANAGER_DUAL_MOCK_H_
|
||||
#define HOST_FLASH_MANAGER_DUAL_MOCK_H_
|
||||
|
||||
#include "host_fw/host_flash_manager_dual.h"
|
||||
#include "mock.h"
|
||||
|
||||
|
||||
/**
|
||||
* A mock for the manager of protected host flash using dual flashes.
|
||||
*/
|
||||
struct host_flash_manager_dual_mock {
|
||||
struct host_flash_manager_dual base; /**< The base manager instance. */
|
||||
struct mock mock; /**< The base mock interface. */
|
||||
};
|
||||
|
||||
|
||||
int host_flash_manager_dual_mock_init (struct host_flash_manager_dual_mock *mock);
|
||||
void host_flash_manager_dual_mock_release (struct host_flash_manager_dual_mock *mock);
|
||||
|
||||
int host_flash_manager_dual_mock_validate_and_release (struct host_flash_manager_dual_mock *mock);
|
||||
|
||||
|
||||
#endif /* HOST_FLASH_MANAGER_DUAL_MOCK_H_ */
|
|
@ -0,0 +1,458 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
#include "host_flash_manager_single_mock.h"
|
||||
|
||||
|
||||
static struct spi_flash* host_flash_manager_single_mock_get_read_only_flash (
|
||||
struct host_flash_manager *manager)
|
||||
{
|
||||
struct host_flash_manager_single_mock *mock = (struct host_flash_manager_single_mock*) manager;
|
||||
|
||||
if (mock == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
MOCK_RETURN_NO_ARGS_CAST (&mock->mock, struct spi_flash*,
|
||||
host_flash_manager_single_mock_get_read_only_flash, manager);
|
||||
}
|
||||
|
||||
static struct spi_flash* host_flash_manager_single_mock_get_read_write_flash (
|
||||
struct host_flash_manager *manager)
|
||||
{
|
||||
struct host_flash_manager_single_mock *mock = (struct host_flash_manager_single_mock*) manager;
|
||||
|
||||
if (mock == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
MOCK_RETURN_NO_ARGS_CAST (&mock->mock, struct spi_flash*,
|
||||
host_flash_manager_single_mock_get_read_write_flash, manager);
|
||||
}
|
||||
|
||||
static int host_flash_manager_single_mock_validate_read_only_flash (
|
||||
struct host_flash_manager *manager, struct pfm *pfm, struct pfm *good_pfm,
|
||||
struct hash_engine *hash, struct rsa_engine *rsa, bool full_validation,
|
||||
struct host_flash_manager_rw_regions *host_rw)
|
||||
{
|
||||
struct host_flash_manager_single_mock *mock = (struct host_flash_manager_single_mock*) manager;
|
||||
|
||||
if (mock == NULL) {
|
||||
return MOCK_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
MOCK_RETURN (&mock->mock, host_flash_manager_single_mock_validate_read_only_flash, manager,
|
||||
MOCK_ARG_CALL (pfm), MOCK_ARG_CALL (good_pfm), MOCK_ARG_CALL (hash), MOCK_ARG_CALL (rsa),
|
||||
MOCK_ARG_CALL (full_validation), MOCK_ARG_CALL (host_rw));
|
||||
}
|
||||
|
||||
static int host_flash_manager_single_mock_validate_read_write_flash (
|
||||
struct host_flash_manager *manager, struct pfm *pfm, struct hash_engine *hash,
|
||||
struct rsa_engine *rsa, struct host_flash_manager_rw_regions *host_rw)
|
||||
{
|
||||
struct host_flash_manager_single_mock *mock = (struct host_flash_manager_single_mock*) manager;
|
||||
|
||||
if (mock == NULL) {
|
||||
return MOCK_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
MOCK_RETURN (&mock->mock, host_flash_manager_single_mock_validate_read_write_flash, manager,
|
||||
MOCK_ARG_CALL (pfm), MOCK_ARG_CALL (hash), MOCK_ARG_CALL (rsa), MOCK_ARG_CALL (host_rw));
|
||||
}
|
||||
|
||||
static int host_flash_manager_single_mock_get_flash_read_write_regions (
|
||||
struct host_flash_manager *manager, struct pfm *pfm, bool rw_flash,
|
||||
struct host_flash_manager_rw_regions *host_rw)
|
||||
{
|
||||
struct host_flash_manager_single_mock *mock = (struct host_flash_manager_single_mock*) manager;
|
||||
|
||||
if (mock == NULL) {
|
||||
return MOCK_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
MOCK_RETURN (&mock->mock, host_flash_manager_single_mock_get_flash_read_write_regions, manager,
|
||||
MOCK_ARG_CALL (pfm), MOCK_ARG_CALL (rw_flash), MOCK_ARG_CALL (host_rw));
|
||||
}
|
||||
|
||||
static void host_flash_manager_single_mock_free_read_write_regions (
|
||||
struct host_flash_manager *manager, struct host_flash_manager_rw_regions *host_rw)
|
||||
{
|
||||
struct host_flash_manager_single_mock *mock = (struct host_flash_manager_single_mock*) manager;
|
||||
|
||||
if (mock == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
MOCK_VOID_RETURN (&mock->mock, host_flash_manager_single_mock_free_read_write_regions, manager,
|
||||
MOCK_ARG_CALL (host_rw));
|
||||
}
|
||||
|
||||
static int host_flash_manager_single_mock_config_spi_filter_flash_type (
|
||||
struct host_flash_manager *manager)
|
||||
{
|
||||
struct host_flash_manager_single_mock *mock = (struct host_flash_manager_single_mock*) manager;
|
||||
|
||||
if (mock == NULL) {
|
||||
return MOCK_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
MOCK_RETURN_NO_ARGS (&mock->mock, host_flash_manager_single_mock_config_spi_filter_flash_type,
|
||||
manager);
|
||||
}
|
||||
|
||||
static int host_flash_manager_single_mock_config_spi_filter_flash_devices (
|
||||
struct host_flash_manager *manager)
|
||||
{
|
||||
struct host_flash_manager_single_mock *mock = (struct host_flash_manager_single_mock*) manager;
|
||||
|
||||
if (mock == NULL) {
|
||||
return MOCK_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
MOCK_RETURN_NO_ARGS (&mock->mock,
|
||||
host_flash_manager_single_mock_config_spi_filter_flash_devices, manager);
|
||||
}
|
||||
|
||||
static int host_flash_manager_single_mock_swap_flash_devices (struct host_flash_manager *manager,
|
||||
struct host_flash_manager_rw_regions *host_rw, struct pfm_manager *used_pending)
|
||||
{
|
||||
struct host_flash_manager_single_mock *mock = (struct host_flash_manager_single_mock*) manager;
|
||||
|
||||
if (mock == NULL) {
|
||||
return MOCK_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
MOCK_RETURN (&mock->mock, host_flash_manager_single_mock_swap_flash_devices, manager,
|
||||
MOCK_ARG_CALL (host_rw), MOCK_ARG_CALL (used_pending));
|
||||
}
|
||||
|
||||
static int host_flash_manager_single_mock_initialize_flash_protection (
|
||||
struct host_flash_manager *manager, struct host_flash_manager_rw_regions *host_rw)
|
||||
{
|
||||
struct host_flash_manager_single_mock *mock = (struct host_flash_manager_single_mock*) manager;
|
||||
|
||||
if (mock == NULL) {
|
||||
return MOCK_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
MOCK_RETURN (&mock->mock, host_flash_manager_single_mock_initialize_flash_protection, manager,
|
||||
MOCK_ARG_CALL (host_rw));
|
||||
}
|
||||
|
||||
static int host_flash_manager_single_mock_restore_flash_read_write_regions (
|
||||
struct host_flash_manager *manager, struct host_flash_manager_rw_regions *host_rw)
|
||||
{
|
||||
struct host_flash_manager_single_mock *mock = (struct host_flash_manager_single_mock*) manager;
|
||||
|
||||
if (mock == NULL) {
|
||||
return MOCK_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
MOCK_RETURN (&mock->mock, host_flash_manager_single_mock_restore_flash_read_write_regions,
|
||||
manager, MOCK_ARG_CALL (host_rw));
|
||||
}
|
||||
|
||||
static int host_flash_manager_single_mock_set_flash_for_rot_access (
|
||||
struct host_flash_manager *manager, struct host_control *control)
|
||||
{
|
||||
struct host_flash_manager_single_mock *mock = (struct host_flash_manager_single_mock*) manager;
|
||||
|
||||
if (mock == NULL) {
|
||||
return MOCK_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
MOCK_RETURN (&mock->mock, host_flash_manager_single_mock_set_flash_for_rot_access, manager,
|
||||
MOCK_ARG_CALL (control));
|
||||
}
|
||||
|
||||
static int host_flash_manager_single_mock_set_flash_for_host_access (
|
||||
struct host_flash_manager *manager, struct host_control *control)
|
||||
{
|
||||
struct host_flash_manager_single_mock *mock = (struct host_flash_manager_single_mock*) manager;
|
||||
|
||||
if (mock == NULL) {
|
||||
return MOCK_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
MOCK_RETURN (&mock->mock, host_flash_manager_single_mock_set_flash_for_host_access, manager,
|
||||
MOCK_ARG_CALL (control));
|
||||
}
|
||||
|
||||
static int host_flash_manager_single_mock_host_has_flash_access (struct host_flash_manager *manager,
|
||||
struct host_control *control)
|
||||
{
|
||||
struct host_flash_manager_single_mock *mock = (struct host_flash_manager_single_mock*) manager;
|
||||
|
||||
if (mock == NULL) {
|
||||
return MOCK_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
MOCK_RETURN (&mock->mock, host_flash_manager_single_mock_host_has_flash_access, manager,
|
||||
MOCK_ARG_CALL (control));
|
||||
}
|
||||
|
||||
static int host_flash_manager_single_mock_func_arg_count (void *func)
|
||||
{
|
||||
if (func == host_flash_manager_single_mock_validate_read_only_flash) {
|
||||
return 6;
|
||||
}
|
||||
else if (func == host_flash_manager_single_mock_validate_read_write_flash) {
|
||||
return 4;
|
||||
}
|
||||
else if (func == host_flash_manager_single_mock_get_flash_read_write_regions) {
|
||||
return 3;
|
||||
}
|
||||
else if (func == host_flash_manager_single_mock_swap_flash_devices) {
|
||||
return 2;
|
||||
}
|
||||
else if ((func == host_flash_manager_single_mock_initialize_flash_protection) ||
|
||||
(func == host_flash_manager_single_mock_set_flash_for_rot_access) ||
|
||||
(func == host_flash_manager_single_mock_set_flash_for_host_access) ||
|
||||
(func == host_flash_manager_single_mock_host_has_flash_access) ||
|
||||
(func == host_flash_manager_single_mock_restore_flash_read_write_regions) ||
|
||||
(func == host_flash_manager_single_mock_free_read_write_regions)) {
|
||||
return 1;
|
||||
}
|
||||
else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
static const char* host_flash_manager_single_mock_func_name_map (void *func)
|
||||
{
|
||||
if (func == host_flash_manager_single_mock_get_read_only_flash) {
|
||||
return "get_read_only_flash";
|
||||
}
|
||||
else if (func == host_flash_manager_single_mock_get_read_write_flash) {
|
||||
return "get_read_write_flash";
|
||||
}
|
||||
else if (func == host_flash_manager_single_mock_validate_read_only_flash) {
|
||||
return "validate_read_only_flash";
|
||||
}
|
||||
else if (func == host_flash_manager_single_mock_validate_read_write_flash) {
|
||||
return "validate_read_write_flash";
|
||||
}
|
||||
else if (func == host_flash_manager_single_mock_get_flash_read_write_regions) {
|
||||
return "get_flash_read_write_regions";
|
||||
}
|
||||
else if (func == host_flash_manager_single_mock_free_read_write_regions) {
|
||||
return "free_read_write_regions";
|
||||
}
|
||||
else if (func == host_flash_manager_single_mock_config_spi_filter_flash_type) {
|
||||
return "config_spi_filter_flash_type";
|
||||
}
|
||||
else if (func == host_flash_manager_single_mock_config_spi_filter_flash_devices) {
|
||||
return "config_spi_filter_flash_devices";
|
||||
}
|
||||
else if (func == host_flash_manager_single_mock_swap_flash_devices) {
|
||||
return "swap_flash_devices";
|
||||
}
|
||||
else if (func == host_flash_manager_single_mock_initialize_flash_protection) {
|
||||
return "initialize_flash_protection";
|
||||
}
|
||||
else if (func == host_flash_manager_single_mock_restore_flash_read_write_regions) {
|
||||
return "restore_flash_read_write_regions";
|
||||
}
|
||||
else if (func == host_flash_manager_single_mock_set_flash_for_rot_access) {
|
||||
return "set_flash_for_rot_access";
|
||||
}
|
||||
else if (func == host_flash_manager_single_mock_set_flash_for_host_access) {
|
||||
return "set_flash_for_host_access";
|
||||
}
|
||||
else if (func == host_flash_manager_single_mock_host_has_flash_access) {
|
||||
return "host_has_flash_access";
|
||||
}
|
||||
else {
|
||||
return "unknown";
|
||||
}
|
||||
}
|
||||
|
||||
static const char* host_flash_manager_single_mock_arg_name_map (void *func, int arg)
|
||||
{
|
||||
if (func == host_flash_manager_single_mock_validate_read_only_flash) {
|
||||
switch (arg) {
|
||||
case 0:
|
||||
return "pfm";
|
||||
|
||||
case 1:
|
||||
return "good_pfm";
|
||||
|
||||
case 2:
|
||||
return "hash";
|
||||
|
||||
case 3:
|
||||
return "rsa";
|
||||
|
||||
case 4:
|
||||
return "full_validation";
|
||||
|
||||
case 5:
|
||||
return "host_rw";
|
||||
}
|
||||
}
|
||||
else if (func == host_flash_manager_single_mock_validate_read_write_flash) {
|
||||
switch (arg) {
|
||||
case 0:
|
||||
return "pfm";
|
||||
|
||||
case 1:
|
||||
return "hash";
|
||||
|
||||
case 2:
|
||||
return "rsa";
|
||||
|
||||
case 3:
|
||||
return "host_rw";
|
||||
}
|
||||
}
|
||||
else if (func == host_flash_manager_single_mock_get_flash_read_write_regions) {
|
||||
switch (arg) {
|
||||
case 0:
|
||||
return "pfm";
|
||||
|
||||
case 1:
|
||||
return "rw_flash";
|
||||
|
||||
case 2:
|
||||
return "host_rw";
|
||||
}
|
||||
}
|
||||
else if (func == host_flash_manager_single_mock_free_read_write_regions) {
|
||||
switch (arg) {
|
||||
case 0:
|
||||
return "host_rw";
|
||||
}
|
||||
}
|
||||
else if (func == host_flash_manager_single_mock_swap_flash_devices) {
|
||||
switch (arg) {
|
||||
case 0:
|
||||
return "host_rw";
|
||||
|
||||
case 1:
|
||||
return "used_pending";
|
||||
}
|
||||
}
|
||||
else if (func == host_flash_manager_single_mock_initialize_flash_protection) {
|
||||
switch (arg) {
|
||||
case 0:
|
||||
return "host_rw";
|
||||
}
|
||||
}
|
||||
else if (func == host_flash_manager_single_mock_restore_flash_read_write_regions) {
|
||||
switch (arg) {
|
||||
case 0:
|
||||
return "host_rw";
|
||||
}
|
||||
}
|
||||
else if (func == host_flash_manager_single_mock_set_flash_for_rot_access) {
|
||||
switch (arg) {
|
||||
case 0:
|
||||
return "control";
|
||||
}
|
||||
}
|
||||
else if (func == host_flash_manager_single_mock_set_flash_for_host_access) {
|
||||
switch (arg) {
|
||||
case 0:
|
||||
return "control";
|
||||
}
|
||||
}
|
||||
else if (func == host_flash_manager_single_mock_host_has_flash_access) {
|
||||
switch (arg) {
|
||||
case 0:
|
||||
return "control";
|
||||
}
|
||||
}
|
||||
|
||||
return "unknown";
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize a mock instance for a manager of protected dual flash.
|
||||
*
|
||||
* @param mock The mock to initialize.
|
||||
*
|
||||
* @return 0 if the mock was successfully initialized or an error code.
|
||||
*/
|
||||
int host_flash_manager_single_mock_init (struct host_flash_manager_single_mock *mock)
|
||||
{
|
||||
int status;
|
||||
|
||||
if (mock == NULL) {
|
||||
return MOCK_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
memset (mock, 0, sizeof (struct host_flash_manager_single_mock));
|
||||
|
||||
status = mock_init (&mock->mock);
|
||||
if (status != 0) {
|
||||
return status;
|
||||
}
|
||||
|
||||
mock_set_name (&mock->mock, "host_processor_single");
|
||||
|
||||
mock->base.base.get_read_only_flash = host_flash_manager_single_mock_get_read_only_flash;
|
||||
mock->base.base.get_read_write_flash = host_flash_manager_single_mock_get_read_write_flash;
|
||||
mock->base.base.validate_read_only_flash =
|
||||
host_flash_manager_single_mock_validate_read_only_flash;
|
||||
mock->base.base.validate_read_write_flash =
|
||||
host_flash_manager_single_mock_validate_read_write_flash;
|
||||
mock->base.base.get_flash_read_write_regions =
|
||||
host_flash_manager_single_mock_get_flash_read_write_regions;
|
||||
mock->base.base.free_read_write_regions =
|
||||
host_flash_manager_single_mock_free_read_write_regions;
|
||||
mock->base.base.config_spi_filter_flash_type =
|
||||
host_flash_manager_single_mock_config_spi_filter_flash_type;
|
||||
mock->base.base.config_spi_filter_flash_devices =
|
||||
host_flash_manager_single_mock_config_spi_filter_flash_devices;
|
||||
mock->base.base.swap_flash_devices = host_flash_manager_single_mock_swap_flash_devices;
|
||||
mock->base.base.initialize_flash_protection =
|
||||
host_flash_manager_single_mock_initialize_flash_protection;
|
||||
mock->base.base.restore_flash_read_write_regions =
|
||||
host_flash_manager_single_mock_restore_flash_read_write_regions;
|
||||
mock->base.base.set_flash_for_rot_access =
|
||||
host_flash_manager_single_mock_set_flash_for_rot_access;
|
||||
mock->base.base.set_flash_for_host_access =
|
||||
host_flash_manager_single_mock_set_flash_for_host_access;
|
||||
mock->base.base.host_has_flash_access = host_flash_manager_single_mock_host_has_flash_access;
|
||||
|
||||
mock->mock.func_arg_count = host_flash_manager_single_mock_func_arg_count;
|
||||
mock->mock.func_name_map = host_flash_manager_single_mock_func_name_map;
|
||||
mock->mock.arg_name_map = host_flash_manager_single_mock_arg_name_map;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Release the resources used by flash manager mock instance.
|
||||
*
|
||||
* @param mock The mock to release.
|
||||
*/
|
||||
void host_flash_manager_single_mock_release (struct host_flash_manager_single_mock *mock)
|
||||
{
|
||||
if (mock) {
|
||||
mock_release (&mock->mock);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate that the flash manager mock was called as expected and release the instance.
|
||||
*
|
||||
* @param mock The mock instance to validate.
|
||||
*
|
||||
* @return 0 if the expectations were met or 1 if not.
|
||||
*/
|
||||
int host_flash_manager_single_mock_validate_and_release (
|
||||
struct host_flash_manager_single_mock *mock)
|
||||
{
|
||||
int status = 1;
|
||||
|
||||
if (mock != NULL) {
|
||||
status = mock_validate (&mock->mock);
|
||||
host_flash_manager_single_mock_release (mock);
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
#ifndef HOST_FLASH_MANAGER_SINGLE_MOCK_H_
|
||||
#define HOST_FLASH_MANAGER_SINGLE_MOCK_H_
|
||||
|
||||
#include "host_fw/host_flash_manager_single.h"
|
||||
#include "mock.h"
|
||||
|
||||
|
||||
/**
|
||||
* A mock for the manager of protected host flash using a single flash.
|
||||
*/
|
||||
struct host_flash_manager_single_mock {
|
||||
struct host_flash_manager_single base; /**< The base manager instance. */
|
||||
struct mock mock; /**< The base mock interface. */
|
||||
};
|
||||
|
||||
|
||||
int host_flash_manager_single_mock_init (struct host_flash_manager_single_mock *mock);
|
||||
void host_flash_manager_single_mock_release (struct host_flash_manager_single_mock *mock);
|
||||
|
||||
int host_flash_manager_single_mock_validate_and_release (
|
||||
struct host_flash_manager_single_mock *mock);
|
||||
|
||||
|
||||
#endif /* HOST_FLASH_MANAGER_SINGLE_MOCK_H_ */
|
|
@ -0,0 +1,285 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
#include "tpm/tpm.h"
|
||||
#include "host_state_observer_mock.h"
|
||||
|
||||
|
||||
static void host_state_observer_mock_on_active_pfm (struct host_state_observer *observer,
|
||||
struct host_state_manager *manager)
|
||||
{
|
||||
struct host_state_observer_mock *mock = (struct host_state_observer_mock*) observer;
|
||||
|
||||
if (mock == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
MOCK_VOID_RETURN (&mock->mock, host_state_observer_mock_on_active_pfm, observer,
|
||||
MOCK_ARG_CALL (manager));
|
||||
}
|
||||
|
||||
static void host_state_observer_mock_on_read_only_flash (struct host_state_observer *observer,
|
||||
struct host_state_manager *manager)
|
||||
{
|
||||
struct host_state_observer_mock *mock = (struct host_state_observer_mock*) observer;
|
||||
|
||||
if (mock == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
MOCK_VOID_RETURN (&mock->mock, host_state_observer_mock_on_read_only_flash, observer,
|
||||
MOCK_ARG_CALL (manager));
|
||||
}
|
||||
|
||||
static void host_state_observer_mock_on_inactive_dirty (struct host_state_observer *observer,
|
||||
struct host_state_manager *manager)
|
||||
{
|
||||
struct host_state_observer_mock *mock = (struct host_state_observer_mock*) observer;
|
||||
|
||||
if (mock == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
MOCK_VOID_RETURN (&mock->mock, host_state_observer_mock_on_inactive_dirty, observer,
|
||||
MOCK_ARG_CALL (manager));
|
||||
}
|
||||
|
||||
static void host_state_observer_mock_on_active_recovery_image (struct host_state_observer *observer,
|
||||
struct host_state_manager *manager)
|
||||
{
|
||||
struct host_state_observer_mock *mock = (struct host_state_observer_mock*) observer;
|
||||
|
||||
if (mock == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
MOCK_VOID_RETURN (&mock->mock, host_state_observer_mock_on_active_recovery_image, observer,
|
||||
MOCK_ARG_CALL (manager));
|
||||
}
|
||||
|
||||
static void host_state_observer_mock_on_pfm_dirty (struct host_state_observer *observer,
|
||||
struct host_state_manager *manager)
|
||||
{
|
||||
struct host_state_observer_mock *mock = (struct host_state_observer_mock*) observer;
|
||||
|
||||
if (mock == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
MOCK_VOID_RETURN (&mock->mock, host_state_observer_mock_on_pfm_dirty, observer,
|
||||
MOCK_ARG_CALL (manager));
|
||||
}
|
||||
|
||||
static void host_state_observer_mock_on_run_time_validation (struct host_state_observer *observer,
|
||||
struct host_state_manager *manager)
|
||||
{
|
||||
struct host_state_observer_mock *mock = (struct host_state_observer_mock*) observer;
|
||||
|
||||
if (mock == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
MOCK_VOID_RETURN (&mock->mock, host_state_observer_mock_on_run_time_validation, observer,
|
||||
MOCK_ARG_CALL (manager));
|
||||
}
|
||||
|
||||
static void host_state_observer_mock_on_bypass_mode (struct host_state_observer *observer,
|
||||
struct host_state_manager *manager)
|
||||
{
|
||||
struct host_state_observer_mock *mock = (struct host_state_observer_mock*) observer;
|
||||
|
||||
if (mock == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
MOCK_VOID_RETURN (&mock->mock, host_state_observer_mock_on_bypass_mode, observer,
|
||||
MOCK_ARG_CALL (manager));
|
||||
}
|
||||
|
||||
static void host_state_observer_mock_on_unsupported_flash (struct host_state_observer *observer,
|
||||
struct host_state_manager *manager)
|
||||
{
|
||||
struct host_state_observer_mock *mock = (struct host_state_observer_mock*) observer;
|
||||
|
||||
if (mock == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
MOCK_VOID_RETURN (&mock->mock, host_state_observer_mock_on_unsupported_flash, observer,
|
||||
MOCK_ARG_CALL (manager));
|
||||
}
|
||||
|
||||
static int host_state_observer_mock_func_arg_count (void *func)
|
||||
{
|
||||
if ((func == host_state_observer_mock_on_active_pfm) ||
|
||||
(func == host_state_observer_mock_on_read_only_flash) ||
|
||||
(func == host_state_observer_mock_on_inactive_dirty) ||
|
||||
(func == host_state_observer_mock_on_active_recovery_image) ||
|
||||
(func == host_state_observer_mock_on_pfm_dirty) ||
|
||||
(func == host_state_observer_mock_on_run_time_validation) ||
|
||||
(func == host_state_observer_mock_on_bypass_mode) ||
|
||||
(func == host_state_observer_mock_on_unsupported_flash)) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const char* host_state_observer_mock_func_name_map (void *func)
|
||||
{
|
||||
if (func == host_state_observer_mock_on_active_pfm) {
|
||||
return "on_active_pfm";
|
||||
}
|
||||
else if (func == host_state_observer_mock_on_read_only_flash) {
|
||||
return "on_read_only_flash";
|
||||
}
|
||||
else if (func == host_state_observer_mock_on_inactive_dirty) {
|
||||
return "on_inactive_dirty";
|
||||
}
|
||||
else if (func == host_state_observer_mock_on_active_recovery_image) {
|
||||
return "on_active_recovery_image";
|
||||
}
|
||||
else if (func == host_state_observer_mock_on_pfm_dirty) {
|
||||
return "on_pfm_dirty";
|
||||
}
|
||||
else if (func == host_state_observer_mock_on_run_time_validation) {
|
||||
return "on_run_time_validation";
|
||||
}
|
||||
else if (func == host_state_observer_mock_on_bypass_mode) {
|
||||
return "on_bypass_mode";
|
||||
}
|
||||
else if (func == host_state_observer_mock_on_unsupported_flash) {
|
||||
return "on_unsupported_flash";
|
||||
}
|
||||
else {
|
||||
return "unknown";
|
||||
}
|
||||
}
|
||||
|
||||
static const char* host_state_observer_mock_arg_name_map (void *func, int arg)
|
||||
{
|
||||
if (func == host_state_observer_mock_on_active_pfm) {
|
||||
switch (arg) {
|
||||
case 0:
|
||||
return "manager";
|
||||
}
|
||||
}
|
||||
else if (func == host_state_observer_mock_on_read_only_flash) {
|
||||
switch (arg) {
|
||||
case 0:
|
||||
return "manager";
|
||||
}
|
||||
}
|
||||
else if (func == host_state_observer_mock_on_inactive_dirty) {
|
||||
switch (arg) {
|
||||
case 0:
|
||||
return "manager";
|
||||
}
|
||||
}
|
||||
else if (func == host_state_observer_mock_on_active_recovery_image) {
|
||||
switch (arg) {
|
||||
case 0:
|
||||
return "manager";
|
||||
}
|
||||
}
|
||||
else if (func == host_state_observer_mock_on_pfm_dirty) {
|
||||
switch (arg) {
|
||||
case 0:
|
||||
return "manager";
|
||||
}
|
||||
}
|
||||
else if (func == host_state_observer_mock_on_run_time_validation) {
|
||||
switch (arg) {
|
||||
case 0:
|
||||
return "manager";
|
||||
}
|
||||
}
|
||||
else if (func == host_state_observer_mock_on_bypass_mode) {
|
||||
switch (arg) {
|
||||
case 0:
|
||||
return "manager";
|
||||
}
|
||||
}
|
||||
else if (func == host_state_observer_mock_on_unsupported_flash) {
|
||||
switch (arg) {
|
||||
case 0:
|
||||
return "manager";
|
||||
}
|
||||
}
|
||||
|
||||
return "unknown";
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize a mock for receiving host state notifications.
|
||||
*
|
||||
* @param mock The mock to initialize.
|
||||
*
|
||||
* @return 0 if the mock was successfully initialized or an error code.
|
||||
*/
|
||||
int host_state_observer_mock_init (struct host_state_observer_mock *mock)
|
||||
{
|
||||
int status;
|
||||
|
||||
if (mock == NULL) {
|
||||
return MOCK_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
memset (mock, 0, sizeof (struct host_state_observer_mock));
|
||||
|
||||
status = mock_init (&mock->mock);
|
||||
if (status != 0) {
|
||||
return status;
|
||||
}
|
||||
|
||||
mock_set_name (&mock->mock, "host_state_observer");
|
||||
|
||||
mock->base.on_active_pfm = host_state_observer_mock_on_active_pfm;
|
||||
mock->base.on_read_only_flash = host_state_observer_mock_on_read_only_flash;
|
||||
mock->base.on_inactive_dirty = host_state_observer_mock_on_inactive_dirty;
|
||||
mock->base.on_active_recovery_image = host_state_observer_mock_on_active_recovery_image;
|
||||
mock->base.on_pfm_dirty = host_state_observer_mock_on_pfm_dirty;
|
||||
mock->base.on_run_time_validation = host_state_observer_mock_on_run_time_validation;
|
||||
mock->base.on_bypass_mode = host_state_observer_mock_on_bypass_mode;
|
||||
mock->base.on_unsupported_flash = host_state_observer_mock_on_unsupported_flash;
|
||||
|
||||
mock->mock.func_arg_count = host_state_observer_mock_func_arg_count;
|
||||
mock->mock.func_name_map = host_state_observer_mock_func_name_map;
|
||||
mock->mock.arg_name_map = host_state_observer_mock_arg_name_map;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Release the resources used by a host state observer mock.
|
||||
*
|
||||
* @param mock The mock to release.
|
||||
*/
|
||||
void host_state_observer_mock_release (struct host_state_observer_mock *mock)
|
||||
{
|
||||
if (mock) {
|
||||
mock_release (&mock->mock);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate the expectations on the mock and release the instance.
|
||||
*
|
||||
* @param mock The mock to validate.
|
||||
*
|
||||
* @return 0 if all expectations were met or 1 if not.
|
||||
*/
|
||||
int host_state_observer_mock_validate_and_release (struct host_state_observer_mock *mock)
|
||||
{
|
||||
int status = 1;
|
||||
|
||||
if (mock != NULL) {
|
||||
status = mock_validate (&mock->mock);
|
||||
host_state_observer_mock_release (mock);
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
#ifndef HOST_STATE_OBSERVER_MOCK_H_
|
||||
#define HOST_STATE_OBSERVER_MOCK_H_
|
||||
|
||||
#include "host_fw/host_state_observer.h"
|
||||
#include "mock.h"
|
||||
|
||||
|
||||
/**
|
||||
* A mock for host state events.
|
||||
*/
|
||||
struct host_state_observer_mock {
|
||||
struct host_state_observer base; /**< The base observer instance. */
|
||||
struct mock mock; /**< The base mock interface. */
|
||||
};
|
||||
|
||||
|
||||
int host_state_observer_mock_init (struct host_state_observer_mock *mock);
|
||||
void host_state_observer_mock_release (struct host_state_observer_mock *mock);
|
||||
|
||||
int host_state_observer_mock_validate_and_release (struct host_state_observer_mock *mock);
|
||||
|
||||
|
||||
#endif /* HOST_STATE_OBSERVER_MOCK_H_ */
|
|
@ -190,7 +190,7 @@ struct pfm_manager_flash_testing {
|
|||
struct flash_master_mock flash_mock_state; /**< Flash master for host state flash. */
|
||||
struct spi_flash flash; /**< Flash containing the PFM data. */
|
||||
struct spi_flash flash_state; /**< Flash containing the host state. */
|
||||
struct state_manager state_mgr; /**< Manager for host state. */
|
||||
struct host_state_manager state_mgr; /**< Manager for host state. */
|
||||
struct pfm_flash pfm1; /**< The first PFM. */
|
||||
uint8_t signature1[256]; /**< Buffer for the first manifest signature. */
|
||||
uint8_t platform_id1[256]; /**< Cache for the first platform ID. */
|
||||
|
@ -570,7 +570,7 @@ static void pfm_manager_flash_testing_init (CuTest *test, struct pfm_manager_fla
|
|||
pfm_manager_flash_testing_init_dependencies (test, manager, addr1, addr2);
|
||||
|
||||
if (!pfm1_active) {
|
||||
status = manager->state_mgr.save_active_manifest (&manager->state_mgr, 0,
|
||||
status = manager->state_mgr.base.save_active_manifest (&manager->state_mgr.base, 0,
|
||||
MANIFEST_REGION_2);
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
}
|
||||
|
@ -877,7 +877,8 @@ static void pfm_manager_flash_test_init_region1_pending_lower_id (CuTest *test)
|
|||
|
||||
pfm_manager_flash_testing_init_dependencies (test, &manager, 0x10000, 0x20000);
|
||||
|
||||
status = manager.state_mgr.save_active_manifest (&manager.state_mgr, 0, MANIFEST_REGION_2);
|
||||
status = manager.state_mgr.base.save_active_manifest (&manager.state_mgr.base, 0,
|
||||
MANIFEST_REGION_2);
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
status = pfm_manager_flash_testing_verify_pfm (&manager, PFM_DATA, PFM_DATA_LEN, PFM_HASH,
|
||||
|
@ -909,7 +910,8 @@ static void pfm_manager_flash_test_init_region1_pending_same_id (CuTest *test)
|
|||
|
||||
pfm_manager_flash_testing_init_dependencies (test, &manager, 0x10000, 0x20000);
|
||||
|
||||
status = manager.state_mgr.save_active_manifest (&manager.state_mgr, 0, MANIFEST_REGION_2);
|
||||
status = manager.state_mgr.base.save_active_manifest (&manager.state_mgr.base, 0,
|
||||
MANIFEST_REGION_2);
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
status = pfm_manager_flash_testing_verify_pfm (&manager, PFM_DATA, PFM_DATA_LEN, PFM_HASH,
|
||||
|
@ -1047,7 +1049,8 @@ static void pfm_manager_flash_test_init_only_pending_region1_empty_manifest (CuT
|
|||
|
||||
pfm_manager_flash_testing_init_dependencies (test, &manager, 0x10000, 0x20000);
|
||||
|
||||
status = manager.state_mgr.save_active_manifest (&manager.state_mgr, 0, MANIFEST_REGION_2);
|
||||
status = manager.state_mgr.base.save_active_manifest (&manager.state_mgr.base, 0,
|
||||
MANIFEST_REGION_2);
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
status = pfm_manager_flash_testing_verify_empty_pfm (&manager, pfm, length, man_offset,
|
||||
|
@ -1894,7 +1897,7 @@ static void pfm_manager_flash_test_activate_pending_pfm_region2 (CuTest *test)
|
|||
CuAssertPtrEquals (test, &manager.pfm2, manager.test.base.get_active_pfm (&manager.test.base));
|
||||
CuAssertPtrEquals (test, NULL, manager.test.base.get_pending_pfm (&manager.test.base));
|
||||
|
||||
active = manager.state_mgr.get_active_manifest (&manager.state_mgr, 0);
|
||||
active = manager.state_mgr.base.get_active_manifest (&manager.state_mgr.base, 0);
|
||||
CuAssertIntEquals (test, MANIFEST_REGION_2, active);
|
||||
|
||||
status = host_state_manager_is_pfm_dirty (&manager.state_mgr);
|
||||
|
@ -1922,7 +1925,7 @@ static void pfm_manager_flash_test_activate_pending_pfm_region1 (CuTest *test)
|
|||
CuAssertPtrEquals (test, &manager.pfm1, manager.test.base.get_active_pfm (&manager.test.base));
|
||||
CuAssertPtrEquals (test, NULL, manager.test.base.get_pending_pfm (&manager.test.base));
|
||||
|
||||
active = manager.state_mgr.get_active_manifest (&manager.state_mgr, 0);
|
||||
active = manager.state_mgr.base.get_active_manifest (&manager.state_mgr.base, 0);
|
||||
CuAssertIntEquals (test, MANIFEST_REGION_1, active);
|
||||
|
||||
status = host_state_manager_is_pfm_dirty (&manager.state_mgr);
|
||||
|
@ -1958,7 +1961,7 @@ static void pfm_manager_flash_test_activate_pending_pfm_region2_notify_observers
|
|||
CuAssertPtrEquals (test, &manager.pfm2, manager.test.base.get_active_pfm (&manager.test.base));
|
||||
CuAssertPtrEquals (test, NULL, manager.test.base.get_pending_pfm (&manager.test.base));
|
||||
|
||||
active = manager.state_mgr.get_active_manifest (&manager.state_mgr, 0);
|
||||
active = manager.state_mgr.base.get_active_manifest (&manager.state_mgr.base, 0);
|
||||
CuAssertIntEquals (test, MANIFEST_REGION_2, active);
|
||||
|
||||
status = host_state_manager_is_pfm_dirty (&manager.state_mgr);
|
||||
|
@ -1993,7 +1996,7 @@ static void pfm_manager_flash_test_activate_pending_pfm_region1_notify_observers
|
|||
CuAssertPtrEquals (test, &manager.pfm1, manager.test.base.get_active_pfm (&manager.test.base));
|
||||
CuAssertPtrEquals (test, NULL, manager.test.base.get_pending_pfm (&manager.test.base));
|
||||
|
||||
active = manager.state_mgr.get_active_manifest (&manager.state_mgr, 0);
|
||||
active = manager.state_mgr.base.get_active_manifest (&manager.state_mgr.base, 0);
|
||||
CuAssertIntEquals (test, MANIFEST_REGION_1, active);
|
||||
|
||||
status = host_state_manager_is_pfm_dirty (&manager.state_mgr);
|
||||
|
|
|
@ -73,7 +73,7 @@ static void recovery_image_manager_testing_write_new_image (CuTest *test,
|
|||
* @param flash The mock for the flash state storage.
|
||||
*/
|
||||
static void recovery_image_manager_testing_init_host_state (CuTest *test,
|
||||
struct state_manager *state, struct flash_mock *flash)
|
||||
struct host_state_manager *state, struct flash_mock *flash)
|
||||
{
|
||||
int status;
|
||||
uint16_t end[4] = {0xffff, 0xffff, 0xffff, 0xffff};
|
||||
|
@ -5141,7 +5141,7 @@ static void recovery_image_manager_test_init_two_region (CuTest *test)
|
|||
struct pfm_manager_mock pfm_manager;
|
||||
struct flash_mock flash;
|
||||
struct flash_mock flash_image;
|
||||
struct state_manager state;
|
||||
struct host_state_manager state;
|
||||
int status;
|
||||
|
||||
TEST_START;
|
||||
|
@ -5225,7 +5225,7 @@ static void recovery_image_manager_test_init_two_region_active_region1 (CuTest *
|
|||
struct pfm_manager_mock pfm_manager;
|
||||
struct flash_mock flash;
|
||||
struct flash_mock flash_image;
|
||||
struct state_manager state;
|
||||
struct host_state_manager state;
|
||||
int status;
|
||||
|
||||
TEST_START;
|
||||
|
@ -5301,7 +5301,7 @@ static void recovery_image_manager_test_init_two_region_active_region2 (CuTest *
|
|||
struct pfm_manager_mock pfm_manager;
|
||||
struct flash_mock flash;
|
||||
struct flash_mock flash_image;
|
||||
struct state_manager state;
|
||||
struct host_state_manager state;
|
||||
int status;
|
||||
|
||||
TEST_START;
|
||||
|
@ -5379,7 +5379,7 @@ static void recovery_image_manager_test_init_two_region_null (CuTest *test)
|
|||
struct signature_verification_mock verification;
|
||||
struct pfm_manager_mock pfm_manager;
|
||||
struct flash_mock flash;
|
||||
struct state_manager state;
|
||||
struct host_state_manager state;
|
||||
int status;
|
||||
|
||||
TEST_START;
|
||||
|
@ -5459,7 +5459,7 @@ static void recovery_image_manager_test_init_two_region_region1_bad_platform_id
|
|||
struct pfm_manager_mock pfm_manager;
|
||||
struct flash_mock flash;
|
||||
struct flash_mock flash_image;
|
||||
struct state_manager state;
|
||||
struct host_state_manager state;
|
||||
int status;
|
||||
|
||||
TEST_START;
|
||||
|
@ -5536,7 +5536,7 @@ static void recovery_image_manager_test_init_two_region_region2_bad_platform_id
|
|||
struct pfm_manager_mock pfm_manager;
|
||||
struct flash_mock flash;
|
||||
struct flash_mock flash_image;
|
||||
struct state_manager state;
|
||||
struct host_state_manager state;
|
||||
int status;
|
||||
|
||||
TEST_START;
|
||||
|
@ -5616,7 +5616,7 @@ static void recovery_image_manager_test_init_two_region_region1_flash_error (CuT
|
|||
struct pfm_manager_mock pfm_manager;
|
||||
struct flash_mock flash;
|
||||
struct flash_mock flash_image;
|
||||
struct state_manager state;
|
||||
struct host_state_manager state;
|
||||
int status;
|
||||
|
||||
TEST_START;
|
||||
|
@ -5691,7 +5691,7 @@ static void recovery_image_manager_test_init_two_region_region2_flash_error (CuT
|
|||
struct pfm_manager_mock pfm_manager;
|
||||
struct flash_mock flash;
|
||||
struct flash_mock flash_image;
|
||||
struct state_manager state;
|
||||
struct host_state_manager state;
|
||||
int status;
|
||||
|
||||
TEST_START;
|
||||
|
@ -5769,7 +5769,7 @@ static void recovery_image_manager_test_init_two_region_region1_bad_signature (C
|
|||
struct pfm_manager_mock pfm_manager;
|
||||
struct flash_mock flash;
|
||||
struct flash_mock flash_image;
|
||||
struct state_manager state;
|
||||
struct host_state_manager state;
|
||||
int status;
|
||||
|
||||
TEST_START;
|
||||
|
@ -5846,7 +5846,7 @@ static void recovery_image_manager_test_init_two_region_region2_bad_signature (C
|
|||
struct pfm_manager_mock pfm_manager;
|
||||
struct flash_mock flash;
|
||||
struct flash_mock flash_image;
|
||||
struct state_manager state;
|
||||
struct host_state_manager state;
|
||||
int status;
|
||||
|
||||
TEST_START;
|
||||
|
@ -5926,7 +5926,7 @@ static void recovery_image_manager_test_init_two_region_region1_bad_signature_ec
|
|||
struct pfm_manager_mock pfm_manager;
|
||||
struct flash_mock flash;
|
||||
struct flash_mock flash_image;
|
||||
struct state_manager state;
|
||||
struct host_state_manager state;
|
||||
int status;
|
||||
|
||||
TEST_START;
|
||||
|
@ -6003,7 +6003,7 @@ static void recovery_image_manager_test_init_two_region_region2_bad_signature_ec
|
|||
struct pfm_manager_mock pfm_manager;
|
||||
struct flash_mock flash;
|
||||
struct flash_mock flash_image;
|
||||
struct state_manager state;
|
||||
struct host_state_manager state;
|
||||
int status;
|
||||
|
||||
TEST_START;
|
||||
|
@ -6083,7 +6083,7 @@ static void recovery_image_manager_test_init_two_region_region1_malformed (CuTes
|
|||
struct pfm_manager_mock pfm_manager;
|
||||
struct flash_mock flash;
|
||||
struct flash_mock flash_image;
|
||||
struct state_manager state;
|
||||
struct host_state_manager state;
|
||||
int status;
|
||||
|
||||
TEST_START;
|
||||
|
@ -6160,7 +6160,7 @@ static void recovery_image_manager_test_init_two_region_region2_malformed (CuTes
|
|||
struct pfm_manager_mock pfm_manager;
|
||||
struct flash_mock flash;
|
||||
struct flash_mock flash_image;
|
||||
struct state_manager state;
|
||||
struct host_state_manager state;
|
||||
int status;
|
||||
|
||||
TEST_START;
|
||||
|
@ -6240,7 +6240,7 @@ static void recovery_image_manager_test_init_two_region_region1_image_header_too
|
|||
struct pfm_manager_mock pfm_manager;
|
||||
struct flash_mock flash;
|
||||
struct flash_mock flash_image;
|
||||
struct state_manager state;
|
||||
struct host_state_manager state;
|
||||
int status;
|
||||
|
||||
TEST_START;
|
||||
|
@ -6317,7 +6317,7 @@ static void recovery_image_manager_test_init_two_region_region2_image_header_too
|
|||
struct pfm_manager_mock pfm_manager;
|
||||
struct flash_mock flash;
|
||||
struct flash_mock flash_image;
|
||||
struct state_manager state;
|
||||
struct host_state_manager state;
|
||||
int status;
|
||||
|
||||
TEST_START;
|
||||
|
@ -6397,7 +6397,7 @@ static void recovery_image_manager_test_init_two_region_region1_image_header_bad
|
|||
struct pfm_manager_mock pfm_manager;
|
||||
struct flash_mock flash;
|
||||
struct flash_mock flash_image;
|
||||
struct state_manager state;
|
||||
struct host_state_manager state;
|
||||
int status;
|
||||
|
||||
TEST_START;
|
||||
|
@ -6474,7 +6474,7 @@ static void recovery_image_manager_test_init_two_region_region2_image_header_bad
|
|||
struct pfm_manager_mock pfm_manager;
|
||||
struct flash_mock flash;
|
||||
struct flash_mock flash_image;
|
||||
struct state_manager state;
|
||||
struct host_state_manager state;
|
||||
int status;
|
||||
|
||||
TEST_START;
|
||||
|
@ -6554,7 +6554,7 @@ static void recovery_image_manager_test_init_two_region_region1_image_header_too
|
|||
struct pfm_manager_mock pfm_manager;
|
||||
struct flash_mock flash;
|
||||
struct flash_mock flash_image;
|
||||
struct state_manager state;
|
||||
struct host_state_manager state;
|
||||
int status;
|
||||
|
||||
TEST_START;
|
||||
|
@ -6631,7 +6631,7 @@ static void recovery_image_manager_test_init_two_region_region2_image_header_too
|
|||
struct pfm_manager_mock pfm_manager;
|
||||
struct flash_mock flash;
|
||||
struct flash_mock flash_image;
|
||||
struct state_manager state;
|
||||
struct host_state_manager state;
|
||||
int status;
|
||||
|
||||
TEST_START;
|
||||
|
@ -6712,7 +6712,7 @@ static void recovery_image_manager_test_init_two_region_region1_image_header_bad
|
|||
struct pfm_manager_mock pfm_manager;
|
||||
struct flash_mock flash;
|
||||
struct flash_mock flash_image;
|
||||
struct state_manager state;
|
||||
struct host_state_manager state;
|
||||
int status;
|
||||
|
||||
TEST_START;
|
||||
|
@ -6790,7 +6790,7 @@ static void recovery_image_manager_test_init_two_region_region2_image_header_bad
|
|||
struct pfm_manager_mock pfm_manager;
|
||||
struct flash_mock flash;
|
||||
struct flash_mock flash_image;
|
||||
struct state_manager state;
|
||||
struct host_state_manager state;
|
||||
int status;
|
||||
|
||||
TEST_START;
|
||||
|
@ -6871,7 +6871,7 @@ static void recovery_image_manager_test_init_two_region_region1_image_header_bad
|
|||
struct pfm_manager_mock pfm_manager;
|
||||
struct flash_mock flash;
|
||||
struct flash_mock flash_image;
|
||||
struct state_manager state;
|
||||
struct host_state_manager state;
|
||||
int status;
|
||||
|
||||
TEST_START;
|
||||
|
@ -6949,7 +6949,7 @@ static void recovery_image_manager_test_init_two_region_region2_image_header_bad
|
|||
struct pfm_manager_mock pfm_manager;
|
||||
struct flash_mock flash;
|
||||
struct flash_mock flash_image;
|
||||
struct state_manager state;
|
||||
struct host_state_manager state;
|
||||
int status;
|
||||
|
||||
TEST_START;
|
||||
|
@ -7030,7 +7030,7 @@ static void recovery_image_manager_test_init_two_region_region1_image_header_bad
|
|||
struct pfm_manager_mock pfm_manager;
|
||||
struct flash_mock flash;
|
||||
struct flash_mock flash_image;
|
||||
struct state_manager state;
|
||||
struct host_state_manager state;
|
||||
int status;
|
||||
|
||||
TEST_START;
|
||||
|
@ -7108,7 +7108,7 @@ static void recovery_image_manager_test_init_two_region_region2_image_header_bad
|
|||
struct pfm_manager_mock pfm_manager;
|
||||
struct flash_mock flash;
|
||||
struct flash_mock flash_image;
|
||||
struct state_manager state;
|
||||
struct host_state_manager state;
|
||||
int status;
|
||||
|
||||
TEST_START;
|
||||
|
@ -7189,7 +7189,7 @@ static void recovery_image_manager_test_init_two_region_region1_image_header_bad
|
|||
struct pfm_manager_mock pfm_manager;
|
||||
struct flash_mock flash;
|
||||
struct flash_mock flash_image;
|
||||
struct state_manager state;
|
||||
struct host_state_manager state;
|
||||
int status;
|
||||
|
||||
TEST_START;
|
||||
|
@ -7267,7 +7267,7 @@ static void recovery_image_manager_test_init_two_region_region2_image_header_bad
|
|||
struct pfm_manager_mock pfm_manager;
|
||||
struct flash_mock flash;
|
||||
struct flash_mock flash_image;
|
||||
struct state_manager state;
|
||||
struct host_state_manager state;
|
||||
int status;
|
||||
|
||||
TEST_START;
|
||||
|
@ -7348,7 +7348,7 @@ static void recovery_image_manager_test_init_two_region_region1_image_section_he
|
|||
struct pfm_manager_mock pfm_manager;
|
||||
struct flash_mock flash;
|
||||
struct flash_mock flash_image;
|
||||
struct state_manager state;
|
||||
struct host_state_manager state;
|
||||
int status;
|
||||
|
||||
TEST_START;
|
||||
|
@ -7426,7 +7426,7 @@ static void recovery_image_manager_test_init_two_region_region2_image_section_he
|
|||
struct pfm_manager_mock pfm_manager;
|
||||
struct flash_mock flash;
|
||||
struct flash_mock flash_image;
|
||||
struct state_manager state;
|
||||
struct host_state_manager state;
|
||||
int status;
|
||||
|
||||
TEST_START;
|
||||
|
@ -7507,7 +7507,7 @@ static void recovery_image_manager_test_init_two_region_region1_invalid_section_
|
|||
struct pfm_manager_mock pfm_manager;
|
||||
struct flash_mock flash;
|
||||
struct flash_mock flash_image;
|
||||
struct state_manager state;
|
||||
struct host_state_manager state;
|
||||
int status;
|
||||
|
||||
TEST_START;
|
||||
|
@ -7585,7 +7585,7 @@ static void recovery_image_manager_test_init_two_region_region2_invalid_section_
|
|||
struct pfm_manager_mock pfm_manager;
|
||||
struct flash_mock flash;
|
||||
struct flash_mock flash_image;
|
||||
struct state_manager state;
|
||||
struct host_state_manager state;
|
||||
int status;
|
||||
|
||||
TEST_START;
|
||||
|
@ -7665,7 +7665,7 @@ static void recovery_image_manager_test_get_active_recovery_image_two_region (Cu
|
|||
struct pfm_manager_mock pfm_manager;
|
||||
struct flash_mock flash;
|
||||
struct flash_mock flash_image;
|
||||
struct state_manager state;
|
||||
struct host_state_manager state;
|
||||
int status;
|
||||
|
||||
TEST_START;
|
||||
|
@ -7741,7 +7741,7 @@ static void recovery_image_manager_test_get_active_recovery_image_two_region_nul
|
|||
struct pfm_manager_mock pfm_manager;
|
||||
struct flash_mock flash;
|
||||
struct flash_mock flash_image;
|
||||
struct state_manager state;
|
||||
struct host_state_manager state;
|
||||
int status;
|
||||
|
||||
TEST_START;
|
||||
|
@ -7817,7 +7817,7 @@ static void recovery_image_manager_test_clear_recovery_image_two_region_null (Cu
|
|||
struct pfm_manager_mock pfm_manager;
|
||||
struct flash_mock flash_state;
|
||||
struct flash_mock flash;
|
||||
struct state_manager state;
|
||||
struct host_state_manager state;
|
||||
int status;
|
||||
|
||||
TEST_START;
|
||||
|
@ -7894,7 +7894,7 @@ static void recovery_image_manager_test_clear_recovery_image_two_region_region1
|
|||
struct pfm_manager_mock pfm_manager;
|
||||
struct flash_mock flash_state;
|
||||
struct flash_mock flash;
|
||||
struct state_manager state;
|
||||
struct host_state_manager state;
|
||||
int status;
|
||||
|
||||
TEST_START;
|
||||
|
@ -7984,7 +7984,7 @@ static void recovery_image_manager_test_clear_recovery_image_two_region_region2
|
|||
struct pfm_manager_mock pfm_manager;
|
||||
struct flash_mock flash_state;
|
||||
struct flash_mock flash;
|
||||
struct state_manager state;
|
||||
struct host_state_manager state;
|
||||
int status;
|
||||
|
||||
TEST_START;
|
||||
|
@ -8072,7 +8072,7 @@ static void recovery_image_manager_test_clear_recovery_image_two_region_region1_
|
|||
struct pfm_manager_mock pfm_manager;
|
||||
struct flash_mock flash_state;
|
||||
struct flash_mock flash;
|
||||
struct state_manager state;
|
||||
struct host_state_manager state;
|
||||
int status;
|
||||
|
||||
TEST_START;
|
||||
|
@ -8155,7 +8155,7 @@ static void recovery_image_manager_test_clear_recovery_image_two_region_region2_
|
|||
struct pfm_manager_mock pfm_manager;
|
||||
struct flash_mock flash_state;
|
||||
struct flash_mock flash;
|
||||
struct state_manager state;
|
||||
struct host_state_manager state;
|
||||
int status;
|
||||
|
||||
TEST_START;
|
||||
|
@ -8235,7 +8235,7 @@ static void recovery_image_manager_test_clear_recovery_image_two_region_erase_er
|
|||
struct pfm_manager_mock pfm_manager;
|
||||
struct flash_mock flash_state;
|
||||
struct flash_mock flash;
|
||||
struct state_manager state;
|
||||
struct host_state_manager state;
|
||||
int status;
|
||||
|
||||
TEST_START;
|
||||
|
@ -8331,7 +8331,7 @@ static void recovery_image_manager_test_clear_recovery_image_two_region_erase_er
|
|||
struct pfm_manager_mock pfm_manager;
|
||||
struct flash_mock flash_state;
|
||||
struct flash_mock flash;
|
||||
struct state_manager state;
|
||||
struct host_state_manager state;
|
||||
int status;
|
||||
|
||||
TEST_START;
|
||||
|
@ -8424,7 +8424,7 @@ static void recovery_image_manager_test_clear_recovery_image_two_region_in_use_r
|
|||
struct pfm_manager_mock pfm_manager;
|
||||
struct flash_mock flash_state;
|
||||
struct flash_mock flash;
|
||||
struct state_manager state;
|
||||
struct host_state_manager state;
|
||||
struct recovery_image *active;
|
||||
int status;
|
||||
|
||||
|
@ -8521,7 +8521,7 @@ static void recovery_image_manager_test_clear_recovery_image_two_region_in_use_r
|
|||
struct pfm_manager_mock pfm_manager;
|
||||
struct flash_mock flash_state;
|
||||
struct flash_mock flash;
|
||||
struct state_manager state;
|
||||
struct host_state_manager state;
|
||||
struct recovery_image *active;
|
||||
int status;
|
||||
|
||||
|
@ -8621,7 +8621,7 @@ static void recovery_image_manager_test_clear_recovery_image_two_region_in_use_m
|
|||
struct pfm_manager_mock pfm_manager;
|
||||
struct flash_mock flash_state;
|
||||
struct flash_mock flash;
|
||||
struct state_manager state;
|
||||
struct host_state_manager state;
|
||||
struct recovery_image *active1;
|
||||
struct recovery_image *active2;
|
||||
|
||||
|
@ -8723,7 +8723,7 @@ static void recovery_image_manager_test_clear_recovery_image_two_region_in_use_m
|
|||
struct pfm_manager_mock pfm_manager;
|
||||
struct flash_mock flash_state;
|
||||
struct flash_mock flash;
|
||||
struct state_manager state;
|
||||
struct host_state_manager state;
|
||||
struct recovery_image *active1;
|
||||
struct recovery_image *active2;
|
||||
|
||||
|
@ -8828,7 +8828,7 @@ static void recovery_image_manager_test_clear_recovery_image_two_region_extra_fr
|
|||
struct pfm_manager_mock pfm_manager;
|
||||
struct flash_mock flash_state;
|
||||
struct flash_mock flash;
|
||||
struct state_manager state;
|
||||
struct host_state_manager state;
|
||||
struct recovery_image *active;
|
||||
int status;
|
||||
|
||||
|
@ -8936,7 +8936,7 @@ static void recovery_image_manager_test_clear_recovery_image_two_region_extra_fr
|
|||
struct pfm_manager_mock pfm_manager;
|
||||
struct flash_mock flash_state;
|
||||
struct flash_mock flash;
|
||||
struct state_manager state;
|
||||
struct host_state_manager state;
|
||||
struct recovery_image *active;
|
||||
int status;
|
||||
|
||||
|
@ -9047,7 +9047,7 @@ static void recovery_image_manager_test_clear_recovery_image_two_region_free_nul
|
|||
struct pfm_manager_mock pfm_manager;
|
||||
struct flash_mock flash_state;
|
||||
struct flash_mock flash;
|
||||
struct state_manager state;
|
||||
struct host_state_manager state;
|
||||
int status;
|
||||
|
||||
TEST_START;
|
||||
|
@ -9131,7 +9131,7 @@ static void recovery_image_manager_test_clear_recovery_image_two_region_free_nul
|
|||
struct pfm_manager_mock pfm_manager;
|
||||
struct flash_mock flash_state;
|
||||
struct flash_mock flash;
|
||||
struct state_manager state;
|
||||
struct host_state_manager state;
|
||||
int status;
|
||||
|
||||
TEST_START;
|
||||
|
@ -9218,7 +9218,7 @@ static void recovery_image_manager_test_clear_recovery_image_two_region_free_nul
|
|||
struct pfm_manager_mock pfm_manager;
|
||||
struct flash_mock flash_state;
|
||||
struct flash_mock flash;
|
||||
struct state_manager state;
|
||||
struct host_state_manager state;
|
||||
struct recovery_image *active;
|
||||
int status;
|
||||
|
||||
|
@ -9303,7 +9303,7 @@ static void recovery_image_manager_test_clear_recovery_image_two_region_free_nul
|
|||
struct pfm_manager_mock pfm_manager;
|
||||
struct flash_mock flash_state;
|
||||
struct flash_mock flash;
|
||||
struct state_manager state;
|
||||
struct host_state_manager state;
|
||||
struct recovery_image *active;
|
||||
int status;
|
||||
|
||||
|
@ -9391,7 +9391,7 @@ static void recovery_image_manager_test_clear_recovery_image_two_region_in_use_a
|
|||
struct pfm_manager_mock pfm_manager;
|
||||
struct flash_mock flash_state;
|
||||
struct flash_mock flash;
|
||||
struct state_manager state;
|
||||
struct host_state_manager state;
|
||||
struct recovery_image *active;
|
||||
uint8_t data[] = {0x01, 0x02, 0x03, 0x04};
|
||||
int status;
|
||||
|
@ -9504,7 +9504,7 @@ static void recovery_image_manager_test_clear_recovery_image_two_region_in_use_a
|
|||
struct pfm_manager_mock pfm_manager;
|
||||
struct flash_mock flash_state;
|
||||
struct flash_mock flash;
|
||||
struct state_manager state;
|
||||
struct host_state_manager state;
|
||||
struct recovery_image *active;
|
||||
uint8_t data[] = {0x01, 0x02, 0x03, 0x04};
|
||||
int status;
|
||||
|
@ -9618,7 +9618,7 @@ static void recovery_image_manager_test_clear_recovery_image_two_region_not_in_u
|
|||
struct pfm_manager_mock pfm_manager;
|
||||
struct flash_mock flash_state;
|
||||
struct flash_mock flash;
|
||||
struct state_manager state;
|
||||
struct host_state_manager state;
|
||||
int status;
|
||||
|
||||
TEST_START;
|
||||
|
@ -9705,7 +9705,7 @@ static void recovery_image_manager_test_clear_recovery_image_two_region_not_in_u
|
|||
struct pfm_manager_mock pfm_manager;
|
||||
struct flash_mock flash_state;
|
||||
struct flash_mock flash;
|
||||
struct state_manager state;
|
||||
struct host_state_manager state;
|
||||
int status;
|
||||
|
||||
TEST_START;
|
||||
|
@ -9796,7 +9796,7 @@ static void recovery_image_manager_test_clear_recovery_image_two_region_notify_o
|
|||
struct flash_mock flash;
|
||||
struct flash_mock flash_image;
|
||||
struct recovery_image_observer_mock observer;
|
||||
struct state_manager state;
|
||||
struct host_state_manager state;
|
||||
uint8_t data[] = {0x01, 0x02, 0x03, 0x04};
|
||||
int status;
|
||||
|
||||
|
@ -9915,7 +9915,7 @@ static void recovery_image_manager_test_clear_recovery_image_two_region_notify_o
|
|||
struct flash_mock flash;
|
||||
struct flash_mock flash_image;
|
||||
struct recovery_image_observer_mock observer;
|
||||
struct state_manager state;
|
||||
struct host_state_manager state;
|
||||
uint8_t data[] = {0x01, 0x02, 0x03, 0x04};
|
||||
int status;
|
||||
|
||||
|
@ -10030,7 +10030,7 @@ static void recovery_image_manager_test_write_recovery_image_data_two_region_reg
|
|||
struct flash_mock flash_state;
|
||||
struct flash_mock flash;
|
||||
uint8_t data[] = {0x01, 0x02, 0x03, 0x04};
|
||||
struct state_manager state;
|
||||
struct host_state_manager state;
|
||||
int status;
|
||||
|
||||
TEST_START;
|
||||
|
@ -10128,7 +10128,7 @@ static void recovery_image_manager_test_write_recovery_image_data_two_region_reg
|
|||
struct flash_mock flash_state;
|
||||
struct flash_mock flash;
|
||||
uint8_t data[] = {0x01, 0x02, 0x03, 0x04};
|
||||
struct state_manager state;
|
||||
struct host_state_manager state;
|
||||
int status;
|
||||
|
||||
TEST_START;
|
||||
|
@ -10225,7 +10225,7 @@ static void recovery_image_manager_test_write_recovery_image_data_two_region_wit
|
|||
struct flash_mock flash_state;
|
||||
struct flash_mock flash;
|
||||
uint8_t data[] = {0x01, 0x02, 0x03, 0x04};
|
||||
struct state_manager state;
|
||||
struct host_state_manager state;
|
||||
int status;
|
||||
|
||||
TEST_START;
|
||||
|
@ -10306,7 +10306,7 @@ static void recovery_image_manager_test_write_recovery_image_data_two_region_too
|
|||
struct flash_mock flash;
|
||||
uint8_t data[] = {0x01, 0x02, 0x03, 0x04};
|
||||
uint8_t fill[RECOVERY_IMAGE_MANAGER_IMAGE_MAX_LEN - sizeof (data) + 1] = {0};
|
||||
struct state_manager state;
|
||||
struct host_state_manager state;
|
||||
int status;
|
||||
|
||||
TEST_START;
|
||||
|
@ -10405,7 +10405,7 @@ static void recovery_image_manager_test_write_recovery_image_data_two_region_wri
|
|||
struct flash_mock flash_state;
|
||||
struct flash_mock flash;
|
||||
uint8_t data[] = {0x01, 0x02, 0x03, 0x04};
|
||||
struct state_manager state;
|
||||
struct host_state_manager state;
|
||||
int status;
|
||||
|
||||
TEST_START;
|
||||
|
@ -10502,7 +10502,7 @@ static void recovery_image_manager_test_write_recovery_image_data_two_region_par
|
|||
struct flash_mock flash;
|
||||
uint8_t data[] = {0x01, 0x02, 0x03, 0x04};
|
||||
uint8_t fill[FLASH_PAGE_SIZE - 1] = {0};
|
||||
struct state_manager state;
|
||||
struct host_state_manager state;
|
||||
int status;
|
||||
|
||||
TEST_START;
|
||||
|
@ -10605,7 +10605,7 @@ static void recovery_image_manager_test_write_recovery_image_data_two_region_mul
|
|||
uint8_t data1[] = {0x01, 0x02, 0x03, 0x04};
|
||||
uint8_t data2[] = {0x05, 0x06, 0x07, 0x08, 0x09};
|
||||
uint8_t data3[] = {0x0a, 0x0b, 0x0c};
|
||||
struct state_manager state;
|
||||
struct host_state_manager state;
|
||||
int status;
|
||||
|
||||
TEST_START;
|
||||
|
@ -10717,7 +10717,7 @@ static void recovery_image_manager_test_write_recovery_image_data_two_region_blo
|
|||
struct flash_mock flash;
|
||||
uint8_t data[] = {0x01, 0x02, 0x03, 0x04};
|
||||
uint8_t fill[FLASH_BLOCK_SIZE - sizeof (data)] = {0};
|
||||
struct state_manager state;
|
||||
struct host_state_manager state;
|
||||
int status;
|
||||
|
||||
TEST_START;
|
||||
|
@ -10821,7 +10821,7 @@ static void recovery_image_manager_test_write_recovery_image_data_two_region_wri
|
|||
uint8_t data1[] = {0x01, 0x02, 0x03, 0x04};
|
||||
uint8_t data2[] = {0x05, 0x06, 0x07, 0x08, 0x09};
|
||||
uint8_t data3[] = {0x0a, 0x0b, 0x0c};
|
||||
struct state_manager state;
|
||||
struct host_state_manager state;
|
||||
int status;
|
||||
|
||||
TEST_START;
|
||||
|
@ -10934,7 +10934,7 @@ static void recovery_image_manager_test_write_recovery_image_data_two_region_wri
|
|||
uint8_t data1[] = {0x01, 0x02, 0x03, 0x04};
|
||||
uint8_t data2[] = {0x05, 0x06, 0x07, 0x08, 0x09};
|
||||
uint8_t fill[FLASH_PAGE_SIZE - 1] = {0};
|
||||
struct state_manager state;
|
||||
struct host_state_manager state;
|
||||
int status;
|
||||
|
||||
TEST_START;
|
||||
|
@ -11045,7 +11045,7 @@ static void recovery_image_manager_test_write_recovery_image_data_two_region_res
|
|||
uint8_t data1[] = {0x01, 0x02, 0x03, 0x04};
|
||||
uint8_t data2[] = {0x05, 0x06, 0x07, 0x08, 0x09};
|
||||
uint8_t data3[] = {0x0a, 0x0b, 0x0c};
|
||||
struct state_manager state;
|
||||
struct host_state_manager state;
|
||||
int status;
|
||||
|
||||
TEST_START;
|
||||
|
@ -11158,7 +11158,7 @@ static void recovery_image_manager_test_write_recovery_image_data_two_region_in_
|
|||
struct flash_mock flash_state;
|
||||
struct flash_mock flash;
|
||||
uint8_t data[] = {0x01, 0x02, 0x03, 0x04};
|
||||
struct state_manager state;
|
||||
struct host_state_manager state;
|
||||
struct recovery_image *active;
|
||||
int status;
|
||||
|
||||
|
@ -11248,7 +11248,7 @@ static void recovery_image_manager_test_write_recovery_image_data_two_region_wri
|
|||
struct flash_mock flash_state;
|
||||
struct flash_mock flash;
|
||||
uint8_t data[] = {0x01, 0x02, 0x03, 0x04};
|
||||
struct state_manager state;
|
||||
struct host_state_manager state;
|
||||
int status;
|
||||
|
||||
TEST_START;
|
||||
|
@ -11339,7 +11339,7 @@ static void recovery_image_manager_test_activate_recovery_image_two_region_regio
|
|||
struct pfm_manager_mock pfm_manager;
|
||||
struct flash_mock flash;
|
||||
struct flash_mock flash_image;
|
||||
struct state_manager state;
|
||||
struct host_state_manager state;
|
||||
enum recovery_image_region active;
|
||||
uint8_t data[] = {0x01, 0x02, 0x03, 0x04};
|
||||
int status;
|
||||
|
@ -11443,7 +11443,7 @@ static void recovery_image_manager_test_activate_recovery_image_two_region_regio
|
|||
struct pfm_manager_mock pfm_manager;
|
||||
struct flash_mock flash;
|
||||
struct flash_mock flash_image;
|
||||
struct state_manager state;
|
||||
struct host_state_manager state;
|
||||
enum recovery_image_region active;
|
||||
uint8_t data[] = {0x01, 0x02, 0x03, 0x04};
|
||||
int status;
|
||||
|
@ -11546,7 +11546,7 @@ static void recovery_image_manager_test_activate_recovery_image_two_region_regio
|
|||
struct flash_mock flash;
|
||||
struct flash_mock flash_image;
|
||||
struct recovery_image_observer_mock observer;
|
||||
struct state_manager state;
|
||||
struct host_state_manager state;
|
||||
enum recovery_image_region active;
|
||||
uint8_t data[] = {0x01, 0x02, 0x03, 0x04};
|
||||
int status;
|
||||
|
@ -11665,7 +11665,7 @@ static void recovery_image_manager_test_activate_recovery_image_two_region_regio
|
|||
struct flash_mock flash;
|
||||
struct flash_mock flash_image;
|
||||
struct recovery_image_observer_mock observer;
|
||||
struct state_manager state;
|
||||
struct host_state_manager state;
|
||||
enum recovery_image_region active;
|
||||
uint8_t data[] = {0x01, 0x02, 0x03, 0x04};
|
||||
int status;
|
||||
|
@ -11780,7 +11780,7 @@ static void recovery_image_manager_test_activate_recovery_image_two_region_no_pe
|
|||
struct pfm_manager_mock pfm_manager;
|
||||
struct flash_mock flash;
|
||||
struct flash_mock flash_image;
|
||||
struct state_manager state;
|
||||
struct host_state_manager state;
|
||||
enum recovery_image_region active;
|
||||
int status;
|
||||
|
||||
|
@ -11867,7 +11867,7 @@ static void recovery_image_manager_test_activate_recovery_image_two_region_no_pe
|
|||
struct pfm_manager_mock pfm_manager;
|
||||
struct flash_mock flash;
|
||||
struct flash_mock flash_image;
|
||||
struct state_manager state;
|
||||
struct host_state_manager state;
|
||||
enum recovery_image_region active;
|
||||
int status;
|
||||
|
||||
|
@ -11951,7 +11951,7 @@ static void recovery_image_manager_test_activate_recovery_image_two_region_no_pe
|
|||
struct pfm_manager_mock pfm_manager;
|
||||
struct flash_mock flash;
|
||||
struct flash_mock flash_image;
|
||||
struct state_manager state;
|
||||
struct host_state_manager state;
|
||||
enum recovery_image_region active;
|
||||
struct recovery_image_observer_mock observer;
|
||||
int status;
|
||||
|
@ -12048,7 +12048,7 @@ static void recovery_image_manager_test_activate_recovery_image_two_region_no_pe
|
|||
struct pfm_manager_mock pfm_manager;
|
||||
struct flash_mock flash;
|
||||
struct flash_mock flash_image;
|
||||
struct state_manager state;
|
||||
struct host_state_manager state;
|
||||
enum recovery_image_region active;
|
||||
struct recovery_image_observer_mock observer;
|
||||
int status;
|
||||
|
@ -12141,7 +12141,7 @@ static void recovery_image_manager_test_activate_recovery_image_two_region_null
|
|||
struct pfm_manager_mock pfm_manager;
|
||||
struct flash_mock flash;
|
||||
struct flash_mock flash_image;
|
||||
struct state_manager state;
|
||||
struct host_state_manager state;
|
||||
enum recovery_image_region active;
|
||||
int status;
|
||||
|
||||
|
@ -12225,7 +12225,7 @@ static void recovery_image_manager_test_activate_recovery_image_two_region_write
|
|||
struct pfm_manager_mock pfm_manager;
|
||||
struct flash_mock flash;
|
||||
struct flash_mock flash_image;
|
||||
struct state_manager state;
|
||||
struct host_state_manager state;
|
||||
uint8_t data[] = {0x01, 0x02, 0x03, 0x04};
|
||||
int status;
|
||||
|
||||
|
@ -12321,7 +12321,7 @@ CuTest *test)
|
|||
struct pfm_manager_mock pfm_manager;
|
||||
struct flash_mock flash;
|
||||
struct flash_mock flash_image;
|
||||
struct state_manager state;
|
||||
struct host_state_manager state;
|
||||
uint8_t data[] = {0x01, 0x02, 0x03, 0x04};
|
||||
int status;
|
||||
|
||||
|
@ -12414,7 +12414,7 @@ static void recovery_image_manager_test_activate_recovery_image_two_region_after
|
|||
struct pfm_manager_mock pfm_manager;
|
||||
struct flash_mock flash;
|
||||
struct flash_mock flash_image;
|
||||
struct state_manager state;
|
||||
struct host_state_manager state;
|
||||
int status;
|
||||
|
||||
TEST_START;
|
||||
|
@ -12501,7 +12501,7 @@ static void recovery_image_manager_test_activate_recovery_image_two_region_after
|
|||
struct pfm_manager_mock pfm_manager;
|
||||
struct flash_mock flash;
|
||||
struct flash_mock flash_image;
|
||||
struct state_manager state;
|
||||
struct host_state_manager state;
|
||||
int status;
|
||||
|
||||
TEST_START;
|
||||
|
@ -12586,7 +12586,7 @@ static void recovery_image_manager_test_activate_recovery_image_two_region_verif
|
|||
struct flash_mock flash;
|
||||
struct flash_mock flash_image;
|
||||
struct recovery_image_observer_mock observer;
|
||||
struct state_manager state;
|
||||
struct host_state_manager state;
|
||||
enum recovery_image_region active;
|
||||
uint8_t data[] = {0x01, 0x02, 0x03, 0x04};
|
||||
int status;
|
||||
|
@ -12704,7 +12704,7 @@ static void recovery_image_manager_test_activate_recovery_image_two_region_verif
|
|||
struct flash_mock flash;
|
||||
struct flash_mock flash_image;
|
||||
struct recovery_image_observer_mock observer;
|
||||
struct state_manager state;
|
||||
struct host_state_manager state;
|
||||
enum recovery_image_region active;
|
||||
uint8_t data[] = {0x01, 0x02, 0x03, 0x04};
|
||||
int status;
|
||||
|
@ -12817,7 +12817,7 @@ static void recovery_image_manager_test_activate_recovery_image_two_region_verif
|
|||
struct pfm_manager_mock pfm_manager;
|
||||
struct flash_mock flash;
|
||||
struct flash_mock flash_image;
|
||||
struct state_manager state;
|
||||
struct host_state_manager state;
|
||||
enum recovery_image_region active;
|
||||
uint8_t data[] = {0x01, 0x02, 0x03, 0x04};
|
||||
int status;
|
||||
|
@ -12921,7 +12921,7 @@ static void recovery_image_manager_test_activate_recovery_image_two_region_verif
|
|||
struct pfm_manager_mock pfm_manager;
|
||||
struct flash_mock flash;
|
||||
struct flash_mock flash_image;
|
||||
struct state_manager state;
|
||||
struct host_state_manager state;
|
||||
enum recovery_image_region active;
|
||||
uint8_t data[] = {0x01, 0x02, 0x03, 0x04};
|
||||
int status;
|
||||
|
@ -13022,7 +13022,7 @@ static void recovery_image_manager_test_activate_recovery_image_two_region_malfo
|
|||
struct pfm_manager_mock pfm_manager;
|
||||
struct flash_mock flash;
|
||||
struct flash_mock flash_image;
|
||||
struct state_manager state;
|
||||
struct host_state_manager state;
|
||||
enum recovery_image_region active;
|
||||
uint8_t data[] = {0x01, 0x02, 0x03, 0x04};
|
||||
int status;
|
||||
|
@ -13127,7 +13127,7 @@ static void recovery_image_manager_test_activate_recovery_image_two_region_malfo
|
|||
struct pfm_manager_mock pfm_manager;
|
||||
struct flash_mock flash;
|
||||
struct flash_mock flash_image;
|
||||
struct state_manager state;
|
||||
struct host_state_manager state;
|
||||
enum recovery_image_region active;
|
||||
uint8_t data[] = {0x01, 0x02, 0x03, 0x04};
|
||||
int status;
|
||||
|
@ -13229,7 +13229,7 @@ static void recovery_image_manager_test_activate_recovery_image_two_region_extra
|
|||
struct pfm_manager_mock pfm_manager;
|
||||
struct flash_mock flash;
|
||||
struct flash_mock flash_image;
|
||||
struct state_manager state;
|
||||
struct host_state_manager state;
|
||||
enum recovery_image_region active;
|
||||
uint8_t data1[] = {0x01, 0x02, 0x03, 0x04};
|
||||
uint8_t data2[] = {0x05, 0x06, 0x07, 0x08, 0x09};
|
||||
|
@ -13343,7 +13343,7 @@ static void recovery_image_manager_test_activate_recovery_image_two_region_extra
|
|||
struct pfm_manager_mock pfm_manager;
|
||||
struct flash_mock flash;
|
||||
struct flash_mock flash_image;
|
||||
struct state_manager state;
|
||||
struct host_state_manager state;
|
||||
enum recovery_image_region active;
|
||||
uint8_t data1[] = {0x01, 0x02, 0x03, 0x04};
|
||||
uint8_t data2[] = {0x05, 0x06, 0x07, 0x08, 0x09};
|
||||
|
@ -13455,7 +13455,7 @@ static void recovery_image_manager_test_activate_recovery_image_two_region_verif
|
|||
struct flash_mock flash;
|
||||
struct flash_mock flash_image;
|
||||
struct recovery_image_observer_mock observer;
|
||||
struct state_manager state;
|
||||
struct host_state_manager state;
|
||||
enum recovery_image_region active;
|
||||
uint8_t data[] = {0x01, 0x02, 0x03, 0x04};
|
||||
int status;
|
||||
|
@ -13570,7 +13570,7 @@ static void recovery_image_manager_test_activate_recovery_image_two_region_verif
|
|||
struct flash_mock flash;
|
||||
struct flash_mock flash_image;
|
||||
struct recovery_image_observer_mock observer;
|
||||
struct state_manager state;
|
||||
struct host_state_manager state;
|
||||
enum recovery_image_region active;
|
||||
uint8_t data[] = {0x01, 0x02, 0x03, 0x04};
|
||||
int status;
|
||||
|
@ -13681,7 +13681,7 @@ static void recovery_image_manager_test_activate_recovery_image_two_region_write
|
|||
struct pfm_manager_mock pfm_manager;
|
||||
struct flash_mock flash;
|
||||
struct flash_mock flash_image;
|
||||
struct state_manager state;
|
||||
struct host_state_manager state;
|
||||
enum recovery_image_region active;
|
||||
uint8_t data[] = {0x01, 0x02, 0x03, 0x04};
|
||||
int status;
|
||||
|
@ -13780,7 +13780,7 @@ static void recovery_image_manager_test_activate_recovery_image_two_region_write
|
|||
struct pfm_manager_mock pfm_manager;
|
||||
struct flash_mock flash;
|
||||
struct flash_mock flash_image;
|
||||
struct state_manager state;
|
||||
struct host_state_manager state;
|
||||
enum recovery_image_region active;
|
||||
uint8_t data[] = {0x01, 0x02, 0x03, 0x04};
|
||||
int status;
|
||||
|
@ -13876,7 +13876,7 @@ static void recovery_image_manager_test_activate_recovery_image_two_region_write
|
|||
struct pfm_manager_mock pfm_manager;
|
||||
struct flash_mock flash;
|
||||
struct flash_mock flash_image;
|
||||
struct state_manager state;
|
||||
struct host_state_manager state;
|
||||
enum recovery_image_region active;
|
||||
uint8_t data[] = {0x01, 0x02, 0x03, 0x04};
|
||||
int status;
|
||||
|
@ -13975,7 +13975,7 @@ static void recovery_image_manager_test_activate_recovery_image_two_region_write
|
|||
struct pfm_manager_mock pfm_manager;
|
||||
struct flash_mock flash;
|
||||
struct flash_mock flash_image;
|
||||
struct state_manager state;
|
||||
struct host_state_manager state;
|
||||
enum recovery_image_region active;
|
||||
uint8_t data[] = {0x01, 0x02, 0x03, 0x04};
|
||||
int status;
|
||||
|
@ -14071,7 +14071,7 @@ static void recovery_image_manager_test_activate_recovery_image_two_region_with_
|
|||
struct pfm_manager_mock pfm_manager;
|
||||
struct flash_mock flash;
|
||||
struct flash_mock flash_image;
|
||||
struct state_manager state;
|
||||
struct host_state_manager state;
|
||||
enum recovery_image_region active;
|
||||
uint8_t data[] = {0x01, 0x02, 0x03, 0x04};
|
||||
int status;
|
||||
|
@ -14171,7 +14171,7 @@ static void recovery_image_manager_test_activate_recovery_image_two_region_with_
|
|||
struct pfm_manager_mock pfm_manager;
|
||||
struct flash_mock flash;
|
||||
struct flash_mock flash_image;
|
||||
struct state_manager state;
|
||||
struct host_state_manager state;
|
||||
enum recovery_image_region active;
|
||||
uint8_t data[] = {0x01, 0x02, 0x03, 0x04};
|
||||
int status;
|
||||
|
@ -14269,7 +14269,7 @@ static void recovery_image_manager_test_activate_recovery_image_two_region_no_ev
|
|||
struct flash_mock flash;
|
||||
struct flash_mock flash_image;
|
||||
struct recovery_image_observer_mock observer;
|
||||
struct state_manager state;
|
||||
struct host_state_manager state;
|
||||
enum recovery_image_region active;
|
||||
uint8_t data[] = {0x01, 0x02, 0x03, 0x04};
|
||||
int status;
|
||||
|
@ -14385,7 +14385,7 @@ static void recovery_image_manager_test_activate_recovery_image_two_region_no_ev
|
|||
struct pfm_manager_mock pfm_manager;
|
||||
struct flash_mock flash;
|
||||
struct recovery_image_observer_mock observer;
|
||||
struct state_manager state;
|
||||
struct host_state_manager state;
|
||||
enum recovery_image_region active;
|
||||
struct flash_mock flash_image;
|
||||
uint8_t data[] = {0x01, 0x02, 0x03, 0x04};
|
||||
|
@ -14498,7 +14498,7 @@ static void recovery_image_manager_test_erase_all_recovery_regions_region1 (CuTe
|
|||
struct pfm_manager_mock pfm_manager;
|
||||
struct flash_mock flash_state;
|
||||
struct flash_mock flash;
|
||||
struct state_manager state;
|
||||
struct host_state_manager state;
|
||||
int status;
|
||||
|
||||
TEST_START;
|
||||
|
@ -14591,7 +14591,7 @@ static void recovery_image_manager_test_erase_all_recovery_regions_region2 (CuTe
|
|||
struct pfm_manager_mock pfm_manager;
|
||||
struct flash_mock flash_state;
|
||||
struct flash_mock flash;
|
||||
struct state_manager state;
|
||||
struct host_state_manager state;
|
||||
int status;
|
||||
|
||||
TEST_START;
|
||||
|
@ -14684,7 +14684,7 @@ static void recovery_image_manager_test_erase_all_recovery_regions_null_region1
|
|||
struct pfm_manager_mock pfm_manager;
|
||||
struct flash_mock flash_state;
|
||||
struct flash_mock flash;
|
||||
struct state_manager state;
|
||||
struct host_state_manager state;
|
||||
int status;
|
||||
|
||||
TEST_START;
|
||||
|
@ -14771,7 +14771,7 @@ static void recovery_image_manager_test_erase_all_recovery_regions_null_region2
|
|||
struct pfm_manager_mock pfm_manager;
|
||||
struct flash_mock flash_state;
|
||||
struct flash_mock flash;
|
||||
struct state_manager state;
|
||||
struct host_state_manager state;
|
||||
int status;
|
||||
|
||||
TEST_START;
|
||||
|
@ -14858,7 +14858,7 @@ static void recovery_image_manager_test_erase_all_recovery_regions_in_use_region
|
|||
struct pfm_manager_mock pfm_manager;
|
||||
struct flash_mock flash_state;
|
||||
struct flash_mock flash;
|
||||
struct state_manager state;
|
||||
struct host_state_manager state;
|
||||
struct recovery_image *active;
|
||||
int status;
|
||||
|
||||
|
@ -14962,7 +14962,7 @@ static void recovery_image_manager_test_erase_all_recovery_regions_in_use_region
|
|||
struct pfm_manager_mock pfm_manager;
|
||||
struct flash_mock flash_state;
|
||||
struct flash_mock flash;
|
||||
struct state_manager state;
|
||||
struct host_state_manager state;
|
||||
struct recovery_image *active;
|
||||
int status;
|
||||
|
||||
|
@ -15067,7 +15067,7 @@ static void recovery_image_manager_test_erase_all_recovery_regions_erase_error_r
|
|||
struct pfm_manager_mock pfm_manager;
|
||||
struct flash_mock flash_state;
|
||||
struct flash_mock flash;
|
||||
struct state_manager state;
|
||||
struct host_state_manager state;
|
||||
int status;
|
||||
|
||||
TEST_START;
|
||||
|
@ -15163,7 +15163,7 @@ static void recovery_image_manager_test_erase_all_recovery_regions_erase_error_r
|
|||
struct pfm_manager_mock pfm_manager;
|
||||
struct flash_mock flash_state;
|
||||
struct flash_mock flash;
|
||||
struct state_manager state;
|
||||
struct host_state_manager state;
|
||||
int status;
|
||||
|
||||
TEST_START;
|
||||
|
@ -15259,7 +15259,7 @@ static void recovery_image_manager_test_erase_all_recovery_regions_valid_image_n
|
|||
struct pfm_manager_mock pfm_manager;
|
||||
struct flash_mock flash_state;
|
||||
struct flash_mock flash;
|
||||
struct state_manager state;
|
||||
struct host_state_manager state;
|
||||
struct recovery_image_observer_mock observer;
|
||||
int status;
|
||||
|
||||
|
@ -15365,7 +15365,7 @@ static void recovery_image_manager_test_erase_all_recovery_regions_invalid_image
|
|||
struct pfm_manager_mock pfm_manager;
|
||||
struct flash_mock flash_state;
|
||||
struct flash_mock flash;
|
||||
struct state_manager state;
|
||||
struct host_state_manager state;
|
||||
struct recovery_image_observer_mock observer;
|
||||
int status;
|
||||
|
||||
|
@ -15470,7 +15470,7 @@ static void recovery_image_manager_test_erase_all_recovery_regions_valid_image_n
|
|||
struct pfm_manager_mock pfm_manager;
|
||||
struct flash_mock flash_state;
|
||||
struct flash_mock flash;
|
||||
struct state_manager state;
|
||||
struct host_state_manager state;
|
||||
struct recovery_image_observer_mock observer;
|
||||
int status;
|
||||
|
||||
|
@ -15576,7 +15576,7 @@ static void recovery_image_manager_test_erase_all_recovery_regions_invalid_image
|
|||
struct pfm_manager_mock pfm_manager;
|
||||
struct flash_mock flash_state;
|
||||
struct flash_mock flash;
|
||||
struct state_manager state;
|
||||
struct host_state_manager state;
|
||||
struct recovery_image_observer_mock observer;
|
||||
int status;
|
||||
|
||||
|
@ -16137,12 +16137,12 @@ static void recovery_image_manager_test_get_measured_data_with_offset (CuTest *t
|
|||
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
status = recovery_image_manager_get_measured_data (&manager, offset, buffer, length,
|
||||
status = recovery_image_manager_get_measured_data (&manager, offset, buffer, length,
|
||||
&total_len);
|
||||
CuAssertIntEquals (test, RECOVERY_IMAGE_HASH_LEN - offset, status);
|
||||
CuAssertIntEquals (test, RECOVERY_IMAGE_HASH_LEN, total_len);
|
||||
|
||||
status = testing_validate_array (RECOVERY_IMAGE_HASH + 2, buffer,
|
||||
status = testing_validate_array (RECOVERY_IMAGE_HASH + 2, buffer,
|
||||
RECOVERY_IMAGE_HASH_LEN - offset);
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
|
@ -16417,7 +16417,7 @@ static void recovery_image_manager_test_get_measured_data_no_active_with_offset
|
|||
&verification.base, &pfm_manager.base, RECOVERY_IMAGE_MANAGER_IMAGE_MAX_LEN);
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
status = recovery_image_manager_get_measured_data (&manager, offset, buffer, length,
|
||||
status = recovery_image_manager_get_measured_data (&manager, offset, buffer, length,
|
||||
&total_len);
|
||||
CuAssertIntEquals (test, SHA256_HASH_LENGTH - offset, status);
|
||||
CuAssertIntEquals (test, RECOVERY_IMAGE_HASH_LEN, total_len);
|
||||
|
@ -16552,7 +16552,7 @@ static void recovery_image_manager_test_get_measured_data_no_active_small_buffer
|
|||
&verification.base, &pfm_manager.base, RECOVERY_IMAGE_MANAGER_IMAGE_MAX_LEN);
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
status = recovery_image_manager_get_measured_data (&manager, offset, buffer, length - 4,
|
||||
status = recovery_image_manager_get_measured_data (&manager, offset, buffer, length - 4,
|
||||
&total_len);
|
||||
CuAssertIntEquals (test, SHA256_HASH_LENGTH - 4, status);
|
||||
CuAssertIntEquals (test, RECOVERY_IMAGE_HASH_LEN, total_len);
|
||||
|
@ -16618,7 +16618,7 @@ static void recovery_image_manager_test_get_measured_data_0_bytes_read (CuTest *
|
|||
&verification.base, &pfm_manager.base, RECOVERY_IMAGE_MANAGER_IMAGE_MAX_LEN);
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
status = recovery_image_manager_get_measured_data (&manager, RECOVERY_IMAGE_HASH_LEN, buffer,
|
||||
status = recovery_image_manager_get_measured_data (&manager, RECOVERY_IMAGE_HASH_LEN, buffer,
|
||||
length, &total_len);
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
CuAssertIntEquals (test, RECOVERY_IMAGE_HASH_LEN, total_len);
|
||||
|
@ -16797,7 +16797,7 @@ static void recovery_image_manager_test_get_measured_data_fail (CuTest *test)
|
|||
MOCK_ARG (manager.base.hash), MOCK_ARG_NOT_NULL, MOCK_ARG (SHA256_HASH_LENGTH));
|
||||
CuAssertIntEquals (test, 0, status);
|
||||
|
||||
status = recovery_image_manager_get_measured_data (&manager.base, 0, buffer, length,
|
||||
status = recovery_image_manager_get_measured_data (&manager.base, 0, buffer, length,
|
||||
&total_len);
|
||||
CuAssertIntEquals (test, RECOVERY_IMAGE_GET_HASH_FAILED, status);
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ static const char *SUITE = "spi_filter_irq_handler_dirty";
|
|||
* @param flash The flash device to initialize for state.
|
||||
*/
|
||||
static void spi_filter_irq_handler_dirty_testing_init_host_state (CuTest *test,
|
||||
struct state_manager *state, struct flash_master_mock *flash_mock, struct spi_flash *flash)
|
||||
struct host_state_manager *state, struct flash_master_mock *flash_mock, struct spi_flash *flash)
|
||||
{
|
||||
int status;
|
||||
uint16_t end[4] = {0xffff, 0xffff, 0xffff, 0xffff};
|
||||
|
@ -66,7 +66,7 @@ static void spi_filter_irq_handler_dirty_test_init (CuTest *test)
|
|||
{
|
||||
struct flash_master_mock flash_mock;
|
||||
struct spi_flash flash;
|
||||
struct state_manager host_state;
|
||||
struct host_state_manager host_state;
|
||||
struct host_control_mock control;
|
||||
struct spi_filter_irq_handler_dirty handler;
|
||||
int status;
|
||||
|
@ -98,7 +98,7 @@ static void spi_filter_irq_handler_dirty_test_init_null (CuTest *test)
|
|||
{
|
||||
struct flash_master_mock flash_mock;
|
||||
struct spi_flash flash;
|
||||
struct state_manager host_state;
|
||||
struct host_state_manager host_state;
|
||||
struct host_control_mock control;
|
||||
struct spi_filter_irq_handler_dirty handler;
|
||||
int status;
|
||||
|
@ -139,7 +139,7 @@ static void spi_filter_irq_handler_dirty_test_ro_flash_dirty (CuTest *test)
|
|||
{
|
||||
struct flash_master_mock flash_mock;
|
||||
struct spi_flash flash;
|
||||
struct state_manager host_state;
|
||||
struct host_state_manager host_state;
|
||||
struct host_control_mock control;
|
||||
struct spi_filter_irq_handler_dirty handler;
|
||||
int status;
|
||||
|
@ -177,7 +177,7 @@ static void spi_filter_irq_handler_dirty_test_ro_flash_dirty_null (CuTest *test)
|
|||
{
|
||||
struct flash_master_mock flash_mock;
|
||||
struct spi_flash flash;
|
||||
struct state_manager host_state;
|
||||
struct host_state_manager host_state;
|
||||
struct host_control_mock control;
|
||||
struct spi_filter_irq_handler_dirty handler;
|
||||
int status;
|
||||
|
|
|
@ -25,7 +25,7 @@ static const char *SUITE = "spi_filter_irq_handler";
|
|||
* @param flash The flash device to initialize for state.
|
||||
*/
|
||||
static void spi_filter_irq_handler_testing_init_host_state (CuTest *test,
|
||||
struct state_manager *state, struct flash_master_mock *flash_mock, struct spi_flash *flash)
|
||||
struct host_state_manager *state, struct flash_master_mock *flash_mock, struct spi_flash *flash)
|
||||
{
|
||||
int status;
|
||||
uint16_t end[4] = {0xffff, 0xffff, 0xffff, 0xffff};
|
||||
|
@ -66,7 +66,7 @@ static void spi_filter_irq_handler_test_init (CuTest *test)
|
|||
{
|
||||
struct flash_master_mock flash_mock;
|
||||
struct spi_flash flash;
|
||||
struct state_manager host_state;
|
||||
struct host_state_manager host_state;
|
||||
struct spi_filter_irq_handler handler;
|
||||
int status;
|
||||
|
||||
|
@ -91,7 +91,7 @@ static void spi_filter_irq_handler_test_init_null (CuTest *test)
|
|||
{
|
||||
struct flash_master_mock flash_mock;
|
||||
struct spi_flash flash;
|
||||
struct state_manager host_state;
|
||||
struct host_state_manager host_state;
|
||||
struct spi_filter_irq_handler handler;
|
||||
int status;
|
||||
|
||||
|
@ -122,7 +122,7 @@ static void spi_filter_irq_handler_test_ro_flash_dirty (CuTest *test)
|
|||
{
|
||||
struct flash_master_mock flash_mock;
|
||||
struct spi_flash flash;
|
||||
struct state_manager host_state;
|
||||
struct host_state_manager host_state;
|
||||
struct spi_filter_irq_handler handler;
|
||||
int status;
|
||||
|
||||
|
@ -149,7 +149,7 @@ static void spi_filter_irq_handler_test_ro_flash_dirty_null (CuTest *test)
|
|||
{
|
||||
struct flash_master_mock flash_mock;
|
||||
struct spi_flash flash;
|
||||
struct state_manager host_state;
|
||||
struct host_state_manager host_state;
|
||||
struct spi_filter_irq_handler handler;
|
||||
int status;
|
||||
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
#include "manifest_cmd_handler_pfm.h"
|
||||
#include "host_fw/host_state_manager.h"
|
||||
#include "manifest/manifest_logging.h"
|
||||
|
||||
|
||||
|
@ -79,8 +78,9 @@ static int manifest_cmd_handler_pfm_activation (struct manifest_cmd_handler *tas
|
|||
* @return 0 if the task was successfully initialized or an error code.
|
||||
*/
|
||||
int manifest_cmd_handler_pfm_init (struct manifest_cmd_handler_pfm *task,
|
||||
struct manifest_manager *manifest, struct host_processor *host, struct state_manager *state,
|
||||
struct hash_engine *hash, struct rsa_engine *rsa, struct spi_filter_interface *filter)
|
||||
struct manifest_manager *manifest, struct host_processor *host,
|
||||
struct host_state_manager *state, struct hash_engine *hash, struct rsa_engine *rsa,
|
||||
struct spi_filter_interface *filter)
|
||||
{
|
||||
int status;
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
#include "manifest_cmd_handler.h"
|
||||
#include "host_fw/host_processor.h"
|
||||
#include "state_manager/state_manager.h"
|
||||
#include "host_fw/host_state_manager.h"
|
||||
#include "spi_filter/spi_filter_interface.h"
|
||||
|
||||
|
||||
|
@ -14,9 +14,9 @@
|
|||
* Task context for executing requests for a single PFM.
|
||||
*/
|
||||
struct manifest_cmd_handler_pfm {
|
||||
struct manifest_cmd_handler base; /**< Base command task. */
|
||||
struct manifest_cmd_handler base; /**< Base command task. */
|
||||
struct host_processor *host; /**< Host instance for the PFM. */
|
||||
struct state_manager *state; /**< Manager for host state information. */
|
||||
struct host_state_manager *state; /**< Manager for host state information. */
|
||||
struct hash_engine *hash; /**< Hash engine for run-time verification. */
|
||||
struct rsa_engine *rsa; /**< RSA engine for run-time verification. */
|
||||
struct spi_filter_interface *filter; /**< SPI filter for the host. */
|
||||
|
@ -24,8 +24,9 @@ struct manifest_cmd_handler_pfm {
|
|||
|
||||
|
||||
int manifest_cmd_handler_pfm_init (struct manifest_cmd_handler_pfm *task,
|
||||
struct manifest_manager *manifest, struct host_processor *host, struct state_manager *state,
|
||||
struct hash_engine *hash, struct rsa_engine *rsa, struct spi_filter_interface *filter);
|
||||
struct manifest_manager *manifest, struct host_processor *host,
|
||||
struct host_state_manager *state, struct hash_engine *hash, struct rsa_engine *rsa,
|
||||
struct spi_filter_interface *filter);
|
||||
|
||||
|
||||
#endif /* MANIFEST_CMD_HANDLER_PFM_H_ */
|
||||
|
|
|
@ -30,11 +30,13 @@
|
|||
#define TESTING_RUN_STATE_MANAGER_SUITE
|
||||
#define TESTING_RUN_HOST_STATE_MANAGER_SUITE
|
||||
#define TESTING_RUN_SYSTEM_STATE_MANAGER_SUITE
|
||||
#define TESTING_RUN_HOST_FLASH_MANAGER_SUITE
|
||||
#define TESTING_RUN_HOST_FLASH_MANAGER_DUAL_SUITE
|
||||
#define TESTING_RUN_HOST_FLASH_MANAGER_SINGLE_SUITE
|
||||
#define TESTING_RUN_PFM_MANAGER_FLASH_SUITE
|
||||
#define TESTING_RUN_CFM_MANAGER_FLASH_SUITE
|
||||
#define TESTING_RUN_HOST_PROCESSOR_SUITE
|
||||
#define TESTING_RUN_HOST_PROCESSOR_DUAL_SUITE
|
||||
#define TESTING_RUN_HOST_PROCESSOR_SINGLE_SUITE
|
||||
#define TESTING_RUN_HOST_IRQ_HANDLER_SUITE
|
||||
#define TESTING_RUN_SPI_FILTER_IRQ_HANDLER_SUITE
|
||||
#define TESTING_RUN_PLATFORM_TIMER_SUITE
|
||||
|
@ -54,7 +56,7 @@
|
|||
#define TESTING_RUN_AUX_ATTESTATION_SUITE
|
||||
#define TESTING_RUN_FIRMWARE_HEADER_SUITE
|
||||
#define TESTING_RUN_SPI_FILTER_IRQ_HANDLER_DIRTY_SUITE
|
||||
#define TESTING_RUN_HOST_IRQ_HANDLER_PFM_CHECK_SUITE
|
||||
#define TESTING_RUN_HOST_IRQ_HANDLER_AUTH_CHECK_SUITE
|
||||
#define TESTING_RUN_ATTESTATION_MASTER_SUITE
|
||||
#define TESTING_RUN_ATTESTATION_SLAVE_SUITE
|
||||
#define TESTING_RUN_RNG_MBEDTLS_SUITE
|
||||
|
@ -66,6 +68,7 @@
|
|||
#define TESTING_RUN_PCR_STORE_SUITE
|
||||
#define TESTING_RUN_HOST_IRQ_HANDLER_MASK_IRQS_SUITE
|
||||
#define TESTING_RUN_HOST_PROCESSOR_DUAL_FULL_BYPASS_SUITE
|
||||
#define TESTING_RUN_HOST_PROCESSOR_SINGLE_FULL_BYPASS_SUITE
|
||||
#define TESTING_RUN_OBSERVABLE_SUITE
|
||||
#define TESTING_RUN_PFM_MANAGER_SUITE
|
||||
#define TESTING_RUN_CFM_MANAGER_SUITE
|
||||
|
@ -114,6 +117,7 @@
|
|||
#define TESTING_RUN_FLASH_STORE_ENCRYPTED_SUITE
|
||||
#define TESTING_RUN_KDF_SUITE
|
||||
#define TESTING_RUN_BUFFER_UTIL_SUITE
|
||||
#define TESTING_RUN_HOST_STATE_OBSERVER_DIRTY_RESET_SUITE
|
||||
|
||||
/* Platform-specific test suites. */
|
||||
#define TESTING_RUN_HASH_OPENSSL_SUITE
|
||||
|
|
|
@ -6,6 +6,10 @@
|
|||
|
||||
#include <openssl/evp.h>
|
||||
#include "CuTest/CuTest.h"
|
||||
#include "testing.h"
|
||||
|
||||
|
||||
const char *SUITE = "linux";
|
||||
|
||||
|
||||
//#define TESTING_RUN_HASH_OPENSSL_SUITE
|
||||
|
@ -27,6 +31,8 @@ CuSuite* get_rng_openssl_suite (void);
|
|||
|
||||
void linux_teardown (CuTest *test)
|
||||
{
|
||||
TEST_START;
|
||||
|
||||
EVP_cleanup ();
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче