qualcomm/qbox
Loading...
Searching...
No Matches
hexagon_globalreg.h
1/*
2 * This file is part of libqbox
3 * Copyright (c) 2025 Qualcomm Innovation Center, Inc. All Rights Reserved.
4 *
5 * SPDX-License-Identifier: BSD-3-Clause
6 */
7
8#ifndef _LIBQBOX_COMPONENTS_HEXAGON_GLOBALREG_INITIATOR_H
9#define _LIBQBOX_COMPONENTS_HEXAGON_GLOBALREG_INITIATOR_H
10
11#include <device.h>
12#include <qemu-instance.h>
13#include <module_factory_registery.h>
14#include <libqemu-cxx/target/hexagon.h>
15#include <qemu_hexagon_qtimer.h>
16#include <hexagon-l2vic.h>
17
18class hexagon_globalreg : public QemuDevice
19{
20private:
21 SCP_LOGGER();
22 qemu_hexagon_qtimer* m_qtimer;
23 hexagon_l2vic* m_l2vic;
24
25public:
26 cci::cci_param<uint64_t> p_config_table_addr;
27 cci::cci_param<uint32_t> p_hexagon_start_addr;
28 cci::cci_param<std::string> p_dsp_arch;
29 cci::cci_param<bool> p_isdben_trusted;
30 cci::cci_param<bool> p_isdben_secure;
31
32 hexagon_globalreg(const sc_core::sc_module_name& name, sc_core::sc_object* o,
33 sc_core::sc_object* qtimer_obj = nullptr, sc_core::sc_object* l2vic_obj = nullptr)
34 : hexagon_globalreg(name, *(dynamic_cast<QemuInstance*>(o)), dynamic_cast<qemu_hexagon_qtimer*>(qtimer_obj),
35 dynamic_cast<hexagon_l2vic*>(l2vic_obj))
36 {
37 }
38 hexagon_globalreg(const sc_core::sc_module_name& n, QemuInstance& inst, qemu_hexagon_qtimer* qtimer = nullptr,
39 hexagon_l2vic* l2vic = nullptr)
40 : QemuDevice(n, inst, "hexagon-globalreg")
41 , m_qtimer(qtimer)
42 , m_l2vic(l2vic)
43 , p_config_table_addr("config_table_addr", 0xffffffffULL, "config table address")
44 , p_hexagon_start_addr("hexagon_start_addr", 0xffffffffULL, "execution start address")
45 , p_dsp_arch("dsp_arch", "v68", "DSP arch")
46 , p_isdben_trusted("isdben_trusted", true, "isdben trusted")
47 , p_isdben_secure("isdben_secure", true, "isdben secure")
48 {
49 SCP_TRACE(())("Init");
50 }
51
52 void set_qtimer(qemu_hexagon_qtimer* qtimer) { m_qtimer = qtimer; }
53 void set_l2vic(hexagon_l2vic* l2vic) { m_l2vic = l2vic; }
54
55 void end_of_elaboration() override
56 {
57 QemuDevice::set_sysbus_as_parent_bus();
58 QemuDevice::end_of_elaboration();
59 }
60
61 void before_end_of_elaboration() override
62 {
63 QemuDevice::before_end_of_elaboration();
64 qemu::Device hex_greg_devs = get_qemu_dev();
65 const std::string dsp_arch = p_dsp_arch.get_value();
66 qemu::CpuHexagon::Rev_t dsp_rev = qemu::CpuHexagon::parse_dsp_arch(dsp_arch);
67 if (dsp_rev == qemu::CpuHexagon::unknown_rev) {
68 SCP_FATAL(())("Unrecognized Architecture Revision: " + dsp_arch);
69 }
70 hex_greg_devs.set_prop_int("config-table-addr", p_config_table_addr);
71 hex_greg_devs.set_prop_int("boot-evb", p_hexagon_start_addr);
72 hex_greg_devs.set_prop_int("dsp-rev", dsp_rev);
73 hex_greg_devs.set_prop_bool("isdben-trusted", p_isdben_trusted);
74 hex_greg_devs.set_prop_bool("isdben-secure", p_isdben_secure);
75
76 if (m_qtimer) {
77 m_qtimer->before_end_of_elaboration();
78 hex_greg_devs.set_prop_link("qtimer", m_qtimer->get_qemu_dev());
79 }
80 if (m_l2vic) {
81 m_l2vic->before_end_of_elaboration();
82 hex_greg_devs.set_prop_link("l2vic", m_l2vic->get_qemu_dev());
83 }
84 }
85};
86
87extern "C" void module_register();
88
89#endif //_LIBQBOX_COMPONENTS_HEXAGON_GLOBALREG_INITIATOR_H
QemuDevice(const sc_core::sc_module_name &name, QemuInstance &inst, const char *qom_type)
Construct a QEMU device.
Definition device.h:86
This class encapsulates a libqemu-cxx qemu::LibQemu instance. It handles QEMU parameters and instance...
Definition qemu-instance.h:89
Definition hexagon-l2vic.h:23
Definition libqemu-cxx.h:675
Definition qemu_hexagon_qtimer.h:24