Software APIs
dt_kmac.h File Reference

Device Tables (DT) for IP kmac and top earlgrey. More...

#include "dt_api.h"
#include <stdint.h>

Go to the source code of this file.

Macros

#define OPENTITAN_KMAC_HAS_MODE_SHA3   1
 List of supported hardware features.
 
#define OPENTITAN_KMAC_HAS_MODE_SHAKE   1
 
#define OPENTITAN_KMAC_HAS_MODE_CSHAKE   1
 
#define OPENTITAN_KMAC_HAS_MODE_KMAC   1
 
#define OPENTITAN_KMAC_HAS_MODE_XOF   1
 
#define OPENTITAN_KMAC_HAS_ENDIANNESS_MESSAGE   1
 
#define OPENTITAN_KMAC_HAS_ENDIANNESS_DIGEST   1
 
#define OPENTITAN_KMAC_HAS_KEY_SIDELOAD   1
 
#define OPENTITAN_KMAC_HAS_ENTROPY_MODES   1
 

Typedefs

typedef enum dt_kmac dt_kmac_t
 List of instances.
 
typedef enum dt_kmac_reg_block dt_kmac_reg_block_t
 List of register blocks.
 
typedef enum dt_kmac_irq dt_kmac_irq_t
 List of IRQs.
 
typedef enum dt_kmac_alert dt_kmac_alert_t
 List of Alerts.
 
typedef enum dt_kmac_clock dt_kmac_clock_t
 List of clock ports.
 
typedef enum dt_kmac_reset dt_kmac_reset_t
 List of reset ports.
 

Enumerations

enum  dt_kmac {
  kDtKmac = 0 ,
  kDtKmacFirst = 0 ,
  kDtKmacCount = 1
}
 List of instances. More...
 
enum  dt_kmac_reg_block {
  kDtKmacRegBlockCore = 0 ,
  kDtKmacRegBlockCount = 1
}
 List of register blocks. More...
 
enum  dt_kmac_irq {
  kDtKmacIrqKmacDone = 0 ,
  kDtKmacIrqFifoEmpty = 1 ,
  kDtKmacIrqKmacErr = 2 ,
  kDtKmacIrqCount = 3
}
 List of IRQs. More...
 
enum  dt_kmac_alert {
  kDtKmacAlertRecovOperationErr = 0 ,
  kDtKmacAlertFatalFaultErr = 1 ,
  kDtKmacAlertCount = 2
}
 List of Alerts. More...
 
enum  dt_kmac_clock {
  kDtKmacClockClk = 0 ,
  kDtKmacClockEdn = 1 ,
  kDtKmacClockCount = 2
}
 List of clock ports. More...
 
enum  dt_kmac_reset {
  kDtKmacResetRst = 0 ,
  kDtKmacResetEdn = 1 ,
  kDtKmacResetCount = 2
}
 List of reset ports. More...
 

Functions

dt_kmac_t dt_kmac_from_instance_id (dt_instance_id_t inst_id)
 Get the kmac instance from an instance ID.
 
dt_instance_id_t dt_kmac_instance_id (dt_kmac_t dt)
 Get the instance ID of an instance.
 
uint32_t dt_kmac_reg_block (dt_kmac_t dt, dt_kmac_reg_block_t reg_block)
 Get the register base address of an instance.
 
dt_plic_irq_id_t dt_kmac_irq_to_plic_id (dt_kmac_t dt, dt_kmac_irq_t irq)
 Get the PLIC ID of a kmac IRQ for a given instance.
 
dt_kmac_irq_t dt_kmac_irq_from_plic_id (dt_kmac_t dt, dt_plic_irq_id_t irq)
 Convert a global IRQ ID to a local kmac IRQ type.
 
dt_alert_id_t dt_kmac_alert_to_alert_id (dt_kmac_t dt, dt_kmac_alert_t alert)
 Get the alert ID of a kmac alert for a given instance.
 
dt_kmac_alert_t dt_kmac_alert_from_alert_id (dt_kmac_t dt, dt_alert_id_t alert)
 Convert a global alert ID to a local kmac alert type.
 
dt_clock_t dt_kmac_clock (dt_kmac_t dt, dt_kmac_clock_t clk)
 Get the clock signal connected to a clock port of an instance.
 
dt_reset_t dt_kmac_reset (dt_kmac_t dt, dt_kmac_reset_t rst)
 Get the reset signal connected to a reset port of an instance.
 

Detailed Description

Device Tables (DT) for IP kmac and top earlgrey.

This file contains the type definitions and global functions of the kmac.

Definition in file dt_kmac.h.

Macro Definition Documentation

◆ OPENTITAN_KMAC_HAS_ENDIANNESS_DIGEST

#define OPENTITAN_KMAC_HAS_ENDIANNESS_DIGEST   1

Definition at line 109 of file dt_kmac.h.

◆ OPENTITAN_KMAC_HAS_ENDIANNESS_MESSAGE

#define OPENTITAN_KMAC_HAS_ENDIANNESS_MESSAGE   1

Definition at line 108 of file dt_kmac.h.

◆ OPENTITAN_KMAC_HAS_ENTROPY_MODES

#define OPENTITAN_KMAC_HAS_ENTROPY_MODES   1

Definition at line 111 of file dt_kmac.h.

◆ OPENTITAN_KMAC_HAS_KEY_SIDELOAD

#define OPENTITAN_KMAC_HAS_KEY_SIDELOAD   1

Definition at line 110 of file dt_kmac.h.

◆ OPENTITAN_KMAC_HAS_MODE_CSHAKE

#define OPENTITAN_KMAC_HAS_MODE_CSHAKE   1

Definition at line 105 of file dt_kmac.h.

◆ OPENTITAN_KMAC_HAS_MODE_KMAC

#define OPENTITAN_KMAC_HAS_MODE_KMAC   1

Definition at line 106 of file dt_kmac.h.

◆ OPENTITAN_KMAC_HAS_MODE_SHA3

#define OPENTITAN_KMAC_HAS_MODE_SHA3   1

List of supported hardware features.

Definition at line 103 of file dt_kmac.h.

◆ OPENTITAN_KMAC_HAS_MODE_SHAKE

#define OPENTITAN_KMAC_HAS_MODE_SHAKE   1

Definition at line 104 of file dt_kmac.h.

◆ OPENTITAN_KMAC_HAS_MODE_XOF

#define OPENTITAN_KMAC_HAS_MODE_XOF   1

Definition at line 107 of file dt_kmac.h.

Typedef Documentation

◆ dt_kmac_alert_t

List of Alerts.

Alerts are guaranteed to be numbered consecutively from 0.

◆ dt_kmac_clock_t

List of clock ports.

Clock ports are guaranteed to be numbered consecutively from 0.

◆ dt_kmac_irq_t

typedef enum dt_kmac_irq dt_kmac_irq_t

List of IRQs.

IRQs are guaranteed to be numbered consecutively from 0.

◆ dt_kmac_reg_block_t

List of register blocks.

Register blocks are guaranteed to start at 0 and to be consecutively numbered.

◆ dt_kmac_reset_t

List of reset ports.

Reset ports are guaranteed to be numbered consecutively from 0.

Enumeration Type Documentation

◆ dt_kmac

enum dt_kmac

List of instances.

Enumerator
kDtKmac 

kmac

Definition at line 23 of file dt_kmac.h.

◆ dt_kmac_alert

List of Alerts.

Alerts are guaranteed to be numbered consecutively from 0.

Enumerator
kDtKmacAlertRecovOperationErr 

Alert for KMAC operation error.

It occurs when the shadow registers have update errors.

kDtKmacAlertFatalFaultErr 

This fatal alert is triggered when a fatal error is detected inside the KMAC unit.

Examples for such faults include: i) TL-UL bus integrity fault. ii) Storage errors in the shadow registers. iii) Errors in the message, round, or key counter. iv) Any internal FSM entering an invalid state. v) An error in the redundant lfsr. The KMAC unit cannot recover from such an error and needs to be reset.

Definition at line 65 of file dt_kmac.h.

◆ dt_kmac_clock

List of clock ports.

Clock ports are guaranteed to be numbered consecutively from 0.

Enumerator
kDtKmacClockClk 

Clock port clk_i.

kDtKmacClockEdn 

Clock port clk_edn_i.

Definition at line 83 of file dt_kmac.h.

◆ dt_kmac_irq

List of IRQs.

IRQs are guaranteed to be numbered consecutively from 0.

Enumerator
kDtKmacIrqKmacDone 

KMAC/SHA3 absorbing has been completed.

kDtKmacIrqFifoEmpty 

The message FIFO is empty.

This interrupt is raised only if the message FIFO is actually writable by software, i.e., if all of the following conditions are met: i) The KMAC block is not exercised by a hardware application interface. ii) The SHA3 block is in the Absorb state. iii) Software has not yet written the Process command to finish the absorption process. For the interrupt to be raised, the message FIFO must also have been full previously. Otherwise, the hardware empties the FIFO faster than software can fill it and there is no point in interrupting the software to inform it about the message FIFO being empty.

kDtKmacIrqKmacErr 

KMAC/SHA3 error occurred.

ERR_CODE register shows the details

Definition at line 47 of file dt_kmac.h.

◆ dt_kmac_reg_block

List of register blocks.

Register blocks are guaranteed to start at 0 and to be consecutively numbered.

Definition at line 34 of file dt_kmac.h.

◆ dt_kmac_reset

List of reset ports.

Reset ports are guaranteed to be numbered consecutively from 0.

Enumerator
kDtKmacResetRst 

Reset port rst_ni.

kDtKmacResetEdn 

Reset port rst_edn_ni.

Definition at line 94 of file dt_kmac.h.

Function Documentation

◆ dt_kmac_alert_from_alert_id()

dt_kmac_alert_t dt_kmac_alert_from_alert_id ( dt_kmac_t dt,
dt_alert_id_t alert )

Convert a global alert ID to a local kmac alert type.

Parameters
dtInstance of kmac.
alertA global alert ID that belongs to this instance.
Returns
The kmac alert, or kDtKmacAlertCount.

Note: This function assumes that the global alert ID belongs to the instance of kmac passed in parameter. In other words, it must be the case that dt_kmac_instance_id(dt) == dt_alert_id_to_instance_id(alert). Otherwise, this function will return kDtKmacAlertCount.

Definition at line 117 of file dt_kmac.c.

◆ dt_kmac_alert_to_alert_id()

dt_alert_id_t dt_kmac_alert_to_alert_id ( dt_kmac_t dt,
dt_kmac_alert_t alert )

Get the alert ID of a kmac alert for a given instance.

Note: This function only makes sense if the instance is connected to the Alert Handler. For any instances where the instance is not connected, the return value is unspecified.

Parameters
dtInstance of kmac.
alertA kmac alert.
Returns
The Alert Handler alert ID of the alert of this instance.

Definition at line 111 of file dt_kmac.c.

◆ dt_kmac_clock()

Get the clock signal connected to a clock port of an instance.

Parameters
dtInstance of kmac.
clkClock port.
Returns
Clock signal.

Definition at line 129 of file dt_kmac.c.

◆ dt_kmac_from_instance_id()

dt_kmac_t dt_kmac_from_instance_id ( dt_instance_id_t inst_id)

Get the kmac instance from an instance ID.

For example, dt_uart_from_instance_id(kDtInstanceIdUart3) == kDtUart3.

Parameters
inst_idInstance ID.
Returns
A kmac instance.

Note: This function only makes sense if the instance ID has device type kmac, otherwise the returned value is unspecified.

Definition at line 67 of file dt_kmac.c.

◆ dt_kmac_instance_id()

dt_instance_id_t dt_kmac_instance_id ( dt_kmac_t dt)

Get the instance ID of an instance.

Parameters
dtInstance of kmac.
Returns
The instance ID of that instance.

Definition at line 74 of file dt_kmac.c.

◆ dt_kmac_irq_from_plic_id()

dt_kmac_irq_t dt_kmac_irq_from_plic_id ( dt_kmac_t dt,
dt_plic_irq_id_t irq )

Convert a global IRQ ID to a local kmac IRQ type.

Parameters
dtInstance of kmac.
irqA PLIC ID that belongs to this instance.
Returns
The kmac IRQ, or kDtKmacIrqCount.

Note: This function assumes that the PLIC ID belongs to the instance of kmac passed in parameter. In other words, it must be the case that dt_kmac_instance_id(dt) == dt_plic_id_to_instance_id(irq). Otherwise, this function will return kDtKmacIrqCount.

Definition at line 96 of file dt_kmac.c.

◆ dt_kmac_irq_to_plic_id()

dt_plic_irq_id_t dt_kmac_irq_to_plic_id ( dt_kmac_t dt,
dt_kmac_irq_t irq )

Get the PLIC ID of a kmac IRQ for a given instance.

If the instance is not connected to the PLIC, this function will return kDtPlicIrqIdNone.

Parameters
dtInstance of kmac.
irqA kmac IRQ.
Returns
The PLIC ID of the IRQ of this instance.

Definition at line 86 of file dt_kmac.c.

◆ dt_kmac_reg_block()

uint32_t dt_kmac_reg_block ( dt_kmac_t dt,
dt_kmac_reg_block_t reg_block )

Get the register base address of an instance.

Parameters
dtInstance of kmac.
reg_blockThe register block requested.
Returns
The register base address of the requested block.

Definition at line 79 of file dt_kmac.c.

◆ dt_kmac_reset()

Get the reset signal connected to a reset port of an instance.

Parameters
dtInstance of kmac.
rstReset port.
Returns
Reset signal.

Definition at line 136 of file dt_kmac.c.