blob: 0aebb3f3293a1b37a03ac7265916c878f7fe45d8 [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 Venture043bafa2018-11-15 08:41:04 -080026 /* TODO: implement this */
Patrick Venture1cde5f92018-11-07 08:26:47 -080027 return {};
28}
29
Patrick Venture8c535332018-11-08 15:58:00 -080030bool LpcDataHandler::write(const std::vector<std::uint8_t>& configuration)
31{
Patrick Venture043bafa2018-11-15 08:41:04 -080032 struct LpcRegion lpcRegion;
Patrick Venture8c535332018-11-08 15:58:00 -080033
Patrick Venture043bafa2018-11-15 08:41:04 -080034 if (configuration.size() != sizeof(lpcRegion))
Patrick Venture8c535332018-11-08 15:58:00 -080035 {
36 return false;
37 }
38
Patrick Venture043bafa2018-11-15 08:41:04 -080039 std::memcpy(&lpcRegion, configuration.data(), configuration.size());
40
41 std::uint32_t windowOffset;
42 std::uint32_t windowSize;
43
44 /* TODO: LpcRegion sanity checking. */
45
46 std::tie(windowOffset, windowSize) =
47 mapper->mapWindow(lpcRegion.address, lpcRegion.length);
48 if (windowSize == 0)
49 {
50 /* Failed to map region. */
51 }
Patrick Venture8c535332018-11-08 15:58:00 -080052
53 return false;
54}
55
56std::vector<std::uint8_t> LpcDataHandler::read()
57{
58 return {};
59}
60
Patrick Venture1cde5f92018-11-07 08:26:47 -080061} // namespace blobs