blob: 9fa908dd2aa4b9b46f7348c0506a69e89b9a1135 [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 *
75 * @return RC_SUCCESS or RC_REG_ACCESS_FAILURE. Note that in the case of a
76 * failure the user application is responsible for reporting why the
77 * register access failed.
Zane Shelley814b1e32019-06-17 20:55:04 -050078 */
Zane Shelley11b89942019-11-07 11:07:28 -060079ReturnCode registerRead(const Chip& i_chip, void* o_buffer, size_t& io_bufSize,
Zane Shelley83da2452019-10-25 15:45:34 -050080 uint64_t i_regType, uint64_t i_address);
Zane Shelley814b1e32019-06-17 20:55:04 -050081
82#ifndef __HEI_READ_ONLY
83
84/**
Zane Shelleyca4b2f42019-08-30 15:48:40 -050085 * @brief Performs a hardware register write operation.
86 *
Zane Shelley11b89942019-11-07 11:07:28 -060087 * @param i_chip The target chip for the register access. It is provided to
88 * the isolator by the user application via the isolator main
89 * APIs.
Zane Shelleyca4b2f42019-08-30 15:48:40 -050090 *
91 * @param i_buffer Allocated memory space containing the register contents to
92 * write to hardware.
93 *
94 * @param io_bufSize The input parameter is the number of byte from i_buffer to
95 * write to the hardware register. The return value is the
96 * actual number of bytes written to the hardware register.
97 *
98 * @param i_regType The user application may support different types of
99 * registers. This value is provided to the isolator by the
100 * user application via the Chip Data Files. The user
101 * application is responsible for knowing what to do with this
102 * parameter.
103 *
104 * @param i_address The register address. The values is a 1, 2, 4, or 8 byte
105 * address (right justified), which is provided to the
106 * isolator by the user application via the Chip Data Files.
107 *
108 * @return RC_SUCCESS or RC_REG_ACCESS_FAILURE. Note that in the case of a
109 * failure the user application is responsible for reporting why the
110 * register access failed.
Zane Shelley814b1e32019-06-17 20:55:04 -0500111 */
Zane Shelley11b89942019-11-07 11:07:28 -0600112ReturnCode registerWrite(const Chip& i_chip, void* i_buffer, size_t& io_bufSize,
Zane Shelley83da2452019-10-25 15:45:34 -0500113 uint64_t i_regType, uint64_t i_address);
Zane Shelley814b1e32019-06-17 20:55:04 -0500114
Ben Tyner032bf9e2020-05-06 21:27:54 -0500115// used by HEI_INF macro in this library
116void hei_inf(char* format, ...); // implemented in user application
117
118// used by HEI_ERR macro in this library
119void hei_err(char* format, ...); // implemented in user application
120
Zane Shelley814b1e32019-06-17 20:55:04 -0500121#endif
122
123} // end namespace libhei