blob: 8ed0af5ba0155642b33b66ecffb58150a16a21f2 [file] [log] [blame]
Patrick Ventured6b337e2021-04-16 14:37:57 -07001#pragma once
2
Patrick Venture22900332021-04-16 15:17:46 -07003#include <cstdlib>
Patrick Ventured6b337e2021-04-16 14:37:57 -07004
5namespace host_tool
6{
7
8class HostIoInterface
9{
10 public:
11 virtual ~HostIoInterface() = default;
12
13 /**
14 * Attempt to read bytes from offset to the destination from the host
15 * memory device.
16 *
17 * @param[in] offset - offset into the host memory device.
18 * @param[in] length - the number of bytes to copy from source.
19 * @param[in] destination - where to write the bytes.
20 * @return true on success, false on failure (such as unable to initialize
21 * device).
22 */
23 virtual bool read(const std::size_t offset, const std::size_t length,
24 void* const destination) = 0;
25
26 /**
27 * Attempt to write bytes from source to offset into the host memory device.
28 *
29 * @param[in] offset - offset into the host memory device.
30 * @param[in] length - the number of bytes to copy from source.
Manojkiran Eda166b4f12024-06-17 10:35:24 +053031 * @param[in] source - the source of the bytes to copy to the memory device.
Patrick Ventured6b337e2021-04-16 14:37:57 -070032 * @return true on success, false on failure (such as unable to initialize
33 * device).
34 */
35 virtual bool write(const std::size_t offset, const std::size_t length,
36 const void* const source) = 0;
37};
38
39} // namespace host_tool