blob: d880ef4be6f38961e53932689b0ea7d5601b03cf [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
Zane Shelley3a02e242020-05-08 16:25:36 -050046#include <stdlib.h>
47
48#include <hei_chip.hpp>
Zane Shelley465e0b32019-04-17 10:15:39 -050049
Zane Shelley814b1e32019-06-17 20:55:04 -050050namespace libhei
51{
52
53/**
Zane Shelleyca4b2f42019-08-30 15:48:40 -050054 * @brief Performs a hardware register read operation.
55 *
Zane Shelley11b89942019-11-07 11:07:28 -060056 * @param i_chip The target chip for the register access. It is provided to
57 * the isolator by the user application via the isolator main
58 * APIs.
Zane Shelleyca4b2f42019-08-30 15:48:40 -050059 *
60 * @param o_buffer Allocated memory space for the returned contents of the
61 * register.
62 *
63 * @param io_bufSize The input parameter is the maximum size of the allocated
64 * o_buffer. The return value is the number of bytes actually
65 * written to the buffer.
66 *
67 * @param i_regType The user application may support different types of
68 * registers. This value is provided to the isolator by the
69 * user application via the Chip Data Files. The user
70 * application is responsible for knowing what to do with this
71 * parameter.
72 *
73 * @param i_address The register address. The values is a 1, 2, 4, or 8 byte
74 * address (right justified), which is provided to the
75 * isolator by the user application via the Chip Data Files.
76 *
Zane Shelley2f4aa912020-05-08 14:28:18 -050077 * @return false => register access was successful
78 * true => hardware access failure
79 * Note that in the case of a failure, the user application is
80 * responsible for reporting why the register access failed.
Zane Shelley814b1e32019-06-17 20:55:04 -050081 */
Zane Shelley2f4aa912020-05-08 14:28:18 -050082bool registerRead(const Chip& i_chip, void* o_buffer, size_t& io_bufSize,
83 uint64_t i_regType, uint64_t i_address);
Zane Shelley814b1e32019-06-17 20:55:04 -050084
85#ifndef __HEI_READ_ONLY
86
87/**
Zane Shelleyca4b2f42019-08-30 15:48:40 -050088 * @brief Performs a hardware register write operation.
89 *
Zane Shelley11b89942019-11-07 11:07:28 -060090 * @param i_chip The target chip for the register access. It is provided to
91 * the isolator by the user application via the isolator main
92 * APIs.
Zane Shelleyca4b2f42019-08-30 15:48:40 -050093 *
94 * @param i_buffer Allocated memory space containing the register contents to
95 * write to hardware.
96 *
97 * @param io_bufSize The input parameter is the number of byte from i_buffer to
98 * write to the hardware register. The return value is the
99 * actual number of bytes written to the hardware register.
100 *
101 * @param i_regType The user application may support different types of
102 * registers. This value is provided to the isolator by the
103 * user application via the Chip Data Files. The user
104 * application is responsible for knowing what to do with this
105 * parameter.
106 *
107 * @param i_address The register address. The values is a 1, 2, 4, or 8 byte
108 * address (right justified), which is provided to the
109 * isolator by the user application via the Chip Data Files.
110 *
Zane Shelley2f4aa912020-05-08 14:28:18 -0500111 * @return false => register access was successful
112 * true => hardware access failure
113 * Note that in the case of a failure, the user application is
114 * responsible for reporting why the register access failed.
Zane Shelley814b1e32019-06-17 20:55:04 -0500115 */
Zane Shelley2f4aa912020-05-08 14:28:18 -0500116bool registerWrite(const Chip& i_chip, void* i_buffer, size_t& io_bufSize,
117 uint64_t i_regType, uint64_t i_address);
Zane Shelley814b1e32019-06-17 20:55:04 -0500118
Ben Tyner032bf9e2020-05-06 21:27:54 -0500119// used by HEI_INF macro in this library
120void hei_inf(char* format, ...); // implemented in user application
121
122// used by HEI_ERR macro in this library
123void hei_err(char* format, ...); // implemented in user application
124
Zane Shelley814b1e32019-06-17 20:55:04 -0500125#endif
126
127} // end namespace libhei