Zane Shelley | 11b8994 | 2019-11-07 11:07:28 -0600 | [diff] [blame] | 1 | /** |
| 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> |
Zane Shelley | d507351 | 2021-01-14 12:51:18 -0600 | [diff] [blame] | 11 | #include <util/hei_includes.hpp> |
Zane Shelley | 11b8994 | 2019-11-07 11:07:28 -0600 | [diff] [blame] | 12 | |
| 13 | namespace libhei |
| 14 | { |
| 15 | |
| 16 | //------------------------------------------------------------------------------ |
| 17 | |
Zane Shelley | 2d4981a | 2020-06-04 14:32:45 -0500 | [diff] [blame] | 18 | bool registerRead(const Chip& i_chip, RegisterType_t i_regType, |
| 19 | uint64_t i_address, uint64_t& o_value) |
Zane Shelley | 11b8994 | 2019-11-07 11:07:28 -0600 | [diff] [blame] | 20 | { |
Zane Shelley | 2f4aa91 | 2020-05-08 14:28:18 -0500 | [diff] [blame] | 21 | bool accessFailure = false; |
Zane Shelley | 11b8994 | 2019-11-07 11:07:28 -0600 | [diff] [blame] | 22 | |
Zane Shelley | 2d4981a | 2020-06-04 14:32:45 -0500 | [diff] [blame] | 23 | // Get access to data through the singleton. |
Paul Greenwood | c091934 | 2019-12-10 15:36:17 -0600 | [diff] [blame] | 24 | SimulatorData& theSimData = SimulatorData::getSingleton(); |
| 25 | |
Zane Shelley | 11b8994 | 2019-11-07 11:07:28 -0600 | [diff] [blame] | 26 | switch (i_regType) |
| 27 | { |
Zane Shelley | 11b8994 | 2019-11-07 11:07:28 -0600 | [diff] [blame] | 28 | case REG_TYPE_SCOM: |
Zane Shelley | 2d4981a | 2020-06-04 14:32:45 -0500 | [diff] [blame] | 29 | o_value = theSimData.getScomReg(i_chip, (uint32_t)i_address); |
Zane Shelley | 11b8994 | 2019-11-07 11:07:28 -0600 | [diff] [blame] | 30 | break; |
Zane Shelley | 11b8994 | 2019-11-07 11:07:28 -0600 | [diff] [blame] | 31 | case REG_TYPE_ID_SCOM: |
Zane Shelley | 2d4981a | 2020-06-04 14:32:45 -0500 | [diff] [blame] | 32 | o_value = theSimData.getIdScomReg(i_chip, i_address); |
Zane Shelley | 11b8994 | 2019-11-07 11:07:28 -0600 | [diff] [blame] | 33 | break; |
Zane Shelley | 11b8994 | 2019-11-07 11:07:28 -0600 | [diff] [blame] | 34 | default: |
Zane Shelley | 2f4aa91 | 2020-05-08 14:28:18 -0500 | [diff] [blame] | 35 | accessFailure = true; |
Zane Shelley | 2d4981a | 2020-06-04 14:32:45 -0500 | [diff] [blame] | 36 | HEI_ERR("registerRead(%p,%" PRIu8 ",%" PRIx64 ")", i_chip.getChip(), |
| 37 | i_regType, i_address); |
Zane Shelley | 11b8994 | 2019-11-07 11:07:28 -0600 | [diff] [blame] | 38 | } |
| 39 | |
Zane Shelley | 2f4aa91 | 2020-05-08 14:28:18 -0500 | [diff] [blame] | 40 | return accessFailure; |
Zane Shelley | 11b8994 | 2019-11-07 11:07:28 -0600 | [diff] [blame] | 41 | } |
| 42 | |
| 43 | //------------------------------------------------------------------------------ |
| 44 | |
Ben Tyner | 7b3420b | 2020-05-11 10:52:07 -0500 | [diff] [blame] | 45 | #ifdef __HEI_ENABLE_HW_WRITE |
Zane Shelley | 11b8994 | 2019-11-07 11:07:28 -0600 | [diff] [blame] | 46 | |
Zane Shelley | 2d4981a | 2020-06-04 14:32:45 -0500 | [diff] [blame] | 47 | bool registerWrite(const Chip& i_chip, RegisterType_t i_regType, |
| 48 | uint64_t i_address, uint64_t i_value) |
Zane Shelley | 11b8994 | 2019-11-07 11:07:28 -0600 | [diff] [blame] | 49 | { |
Zane Shelley | 2f4aa91 | 2020-05-08 14:28:18 -0500 | [diff] [blame] | 50 | bool accessFailure = false; |
Zane Shelley | 11b8994 | 2019-11-07 11:07:28 -0600 | [diff] [blame] | 51 | |
Zane Shelley | 11b8994 | 2019-11-07 11:07:28 -0600 | [diff] [blame] | 52 | switch (i_regType) |
| 53 | { |
| 54 | // TODO: add cases for REG_TYPE_SCOM and REG_TYPE_ID_SCOM |
| 55 | default: |
Zane Shelley | 2f4aa91 | 2020-05-08 14:28:18 -0500 | [diff] [blame] | 56 | accessFailure = true; |
Zane Shelley | 2d4981a | 2020-06-04 14:32:45 -0500 | [diff] [blame] | 57 | HEI_ERR("registerWrite(%p,%" PRIu8 ",%" PRIx64 ",%" PRIx64 ")", |
| 58 | i_chip.getChip(), i_regType, i_address, i_value); |
Zane Shelley | 11b8994 | 2019-11-07 11:07:28 -0600 | [diff] [blame] | 59 | } |
| 60 | |
Zane Shelley | 2f4aa91 | 2020-05-08 14:28:18 -0500 | [diff] [blame] | 61 | return accessFailure; |
Zane Shelley | 11b8994 | 2019-11-07 11:07:28 -0600 | [diff] [blame] | 62 | } |
| 63 | |
Ben Tyner | 7b3420b | 2020-05-11 10:52:07 -0500 | [diff] [blame] | 64 | #endif // __HEI_ENABLE_HW_WRITE |
Zane Shelley | 11b8994 | 2019-11-07 11:07:28 -0600 | [diff] [blame] | 65 | |
| 66 | //------------------------------------------------------------------------------ |
| 67 | |
| 68 | } // namespace libhei |