Add event log parameter handling in SP
A generic publish/subscribe mechanism is implemented to allow
boot information such as the TPM event log to be passed to
specific SPs, based on subscriptions specified in the SP
manifest. This change implements the in-SP handling
for the initialization parameters. The env_test has
been extended to include tests that check that the
event log is being passed and stored in the config store.
Signed-off-by: Julian Hall <julian.hall@arm.com>
Change-Id: I89211ebffd9e2d1768eaf5736e6b28dceafb0a02
diff --git a/components/config/interface/config_blob.h b/components/config/interface/config_blob.h
new file mode 100644
index 0000000..4f8325f
--- /dev/null
+++ b/components/config/interface/config_blob.h
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2021, Arm Limited and Contributors. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#ifndef CONFIG_BLOB_H
+#define CONFIG_BLOB_H
+
+#include <stddef.h>
+
+/**
+ * A general-purpose blob of configuarion data. Points to a buffer
+ * that contains the actual data.
+ */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * \brief Structure definition for a config_blob
+ *
+ */
+struct config_blob
+{
+ const void *data;
+ size_t data_len;
+};
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* CONFIG_BLOB_H */
diff --git a/components/config/interface/config_store.h b/components/config/interface/config_store.h
new file mode 100644
index 0000000..63f9282
--- /dev/null
+++ b/components/config/interface/config_store.h
@@ -0,0 +1,90 @@
+/*
+ * Copyright (c) 2021, Arm Limited and Contributors. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#ifndef CONFIG_STORE_H
+#define CONFIG_STORE_H
+
+#include <stdbool.h>
+#include <stddef.h>
+
+/**
+ * Provides a common interface for retrieving configuration
+ * objects. Configuration objects are used at run-time
+ * to configure TS deployments such as a service provider
+ * running within a secure partition.
+ */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * \brief A classifier for configuration objects
+ *
+ * Used as a label to identifier the general class of a configuartion object.
+ */
+enum config_classifier
+{
+ /* A classifier for a device region that describes a region of IO mapped memory */
+ CONFIG_CLASSIFIER_DEVICE_REGION,
+
+ /* A classifier for a memory region that describes a region of memory */
+ CONFIG_CLASSIFIER_MEMORY_REGION,
+
+ /* A classifier for an opaque configuration blob */
+ CONFIG_CLASSIFIER_BLOB
+};
+
+
+/**
+ * \brief Query for a particular configuration object
+ *
+ * \param[in] classifier The class of object
+ * \param[in] name The name of the object
+ * \param[in] instance The instance number
+ * \param[out] data Pointer to client provided buffer for the object
+ * \param[in] data_buf_size Size of the client provided buffer
+ *
+ * \return True if successful
+ */
+bool config_store_query(enum config_classifier classifier,
+ const char *name,
+ unsigned int instance,
+ void *data,
+ size_t data_buf_size);
+
+/**
+ * \brief Add an object to the config store
+ *
+ * \param[in] classifier The class of object
+ * \param[in] name The name of the object
+ * \param[in] instance The instance number
+ * \param[in] data The object data to add
+ * \param[in] data_len The size of the object
+ *
+ * \return True if successful
+ */
+bool config_store_add(enum config_classifier classifier,
+ const char *name,
+ unsigned int instance,
+ const void *data,
+ size_t data_len);
+
+/**
+ * \brief Returns a count of the number of objects of a particular class
+ *
+ * \param[in] classifier The class of object
+ *
+ * \return Count of objects held
+ */
+unsigned int config_store_count(enum config_classifier classifier);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* CONFIG_STORE_H */
diff --git a/components/config/interface/platform_config.h b/components/config/interface/platform_config.h
deleted file mode 100644
index 3f7eb94..0000000
--- a/components/config/interface/platform_config.h
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Copyright (c) 2021, Arm Limited and Contributors. All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- */
-
-#ifndef TS_CONFIG_INTERFACE_PLATFORM_CONFIG_H
-#define TS_CONFIG_INTERFACE_PLATFORM_CONFIG_H
-
-#include <platform/interface/device_region.h>
-#include <stddef.h>
-
-/**
- * Provides a common interface for retrieving platform configuration
- * data for initializing platform provided devices or services.
- */
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/**
- * \brief Query platform configuartion for a particular device_region
- *
- * \param[in] dev_class Class of device (e.g. 'trng')
- * \param[in] dev_instance The instance of the class of a device on platform
- *
- * \return Pointer to device_region or NULL if no qualifying configuration
- */
-struct device_region *platform_config_device_query(const char *dev_class,
- int dev_instance);
-
-/**
- * \brief Frees a device region returned by platform_config_device_query()
- *
- * \param[in] device_region Device region object to free. Can be NULL.
- */
-void platform_config_device_query_free(struct device_region *device_region);
-
-/**
- * \brief Add a device_region to the platform configuration
- *
- * \param[in] device_region The device_region object to add
- *
- * \return 0 if successful
- */
-int platform_config_device_add(const struct device_region *device_region);
-
-/**
- * \brief Returns a count of the number of device regions
- *
- * \return 0 if successful
- */
-unsigned int platform_config_device_region_count(void);
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* TS_CONFIG_INTERFACE_PLATFORM_CONFIG_H */
diff --git a/components/config/loader/sp/sp_config_loader.c b/components/config/loader/sp/sp_config_loader.c
index a1c8804..5fa953b 100644
--- a/components/config/loader/sp/sp_config_loader.c
+++ b/components/config/loader/sp/sp_config_loader.c
@@ -4,7 +4,8 @@
*/
#include <string.h>
-#include <config/interface/platform_config.h>
+#include <config/interface/config_store.h>
+#include <config/interface/config_blob.h>
#include <platform/interface/device_region.h>
#include "sp_config_loader.h"
@@ -16,9 +17,15 @@
size_t size;
};
+static void load_device_regions(const struct ffa_name_value_pair *value_pair);
+static void load_memory_regions(const struct ffa_name_value_pair *value_pair);
+static void load_blob(const struct ffa_name_value_pair *value_pair);
+
/**
- * Loads externally provided configuration data originating from
- * theh SP manifest.
+ * Loads externally provided configuration data passed into the SP via
+ * FFA initialisation parameters. Data can originate from
+ * the SP manifest, an external device tree or a dynamic configuration
+ * mechanism such as a handover block (HOB).
*/
void sp_config_load(struct ffa_init_info *init_info)
{
@@ -27,22 +34,55 @@
if (!strcmp((const char *)init_info->nvp[param_index].name,"DEVICE_REGIONS")) {
- struct sp_param_device_region *d = (struct sp_param_device_region *)init_info->nvp[param_index].value;
+ load_device_regions(&init_info->nvp[param_index]);
+ }
+ else if (!strcmp((const char *)init_info->nvp[param_index].name,"MEMORY_REGIONS")) {
- /*Iterate over the device regions*/
- while ((uintptr_t)d < (init_info->nvp[param_index].value + init_info->nvp[param_index].size)) {
+ load_memory_regions(&init_info->nvp[param_index]);
+ }
+ else {
- struct device_region device_region;
-
- strcpy(device_region.dev_class, d->name);
- device_region.dev_instance = 0;
- device_region.base_addr = d->location;
- device_region.io_region_size = d->size;
-
- platform_config_device_add(&device_region);
-
- ++d;
- }
+ load_blob(&init_info->nvp[param_index]);
}
}
}
+
+static void load_device_regions(const struct ffa_name_value_pair *value_pair)
+{
+ struct sp_param_device_region *d = (struct sp_param_device_region *)value_pair->value;
+
+ /* Iterate over the device regions */
+ while ((uintptr_t)d < (value_pair->value + value_pair->size)) {
+
+ struct device_region device_region;
+
+ strcpy(device_region.dev_class, d->name);
+ device_region.dev_instance = 0;
+ device_region.base_addr = d->location;
+ device_region.io_region_size = d->size;
+
+ config_store_add(CONFIG_CLASSIFIER_DEVICE_REGION,
+ device_region.dev_class, device_region.dev_instance,
+ &device_region, sizeof(device_region));
+
+ ++d;
+ }
+}
+
+static void load_memory_regions(const struct ffa_name_value_pair *value_pair)
+{
+ /* Not yet supported */
+ (void)value_pair;
+}
+
+static void load_blob(const struct ffa_name_value_pair *value_pair)
+{
+ struct config_blob blob;
+
+ blob.data = (const void*)value_pair->value;
+ blob.data_len = value_pair->size;
+
+ config_store_add(CONFIG_CLASSIFIER_BLOB,
+ (const char *)value_pair->name, 0,
+ &blob, sizeof(blob));
+}
diff --git a/components/config/ramstore/config_ramstore.c b/components/config/ramstore/config_ramstore.c
index 2e24645..42d749e 100644
--- a/components/config/ramstore/config_ramstore.c
+++ b/components/config/ramstore/config_ramstore.c
@@ -5,7 +5,7 @@
*/
#include "config_ramstore.h"
-#include <config/interface/platform_config.h>
+#include <config/interface/config_store.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
@@ -15,16 +15,25 @@
*/
struct config_container
{
+ enum config_classifier classifier;
+ char name[32];
+ unsigned int instance;
size_t size;
struct config_container *next;
};
-static struct config_container *config_container_create(const void *data, size_t size)
+static struct config_container *config_container_create(enum config_classifier classifier,
+ const char *name, unsigned int instance,
+ const void *data, size_t size)
{
struct config_container *container = malloc(sizeof(struct config_container) + size);
if (container) {
+ container->classifier = classifier;
+ strncpy(container->name, name, sizeof(container->name));
+ container->name[sizeof(container->name) - 1] = '\0';
+ container->instance = instance;
container->size = size;
container->next = NULL;
@@ -49,56 +58,61 @@
*/
static struct config_ramstore
{
- struct config_container *device_region_list;
+ struct config_container *object_list;
} ramstore = {0};
void config_ramstore_init(void)
{
- ramstore.device_region_list = NULL;
+
}
void config_ramstore_deinit(void)
{
- while (ramstore.device_region_list) {
+ while (ramstore.object_list) {
- struct config_container *next = ramstore.device_region_list->next;
- free(ramstore.device_region_list);
- ramstore.device_region_list = next;
+ struct config_container *next = ramstore.object_list->next;
+ free(ramstore.object_list);
+ ramstore.object_list = next;
}
}
-int platform_config_device_add(const struct device_region *device_region)
+bool config_store_add(enum config_classifier classifier,
+ const char *name,
+ unsigned int instance,
+ const void *data,
+ size_t data_len)
{
struct config_container *container;
- container = config_container_create(device_region, sizeof(struct device_region));
- if (!container) return -1;
+ container = config_container_create(classifier, name, instance, data, data_len);
+ if (!container) return false;
- container->next = ramstore.device_region_list;
- ramstore.device_region_list = container;
+ container->next = ramstore.object_list;
+ ramstore.object_list = container;
- return 0;
+ return true;
}
-struct device_region *platform_config_device_query(const char *dev_class,
- int dev_instance)
+bool config_store_query(enum config_classifier classifier,
+ const char *name,
+ unsigned int instance,
+ void *data,
+ size_t data_buf_size)
{
- struct device_region *result = NULL;
- const struct config_container *container = ramstore.device_region_list;
+ bool success = false;
+ const struct config_container *container = ramstore.object_list;
while (container) {
- const struct device_region *candidate;
- candidate = (const struct device_region*)config_container_data(container);
+ if ((container->classifier == classifier) &&
+ (strcmp(container->name, name) == 0) &&
+ (container->instance == instance)) {
- if ((candidate->dev_instance == dev_instance) &&
- (strcmp(candidate->dev_class, dev_class) == 0)) {
+ if (data_buf_size == container->size) {
- result = malloc(container->size);
- if (result) {
-
- memcpy(result, candidate, container->size);
+ memcpy(data, config_container_data(container), container->size);
+ success = true;
}
break;
@@ -107,23 +121,18 @@
container = container->next;
}
- return result;
+ return success;
}
-void platform_config_device_query_free(struct device_region *device_region)
-{
- free(device_region);
-}
-
-unsigned int platform_config_device_region_count(void)
+unsigned int config_store_count(enum config_classifier classifier)
{
unsigned int count = 0;
- const struct config_container *container = ramstore.device_region_list;
+ const struct config_container *container = ramstore.object_list;
while (container) {
- ++count;
+ if (container->classifier == classifier) ++count;
container = container->next;
}
diff --git a/components/config/ramstore/config_ramstore.h b/components/config/ramstore/config_ramstore.h
index 5df1838..cf9b80a 100644
--- a/components/config/ramstore/config_ramstore.h
+++ b/components/config/ramstore/config_ramstore.h
@@ -13,10 +13,6 @@
#ifndef CONFIG_RAMSTORE_H
#define CONFIG_RAMSTORE_H
-#include <stddef.h>
-#include <platform/interface/device_region.h>
-#include <config/interface/platform_config.h>
-
#ifdef __cplusplus
extern "C" {
#endif
diff --git a/components/config/ramstore/test/ramstore_tests.cpp b/components/config/ramstore/test/ramstore_tests.cpp
index aadb62b..a9cde4f 100644
--- a/components/config/ramstore/test/ramstore_tests.cpp
+++ b/components/config/ramstore/test/ramstore_tests.cpp
@@ -5,91 +5,110 @@
*/
#include <cstring>
+#include <config/interface/config_store.h>
#include <config/ramstore/config_ramstore.h>
+#include <config/interface/config_blob.h>
+#include <platform/interface/device_region.h>
#include <CppUTest/TestHarness.h>
TEST_GROUP(ConfigRamstoreTests)
{
- void setup()
- {
- config_ramstore_init();
- }
+ void setup()
+ {
+ config_ramstore_init();
+ }
- void teardown()
- {
- config_ramstore_deinit();
- }
+ void teardown()
+ {
+ config_ramstore_deinit();
+ }
};
TEST(ConfigRamstoreTests, checkEmptyConfig)
{
- /* Expect queries to an empty store to return gracefully */
- struct device_region *query_result = platform_config_device_query("flash", 0);
- CHECK(!query_result);
+ struct config_blob blob;
- /* Expect freeing a null pointer to be harmless */
- platform_config_device_query_free(query_result);
+ /* Expect queries to an empty store to return gracefully */
+ bool query_result = config_store_query(CONFIG_CLASSIFIER_BLOB, "flash", 0,
+ &blob, sizeof(blob));
+
+ CHECK_FALSE(query_result);
+ UNSIGNED_LONGS_EQUAL(0, config_store_count(CONFIG_CLASSIFIER_DEVICE_REGION));
+ UNSIGNED_LONGS_EQUAL(0, config_store_count(CONFIG_CLASSIFIER_MEMORY_REGION));
+ UNSIGNED_LONGS_EQUAL(0, config_store_count(CONFIG_CLASSIFIER_BLOB));
}
TEST(ConfigRamstoreTests, checkSingleConfig)
{
- struct device_region config;
+ struct device_region config;
- /* This would be external configuration, obtained say from device tree */
- strcpy(config.dev_class, "fs");
- config.dev_instance = 2;
- config.base_addr = (uintptr_t)0x0f000010;
- config.io_region_size = 0x100;
+ /* This would be external configuration, obtained say from device tree */
+ strcpy(config.dev_class, "fs");
+ config.dev_instance = 2;
+ config.base_addr = (uintptr_t)0x0f000010;
+ config.io_region_size = 0x100;
- /* Add the configuration object */
- int status = platform_config_device_add(&config);
- CHECK_EQUAL(0, status);
+ /* Add the configuration object */
+ bool success = config_store_add(CONFIG_CLASSIFIER_DEVICE_REGION,
+ config.dev_class, config.dev_instance,
+ &config, sizeof(config));
- /* Expect query find the config object */
- struct device_region *query_result = platform_config_device_query(config.dev_class, config.dev_instance);
- CHECK(query_result);
- CHECK(strcmp(config.dev_class, query_result->dev_class) == 0);
- CHECK_EQUAL(config.dev_instance, query_result->dev_instance);
- CHECK_EQUAL(config.base_addr, query_result->base_addr);
- CHECK_EQUAL(config.io_region_size, query_result->io_region_size);
+ CHECK_TRUE(success);
- platform_config_device_query_free(query_result);
+ /* Expect query find the config object */
+ struct device_region query_result;
+ success = config_store_query(CONFIG_CLASSIFIER_DEVICE_REGION,
+ config.dev_class, config.dev_instance,
+ &query_result, sizeof(query_result));
+
+ CHECK_TRUE(success);
+ STRCMP_EQUAL(config.dev_class, query_result.dev_class);
+ UNSIGNED_LONGS_EQUAL(config.dev_instance, query_result.dev_instance);
+ UNSIGNED_LONGS_EQUAL(config.base_addr, query_result.base_addr);
+ UNSIGNED_LONGS_EQUAL(config.io_region_size, query_result.io_region_size);
}
TEST(ConfigRamstoreTests, checkMultipleConfig)
{
- int status;
+ int status;
- /* Add first config object */
- struct device_region config1;
+ /* Add first config object */
+ struct device_region config1;
- strcpy(config1.dev_class, "flash");
- config1.dev_instance = 0;
- config1.base_addr = (uintptr_t)0x0f000010;
- config1.io_region_size = 0x100;
+ strcpy(config1.dev_class, "flash");
+ config1.dev_instance = 0;
+ config1.base_addr = (uintptr_t)0x0f000010;
+ config1.io_region_size = 0x100;
- status = platform_config_device_add(&config1);
- CHECK_EQUAL(0, status);
+ bool success = config_store_add(CONFIG_CLASSIFIER_DEVICE_REGION,
+ config1.dev_class, config1.dev_instance,
+ &config1, sizeof(config1));
- /* Add second config object */
- struct device_region config2;
+ CHECK_TRUE(success);
- strcpy(config2.dev_class, "flash");
- config2.dev_instance = 1;
- config2.base_addr = (uintptr_t)0x0f000010;
- config2.io_region_size = 0x100;
+ /* Add second config object */
+ struct config_blob config2;
- status = platform_config_device_add(&config2);
- CHECK_EQUAL(0, status);
+ uint8_t config2_data[100];
+ config2.data = config2_data;
+ config2.data_len = sizeof(config2_data);
- CHECK_EQUAL(2, platform_config_device_region_count());
+ success = config_store_add(CONFIG_CLASSIFIER_BLOB,
+ "a_config_blob", 0,
+ &config2, sizeof(config2));
- /* Expect queries for both objects to work */
- struct device_region *query1_result = platform_config_device_query(config1.dev_class, config1.dev_instance);
- CHECK(query1_result);
+ CHECK_TRUE(success);
+ UNSIGNED_LONGS_EQUAL(1, config_store_count(CONFIG_CLASSIFIER_DEVICE_REGION));
+ UNSIGNED_LONGS_EQUAL(1, config_store_count(CONFIG_CLASSIFIER_BLOB));
- struct device_region *query2_result = platform_config_device_query(config2.dev_class, config2.dev_instance);
- CHECK(query2_result);
+ /* Expect queries for both objects to work */
+ struct device_region query1_result;
+ CHECK_TRUE(config_store_query(CONFIG_CLASSIFIER_DEVICE_REGION,
+ config1.dev_class, config1.dev_instance,
+ &query1_result, sizeof(query1_result)));
- platform_config_device_query_free(query2_result);
-}
\ No newline at end of file
+ struct config_blob query2_result;
+ CHECK_TRUE(config_store_query(CONFIG_CLASSIFIER_BLOB,
+ "a_config_blob", 0,
+ &query2_result, sizeof(query2_result)));
+}
diff --git a/components/config/test/sp/sp_config_tests.c b/components/config/test/sp/sp_config_tests.c
index 94ba268..023f5ac 100644
--- a/components/config/test/sp/sp_config_tests.c
+++ b/components/config/test/sp/sp_config_tests.c
@@ -4,14 +4,15 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
#include <service/test_runner/provider/backend/simple_c/simple_c_test_runner.h>
-#include <config/interface/platform_config.h>
+#include <config/interface/config_store.h>
+#include <config/interface/config_blob.h>
+#include <platform/interface/device_region.h>
#include <stdint.h>
/**
* Secure Partition configuration tests for checking configuartion
- * data passed to an SP at initialisation. These tests assume
- * use of the FFA manifest for any SP deployments of
- * deployments/env_test.
+ * data passed to an SP at initialisation. These tests rely on
+ * the SP manifest for deployments/env_test.
*/
/*
@@ -20,7 +21,7 @@
*/
static bool check_device_region_loaded(struct test_failure *failure)
{
- return platform_config_device_region_count() > 0;
+ return config_store_count(CONFIG_CLASSIFIER_DEVICE_REGION) > 0;
}
/*
@@ -29,19 +30,30 @@
*/
static bool check_trng_device_region_loaded(struct test_failure *failure)
{
- bool passed = false;
- struct device_region *dev_region = platform_config_device_query("trng", 0);
+ struct device_region dev_region;
- if (dev_region) {
+ bool passed = config_store_query(CONFIG_CLASSIFIER_DEVICE_REGION,
+ "trng", 0,
+ &dev_region, sizeof(dev_region));
- passed =
- (dev_region->dev_instance == 0) &&
- (dev_region->io_region_size == 0x1000);
- }
+ if (passed) {
- platform_config_device_query_free(dev_region);
+ passed = (dev_region.dev_instance == 0);
+ failure->line_num = __LINE__;
+ failure->info = dev_region.dev_instance;
- return passed;
+ if (passed) {
+ passed = (dev_region.io_region_size == 0x1000);
+ failure->line_num = __LINE__;
+ failure->info = dev_region.io_region_size;
+ }
+ }
+ else {
+
+ failure->line_num = __LINE__;
+ }
+
+ return passed;
}
/*
@@ -49,54 +61,111 @@
*/
static bool check_trng_register_access(struct test_failure *failure)
{
- bool passed = false;
+ struct device_region dev_region;
- struct device_region *dev_region = platform_config_device_query("trng", 0);
+ bool passed = config_store_query(CONFIG_CLASSIFIER_DEVICE_REGION,
+ "trng", 0,
+ &dev_region, sizeof(dev_region));
- if (dev_region) {
+ if (passed) {
- /* Expect reset values to be read from a selection of TRNG registers */
- uint32_t reg_val;
- passed = true;
+ /* Expect reset values to be read from a selection of TRNG registers */
+ uint32_t reg_val;
- /* PID4 */
- if (passed) {
- reg_val = *((volatile uint32_t*)((uint8_t*)dev_region->base_addr + 0xfd0));
- passed = (reg_val == 0x00000004);
- failure->line_num = __LINE__;
- failure->info = reg_val;
- }
+ /* PID4 */
+ reg_val = *((volatile uint32_t*)((uint8_t*)dev_region.base_addr + 0xfd0));
+ passed = (reg_val == 0x00000004);
+ failure->line_num = __LINE__;
+ failure->info = reg_val;
- /* PID0 */
- if (passed) {
- reg_val = *((volatile uint32_t*)((uint8_t*)dev_region->base_addr + 0xfe0));
- passed = (reg_val == 0x000000aa);
- failure->line_num = __LINE__;
- failure->info = reg_val;
- }
- }
+ /* PID0 */
+ if (passed) {
+ reg_val = *((volatile uint32_t*)((uint8_t*)dev_region.base_addr + 0xfe0));
+ passed = (reg_val == 0x000000aa);
+ failure->line_num = __LINE__;
+ failure->info = reg_val;
+ }
+ }
+ else {
- return passed;
+ failure->line_num = __LINE__;
+ }
+
+ return passed;
}
+/*
+ * Check that the loaded configuration includes one or more
+ * configuration blobs. One is expected for teh TPM event log.
+ */
+static bool check_config_blob_loaded(struct test_failure *failure)
+{
+ return config_store_count(CONFIG_CLASSIFIER_BLOB) > 0;
+}
+
+/*
+ * Check that the event log has been loaded.
+ */
+static bool check_event_log_loaded(struct test_failure *failure)
+{
+ struct config_blob config_blob;
+
+ bool passed = config_store_query(CONFIG_CLASSIFIER_BLOB,
+ "EVENT_LOG", 0,
+ &config_blob, sizeof(config_blob));
+
+ return passed;
+}
+
+/*
+ * Check that the event log can be accessed
+ */
+static bool check_event_log_access(struct test_failure *failure)
+{
+ struct config_blob config_blob;
+
+ bool passed = config_store_query(CONFIG_CLASSIFIER_BLOB,
+ "EVENT_LOG", 0,
+ &config_blob, sizeof(config_blob));
+
+ if (passed) {
+
+ passed = (config_blob.data_len > 0);
+ failure->line_num = __LINE__;
+
+ if (passed) {
+ passed = (config_blob.data);
+ failure->line_num = __LINE__;
+ }
+ }
+ else {
+
+ failure->line_num = __LINE__;
+ }
+
+ return passed;
+}
/**
* Define an register test group
*/
void sp_config_tests_register(void)
{
- static const struct simple_c_test_case sp_config_tests[] = {
- {.name = "DevRegionLoaded", .test_func = check_device_region_loaded},
- {.name = "TrngDevRegionLoaded", .test_func = check_trng_device_region_loaded},
- {.name = "TrngRegAccess", .test_func = check_trng_register_access}
- };
+ static const struct simple_c_test_case sp_config_tests[] = {
+ {.name = "DevRegionLoaded", .test_func = check_device_region_loaded},
+ {.name = "TrngDevRegionLoaded", .test_func = check_trng_device_region_loaded},
+ {.name = "TrngRegAccess", .test_func = check_trng_register_access},
+ {.name = "ConfigBlobLoaded", .test_func = check_config_blob_loaded},
+ {.name = "EventLogLoaded", .test_func = check_event_log_loaded},
+ {.name = "EventLogAccess", .test_func = check_event_log_access}
+ };
- static const struct simple_c_test_group sp_config_test_group =
- {
- .group = "SpConfigTests",
- .num_test_cases = sizeof(sp_config_tests)/sizeof(struct simple_c_test_case),
- .test_cases = sp_config_tests
- };
+ static const struct simple_c_test_group sp_config_test_group =
+ {
+ .group = "SpConfigTests",
+ .num_test_cases = sizeof(sp_config_tests)/sizeof(struct simple_c_test_case),
+ .test_cases = sp_config_tests
+ };
- simple_c_test_runner_register_group(&sp_config_test_group);
-}
\ No newline at end of file
+ simple_c_test_runner_register_group(&sp_config_test_group);
+}