blob: 17bccb1f84b8b7a73f25a08ba75df16c2c0b08c6 [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 *
Zane Shelley7649b8b2020-05-08 20:12:35 -05006 * The process for actions like hardware register access will vary per user
Zane Shelleyca4b2f42019-08-30 15:48:40 -05007 * application. Therefore, the user application must define all of the APIs
Zane Shelley7649b8b2020-05-08 20:12:35 -05008 * declared in this header file.
Zane Shelleyca4b2f42019-08-30 15:48:40 -05009 */
10
Zane Shelley3a02e242020-05-08 16:25:36 -050011#include <stdlib.h>
12
13#include <hei_chip.hpp>
Zane Shelley465e0b32019-04-17 10:15:39 -050014
Zane Shelley814b1e32019-06-17 20:55:04 -050015namespace libhei
16{
17
18/**
Zane Shelleyca4b2f42019-08-30 15:48:40 -050019 * @brief Performs a hardware register read operation.
20 *
Zane Shelley11b89942019-11-07 11:07:28 -060021 * @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 Shelleyca4b2f42019-08-30 15:48:40 -050024 *
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 Shelley2f4aa912020-05-08 14:28:18 -050042 * @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 Shelley814b1e32019-06-17 20:55:04 -050046 */
Zane Shelley2f4aa912020-05-08 14:28:18 -050047bool registerRead(const Chip& i_chip, void* o_buffer, size_t& io_bufSize,
48 uint64_t i_regType, uint64_t i_address);
Zane Shelley814b1e32019-06-17 20:55:04 -050049
50#ifndef __HEI_READ_ONLY
51
52/**
Zane Shelleyca4b2f42019-08-30 15:48:40 -050053 * @brief Performs a hardware register write operation.
54 *
Zane Shelley11b89942019-11-07 11:07:28 -060055 * @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 Shelleyca4b2f42019-08-30 15:48:40 -050058 *
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 Shelley2f4aa912020-05-08 14:28:18 -050076 * @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 Shelley814b1e32019-06-17 20:55:04 -050080 */
Zane Shelley2f4aa912020-05-08 14:28:18 -050081bool registerWrite(const Chip& i_chip, void* i_buffer, size_t& io_bufSize,
82 uint64_t i_regType, uint64_t i_address);
Zane Shelley814b1e32019-06-17 20:55:04 -050083
84#endif
85
Zane Shelley7649b8b2020-05-08 20:12:35 -050086/**
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 */
102void 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 */
120void hei_err(char* i_format, ...);
121
Zane Shelley814b1e32019-06-17 20:55:04 -0500122} // end namespace libhei