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
11 #include <test/sim-hw-access.hpp>
12 #include <util/log.hpp>
13 #include <util/pdbg.hpp>
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
26 //------------------------------------------------------------------------------
27
28 // This is the simulated version of this function.
queryLpcTimeout(pdbg_target * target)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
38 //------------------------------------------------------------------------------
39
getScom(pdbg_target * i_target,uint64_t i_addr,uint64_t & o_val)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 {
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);
54 }
55
56 return rc;
57 }
58
59 //------------------------------------------------------------------------------
60
getCfam(pdbg_target * i_target,uint32_t i_addr,uint32_t & o_val)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 {
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);
74 }
75
76 return rc;
77 }
78
79 //------------------------------------------------------------------------------
80
81 } // namespace pdbg
82 } // namespace util
83