blob: 98519d357c9d022f015c5b23023197226e9ef23b [file] [log] [blame]
Zane Shelleye90b85d2021-12-17 17:24:49 -06001//------------------------------------------------------------------------------
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 Shelleyc7026262022-02-22 16:37:36 -060011#include <test/sim-hw-access.hpp>
Zane Shelley20ed74d2022-03-26 13:50:57 -050012#include <util/log.hpp>
Zane Shelleye90b85d2021-12-17 17:24:49 -060013#include <util/pdbg.hpp>
Zane Shelleye90b85d2021-12-17 17:24:49 -060014
15//------------------------------------------------------------------------------
16
17// Using this to fake the value returned from the simulation-only version of
18// util::pdbg::queryLpcTimeout().
19bool g_lpcTimeout = false;
20
21namespace util
22{
23namespace pdbg
24{
25
Zane Shelleyc7026262022-02-22 16:37:36 -060026//------------------------------------------------------------------------------
27
Zane Shelleye90b85d2021-12-17 17:24:49 -060028// This is the simulated version of this function.
29bool 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 Shelleyc7026262022-02-22 16:37:36 -060038//------------------------------------------------------------------------------
39
40int 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 Shelley20ed74d2022-03-26 13:50:57 -050050 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 Shelleyc7026262022-02-22 16:37:36 -060054 }
55
56 return rc;
57}
58
59//------------------------------------------------------------------------------
60
61int 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 Shelley20ed74d2022-03-26 13:50:57 -050070 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 Shelleyc7026262022-02-22 16:37:36 -060074 }
75
76 return rc;
77}
78
79//------------------------------------------------------------------------------
80
Zane Shelleye90b85d2021-12-17 17:24:49 -060081} // namespace pdbg
82} // namespace util