Software APIs
dt_soc_dbg_ctrl.c
Go to the documentation of this file.
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// Device table API auto-generated by `dtgen`
6
7/**
8 * @file
9 * @brief Device Tables (DT) for IP soc_dbg_ctrl and top darjeeling.
10 */
11
13
14
15
16/**
17 * Description of instances.
18 */
19typedef struct dt_desc_soc_dbg_ctrl {
20 dt_instance_id_t inst_id; /**< Instance ID */
21 uint32_t reg_addr[kDtSocDbgCtrlRegBlockCount]; /**< Base address of each register block */
22 uint32_t mem_addr[kDtSocDbgCtrlMemoryCount]; /**< Base address of each memory */
23 uint32_t mem_size[kDtSocDbgCtrlMemoryCount]; /**< Size in bytes of each memory */
24 /**
25 * Alert ID of the first Alert of this instance.
26 *
27 * This value is undefined if the block is not connected to the Alert Handler.
28 */
30 dt_clock_t clock[kDtSocDbgCtrlClockCount]; /**< Clock signal connected to each clock port */
31 dt_reset_t reset[kDtSocDbgCtrlResetCount]; /**< Reset signal connected to each reset port */
33
34
35
36
37static const dt_desc_soc_dbg_ctrl_t soc_dbg_ctrl_desc[kDtSocDbgCtrlCount] = {
38 [kDtSocDbgCtrl] = {
39 .inst_id = kDtInstanceIdSocDbgCtrl,
40 .reg_addr = {
41 [kDtSocDbgCtrlRegBlockCore] = 0x30170000,
42 [kDtSocDbgCtrlRegBlockJtag] = 0xffffffff,
43 },
44 .mem_addr = {
45 },
46 .mem_size = {
47 },
49 .clock = {
51 },
52 .reset = {
54 },
55 },
56};
57
58/**
59 * Return a pointer to the `dt_soc_dbg_ctrl_desc_t` structure of the requested
60 * `dt` if it's a valid index. Otherwise, this macro will `return` (i.e. exit
61 * the function) with the provided default value.
62 */
63#define TRY_GET_DT(dt, default) ({ if ((dt) < (dt_soc_dbg_ctrl_t)0 || (dt) >= kDtSocDbgCtrlCount) return (default); &soc_dbg_ctrl_desc[dt]; })
64
71
76
80 // Return a recognizable address in case of wrong argument.
81 return TRY_GET_DT(dt, 0xdeadbeef)->reg_addr[reg_block];
82}
83
87 // Return a recognizable address in case of wrong argument.
88 return TRY_GET_DT(dt, 0xdeadbeef)->mem_addr[mem];
89}
90
94 // Return an empty size in case of wrong argument.
95 return TRY_GET_DT(dt, 0)->mem_size[mem];
96}
97
98
102 return (dt_alert_id_t)((uint32_t)soc_dbg_ctrl_desc[dt].first_alert + (uint32_t)alert);
103}
104
107 dt_alert_id_t alert) {
108 dt_soc_dbg_ctrl_alert_t count = kDtSocDbgCtrlAlertCount;
109 if (alert < soc_dbg_ctrl_desc[dt].first_alert || alert >= soc_dbg_ctrl_desc[dt].first_alert + (dt_alert_id_t)count) {
110 return count;
111 }
112 return (dt_soc_dbg_ctrl_alert_t)(alert - soc_dbg_ctrl_desc[dt].first_alert);
113}
114
115
116
120 // Return the first clock in case of invalid argument.
121 return TRY_GET_DT(dt, (dt_clock_t)0)->clock[clk];
122}
123
127 const dt_soc_dbg_ctrl_reset_t count = kDtSocDbgCtrlResetCount;
128 if (rst >= count) {
129 return kDtResetUnknown;
130 }
131 return TRY_GET_DT(dt, kDtResetUnknown)->reset[rst];
132}
133
134