|  | /* | 
|  | * Copyright 2023 Google LLC | 
|  | * Copyright lowRISC contributors | 
|  | * | 
|  | * Licensed under the Apache License, Version 2.0 (the "License"); | 
|  | * you may not use this file except in compliance with the License. | 
|  | * You may obtain a copy of the License at | 
|  | * | 
|  | *      http://www.apache.org/licenses/LICENSE-2.0 | 
|  | * | 
|  | * Unless required by applicable law or agreed to in writing, software | 
|  | * distributed under the License is distributed on an "AS IS" BASIS, | 
|  | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 
|  | * See the License for the specific language governing permissions and | 
|  | * limitations under the License. | 
|  | */ | 
|  |  | 
|  |  | 
|  | #ifndef OPENTITAN_SW_DEVICE_LIB_DIF_AUTOGEN_DIF_TLUL_MAILBOX_AUTOGEN_H_ | 
|  | #define OPENTITAN_SW_DEVICE_LIB_DIF_AUTOGEN_DIF_TLUL_MAILBOX_AUTOGEN_H_ | 
|  |  | 
|  | // THIS FILE HAS BEEN GENERATED, DO NOT EDIT MANUALLY. COMMAND: | 
|  | // util/make_new_dif.py --mode=regen --only=autogen | 
|  |  | 
|  | /** | 
|  | * @file | 
|  | * @brief <a href="/hw/ip/tlul_mailbox/doc/">TLUL_MAILBOX</a> Device Interface | 
|  | * Functions | 
|  | */ | 
|  |  | 
|  | #include <stdbool.h> | 
|  | #include <stdint.h> | 
|  |  | 
|  | #include "sw/device/lib/base/macros.h" | 
|  | #include "sw/device/lib/base/mmio.h" | 
|  | #include "sw/device/lib/dif/dif_base.h" | 
|  |  | 
|  | #ifdef __cplusplus | 
|  | extern "C" { | 
|  | #endif // __cplusplus | 
|  |  | 
|  | /** | 
|  | * A handle to tlul_mailbox. | 
|  | * | 
|  | * This type should be treated as opaque by users. | 
|  | */ | 
|  | typedef struct dif_tlul_mailbox { | 
|  | /** | 
|  | * The base address for the tlul_mailbox hardware registers. | 
|  | */ | 
|  | mmio_region_t base_addr; | 
|  | } dif_tlul_mailbox_t; | 
|  |  | 
|  | /** | 
|  | * Creates a new handle for a(n) tlul_mailbox peripheral. | 
|  | * | 
|  | * This function does not actuate the hardware. | 
|  | * | 
|  | * @param base_addr The MMIO base address of the tlul_mailbox peripheral. | 
|  | * @param[out] tlul_mailbox Out param for the initialized handle. | 
|  | * @return The result of the operation. | 
|  | */ | 
|  | OT_WARN_UNUSED_RESULT | 
|  | dif_result_t dif_tlul_mailbox_init(mmio_region_t base_addr, | 
|  | dif_tlul_mailbox_t *tlul_mailbox); | 
|  |  | 
|  | /** | 
|  | * A tlul_mailbox interrupt request type. | 
|  | */ | 
|  | typedef enum dif_tlul_mailbox_irq { | 
|  | /** | 
|  | * Raised if the write fifo threshold exceed threshold. | 
|  | */ | 
|  | kDifTlulMailboxIrqWtirq = 0, | 
|  | /** | 
|  | * Raised if the read fifo threshold exceed threshold. | 
|  | */ | 
|  | kDifTlulMailboxIrqRtirq = 1, | 
|  | /** | 
|  | * Raised if error on tlul_mailbox access. | 
|  | */ | 
|  | kDifTlulMailboxIrqEirq = 2, | 
|  | } dif_tlul_mailbox_irq_t; | 
|  |  | 
|  | /** | 
|  | * A snapshot of the state of the interrupts for this IP. | 
|  | * | 
|  | * This is an opaque type, to be used with the | 
|  | * `dif_tlul_mailbox_irq_get_state()` and | 
|  | * `dif_tlul_mailbox_irq_acknowledge_state()` functions. | 
|  | */ | 
|  | typedef uint32_t dif_tlul_mailbox_irq_state_snapshot_t; | 
|  |  | 
|  | /** | 
|  | * Returns the type of a given interrupt (i.e., event or status) for this IP. | 
|  | * | 
|  | * @param tlul_mailbox A tlul_mailbox handle. | 
|  | * @param irq An interrupt request. | 
|  | * @param[out] type Out-param for the interrupt type. | 
|  | * @return The result of the operation. | 
|  | */ | 
|  | OT_WARN_UNUSED_RESULT | 
|  | dif_result_t | 
|  | dif_tlul_mailbox_irq_get_type(const dif_tlul_mailbox_t *tlul_mailbox, | 
|  | dif_tlul_mailbox_irq_t irq, dif_irq_type_t *type); | 
|  |  | 
|  | /** | 
|  | * Returns the state of all interrupts (i.e., pending or not) for this IP. | 
|  | * | 
|  | * @param tlul_mailbox A tlul_mailbox handle. | 
|  | * @param[out] snapshot Out-param for interrupt state snapshot. | 
|  | * @return The result of the operation. | 
|  | */ | 
|  | OT_WARN_UNUSED_RESULT | 
|  | dif_result_t | 
|  | dif_tlul_mailbox_irq_get_state(const dif_tlul_mailbox_t *tlul_mailbox, | 
|  | dif_tlul_mailbox_irq_state_snapshot_t *snapshot); | 
|  |  | 
|  | /** | 
|  | * Returns whether a particular interrupt is currently pending. | 
|  | * | 
|  | * @param tlul_mailbox A tlul_mailbox handle. | 
|  | * @param irq An interrupt request. | 
|  | * @param[out] is_pending Out-param for whether the interrupt is pending. | 
|  | * @return The result of the operation. | 
|  | */ | 
|  | OT_WARN_UNUSED_RESULT | 
|  | dif_result_t | 
|  | dif_tlul_mailbox_irq_is_pending(const dif_tlul_mailbox_t *tlul_mailbox, | 
|  | dif_tlul_mailbox_irq_t irq, bool *is_pending); | 
|  |  | 
|  | /** | 
|  | * Acknowledges all interrupts that were pending at the time of the state | 
|  | * snapshot. | 
|  | * | 
|  | * @param tlul_mailbox A tlul_mailbox handle. | 
|  | * @param snapshot Interrupt state snapshot. | 
|  | * @return The result of the operation. | 
|  | */ | 
|  | OT_WARN_UNUSED_RESULT | 
|  | dif_result_t dif_tlul_mailbox_irq_acknowledge_state( | 
|  | const dif_tlul_mailbox_t *tlul_mailbox, | 
|  | dif_tlul_mailbox_irq_state_snapshot_t snapshot); | 
|  |  | 
|  | /** | 
|  | * Acknowledges all interrupts, indicating to the hardware that all | 
|  | * interrupts have been successfully serviced. | 
|  | * | 
|  | * @param tlul_mailbox A tlul_mailbox handle. | 
|  | * @return The result of the operation. | 
|  | */ | 
|  | OT_WARN_UNUSED_RESULT | 
|  | dif_result_t | 
|  | dif_tlul_mailbox_irq_acknowledge_all(const dif_tlul_mailbox_t *tlul_mailbox); | 
|  |  | 
|  | /** | 
|  | * Acknowledges a particular interrupt, indicating to the hardware that it has | 
|  | * been successfully serviced. | 
|  | * | 
|  | * @param tlul_mailbox A tlul_mailbox handle. | 
|  | * @param irq An interrupt request. | 
|  | * @return The result of the operation. | 
|  | */ | 
|  | OT_WARN_UNUSED_RESULT | 
|  | dif_result_t | 
|  | dif_tlul_mailbox_irq_acknowledge(const dif_tlul_mailbox_t *tlul_mailbox, | 
|  | dif_tlul_mailbox_irq_t irq); | 
|  |  | 
|  | /** | 
|  | * Forces a particular interrupt, causing it to be serviced as if hardware had | 
|  | * asserted it. | 
|  | * | 
|  | * @param tlul_mailbox A tlul_mailbox handle. | 
|  | * @param irq An interrupt request. | 
|  | * @param val Value to be set. | 
|  | * @return The result of the operation. | 
|  | */ | 
|  | OT_WARN_UNUSED_RESULT | 
|  | dif_result_t dif_tlul_mailbox_irq_force(const dif_tlul_mailbox_t *tlul_mailbox, | 
|  | dif_tlul_mailbox_irq_t irq, | 
|  | const bool val); | 
|  |  | 
|  | /** | 
|  | * A snapshot of the enablement state of the interrupts for this IP. | 
|  | * | 
|  | * This is an opaque type, to be used with the | 
|  | * `dif_tlul_mailbox_irq_disable_all()` and `dif_tlul_mailbox_irq_restore_all()` | 
|  | * functions. | 
|  | */ | 
|  | typedef uint32_t dif_tlul_mailbox_irq_enable_snapshot_t; | 
|  |  | 
|  | /** | 
|  | * Checks whether a particular interrupt is currently enabled or disabled. | 
|  | * | 
|  | * @param tlul_mailbox A tlul_mailbox handle. | 
|  | * @param irq An interrupt request. | 
|  | * @param[out] state Out-param toggle state of the interrupt. | 
|  | * @return The result of the operation. | 
|  | */ | 
|  | OT_WARN_UNUSED_RESULT | 
|  | dif_result_t | 
|  | dif_tlul_mailbox_irq_get_enabled(const dif_tlul_mailbox_t *tlul_mailbox, | 
|  | dif_tlul_mailbox_irq_t irq, | 
|  | dif_toggle_t *state); | 
|  |  | 
|  | /** | 
|  | * Sets whether a particular interrupt is currently enabled or disabled. | 
|  | * | 
|  | * @param tlul_mailbox A tlul_mailbox handle. | 
|  | * @param irq An interrupt request. | 
|  | * @param state The new toggle state for the interrupt. | 
|  | * @return The result of the operation. | 
|  | */ | 
|  | OT_WARN_UNUSED_RESULT | 
|  | dif_result_t | 
|  | dif_tlul_mailbox_irq_set_enabled(const dif_tlul_mailbox_t *tlul_mailbox, | 
|  | dif_tlul_mailbox_irq_t irq, | 
|  | dif_toggle_t state); | 
|  |  | 
|  | /** | 
|  | * Disables all interrupts, optionally snapshotting all enable states for later | 
|  | * restoration. | 
|  | * | 
|  | * @param tlul_mailbox A tlul_mailbox handle. | 
|  | * @param[out] snapshot Out-param for the snapshot; may be `NULL`. | 
|  | * @return The result of the operation. | 
|  | */ | 
|  | OT_WARN_UNUSED_RESULT | 
|  | dif_result_t dif_tlul_mailbox_irq_disable_all( | 
|  | const dif_tlul_mailbox_t *tlul_mailbox, | 
|  | dif_tlul_mailbox_irq_enable_snapshot_t *snapshot); | 
|  |  | 
|  | /** | 
|  | * Restores interrupts from the given (enable) snapshot. | 
|  | * | 
|  | * @param tlul_mailbox A tlul_mailbox handle. | 
|  | * @param snapshot A snapshot to restore from. | 
|  | * @return The result of the operation. | 
|  | */ | 
|  | OT_WARN_UNUSED_RESULT | 
|  | dif_result_t dif_tlul_mailbox_irq_restore_all( | 
|  | const dif_tlul_mailbox_t *tlul_mailbox, | 
|  | const dif_tlul_mailbox_irq_enable_snapshot_t *snapshot); | 
|  |  | 
|  | #ifdef __cplusplus | 
|  | } // extern "C" | 
|  | #endif // __cplusplus | 
|  |  | 
|  | #endif // OPENTITAN_SW_DEVICE_LIB_DIF_AUTOGEN_DIF_TLUL_MAILBOX_AUTOGEN_H_ |