blob: 7ed998a7d0e1c41c8911a722e0aee07c50ad5f52 [file] [log] [blame]
Zane Shelley11b89942019-11-07 11:07:28 -06001/**
2 * @file These are the simulated implementations of the user interfaces declared
3 * in hei_user_interface.hpp
4 */
5
6#include "simulator.hpp"
7
8#include <endian.h>
9
10#include <hei_user_interface.hpp>
11
12namespace libhei
13{
14
15//------------------------------------------------------------------------------
16
17ReturnCode registerRead(const Chip& i_chip, void* o_buffer, size_t& io_bufSize,
18 uint64_t i_regType, uint64_t i_address)
19{
20 ReturnCode rc{};
21
22 HEI_ASSERT(nullptr != o_buffer);
23 HEI_ASSERT(0 != io_bufSize);
24
25 switch (i_regType)
26 {
27 // BEGIN temporary code
28 // TODO: add cases for REG_TYPE_SCOM and REG_TYPE_ID_SCOM
29 case REG_TYPE_SCOM:
30 {
31 uint64_t x = htobe64(0x8800000000000000);
32 memcpy(o_buffer, &x, sizeof(x));
33 break;
34 }
35 case REG_TYPE_ID_SCOM:
36 {
37 uint64_t x = htobe64(0x8000);
38 memcpy(o_buffer, &x, sizeof(x));
39 break;
40 }
41 // END temporary code
42 default:
43 rc = RC_REG_ACCESS_FAILURE;
44 HEI_ERR("registerRead(%p,%p,%lx,%lx,%lx)", i_chip.getChip(),
45 o_buffer, io_bufSize, i_regType, i_address);
46 }
47
48 return rc;
49}
50
51//------------------------------------------------------------------------------
52
53#ifndef __HEI_READ_ONLY
54
55ReturnCode registerWrite(const Chip& i_chip, void* i_buffer, size_t& io_bufSize,
56 uint64_t i_regType, uint64_t i_address)
57{
58 ReturnCode rc{};
59
60 HEI_ASSERT(nullptr != i_buffer);
61 HEI_ASSERT(0 != io_bufSize);
62
63 switch (i_regType)
64 {
65 // TODO: add cases for REG_TYPE_SCOM and REG_TYPE_ID_SCOM
66 default:
67 rc = RC_REG_ACCESS_FAILURE;
68 HEI_ERR("registerWrite(%p,%p,%lx,%lx,%lx)", i_chip.getChip(),
69 i_buffer, io_bufSize, i_regType, i_address);
70 }
71
72 return rc;
73}
74
75#endif
76
77//------------------------------------------------------------------------------
78
79} // namespace libhei