Software APIs
dif_soc_proxy_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
6
7
8
9
10
11
// THIS FILE HAS BEEN GENERATED, DO NOT EDIT MANUALLY. COMMAND:
12
// util/autogen_dif.py -i
13
// hw/top_darjeeling/ip/soc_proxy/data/soc_proxy.hjson -o
14
// bazel-out/k8-fastbuild-ST-24cc6a2908d2/bin/sw/device/lib/dif/autogen
15
16
17
#include <stdint.h>
18
19
#include "
sw/device/lib/dif/dif_base.h
"
20
#include "
sw/device/lib/dif/autogen/dif_soc_proxy_autogen.h
"
21
22
#include "
hw/top/soc_proxy_regs.h
"
// Generated.
23
24
25
OT_WARN_UNUSED_RESULT
26
dif_result_t
dif_soc_proxy_init(
27
mmio_region_t
base_addr,
28
dif_soc_proxy_t
*soc_proxy) {
29
if
(soc_proxy == NULL) {
30
return
kDifBadArg
;
31
}
32
33
soc_proxy->
dt
= kDtSocProxyCount;
34
soc_proxy->
base_addr
= base_addr;
35
36
return
kDifOk
;
37
}
38
39
OT_WARN_UNUSED_RESULT
40
dif_result_t
dif_soc_proxy_init_from_dt(
41
dt_soc_proxy_t
dt,
42
dif_soc_proxy_t
*soc_proxy) {
43
if
(soc_proxy == NULL) {
44
return
kDifBadArg
;
45
}
46
47
soc_proxy->
dt
= dt;
48
soc_proxy->
base_addr
= mmio_region_from_addr(dt_soc_proxy_primary_reg_block(dt));
49
50
return
kDifOk
;
51
}
52
53
dif_result_t
dif_soc_proxy_get_dt(
54
const
dif_soc_proxy_t
*soc_proxy,
55
dt_soc_proxy_t
*dt) {
56
if
(soc_proxy->
dt
== kDtSocProxyCount || dt == NULL) {
57
return
kDifBadArg
;
58
}
59
*dt = soc_proxy->
dt
;
60
return
kDifOk
;
61
}
62
63
dif_result_t
dif_soc_proxy_alert_force(
64
const
dif_soc_proxy_t
*soc_proxy,
65
dif_soc_proxy_alert_t
alert) {
66
if
(soc_proxy == NULL) {
67
return
kDifBadArg
;
68
}
69
70
bitfield_bit32_index_t
alert_idx;
71
switch
(alert) {
72
case
kDifSocProxyAlertFatalAlertIntg
:
73
alert_idx = SOC_PROXY_ALERT_TEST_FATAL_ALERT_INTG_BIT;
74
break
;
75
default
:
76
return
kDifBadArg
;
77
}
78
79
uint32_t alert_test_reg = bitfield_bit32_write(0, alert_idx,
true
);
80
mmio_region_write32(
81
soc_proxy->
base_addr
,
82
(ptrdiff_t)SOC_PROXY_ALERT_TEST_REG_OFFSET,
83
alert_test_reg);
84
85
86
return
kDifOk
;
87
}
88
(darjeeling)
sw
device
lib
dif
autogen
dif_soc_proxy_autogen.c
Return to
OpenTitan Documentation