blob: 0da4b8634038b4671c15c7d56600e400d094189d [file] [log] [blame]
// Copyright 2022 Google LLC.
// Copyright lowRISC contributors.
// Licensed under the Apache License, Version 2.0, see LICENSE for details.
// SPDX-License-Identifier: Apache-2.0
#ifndef MATCHA_SW_DEVICE_LIB_DIF_DIF_TLUL_MAILBOX_H_
#define MATCHA_SW_DEVICE_LIB_DIF_DIF_TLUL_MAILBOX_H_
/**
* @file
* @brief <a href="/hw/ip/tlul_mailbox/doc/">tlul_mailbox for SC<->SMC communication</a> Device Interface Functions
*/
#include <stdint.h>
#include "sw/device/lib/dif/autogen/dif_tlul_mailbox_autogen.h"
#ifdef __cplusplus
extern "C" {
#endif // __cplusplus
dif_result_t dif_tlul_mailbox_send_message(const dif_tlul_mailbox_t *tlul_mailbox, uint32_t *buf);
dif_result_t dif_tlul_mailbox_read_message(const dif_tlul_mailbox_t *tlul_mailbox, uint32_t *buf);
/**
* Runtime configuration for tlul_mailbox for SC<->SMC communication.
*
* This struct describes (SOFTWARE) runtime information for one-time
* configuration of the hardware.
*/
typedef struct dif_tlul_mailbox_config {
} dif_tlul_mailbox_config_t;
/**
* Parameters for a tlul_mailbox for SC<->SMC communication transaction.
*/
typedef struct dif_tlul_mailbox_transaction {
// Your fields here.
} dif_tlul_mailbox_transaction_t;
/**
* An output location for a tlul_mailbox for SC<->SMC communication transaction.
*/
typedef struct dif_tlul_mailbox_output {
// Your fields here.
} dif_tlul_mailbox_output_t;
/**
* Configures tlul_mailbox for SC<->SMC communication with runtime information.
*
* This function should only need to be called once for the lifetime of
* `handle`.
*
* @param tlul_mailbox A tlul_mailbox for SC<->SMC communication handle.
* @param config Runtime configuration parameters.
* @return The result of the operation.
*/
OT_WARN_UNUSED_RESULT
dif_result_t dif_tlul_mailbox_configure(
const dif_tlul_mailbox_t *tlul_mailbox);
/**
* Begins a tlul_mailbox for SC<->SMC communication transaction.
*
* Each call to this function should be sequenced with a call to
* `dif_tlul_mailbox_end()`.
*
* @param tlul_mailbox A tlul_mailbox for SC<->SMC communication handle.
* @param transaction Transaction configuration parameters.
* @return The result of the operation.
*/
OT_WARN_UNUSED_RESULT
dif_result_t dif_tlul_mailbox_start(
const dif_tlul_mailbox_t *tlul_mailbox,
dif_tlul_mailbox_transaction_t transaction);
/** Ends a tlul_mailbox for SC<->SMC communication transaction, writing the results to the given output.
*
* @param tlul_mailbox A tlul_mailbox for SC<->SMC communication handle.
* @param output Transaction output parameters.
* @return The result of the operation.
*/
OT_WARN_UNUSED_RESULT
dif_result_t dif_tlul_mailbox_end(
const dif_tlul_mailbox_t *tlul_mailbox,
dif_tlul_mailbox_output_t output);
/**
* Locks out tlul_mailbox for SC<->SMC communication functionality.
*
* This function is reentrant: calling it while functionality is locked will
* have no effect and return `kDifOk`.
*
* @param tlul_mailbox A tlul_mailbox for SC<->SMC communication handle.
* @return The result of the operation.
*/
OT_WARN_UNUSED_RESULT
dif_result_t dif_tlul_mailbox_lock(
const dif_tlul_mailbox_t *tlul_mailbox);
/**
* Checks whether this tlul_mailbox for SC<->SMC communication is locked.
*
* @param tlul_mailbox A tlul_mailbox for SC<->SMC communication handle.
* @param[out] is_locked Out-param for the locked state.
* @return The result of the operation.
*/
OT_WARN_UNUSED_RESULT
dif_result_t dif_tlul_mailbox_is_locked(
const dif_tlul_mailbox_t *tlul_mailbox,
bool *is_locked);
#ifdef __cplusplus
} // extern "C"
#endif // __cplusplus
#endif // MATCHA_SW_DEVICE_LIB_DIF_DIF_TLUL_MAILBOX_H_