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