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 | * |
| 6 | * The method for actions like hardware register access will vary per user |
| 7 | * application. Therefore, the user application must define all of the APIs |
| 8 | * listed below. |
Ben Tyner | 032bf9e | 2020-05-06 21:27:54 -0500 | [diff] [blame] | 9 | * |
| 10 | * 1. ReturnCode libhei::registerRead(const Chip& i_chip, void* o_buffer, |
| 11 | * size_t& io_bufSize, uint64_t i_regType, |
| 12 | * uint64_t i_address); |
| 13 | * |
| 14 | * 2. ReturnCode libhei::registerWrite(const Chip& i_chip, void* i_buffer, |
| 15 | * size_t& io_bufSize, uint64_t i_regType, |
| 16 | * uint64_t i_address); |
| 17 | * |
| 18 | * 3. void libhei::hei_inf(...) |
| 19 | * 4. void libhei::hei_err(...) |
| 20 | * |
| 21 | * Example user application implementation of hei_inf(...) and hei_err(...) |
| 22 | * |
| 23 | * void hei_inf(char* format, ...) |
| 24 | * { |
| 25 | * va_list args; |
| 26 | * |
| 27 | * printf("I> "); |
| 28 | * va_start(args, format); |
| 29 | * vprintf(format, args); |
| 30 | * va_end(args); |
| 31 | * printf("\n"); |
| 32 | * } |
| 33 | * |
| 34 | * void hei_err(char* format, ...) |
| 35 | * { |
| 36 | * va_list args; |
| 37 | * |
| 38 | * printf("E> "); |
| 39 | * va_start(args, format); |
| 40 | * vprintf(format, args); |
| 41 | * va_end(args); |
| 42 | * printf("\n"); |
| 43 | * } |
Zane Shelley | ca4b2f4 | 2019-08-30 15:48:40 -0500 | [diff] [blame] | 44 | */ |
| 45 | |
| 46 | #include <hei_includes.hpp> |
Zane Shelley | 465e0b3 | 2019-04-17 10:15:39 -0500 | [diff] [blame] | 47 | |
Zane Shelley | 814b1e3 | 2019-06-17 20:55:04 -0500 | [diff] [blame] | 48 | namespace libhei |
| 49 | { |
| 50 | |
| 51 | /** |
Zane Shelley | ca4b2f4 | 2019-08-30 15:48:40 -0500 | [diff] [blame] | 52 | * @brief Performs a hardware register read operation. |
| 53 | * |
Zane Shelley | 11b8994 | 2019-11-07 11:07:28 -0600 | [diff] [blame] | 54 | * @param i_chip The target chip for the register access. It is provided to |
| 55 | * the isolator by the user application via the isolator main |
| 56 | * APIs. |
Zane Shelley | ca4b2f4 | 2019-08-30 15:48:40 -0500 | [diff] [blame] | 57 | * |
| 58 | * @param o_buffer Allocated memory space for the returned contents of the |
| 59 | * register. |
| 60 | * |
| 61 | * @param io_bufSize The input parameter is the maximum size of the allocated |
| 62 | * o_buffer. The return value is the number of bytes actually |
| 63 | * written to the buffer. |
| 64 | * |
| 65 | * @param i_regType The user application may support different types of |
| 66 | * registers. This value is provided to the isolator by the |
| 67 | * user application via the Chip Data Files. The user |
| 68 | * application is responsible for knowing what to do with this |
| 69 | * parameter. |
| 70 | * |
| 71 | * @param i_address The register address. The values is a 1, 2, 4, or 8 byte |
| 72 | * address (right justified), which is provided to the |
| 73 | * isolator by the user application via the Chip Data Files. |
| 74 | * |
Zane Shelley | 2f4aa91 | 2020-05-08 14:28:18 -0500 | [diff] [blame^] | 75 | * @return false => register access was successful |
| 76 | * true => hardware access failure |
| 77 | * Note that in the case of a failure, the user application is |
| 78 | * responsible for reporting why the register access failed. |
Zane Shelley | 814b1e3 | 2019-06-17 20:55:04 -0500 | [diff] [blame] | 79 | */ |
Zane Shelley | 2f4aa91 | 2020-05-08 14:28:18 -0500 | [diff] [blame^] | 80 | bool registerRead(const Chip& i_chip, void* o_buffer, size_t& io_bufSize, |
| 81 | uint64_t i_regType, uint64_t i_address); |
Zane Shelley | 814b1e3 | 2019-06-17 20:55:04 -0500 | [diff] [blame] | 82 | |
| 83 | #ifndef __HEI_READ_ONLY |
| 84 | |
| 85 | /** |
Zane Shelley | ca4b2f4 | 2019-08-30 15:48:40 -0500 | [diff] [blame] | 86 | * @brief Performs a hardware register write operation. |
| 87 | * |
Zane Shelley | 11b8994 | 2019-11-07 11:07:28 -0600 | [diff] [blame] | 88 | * @param i_chip The target chip for the register access. It is provided to |
| 89 | * the isolator by the user application via the isolator main |
| 90 | * APIs. |
Zane Shelley | ca4b2f4 | 2019-08-30 15:48:40 -0500 | [diff] [blame] | 91 | * |
| 92 | * @param i_buffer Allocated memory space containing the register contents to |
| 93 | * write to hardware. |
| 94 | * |
| 95 | * @param io_bufSize The input parameter is the number of byte from i_buffer to |
| 96 | * write to the hardware register. The return value is the |
| 97 | * actual number of bytes written to the hardware register. |
| 98 | * |
| 99 | * @param i_regType The user application may support different types of |
| 100 | * registers. This value is provided to the isolator by the |
| 101 | * user application via the Chip Data Files. The user |
| 102 | * application is responsible for knowing what to do with this |
| 103 | * parameter. |
| 104 | * |
| 105 | * @param i_address The register address. The values is a 1, 2, 4, or 8 byte |
| 106 | * address (right justified), which is provided to the |
| 107 | * isolator by the user application via the Chip Data Files. |
| 108 | * |
Zane Shelley | 2f4aa91 | 2020-05-08 14:28:18 -0500 | [diff] [blame^] | 109 | * @return false => register access was successful |
| 110 | * true => hardware access failure |
| 111 | * Note that in the case of a failure, the user application is |
| 112 | * responsible for reporting why the register access failed. |
Zane Shelley | 814b1e3 | 2019-06-17 20:55:04 -0500 | [diff] [blame] | 113 | */ |
Zane Shelley | 2f4aa91 | 2020-05-08 14:28:18 -0500 | [diff] [blame^] | 114 | bool registerWrite(const Chip& i_chip, void* i_buffer, size_t& io_bufSize, |
| 115 | uint64_t i_regType, uint64_t i_address); |
Zane Shelley | 814b1e3 | 2019-06-17 20:55:04 -0500 | [diff] [blame] | 116 | |
Ben Tyner | 032bf9e | 2020-05-06 21:27:54 -0500 | [diff] [blame] | 117 | // used by HEI_INF macro in this library |
| 118 | void hei_inf(char* format, ...); // implemented in user application |
| 119 | |
| 120 | // used by HEI_ERR macro in this library |
| 121 | void hei_err(char* format, ...); // implemented in user application |
| 122 | |
Zane Shelley | 814b1e3 | 2019-06-17 20:55:04 -0500 | [diff] [blame] | 123 | #endif |
| 124 | |
| 125 | } // end namespace libhei |