blob: 5ba4b6f7b7aa2b3bec9dc591375ea5debf2ed44e [file] [log] [blame]
Zane Shelley15527a42021-12-16 21:43:13 -06001#include <analyzer/plugins/plugin.hpp>
Zane Shelley0b8368c2021-03-18 17:33:41 -05002#include <analyzer/resolution.hpp>
Zane Shelley236bb732021-03-24 17:07:46 -05003#include <util/pdbg.hpp>
4#include <util/trace.hpp>
Zane Shelley0b8368c2021-03-18 17:33:41 -05005
6namespace analyzer
7{
8
Zane Shelley2d114322021-08-25 17:06:12 -05009//------------------------------------------------------------------------------
10
Zane Shelley96d54862021-09-17 11:16:12 -050011// Helper function to get the root cause chip target from the service data.
12pdbg_target* __getRootCauseChipTarget(const ServiceData& i_sd)
Zane Shelley0b8368c2021-03-18 17:33:41 -050013{
Zane Shelley96d54862021-09-17 11:16:12 -050014 auto target = util::pdbg::getTrgt(i_sd.getRootCause().getChip());
15 assert(nullptr != target); // This would be a really bad bug.
16 return target;
17}
Zane Shelley236bb732021-03-24 17:07:46 -050018
Zane Shelley96d54862021-09-17 11:16:12 -050019//------------------------------------------------------------------------------
20
21// Helper function to get a unit target from the given unit path, which is a
22// devtree path relative the the containing chip. An empty string indicates the
23// chip target should be returned.
24pdbg_target* __getUnitTarget(pdbg_target* i_chipTarget,
25 const std::string& i_unitPath)
26{
27 assert(nullptr != i_chipTarget);
28
29 auto target = i_chipTarget; // default, if i_unitPath is empty
30
31 if (!i_unitPath.empty())
Zane Shelley236bb732021-03-24 17:07:46 -050032 {
Zane Shelley96d54862021-09-17 11:16:12 -050033 auto path = std::string{util::pdbg::getPath(target)} + "/" + i_unitPath;
34
35 target = util::pdbg::getTrgt(path);
36 if (nullptr == target)
Zane Shelley236bb732021-03-24 17:07:46 -050037 {
Zane Shelley96d54862021-09-17 11:16:12 -050038 // Likely a bug the RAS data files.
39 throw std::logic_error("Unable to find target for " + path);
Zane Shelley236bb732021-03-24 17:07:46 -050040 }
41 }
42
Zane Shelley96d54862021-09-17 11:16:12 -050043 return target;
44}
45
46//------------------------------------------------------------------------------
47
48void HardwareCalloutResolution::resolve(ServiceData& io_sd) const
49{
50 // Get the target for the hardware callout.
51 auto target = __getUnitTarget(__getRootCauseChipTarget(io_sd), iv_unitPath);
52
Zane Shelley37acb282022-01-10 16:05:22 -060053 // Add the callout and the FFDC to the service data.
54 io_sd.calloutTarget(target, iv_priority, iv_guard);
Zane Shelley0b8368c2021-03-18 17:33:41 -050055}
56
Zane Shelleyc85716c2021-08-17 10:54:06 -050057//------------------------------------------------------------------------------
58
Zane Shelley5d63cef2021-09-17 18:10:17 -050059void ConnectedCalloutResolution::resolve(ServiceData& io_sd) const
60{
61 // Get the chip target from the root cause signature.
62 auto chipTarget = __getRootCauseChipTarget(io_sd);
63
64 // Get the endpoint target for the receiving side of the bus.
65 auto rxTarget = __getUnitTarget(chipTarget, iv_unitPath);
66
Zane Shelley37acb282022-01-10 16:05:22 -060067 // Add the callout and the FFDC to the service data.
68 io_sd.calloutConnected(rxTarget, iv_busType, iv_priority, iv_guard);
Zane Shelley5d63cef2021-09-17 18:10:17 -050069}
70
71//------------------------------------------------------------------------------
72
Zane Shelley4757a7b2021-09-20 22:23:38 -050073void BusCalloutResolution::resolve(ServiceData& io_sd) const
74{
75 // Get the chip target from the root cause signature.
76 auto chipTarget = __getRootCauseChipTarget(io_sd);
77
78 // Get the endpoint target for the receiving side of the bus.
79 auto rxTarget = __getUnitTarget(chipTarget, iv_unitPath);
80
Zane Shelley37acb282022-01-10 16:05:22 -060081 // Add the callout and the FFDC to the service data.
82 io_sd.calloutBus(rxTarget, iv_busType, iv_priority, iv_guard);
Zane Shelley4757a7b2021-09-20 22:23:38 -050083}
84
85//------------------------------------------------------------------------------
86
Zane Shelley84721d92021-09-08 13:30:27 -050087void ClockCalloutResolution::resolve(ServiceData& io_sd) const
88{
Zane Shelley37acb282022-01-10 16:05:22 -060089 // Add the callout and the FFDC to the service data.
90 io_sd.calloutClock(iv_clockType, iv_priority, iv_guard);
Zane Shelley84721d92021-09-08 13:30:27 -050091}
92
93//------------------------------------------------------------------------------
94
Zane Shelleyc85716c2021-08-17 10:54:06 -050095void ProcedureCalloutResolution::resolve(ServiceData& io_sd) const
96{
Zane Shelley37acb282022-01-10 16:05:22 -060097 // Add the callout and the FFDC to the service data.
98 io_sd.calloutProcedure(iv_procedure, iv_priority);
Zane Shelleyc85716c2021-08-17 10:54:06 -050099}
100
101//------------------------------------------------------------------------------
102
Zane Shelleya4134772022-01-10 17:22:44 -0600103void PartCalloutResolution::resolve(ServiceData& io_sd) const
104{
105 // Add the callout and the FFDC to the service data.
106 io_sd.calloutPart(iv_part, iv_priority);
107}
108
109//------------------------------------------------------------------------------
110
Zane Shelley15527a42021-12-16 21:43:13 -0600111void PluginResolution::resolve(ServiceData& io_sd) const
Zane Shelleye13a9f92021-12-16 21:19:11 -0600112{
Zane Shelley15527a42021-12-16 21:43:13 -0600113 // Get the plugin function and call it.
114
115 auto chip = io_sd.getRootCause().getChip();
116
117 auto func = PluginMap::getSingleton().get(chip.getType(), iv_name);
118
119 func(iv_instance, chip, io_sd);
Zane Shelleye13a9f92021-12-16 21:19:11 -0600120}
121
122//------------------------------------------------------------------------------
123
Zane Shelley0b8368c2021-03-18 17:33:41 -0500124} // namespace analyzer