Software APIs
sw
device
lib
dif
autogen
dif_lc_ctrl_autogen.c
1
// Copyright lowRISC contributors (OpenTitan project).
2
// Licensed under the Apache License, Version 2.0, see LICENSE for details.
3
// SPDX-License-Identifier: Apache-2.0
4
5
// THIS FILE HAS BEEN GENERATED, DO NOT EDIT MANUALLY. COMMAND:
6
// util/make_new_dif.py --mode=regen --only=autogen
7
8
#include "
sw/device/lib/dif/autogen/dif_lc_ctrl_autogen.h
"
9
10
#include <
stdint.h
>
11
12
#include "
sw/device/lib/dif/dif_base.h
"
13
14
#include "lc_ctrl_regs.h"
// Generated.
15
16
OT_WARN_UNUSED_RESULT
17
dif_result_t
dif_lc_ctrl_init
(
mmio_region_t
base_addr,
dif_lc_ctrl_t
*lc_ctrl) {
18
if
(lc_ctrl == NULL) {
19
return
kDifBadArg
;
20
}
21
22
lc_ctrl->
base_addr
= base_addr;
23
24
return
kDifOk
;
25
}
26
27
dif_result_t
dif_lc_ctrl_alert_force
(
const
dif_lc_ctrl_t
*lc_ctrl,
28
dif_lc_ctrl_alert_t
alert) {
29
if
(lc_ctrl == NULL) {
30
return
kDifBadArg
;
31
}
32
33
bitfield_bit32_index_t
alert_idx;
34
switch
(alert) {
35
case
kDifLcCtrlAlertFatalProgError
:
36
alert_idx = LC_CTRL_ALERT_TEST_FATAL_PROG_ERROR_BIT;
37
break
;
38
case
kDifLcCtrlAlertFatalStateError
:
39
alert_idx = LC_CTRL_ALERT_TEST_FATAL_STATE_ERROR_BIT;
40
break
;
41
case
kDifLcCtrlAlertFatalBusIntegError
:
42
alert_idx = LC_CTRL_ALERT_TEST_FATAL_BUS_INTEG_ERROR_BIT;
43
break
;
44
default
:
45
return
kDifBadArg
;
46
}
47
48
uint32_t alert_test_reg =
bitfield_bit32_write
(0, alert_idx,
true
);
49
mmio_region_write32(lc_ctrl->
base_addr
,
50
(ptrdiff_t)LC_CTRL_ALERT_TEST_REG_OFFSET, alert_test_reg);
51
52
return
kDifOk
;
53
}
Return to
OpenTitan Documentation