diff --git a/include/lib/transfer_list.h b/include/lib/transfer_list.h index 1b5ec2d63..047b2d0ad 100644 --- a/include/lib/transfer_list.h +++ b/include/lib/transfer_list.h @@ -110,6 +110,7 @@ struct __attribute__((packed)) transfer_list_entry { CASSERT(sizeof(struct transfer_list_entry) == U(0x8), assert_transfer_list_entry_size); void transfer_list_dump(struct transfer_list_header *tl); +struct transfer_list_header *transfer_list_ensure(void *addr, size_t size); entry_point_info_t * transfer_list_set_handoff_args(struct transfer_list_header *tl, entry_point_info_t *ep_info); diff --git a/lib/transfer_list/transfer_list.c b/lib/transfer_list/transfer_list.c index 8d82d259f..35dc418d5 100644 --- a/lib/transfer_list/transfer_list.c +++ b/lib/transfer_list/transfer_list.c @@ -521,3 +521,22 @@ void *transfer_list_entry_data(struct transfer_list_entry *entry) } return (uint8_t *)entry + entry->hdr_size; } + +/******************************************************************************* + * Verifies that the transfer list has not already been initialized, then + * initializes it at the specified memory location. + * + * Return pointer to the transfer list or NULL on error + * *****************************************************************************/ +struct transfer_list_header *transfer_list_ensure(void *addr, size_t size) +{ + struct transfer_list_header *tl = NULL; + + if (transfer_list_check_header(addr) == TL_OPS_ALL) { + return (struct transfer_list_header *)addr; + } + + tl = transfer_list_init((void *)addr, size); + + return tl; +}