blob: 71cf24dd7a6349e63a00e62b69c70f6322767a40 [file] [log] [blame]
Patrick Venture1cde5f92018-11-07 08:26:47 -08001#include "lpc_handler.hpp"
2
3#include <cstdint>
Patrick Venture8c535332018-11-08 15:58:00 -08004#include <cstring>
Patrick Venture1cde5f92018-11-07 08:26:47 -08005#include <vector>
6
7namespace blobs
8{
9
Patrick Venture0d2a8132018-11-09 11:34:21 -080010bool LpcDataHandler::open()
11{
12 /* For the ASPEED LPC CTRL driver, the ioctl is required to set up the
13 * window, with information from write() below.
14 */
15 return true;
16}
17
Patrick Venture0fbabf22018-11-09 11:54:12 -080018bool LpcDataHandler::close()
19{
20 /* TODO: implement ioctl call to close window. */
21 return false;
22}
23
Patrick Venture1cde5f92018-11-07 08:26:47 -080024std::vector<std::uint8_t> LpcDataHandler::copyFrom(std::uint32_t length)
25{
Patrick Venturef9047502018-11-15 08:44:14 -080026 /* TODO: implement this -- in an earlier and different version of this that
27 * didn't use BLOBs, the region was memory-mapped and the writes to the data
28 * were just done directly from the memory-mapped region instead of a
29 * copyFrom() first call. The idea with this change is that we may not be
30 * able to get a memory-mapped handle from the driver from which to
31 * automatically read data, but rather must perform some ioctl or other
32 * access to get the data from the driver.
33 */
Patrick Venture1cde5f92018-11-07 08:26:47 -080034 return {};
35}
36
Patrick Venture8c535332018-11-08 15:58:00 -080037bool LpcDataHandler::write(const std::vector<std::uint8_t>& configuration)
38{
Patrick Venture043bafa2018-11-15 08:41:04 -080039 struct LpcRegion lpcRegion;
Patrick Venture8c535332018-11-08 15:58:00 -080040
Patrick Venture043bafa2018-11-15 08:41:04 -080041 if (configuration.size() != sizeof(lpcRegion))
Patrick Venture8c535332018-11-08 15:58:00 -080042 {
43 return false;
44 }
45
Patrick Venture043bafa2018-11-15 08:41:04 -080046 std::memcpy(&lpcRegion, configuration.data(), configuration.size());
47
48 std::uint32_t windowOffset;
49 std::uint32_t windowSize;
50
51 /* TODO: LpcRegion sanity checking. */
52
53 std::tie(windowOffset, windowSize) =
54 mapper->mapWindow(lpcRegion.address, lpcRegion.length);
55 if (windowSize == 0)
56 {
57 /* Failed to map region. */
58 }
Patrick Venture8c535332018-11-08 15:58:00 -080059
60 return false;
61}
62
63std::vector<std::uint8_t> LpcDataHandler::read()
64{
65 return {};
66}
67
Patrick Venture1cde5f92018-11-07 08:26:47 -080068} // namespace blobs