Zane Shelley | e90b85d | 2021-12-17 17:24:49 -0600 | [diff] [blame] | 1 | //------------------------------------------------------------------------------ |
| 2 | // IMPORTANT: |
| 3 | // This file will ONLY be built in CI test and should be used for any functions |
| 4 | // that require addition support to simulate in CI test. Any functions that will |
| 5 | // work out-of-the-box in CI test with use of the fake device tree should be put |
| 6 | // in `pdbg.cpp`. |
| 7 | //------------------------------------------------------------------------------ |
| 8 | |
| 9 | #include <assert.h> |
| 10 | |
Zane Shelley | c702626 | 2022-02-22 16:37:36 -0600 | [diff] [blame] | 11 | #include <test/sim-hw-access.hpp> |
Zane Shelley | 20ed74d | 2022-03-26 13:50:57 -0500 | [diff] [blame] | 12 | #include <util/log.hpp> |
Zane Shelley | e90b85d | 2021-12-17 17:24:49 -0600 | [diff] [blame] | 13 | #include <util/pdbg.hpp> |
Zane Shelley | e90b85d | 2021-12-17 17:24:49 -0600 | [diff] [blame] | 14 | |
| 15 | //------------------------------------------------------------------------------ |
| 16 | |
| 17 | // Using this to fake the value returned from the simulation-only version of |
| 18 | // util::pdbg::queryLpcTimeout(). |
| 19 | bool g_lpcTimeout = false; |
| 20 | |
| 21 | namespace util |
| 22 | { |
| 23 | namespace pdbg |
| 24 | { |
| 25 | |
Zane Shelley | c702626 | 2022-02-22 16:37:36 -0600 | [diff] [blame] | 26 | //------------------------------------------------------------------------------ |
| 27 | |
Zane Shelley | e90b85d | 2021-12-17 17:24:49 -0600 | [diff] [blame] | 28 | // This is the simulated version of this function. |
| 29 | bool queryLpcTimeout(pdbg_target* target) |
| 30 | { |
| 31 | // Must be a processor target. |
| 32 | assert(TYPE_PROC == getTrgtType(target)); |
| 33 | |
| 34 | // Instead of the SBE chip-op, use the faked value. |
| 35 | return g_lpcTimeout; |
| 36 | } |
| 37 | |
Zane Shelley | c702626 | 2022-02-22 16:37:36 -0600 | [diff] [blame] | 38 | //------------------------------------------------------------------------------ |
| 39 | |
| 40 | int getScom(pdbg_target* i_target, uint64_t i_addr, uint64_t& o_val) |
| 41 | { |
| 42 | assert(nullptr != i_target); |
| 43 | assert(TYPE_PROC == getTrgtType(i_target) || |
| 44 | TYPE_OCMB == getTrgtType(i_target)); |
| 45 | |
| 46 | int rc = sim::ScomAccess::getSingleton().get(i_target, i_addr, o_val); |
| 47 | |
| 48 | if (0 != rc) |
| 49 | { |
Zane Shelley | 20ed74d | 2022-03-26 13:50:57 -0500 | [diff] [blame] | 50 | lg2::error( |
| 51 | "SCOM read failure: target={SCOM_TARGET} addr={SCOM_ADDRESS}", |
| 52 | "SCOM_TARGET", getPath(i_target), "SCOM_ADDRESS", |
| 53 | (lg2::hex | lg2::field64), i_addr, "SCOM_ACCESS_RC", rc); |
Zane Shelley | c702626 | 2022-02-22 16:37:36 -0600 | [diff] [blame] | 54 | } |
| 55 | |
| 56 | return rc; |
| 57 | } |
| 58 | |
| 59 | //------------------------------------------------------------------------------ |
| 60 | |
| 61 | int getCfam(pdbg_target* i_target, uint32_t i_addr, uint32_t& o_val) |
| 62 | { |
| 63 | assert(nullptr != i_target); |
| 64 | assert(TYPE_PROC == getTrgtType(i_target)); |
| 65 | |
| 66 | int rc = sim::CfamAccess::getSingleton().get(i_target, i_addr, o_val); |
| 67 | |
| 68 | if (0 != rc) |
| 69 | { |
Zane Shelley | 20ed74d | 2022-03-26 13:50:57 -0500 | [diff] [blame] | 70 | lg2::error( |
| 71 | "CFAM read failure: target={CFAM_TARGET} addr={CFAM_ADDRESS}", |
| 72 | "CFAM_TARGET", getPath(i_target), "CFAM_ADDRESS", |
| 73 | (lg2::hex | lg2::field32), i_addr, "CFAM_ACCESS_RC", rc); |
Zane Shelley | c702626 | 2022-02-22 16:37:36 -0600 | [diff] [blame] | 74 | } |
| 75 | |
| 76 | return rc; |
| 77 | } |
| 78 | |
| 79 | //------------------------------------------------------------------------------ |
| 80 | |
Zane Shelley | e90b85d | 2021-12-17 17:24:49 -0600 | [diff] [blame] | 81 | } // namespace pdbg |
| 82 | } // namespace util |