Zane Shelley | 15527a4 | 2021-12-16 21:43:13 -0600 | [diff] [blame] | 1 | #include <analyzer/plugins/plugin.hpp> |
Zane Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 2 | #include <analyzer/resolution.hpp> |
Zane Shelley | 236bb73 | 2021-03-24 17:07:46 -0500 | [diff] [blame] | 3 | #include <util/pdbg.hpp> |
| 4 | #include <util/trace.hpp> |
Zane Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 5 | |
| 6 | namespace analyzer |
| 7 | { |
| 8 | |
Zane Shelley | 2d11432 | 2021-08-25 17:06:12 -0500 | [diff] [blame] | 9 | //------------------------------------------------------------------------------ |
| 10 | |
Zane Shelley | 96d5486 | 2021-09-17 11:16:12 -0500 | [diff] [blame] | 11 | // Helper function to get the root cause chip target from the service data. |
| 12 | pdbg_target* __getRootCauseChipTarget(const ServiceData& i_sd) |
Zane Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 13 | { |
Zane Shelley | 96d5486 | 2021-09-17 11:16:12 -0500 | [diff] [blame] | 14 | 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 Shelley | 236bb73 | 2021-03-24 17:07:46 -0500 | [diff] [blame] | 18 | |
Zane Shelley | 96d5486 | 2021-09-17 11:16:12 -0500 | [diff] [blame] | 19 | //------------------------------------------------------------------------------ |
| 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. |
| 24 | pdbg_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 Shelley | 236bb73 | 2021-03-24 17:07:46 -0500 | [diff] [blame] | 32 | { |
Zane Shelley | 96d5486 | 2021-09-17 11:16:12 -0500 | [diff] [blame] | 33 | auto path = std::string{util::pdbg::getPath(target)} + "/" + i_unitPath; |
| 34 | |
| 35 | target = util::pdbg::getTrgt(path); |
| 36 | if (nullptr == target) |
Zane Shelley | 236bb73 | 2021-03-24 17:07:46 -0500 | [diff] [blame] | 37 | { |
Zane Shelley | 96d5486 | 2021-09-17 11:16:12 -0500 | [diff] [blame] | 38 | // Likely a bug the RAS data files. |
| 39 | throw std::logic_error("Unable to find target for " + path); |
Zane Shelley | 236bb73 | 2021-03-24 17:07:46 -0500 | [diff] [blame] | 40 | } |
| 41 | } |
| 42 | |
Zane Shelley | 96d5486 | 2021-09-17 11:16:12 -0500 | [diff] [blame] | 43 | return target; |
| 44 | } |
| 45 | |
| 46 | //------------------------------------------------------------------------------ |
| 47 | |
| 48 | void 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 Shelley | 37acb28 | 2022-01-10 16:05:22 -0600 | [diff] [blame] | 53 | // Add the callout and the FFDC to the service data. |
| 54 | io_sd.calloutTarget(target, iv_priority, iv_guard); |
Zane Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 55 | } |
| 56 | |
Zane Shelley | c85716c | 2021-08-17 10:54:06 -0500 | [diff] [blame] | 57 | //------------------------------------------------------------------------------ |
| 58 | |
Zane Shelley | 5d63cef | 2021-09-17 18:10:17 -0500 | [diff] [blame] | 59 | void 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 Shelley | 37acb28 | 2022-01-10 16:05:22 -0600 | [diff] [blame] | 67 | // Add the callout and the FFDC to the service data. |
| 68 | io_sd.calloutConnected(rxTarget, iv_busType, iv_priority, iv_guard); |
Zane Shelley | 5d63cef | 2021-09-17 18:10:17 -0500 | [diff] [blame] | 69 | } |
| 70 | |
| 71 | //------------------------------------------------------------------------------ |
| 72 | |
Zane Shelley | 4757a7b | 2021-09-20 22:23:38 -0500 | [diff] [blame] | 73 | void 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 Shelley | 37acb28 | 2022-01-10 16:05:22 -0600 | [diff] [blame] | 81 | // Add the callout and the FFDC to the service data. |
| 82 | io_sd.calloutBus(rxTarget, iv_busType, iv_priority, iv_guard); |
Zane Shelley | 4757a7b | 2021-09-20 22:23:38 -0500 | [diff] [blame] | 83 | } |
| 84 | |
| 85 | //------------------------------------------------------------------------------ |
| 86 | |
Zane Shelley | 84721d9 | 2021-09-08 13:30:27 -0500 | [diff] [blame] | 87 | void ClockCalloutResolution::resolve(ServiceData& io_sd) const |
| 88 | { |
Zane Shelley | 37acb28 | 2022-01-10 16:05:22 -0600 | [diff] [blame] | 89 | // Add the callout and the FFDC to the service data. |
| 90 | io_sd.calloutClock(iv_clockType, iv_priority, iv_guard); |
Zane Shelley | 84721d9 | 2021-09-08 13:30:27 -0500 | [diff] [blame] | 91 | } |
| 92 | |
| 93 | //------------------------------------------------------------------------------ |
| 94 | |
Zane Shelley | c85716c | 2021-08-17 10:54:06 -0500 | [diff] [blame] | 95 | void ProcedureCalloutResolution::resolve(ServiceData& io_sd) const |
| 96 | { |
Zane Shelley | 37acb28 | 2022-01-10 16:05:22 -0600 | [diff] [blame] | 97 | // Add the callout and the FFDC to the service data. |
| 98 | io_sd.calloutProcedure(iv_procedure, iv_priority); |
Zane Shelley | c85716c | 2021-08-17 10:54:06 -0500 | [diff] [blame] | 99 | } |
| 100 | |
| 101 | //------------------------------------------------------------------------------ |
| 102 | |
Zane Shelley | a413477 | 2022-01-10 17:22:44 -0600 | [diff] [blame] | 103 | void 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 Shelley | 15527a4 | 2021-12-16 21:43:13 -0600 | [diff] [blame] | 111 | void PluginResolution::resolve(ServiceData& io_sd) const |
Zane Shelley | e13a9f9 | 2021-12-16 21:19:11 -0600 | [diff] [blame] | 112 | { |
Zane Shelley | 15527a4 | 2021-12-16 21:43:13 -0600 | [diff] [blame] | 113 | // 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 Shelley | e13a9f9 | 2021-12-16 21:19:11 -0600 | [diff] [blame] | 120 | } |
| 121 | |
| 122 | //------------------------------------------------------------------------------ |
| 123 | |
Zane Shelley | 0b8368c | 2021-03-18 17:33:41 -0500 | [diff] [blame] | 124 | } // namespace analyzer |