Zane Shelley | 465e0b3 | 2019-04-17 10:15:39 -0500 | [diff] [blame] | 1 | #pragma once |
| 2 | |
Zane Shelley | ca4b2f4 | 2019-08-30 15:48:40 -0500 | [diff] [blame] | 3 | /** |
| 4 | * @file hei_user_interface.hpp |
| 5 | * |
Zane Shelley | 7649b8b | 2020-05-08 20:12:35 -0500 | [diff] [blame] | 6 | * The process for actions like hardware register access will vary per user |
Zane Shelley | ca4b2f4 | 2019-08-30 15:48:40 -0500 | [diff] [blame] | 7 | * application. Therefore, the user application must define all of the APIs |
Zane Shelley | 7649b8b | 2020-05-08 20:12:35 -0500 | [diff] [blame] | 8 | * declared in this header file. |
Zane Shelley | ca4b2f4 | 2019-08-30 15:48:40 -0500 | [diff] [blame] | 9 | */ |
| 10 | |
Zane Shelley | 3a02e24 | 2020-05-08 16:25:36 -0500 | [diff] [blame] | 11 | #include <stdlib.h> |
| 12 | |
| 13 | #include <hei_chip.hpp> |
Zane Shelley | 2d4981a | 2020-06-04 14:32:45 -0500 | [diff] [blame] | 14 | #include <hei_types.hpp> |
Zane Shelley | 465e0b3 | 2019-04-17 10:15:39 -0500 | [diff] [blame] | 15 | |
Zane Shelley | 814b1e3 | 2019-06-17 20:55:04 -0500 | [diff] [blame] | 16 | namespace libhei |
| 17 | { |
| 18 | |
| 19 | /** |
Zane Shelley | ca4b2f4 | 2019-08-30 15:48:40 -0500 | [diff] [blame] | 20 | * @brief Performs a hardware register read operation. |
| 21 | * |
Zane Shelley | 11b8994 | 2019-11-07 11:07:28 -0600 | [diff] [blame] | 22 | * @param i_chip The target chip for the register access. It is provided to |
| 23 | * the isolator by the user application via the isolator main |
| 24 | * APIs. |
Zane Shelley | ca4b2f4 | 2019-08-30 15:48:40 -0500 | [diff] [blame] | 25 | * |
Zane Shelley | ca4b2f4 | 2019-08-30 15:48:40 -0500 | [diff] [blame] | 26 | * @param i_regType The user application may support different types of |
| 27 | * registers. This value is provided to the isolator by the |
| 28 | * user application via the Chip Data Files. The user |
| 29 | * application is responsible for knowing what to do with this |
| 30 | * parameter. |
| 31 | * |
Zane Shelley | 2d4981a | 2020-06-04 14:32:45 -0500 | [diff] [blame] | 32 | * @param i_address The register address, which is provided to the isolator by |
| 33 | * the user application via the Chip Data Files. This is a 1, |
| 34 | * 2, 4, or 8 byte value (right justified) as defined by the |
| 35 | * register type. |
| 36 | * |
| 37 | * @param o_value The returned register value. This is a 1, 2, 4, or 8 byte |
| 38 | * value (right justified) as defined by the register type. |
Zane Shelley | ca4b2f4 | 2019-08-30 15:48:40 -0500 | [diff] [blame] | 39 | * |
Zane Shelley | 2f4aa91 | 2020-05-08 14:28:18 -0500 | [diff] [blame] | 40 | * @return false => register access was successful |
| 41 | * true => hardware access failure |
| 42 | * Note that in the case of a failure, the user application is |
| 43 | * responsible for reporting why the register access failed. |
Zane Shelley | 814b1e3 | 2019-06-17 20:55:04 -0500 | [diff] [blame] | 44 | */ |
Zane Shelley | 2d4981a | 2020-06-04 14:32:45 -0500 | [diff] [blame] | 45 | bool registerRead(const Chip& i_chip, RegisterType_t i_regType, |
| 46 | uint64_t i_address, uint64_t& o_value); |
Zane Shelley | 814b1e3 | 2019-06-17 20:55:04 -0500 | [diff] [blame] | 47 | |
Ben Tyner | 7b3420b | 2020-05-11 10:52:07 -0500 | [diff] [blame] | 48 | #ifdef __HEI_ENABLE_HW_WRITE |
Zane Shelley | 814b1e3 | 2019-06-17 20:55:04 -0500 | [diff] [blame] | 49 | |
| 50 | /** |
Zane Shelley | ca4b2f4 | 2019-08-30 15:48:40 -0500 | [diff] [blame] | 51 | * @brief Performs a hardware register write operation. |
| 52 | * |
Zane Shelley | 11b8994 | 2019-11-07 11:07:28 -0600 | [diff] [blame] | 53 | * @param i_chip The target chip for the register access. It is provided to |
| 54 | * the isolator by the user application via the isolator main |
| 55 | * APIs. |
Zane Shelley | ca4b2f4 | 2019-08-30 15:48:40 -0500 | [diff] [blame] | 56 | * |
Zane Shelley | ca4b2f4 | 2019-08-30 15:48:40 -0500 | [diff] [blame] | 57 | * @param i_regType The user application may support different types of |
| 58 | * registers. This value is provided to the isolator by the |
| 59 | * user application via the Chip Data Files. The user |
| 60 | * application is responsible for knowing what to do with this |
| 61 | * parameter. |
| 62 | * |
Zane Shelley | 2d4981a | 2020-06-04 14:32:45 -0500 | [diff] [blame] | 63 | * @param i_address The register address, which is provided to the isolator by |
| 64 | * the user application via the Chip Data Files. This is a 1, |
| 65 | * 2, 4, or 8 byte value (right justified) as defined by the |
| 66 | * register type. |
| 67 | * |
| 68 | * @param i_value The register value to write. This is a 1, 2, 4, or 8 byte |
| 69 | * value (right justified) as defined by the register type. |
Zane Shelley | ca4b2f4 | 2019-08-30 15:48:40 -0500 | [diff] [blame] | 70 | * |
Zane Shelley | 2f4aa91 | 2020-05-08 14:28:18 -0500 | [diff] [blame] | 71 | * @return false => register access was successful |
| 72 | * true => hardware access failure |
| 73 | * Note that in the case of a failure, the user application is |
| 74 | * responsible for reporting why the register access failed. |
Zane Shelley | 814b1e3 | 2019-06-17 20:55:04 -0500 | [diff] [blame] | 75 | */ |
Zane Shelley | 2d4981a | 2020-06-04 14:32:45 -0500 | [diff] [blame] | 76 | bool registerWrite(const Chip& i_chip, RegisterType_t i_regType, |
| 77 | uint64_t i_address, uint64_t i_value); |
Zane Shelley | 814b1e3 | 2019-06-17 20:55:04 -0500 | [diff] [blame] | 78 | |
Ben Tyner | 7b3420b | 2020-05-11 10:52:07 -0500 | [diff] [blame] | 79 | #endif // __HEI_ENABLE_HW_WRITE |
Zane Shelley | 814b1e3 | 2019-06-17 20:55:04 -0500 | [diff] [blame] | 80 | |
Zane Shelley | 7649b8b | 2020-05-08 20:12:35 -0500 | [diff] [blame] | 81 | /** |
| 82 | * @brief Prints an informational trace/log. |
| 83 | * |
| 84 | * This is similar to printing a single line of text to stdout. Example |
| 85 | * implementation: |
| 86 | * void hei_inf(char* format, ...) |
| 87 | * { |
| 88 | * va_list args; |
| 89 | * va_start(args, format); |
| 90 | * vfprintf(stdout, format, args); |
| 91 | * va_end(args); |
| 92 | * fprintf(stdout, "\n"); |
| 93 | * } |
| 94 | * |
| 95 | * @param i_format The string format and variatic arguments. |
| 96 | */ |
| 97 | void hei_inf(char* i_format, ...); |
| 98 | |
| 99 | /** |
| 100 | * @brief Prints an error trace/log. |
| 101 | * |
| 102 | * This is similar to printing a single line of text to stderr. Example |
| 103 | * implementation: |
| 104 | * void hei_inf(char* format, ...) |
| 105 | * { |
| 106 | * va_list args; |
| 107 | * va_start(args, format); |
| 108 | * vfprintf(stderr, format, args); |
| 109 | * va_end(args); |
| 110 | * fprintf(stderr, "\n"); |
| 111 | * } |
| 112 | * |
| 113 | * @param i_format The string format and variatic arguments. |
| 114 | */ |
| 115 | void hei_err(char* i_format, ...); |
| 116 | |
Zane Shelley | 814b1e3 | 2019-06-17 20:55:04 -0500 | [diff] [blame] | 117 | } // end namespace libhei |