Pavona Software APIs
dif_acc.h File Reference

ACC Device Interface Functions. More...

#include <stddef.h>
#include <stdint.h>
#include "sw/device/lib/base/mmio.h"
#include "sw/device/lib/dif/dif_base.h"
#include "sw/device/lib/dif/autogen/dif_acc_autogen.h"

Go to the source code of this file.

Typedefs

typedef enum dif_acc_cmd dif_acc_cmd_t
 ACC commands.
 
typedef enum dif_acc_status dif_acc_status_t
 ACC status.
 
typedef enum dif_acc_err_bits dif_acc_err_bits_t
 ACC Errors.
 

Enumerations

enum  dif_acc_cmd {
  kDifAccCmdExecute = 0xd8 ,
  kDifAccCmdSecWipeDmem = 0xc3 ,
  kDifAccCmdSecWipeImem = 0x1e
}
 ACC commands. More...
 
enum  dif_acc_status {
  kDifAccStatusIdle = 0x00 ,
  kDifAccStatusBusyExecute = 0x01 ,
  kDifAccStatusBusySecWipeDmem = 0x02 ,
  kDifAccStatusBusySecWipeImem = 0x03 ,
  kDifAccStatusBusySecWipeInt = 0x04 ,
  kDifAccStatusLocked = 0xFF
}
 ACC status. More...
 
enum  dif_acc_err_bits {
  kDifAccErrBitsNoError = 0 ,
  kDifAccErrBitsBadDataAddr = (1 << 0) ,
  kDifAccErrBitsBadInsnAddr = (1 << 1) ,
  kDifAccErrBitsCallStack = (1 << 2) ,
  kDifAccErrBitsIllegalInsn = (1 << 3) ,
  kDifAccErrBitsLoop = (1 << 4) ,
  kDifAccErrBitsRndFipsChkFail = (1 << 7) ,
  kDifAccErrBitsImemIntgViolation = (1 << 16) ,
  kDifAccErrBitsDmemIntgViolation = (1 << 17) ,
  kDifAccErrBitsRegIntgViolation = (1 << 18) ,
  kDifAccErrBitsBusIntgViolation = (1 << 19) ,
  kDifAccErrBitsBadInternalState = (1 << 20) ,
  kDifAccErrBitsIllegalBusAccess = (1 << 21) ,
  kDifAccErrBitsLifecycleEscalation = (1 << 22) ,
  kDifAccErrBitsFatalSoftware = (1 << 23)
}
 ACC Errors. More...
 

Functions

OT_WARN_UNUSED_RESULT dif_result_t dif_acc_reset (const dif_acc_t *acc)
 Reset ACC device.
 
OT_WARN_UNUSED_RESULT dif_result_t dif_acc_write_cmd (const dif_acc_t *acc, dif_acc_cmd_t cmd)
 Start an operation by issuing a command.
 
OT_WARN_UNUSED_RESULT dif_result_t dif_acc_get_status (const dif_acc_t *acc, dif_acc_status_t *status)
 Gets the current status of ACC.
 
OT_WARN_UNUSED_RESULT dif_result_t dif_acc_get_err_bits (const dif_acc_t *acc, dif_acc_err_bits_t *err_bits)
 Get the error bits set by the device if the operation failed.
 
OT_WARN_UNUSED_RESULT dif_result_t dif_acc_get_insn_cnt (const dif_acc_t *acc, uint32_t *insn_cnt)
 Gets the number of executed ACC instructions.
 
OT_WARN_UNUSED_RESULT dif_result_t dif_acc_get_load_checksum (const dif_acc_t *acc, uint32_t *insn_cnt)
 Gets the content of the load checksum register.
 
OT_WARN_UNUSED_RESULT dif_result_t dif_acc_clear_load_checksum (const dif_acc_t *acc)
 Clears the load checksum register.
 
OT_WARN_UNUSED_RESULT dif_result_t dif_acc_imem_write (const dif_acc_t *acc, uint32_t offset_bytes, const void *src, size_t len_bytes)
 Write an ACC application into its instruction memory (IMEM).
 
OT_WARN_UNUSED_RESULT dif_result_t dif_acc_imem_read (const dif_acc_t *acc, uint32_t offset_bytes, void *dest, size_t len_bytes)
 Read from ACC's instruction memory (IMEM).
 
OT_WARN_UNUSED_RESULT dif_result_t dif_acc_dmem_write (const dif_acc_t *acc, uint32_t offset_bytes, const void *src, size_t len_bytes)
 Write to ACC's data memory (DMEM).
 
OT_WARN_UNUSED_RESULT dif_result_t dif_acc_dmem_read (const dif_acc_t *acc, uint32_t offset_bytes, void *dest, size_t len_bytes)
 Read from ACC's data memory (DMEM).
 
OT_WARN_UNUSED_RESULT dif_result_t dif_acc_set_ctrl_software_errs_fatal (const dif_acc_t *acc, bool enable)
 Sets the software errors are fatal bit in the control register.
 
size_t dif_acc_get_dmem_size_bytes (const dif_acc_t *acc)
 Get the size of ACC's data memory in bytes.
 
size_t dif_acc_get_imem_size_bytes (const dif_acc_t *acc)
 Get the size of ACC's instruction memory in bytes.
 

Detailed Description

ACC Device Interface Functions.

Definition in file dif_acc.h.

Typedef Documentation

◆ dif_acc_err_bits_t

ACC Errors.

ACC uses a bitfield to indicate which errors have been seen. Multiple errors can be seen at the same time. This enum gives the individual bits that may be set for different errors.

Enumeration Type Documentation

◆ dif_acc_cmd

ACC commands.

Definition at line 28 of file dif_acc.h.

◆ dif_acc_err_bits

ACC Errors.

ACC uses a bitfield to indicate which errors have been seen. Multiple errors can be seen at the same time. This enum gives the individual bits that may be set for different errors.

Enumerator
kDifAccErrBitsBadDataAddr 

A BAD_DATA_ADDR error was observed.

kDifAccErrBitsBadInsnAddr 

A BAD_INSN_ADDR error was observed.

kDifAccErrBitsCallStack 

A CALL_STACK error was observed.

kDifAccErrBitsIllegalInsn 

An ILLEGAL_INSN error was observed.

kDifAccErrBitsLoop 

A LOOP error was observed.

kDifAccErrBitsRndFipsChkFail 

A RND_FIPS_CHECK_FAIL error was observed.

kDifAccErrBitsImemIntgViolation 

A IMEM_INTG_VIOLATION error was observed.

kDifAccErrBitsDmemIntgViolation 

A DMEM_INTG_VIOLATION error was observed.

kDifAccErrBitsRegIntgViolation 

A REG_INTG_VIOLATION error was observed.

kDifAccErrBitsBusIntgViolation 

A BUS_INTG_VIOLATION error was observed.

kDifAccErrBitsBadInternalState 

A BAD_INTERNAL_STATE error was observed.

kDifAccErrBitsIllegalBusAccess 

An ILLEGAL_BUS_ACCESS error was observed.

kDifAccErrBitsLifecycleEscalation 

A LIFECYCLE_ESCALATION error was observed.

kDifAccErrBitsFatalSoftware 

A FATAL_SOFTWARE error was observed.

Definition at line 53 of file dif_acc.h.

◆ dif_acc_status

ACC status.

Definition at line 37 of file dif_acc.h.

Function Documentation

◆ dif_acc_clear_load_checksum()

OT_WARN_UNUSED_RESULT dif_result_t dif_acc_clear_load_checksum ( const dif_acc_t * acc)

Clears the load checksum register.

Writes 0 to the load checksum register to clear it.

Parameters
accACC instance.
Returns
The result of the operation.

Definition at line 135 of file dif_acc.c.

◆ dif_acc_dmem_read()

OT_WARN_UNUSED_RESULT dif_result_t dif_acc_dmem_read ( const dif_acc_t * acc,
uint32_t offset_bytes,
void * dest,
size_t len_bytes )

Read from ACC's data memory (DMEM).

Only 32b-aligned 32b word accesses are allowed.

Parameters
accACC instance
offset_bytesthe byte offset in DMEM the first word is read from.
[out]destthe main memory location to copy the data to (preallocated).
len_bytesnumber of bytes to copy.
Returns
The result of the operation.

Definition at line 184 of file dif_acc.c.

◆ dif_acc_dmem_write()

OT_WARN_UNUSED_RESULT dif_result_t dif_acc_dmem_write ( const dif_acc_t * acc,
uint32_t offset_bytes,
const void * src,
size_t len_bytes )

Write to ACC's data memory (DMEM).

Only 32b-aligned 32b word accesses are allowed.

Parameters
accACC instance.
offset_bytesthe byte offset in DMEM the first word is written to.
srcthe main memory location to start reading from.
len_bytesnumber of bytes to copy.
Returns
The result of the operation.

Definition at line 171 of file dif_acc.c.

◆ dif_acc_get_dmem_size_bytes()

size_t dif_acc_get_dmem_size_bytes ( const dif_acc_t * acc)

Get the size of ACC's data memory in bytes.

Parameters
accACC instance.
Returns
data memory size in bytes.

Definition at line 220 of file dif_acc.c.

◆ dif_acc_get_err_bits()

OT_WARN_UNUSED_RESULT dif_result_t dif_acc_get_err_bits ( const dif_acc_t * acc,
dif_acc_err_bits_t * err_bits )

Get the error bits set by the device if the operation failed.

Parameters
accACC instance.
[out]err_bitsThe error bits returned by the hardware.
Returns
The result of the operation.

Definition at line 103 of file dif_acc.c.

◆ dif_acc_get_imem_size_bytes()

size_t dif_acc_get_imem_size_bytes ( const dif_acc_t * acc)

Get the size of ACC's instruction memory in bytes.

Parameters
accACC instance.
Returns
instruction memory size in bytes.

Definition at line 224 of file dif_acc.c.

◆ dif_acc_get_insn_cnt()

OT_WARN_UNUSED_RESULT dif_result_t dif_acc_get_insn_cnt ( const dif_acc_t * acc,
uint32_t * insn_cnt )

Gets the number of executed ACC instructions.

Gets the number of instructions executed so far in the current ACC run if there is one. Otherwise, gets the number executed in total in the previous ACC run.

Parameters
accACC instance.
[out]insn_cntThe number of instructions executed by ACC.
Returns
The result of the operation.

Definition at line 116 of file dif_acc.c.

◆ dif_acc_get_load_checksum()

OT_WARN_UNUSED_RESULT dif_result_t dif_acc_get_load_checksum ( const dif_acc_t * acc,
uint32_t * insn_cnt )

Gets the content of the load checksum register.

Gets the 32-bit CRC checksum of data written to memory.

Parameters
accACC instance.
[out]insn_cntThe number of instructions executed by ACC.
Returns
The result of the operation.

Definition at line 125 of file dif_acc.c.

◆ dif_acc_get_status()

OT_WARN_UNUSED_RESULT dif_result_t dif_acc_get_status ( const dif_acc_t * acc,
dif_acc_status_t * status )

Gets the current status of ACC.

Parameters
accACC instance.
[out]statusACC status.
Returns
The result of the operation.

Definition at line 92 of file dif_acc.c.

◆ dif_acc_imem_read()

OT_WARN_UNUSED_RESULT dif_result_t dif_acc_imem_read ( const dif_acc_t * acc,
uint32_t offset_bytes,
void * dest,
size_t len_bytes )

Read from ACC's instruction memory (IMEM).

Only 32b-aligned 32b word accesses are allowed.

Parameters
accACC instance
offset_bytesthe byte offset in IMEM the first word is read from.
[out]destthe main memory location to copy the data to (preallocated).
len_bytesnumber of bytes to copy.
Returns
The result of the operation.

Definition at line 158 of file dif_acc.c.

◆ dif_acc_imem_write()

OT_WARN_UNUSED_RESULT dif_result_t dif_acc_imem_write ( const dif_acc_t * acc,
uint32_t offset_bytes,
const void * src,
size_t len_bytes )

Write an ACC application into its instruction memory (IMEM).

Only 32b-aligned 32b word accesses are allowed.

Parameters
accACC instance.
offset_bytesthe byte offset in IMEM the first word is written to.
srcthe main memory location to start reading from.
len_bytesnumber of bytes to copy.
Returns
The result of the operation.

Definition at line 145 of file dif_acc.c.

◆ dif_acc_reset()

OT_WARN_UNUSED_RESULT dif_result_t dif_acc_reset ( const dif_acc_t * acc)

Reset ACC device.

Resets the given ACC device by setting its configuration registers to reset values. Disables interrupts, output, and input filter.

Parameters
accACC instance.
Returns
The result of the operation.

Definition at line 69 of file dif_acc.c.

◆ dif_acc_set_ctrl_software_errs_fatal()

OT_WARN_UNUSED_RESULT dif_result_t dif_acc_set_ctrl_software_errs_fatal ( const dif_acc_t * acc,
bool enable )

Sets the software errors are fatal bit in the control register.

When set any software error becomes a fatal error. The bit can only be changed when the ACC status is IDLE.

Parameters
accACC instance.
enableEnable or disable whether software errors are fatal.
Returns
The result of the operation, kDifUnavailable is returned when the requested change cannot be made.

Definition at line 197 of file dif_acc.c.

◆ dif_acc_write_cmd()

OT_WARN_UNUSED_RESULT dif_result_t dif_acc_write_cmd ( const dif_acc_t * acc,
dif_acc_cmd_t cmd )

Start an operation by issuing a command.

Parameters
accACC instance.
cmdThe command.
Returns
The result of the operation.

Definition at line 82 of file dif_acc.c.