blob: e8740f3a34f8bd57995d5d3180d71bcab179eeb6 [file] [log] [blame]
Zane Shelley465e0b32019-04-17 10:15:39 -05001#pragma once
2
Zane Shelleyca4b2f42019-08-30 15:48:40 -05003/**
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 Tyner032bf9e2020-05-06 21:27:54 -05009 *
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 Shelleyca4b2f42019-08-30 15:48:40 -050044 */
45
46#include <hei_includes.hpp>
Zane Shelley465e0b32019-04-17 10:15:39 -050047
Zane Shelley814b1e32019-06-17 20:55:04 -050048namespace libhei
49{
50
51/**
Zane Shelleyca4b2f42019-08-30 15:48:40 -050052 * @brief Performs a hardware register read operation.
53 *
Zane Shelley11b89942019-11-07 11:07:28 -060054 * @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 Shelleyca4b2f42019-08-30 15:48:40 -050057 *
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 Shelley2f4aa912020-05-08 14:28:18 -050075 * @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 Shelley814b1e32019-06-17 20:55:04 -050079 */
Zane Shelley2f4aa912020-05-08 14:28:18 -050080bool registerRead(const Chip& i_chip, void* o_buffer, size_t& io_bufSize,
81 uint64_t i_regType, uint64_t i_address);
Zane Shelley814b1e32019-06-17 20:55:04 -050082
83#ifndef __HEI_READ_ONLY
84
85/**
Zane Shelleyca4b2f42019-08-30 15:48:40 -050086 * @brief Performs a hardware register write operation.
87 *
Zane Shelley11b89942019-11-07 11:07:28 -060088 * @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 Shelleyca4b2f42019-08-30 15:48:40 -050091 *
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 Shelley2f4aa912020-05-08 14:28:18 -0500109 * @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 Shelley814b1e32019-06-17 20:55:04 -0500113 */
Zane Shelley2f4aa912020-05-08 14:28:18 -0500114bool registerWrite(const Chip& i_chip, void* i_buffer, size_t& io_bufSize,
115 uint64_t i_regType, uint64_t i_address);
Zane Shelley814b1e32019-06-17 20:55:04 -0500116
Ben Tyner032bf9e2020-05-06 21:27:54 -0500117// used by HEI_INF macro in this library
118void hei_inf(char* format, ...); // implemented in user application
119
120// used by HEI_ERR macro in this library
121void hei_err(char* format, ...); // implemented in user application
122
Zane Shelley814b1e32019-06-17 20:55:04 -0500123#endif
124
125} // end namespace libhei