]> git.baikalelectronics.ru Git - arm-tf.git/commitdiff
refactor(measured-boot): accept metadata as a function's argument
authorManish V Badarkhe <Manish.Badarkhe@arm.com>
Fri, 18 Nov 2022 18:30:08 +0000 (18:30 +0000)
committerManish V Badarkhe <Manish.Badarkhe@arm.com>
Tue, 22 Nov 2022 10:06:56 +0000 (10:06 +0000)
Updated the event log driver's function to accept metadata as an
argument, to remove the platform function usage from the event log
driver to make it a standalone driver.

Change-Id: I512cf693d51dc3c0b9d2c1bfde4f89414e273049
Signed-off-by: Manish V Badarkhe <Manish.Badarkhe@arm.com>
drivers/measured_boot/event_log/event_log.c
include/drivers/measured_boot/event_log/event_log.h

index d661c35e70b521c69d85a4e74d325c72f653efab..6f2898df61bf74b8a72a1df7faa57c38e621e9a2 100644 (file)
@@ -14,8 +14,6 @@
 #include <drivers/auth/crypto_mod.h>
 #include <drivers/measured_boot/event_log/event_log.h>
 
-#include <plat/common/platform.h>
-
 #if TPM_ALG_ID == TPM_ALG_SHA512
 #define        CRYPTO_MD_ID    CRYPTO_MD_SHA512
 #elif TPM_ALG_ID == TPM_ALG_SHA384
@@ -32,9 +30,6 @@ static uint8_t *log_ptr;
 /* Pointer to the first byte past end of the Event Log buffer */
 static uintptr_t log_end;
 
-/* Pointer to event_log_metadata_t */
-static const event_log_metadata_t *plat_metadata_ptr;
-
 /* TCG_EfiSpecIdEvent */
 static const id_event_headers_t id_event_header = {
        .header = {
@@ -173,10 +168,6 @@ void event_log_buf_init(uint8_t *event_log_start, uint8_t *event_log_finish)
 void event_log_init(uint8_t *event_log_start, uint8_t *event_log_finish)
 {
        event_log_buf_init(event_log_start, event_log_finish);
-
-       /* Get pointer to platform's event_log_metadata_t structure */
-       plat_metadata_ptr = plat_event_log_get_metadata();
-       assert(plat_metadata_ptr != NULL);
 }
 
 void event_log_write_specid_event(void)
@@ -276,16 +267,19 @@ int event_log_measure(uintptr_t data_base, uint32_t data_size,
  * @param[in] data_base                Address of data
  * @param[in] data_size                Size of data
  * @param[in] data_id          Data ID
+ * @param[in] metadata_ptr     Event Log metadata
  * @return:
  *     0 = success
  *    < 0 = error
  */
 int event_log_measure_and_record(uintptr_t data_base, uint32_t data_size,
-                                uint32_t data_id)
+                                uint32_t data_id,
+                                const event_log_metadata_t *metadata_ptr)
 {
        unsigned char hash_data[CRYPTO_MD_MAX_SIZE];
        int rc;
-       const event_log_metadata_t *metadata_ptr = plat_metadata_ptr;
+
+       assert(metadata_ptr != NULL);
 
        /* Get the metadata associated with this image. */
        while ((metadata_ptr->id != EVLOG_INVALID_ID) &&
index eb0e2b12924e9d4cced1eeb6a3bdb70856a76f45..794d6133e1bb615c8d1c6a6d66c07d3792d70ca5 100644 (file)
@@ -115,13 +115,13 @@ void event_log_init(uint8_t *event_log_start, uint8_t *event_log_finish);
 void event_log_write_specid_event(void);
 void event_log_write_header(void);
 void dump_event_log(uint8_t *log_addr, size_t log_size);
-const event_log_metadata_t *plat_event_log_get_metadata(void);
 int event_log_measure(uintptr_t data_base, uint32_t data_size,
                      unsigned char hash_data[CRYPTO_MD_MAX_SIZE]);
 void event_log_record(const uint8_t *hash, uint32_t event_type,
                      const event_log_metadata_t *metadata_ptr);
 int event_log_measure_and_record(uintptr_t data_base, uint32_t data_size,
-                                uint32_t data_id);
+                                uint32_t data_id,
+                                const event_log_metadata_t *metadata_ptr);
 size_t event_log_get_cur_size(uint8_t *event_log_start);
 
 #endif /* EVENT_LOG_H */