Harrison Mutai | b674809 | 2025-04-25 16:03:03 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2025, Arm Limited. All rights reserved. |
| 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | */ |
| 6 | |
| 7 | |
| 8 | #ifndef HANDOFF_H |
| 9 | #define HANDOFF_H |
| 10 | |
| 11 | #include <stdint.h> |
| 12 | |
Harrison Mutai | 68ecce1 | 2025-05-12 12:38:24 +0000 | [diff] [blame^] | 13 | #include <transfer_list.h> |
Harrison Mutai | b674809 | 2025-04-25 16:03:03 +0000 | [diff] [blame] | 14 | |
| 15 | /** |
| 16 | * Initializes or extends the TPM event log in the transfer list. |
| 17 | * |
| 18 | * If an event log entry exists, attempts to resize it. Otherwise, adds a new entry. |
| 19 | * Copies old data if needed. Updates free to reflect available space. |
| 20 | * |
| 21 | * @param tl Pointer to the transfer list header. |
| 22 | * @param req_size Requested size (bytes) |
| 23 | * @param free Available size (bytes) |
| 24 | * @return Pointer to writable space in the log, or NULL on failure. |
| 25 | */ |
| 26 | uint8_t *transfer_list_event_log_extend(struct transfer_list_header *tl, |
| 27 | size_t req_size, size_t *free); |
| 28 | |
| 29 | /** |
| 30 | * Finalizes the event log after writing is complete. |
| 31 | * |
| 32 | * Resizes the event log to match actual data written, updates checksum, |
| 33 | * and flushes cache for the next stage. |
| 34 | * |
| 35 | * @param tl Pointer to the transfer list header. |
| 36 | * @param cursor End offset of written log data. |
| 37 | * @return Pointer to finalized log data (past reserved bytes), or NULL. |
| 38 | */ |
| 39 | uint8_t *transfer_list_event_log_finish(struct transfer_list_header *tl, |
| 40 | uintptr_t cursor); |
| 41 | |
| 42 | #define EVENT_LOG_RESERVED_BYTES U(4) |
| 43 | |
| 44 | #endif /* HANDOFF_H */ |