Lifecycle Controller Device Interface Functions More...
#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"
#include "sw/device/lib/dif/autogen/dif_lc_ctrl_autogen.h"
Go to the source code of this file.
Data Structures | |
struct | dif_lc_ctrl_token |
A 128-bit unlock token used for certain kinds of lifecycle transitions. More... | |
struct | dif_lc_ctrl_hw_rev_t |
A 32-bit hardware revision number. More... | |
struct | dif_lc_ctrl_device_id |
A 256-bit device id stored in OTP's hw_cfg0 partition. More... | |
Typedefs | |
typedef enum dif_lc_ctrl_status_code | dif_lc_ctrl_status_code_t |
A lifecycle controller status code. More... | |
typedef uint32_t | dif_lc_ctrl_status_t |
A bit-vector of dif_lc_ctrl_status_code_t s. More... | |
typedef enum dif_lc_ctrl_state | dif_lc_ctrl_state_t |
A lifecycle state. More... | |
typedef enum dif_lc_ctrl_id_state | dif_lc_ctrl_id_state_t |
A personalization state, indicating whether the device has been successfully personalized. | |
typedef struct dif_lc_ctrl_token | dif_lc_ctrl_token_t |
A 128-bit unlock token used for certain kinds of lifecycle transitions. | |
typedef struct dif_lc_ctrl_device_id | dif_lc_ctrl_device_id_t |
A 256-bit device id stored in OTP's hw_cfg0 partition. | |
Functions | |
OT_WARN_UNUSED_RESULT dif_result_t | dif_lc_ctrl_get_state (const dif_lc_ctrl_t *lc, dif_lc_ctrl_state_t *state) |
Returns the current state of the lifecycle controller. More... | |
OT_WARN_UNUSED_RESULT dif_result_t | dif_lc_ctrl_get_attempts (const dif_lc_ctrl_t *lc, uint8_t *count) |
Returns the number of lifecycle transitions that this device has attempted, up to 16. More... | |
OT_WARN_UNUSED_RESULT dif_result_t | dif_lc_ctrl_get_status (const dif_lc_ctrl_t *lc, dif_lc_ctrl_status_t *status) |
Returns the current status of the lifecycle controller. More... | |
OT_WARN_UNUSED_RESULT dif_result_t | dif_lc_ctrl_get_id_state (const dif_lc_ctrl_t *lc, dif_lc_ctrl_id_state_t *state) |
Returns the current personalization state of the lifecycle controller. More... | |
OT_WARN_UNUSED_RESULT dif_result_t | dif_lc_ctrl_get_hw_rev (const dif_lc_ctrl_t *lc, dif_lc_ctrl_hw_rev_t *hw_rev) |
Returns the hardware revision number reading from lifecycle controller's hardware revision register. More... | |
OT_WARN_UNUSED_RESULT dif_result_t | dif_lc_ctrl_get_device_id (const dif_lc_ctrl_t *lc, dif_lc_ctrl_device_id_t *device_id) |
Returns the current device id reading from lifecycle controller's device id registers. More... | |
OT_WARN_UNUSED_RESULT dif_result_t | dif_lc_ctrl_mutex_try_acquire (const dif_lc_ctrl_t *lc) |
Attempts to acquire the lifecycle controller's HW mutex. More... | |
OT_WARN_UNUSED_RESULT dif_result_t | dif_lc_ctrl_mutex_release (const dif_lc_ctrl_t *lc) |
Releases the lifecycle controller's HW mutex. More... | |
OT_WARN_UNUSED_RESULT dif_result_t | dif_lc_ctrl_configure (const dif_lc_ctrl_t *lc, dif_lc_ctrl_state_t target_state, bool use_ext_clock, const dif_lc_ctrl_token_t *token) |
Configures the lifecycle controller to perform a transition. More... | |
OT_WARN_UNUSED_RESULT dif_result_t | dif_lc_ctrl_transition (const dif_lc_ctrl_t *lc) |
Performs a lifecycle transition. More... | |
OT_WARN_UNUSED_RESULT dif_result_t | dif_lc_ctrl_set_otp_vendor_test_reg (const dif_lc_ctrl_t *lc, uint32_t settings) |
Writes settings to the vendor-specific OTP test control register. More... | |
OT_WARN_UNUSED_RESULT dif_result_t | dif_lc_ctrl_get_otp_vendor_test_reg (const dif_lc_ctrl_t *lc, uint32_t *settings) |
Reads settings from the vendor-specific OTP test control register. More... | |
OT_WARN_UNUSED_RESULT dif_result_t | dif_lc_ctrl_sw_mutex_lock (const dif_lc_ctrl_t *lc) |
Clears LC_CTRL_CLAIM_TRANSITION_IF_REGWEN to lock ability to claim mutex over TL-UL, effectively disabling SW-initiated lifecycle transitions. More... | |
Lifecycle Controller Device Interface Functions
Definition in file dif_lc_ctrl.h.
struct dif_lc_ctrl_token |
A 128-bit unlock token used for certain kinds of lifecycle transitions.
Definition at line 275 of file dif_lc_ctrl.h.
Data Fields | ||
---|---|---|
uint8_t | data[128/8] |
struct dif_lc_ctrl_hw_rev_t |
A 32-bit hardware revision number.
Definition at line 282 of file dif_lc_ctrl.h.
Data Fields | ||
---|---|---|
uint16_t | product_id | |
uint8_t | revision_id | |
uint16_t | silicon_creator_id |
struct dif_lc_ctrl_device_id |
A 256-bit device id stored in OTP's hw_cfg0 partition.
Definition at line 291 of file dif_lc_ctrl.h.
Data Fields | ||
---|---|---|
uint32_t | data[256/32] |
typedef enum dif_lc_ctrl_state dif_lc_ctrl_state_t |
A lifecycle state.
This enum represents all states that the lifecycle state register can be in; some of these do not correspond to "real" lifecycle states, and cannot be transitioned to.
typedef enum dif_lc_ctrl_status_code dif_lc_ctrl_status_code_t |
A lifecycle controller status code.
typedef uint32_t dif_lc_ctrl_status_t |
A bit-vector of dif_lc_ctrl_status_code_t
s.
Whether a particular status is contained in this vector can be discovered by using it as a bit index: bitfield_bit32_read(status, status_code);
.
Definition at line 98 of file dif_lc_ctrl.h.
enum dif_lc_ctrl_id_state |
A personalization state, indicating whether the device has been successfully personalized.
Definition at line 257 of file dif_lc_ctrl.h.
enum dif_lc_ctrl_state |
A lifecycle state.
This enum represents all states that the lifecycle state register can be in; some of these do not correspond to "real" lifecycle states, and cannot be transitioned to.
Definition at line 107 of file dif_lc_ctrl.h.
A lifecycle controller status code.
Definition at line 32 of file dif_lc_ctrl.h.
OT_WARN_UNUSED_RESULT dif_result_t dif_lc_ctrl_configure | ( | const dif_lc_ctrl_t * | lc, |
dif_lc_ctrl_state_t | target_state, | ||
bool | use_ext_clock, | ||
const dif_lc_ctrl_token_t * | token | ||
) |
Configures the lifecycle controller to perform a transition.
Note that not all transitions require an unlock token; in that case, NULL should be passed as the token.
lc | A lifecycle handle. |
state | The state to transition to. |
use_ext_clock | Whether to use the external clock for the transition. |
token | A token for unlocking the transition; may be null. |
Definition at line 288 of file dif_lc_ctrl.c.
OT_WARN_UNUSED_RESULT dif_result_t dif_lc_ctrl_get_attempts | ( | const dif_lc_ctrl_t * | lc, |
uint8_t * | count | ||
) |
Returns the number of lifecycle transitions that this device has attempted, up to 16.
lc | A lifecycle handle. | |
[out] | count | Out-param for the number of attempts. |
Definition at line 102 of file dif_lc_ctrl.c.
OT_WARN_UNUSED_RESULT dif_result_t dif_lc_ctrl_get_device_id | ( | const dif_lc_ctrl_t * | lc, |
dif_lc_ctrl_device_id_t * | device_id | ||
) |
Returns the current device id reading from lifecycle controller's device id registers.
lc | A lifecycle handle. | |
[out] | device_id | Out-param for the device id. |
Definition at line 235 of file dif_lc_ctrl.c.
OT_WARN_UNUSED_RESULT dif_result_t dif_lc_ctrl_get_hw_rev | ( | const dif_lc_ctrl_t * | lc, |
dif_lc_ctrl_hw_rev_t * | hw_rev | ||
) |
Returns the hardware revision number reading from lifecycle controller's hardware revision register.
lc | A lifecycle handle. | |
[out] | hw_rev | Out-param for the hardware revision. |
Definition at line 218 of file dif_lc_ctrl.c.
OT_WARN_UNUSED_RESULT dif_result_t dif_lc_ctrl_get_id_state | ( | const dif_lc_ctrl_t * | lc, |
dif_lc_ctrl_id_state_t * | state | ||
) |
Returns the current personalization state of the lifecycle controller.
lc | A lifecycle handle. | |
[out] | state | Out-param for the controller's personalization state. |
Definition at line 193 of file dif_lc_ctrl.c.
OT_WARN_UNUSED_RESULT dif_result_t dif_lc_ctrl_get_otp_vendor_test_reg | ( | const dif_lc_ctrl_t * | lc, |
uint32_t * | settings | ||
) |
Reads settings from the vendor-specific OTP test control register.
This returns kDifUnavailable
if the mutex has not been acquired.
lc | A lifecycle handle. |
settings | Output parameter for the settings. |
Definition at line 436 of file dif_lc_ctrl.c.
OT_WARN_UNUSED_RESULT dif_result_t dif_lc_ctrl_get_state | ( | const dif_lc_ctrl_t * | lc, |
dif_lc_ctrl_state_t * | state | ||
) |
Returns the current state of the lifecycle controller.
lc | A lifecycle handle. | |
[out] | state | Out-param for the controller's state. |
Definition at line 13 of file dif_lc_ctrl.c.
OT_WARN_UNUSED_RESULT dif_result_t dif_lc_ctrl_get_status | ( | const dif_lc_ctrl_t * | lc, |
dif_lc_ctrl_status_t * | status | ||
) |
Returns the current status of the lifecycle controller.
lc | A lifecycle handle. | |
[out] | status | Out-param for the controller's status. |
Definition at line 119 of file dif_lc_ctrl.c.
OT_WARN_UNUSED_RESULT dif_result_t dif_lc_ctrl_mutex_release | ( | const dif_lc_ctrl_t * | lc | ) |
Releases the lifecycle controller's HW mutex.
Calls to this function must be sequenced with successful calls to dif_lc_ctrl_mutex_try_acquire()
.
lc | A lifecycle handle. |
Definition at line 271 of file dif_lc_ctrl.c.
OT_WARN_UNUSED_RESULT dif_result_t dif_lc_ctrl_mutex_try_acquire | ( | const dif_lc_ctrl_t * | lc | ) |
Attempts to acquire the lifecycle controller's HW mutex.
Returns kDifLcCtrlMutexHeld
if acquisition fails. It is recommended to call this function in a busy loop to acquire the mutex.
lc | A lifecycle handle. |
Definition at line 247 of file dif_lc_ctrl.c.
OT_WARN_UNUSED_RESULT dif_result_t dif_lc_ctrl_set_otp_vendor_test_reg | ( | const dif_lc_ctrl_t * | lc, |
uint32_t | settings | ||
) |
Writes settings to the vendor-specific OTP test control register.
This returns kDifUnavailable
if the mutex has not been acquired.
lc | A lifecycle handle. |
settings | The settings to write to the register. |
Definition at line 418 of file dif_lc_ctrl.c.
OT_WARN_UNUSED_RESULT dif_result_t dif_lc_ctrl_sw_mutex_lock | ( | const dif_lc_ctrl_t * | lc | ) |
Clears LC_CTRL_CLAIM_TRANSITION_IF_REGWEN to lock ability to claim mutex over TL-UL, effectively disabling SW-initiated lifecycle transitions.
lc | A lifecycle handle. |
Definition at line 454 of file dif_lc_ctrl.c.
OT_WARN_UNUSED_RESULT dif_result_t dif_lc_ctrl_transition | ( | const dif_lc_ctrl_t * | lc | ) |
Performs a lifecycle transition.
lc | A lifecycle handle. |
Definition at line 402 of file dif_lc_ctrl.c.