Patrick Venture | 1cde5f9 | 2018-11-07 08:26:47 -0800 | [diff] [blame] | 1 | #include "lpc_handler.hpp" |
| 2 | |
| 3 | #include <cstdint> |
Patrick Venture | 8c53533 | 2018-11-08 15:58:00 -0800 | [diff] [blame] | 4 | #include <cstring> |
Patrick Venture | 1cde5f9 | 2018-11-07 08:26:47 -0800 | [diff] [blame] | 5 | #include <vector> |
| 6 | |
| 7 | namespace blobs |
| 8 | { |
| 9 | |
Patrick Venture | 0d2a813 | 2018-11-09 11:34:21 -0800 | [diff] [blame] | 10 | bool 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 Venture | 0fbabf2 | 2018-11-09 11:54:12 -0800 | [diff] [blame] | 18 | bool LpcDataHandler::close() |
| 19 | { |
| 20 | /* TODO: implement ioctl call to close window. */ |
| 21 | return false; |
| 22 | } |
| 23 | |
Patrick Venture | 1cde5f9 | 2018-11-07 08:26:47 -0800 | [diff] [blame] | 24 | std::vector<std::uint8_t> LpcDataHandler::copyFrom(std::uint32_t length) |
| 25 | { |
Patrick Venture | f904750 | 2018-11-15 08:44:14 -0800 | [diff] [blame^] | 26 | /* 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 Venture | 1cde5f9 | 2018-11-07 08:26:47 -0800 | [diff] [blame] | 34 | return {}; |
| 35 | } |
| 36 | |
Patrick Venture | 8c53533 | 2018-11-08 15:58:00 -0800 | [diff] [blame] | 37 | bool LpcDataHandler::write(const std::vector<std::uint8_t>& configuration) |
| 38 | { |
Patrick Venture | 043bafa | 2018-11-15 08:41:04 -0800 | [diff] [blame] | 39 | struct LpcRegion lpcRegion; |
Patrick Venture | 8c53533 | 2018-11-08 15:58:00 -0800 | [diff] [blame] | 40 | |
Patrick Venture | 043bafa | 2018-11-15 08:41:04 -0800 | [diff] [blame] | 41 | if (configuration.size() != sizeof(lpcRegion)) |
Patrick Venture | 8c53533 | 2018-11-08 15:58:00 -0800 | [diff] [blame] | 42 | { |
| 43 | return false; |
| 44 | } |
| 45 | |
Patrick Venture | 043bafa | 2018-11-15 08:41:04 -0800 | [diff] [blame] | 46 | 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 Venture | 8c53533 | 2018-11-08 15:58:00 -0800 | [diff] [blame] | 59 | |
| 60 | return false; |
| 61 | } |
| 62 | |
| 63 | std::vector<std::uint8_t> LpcDataHandler::read() |
| 64 | { |
| 65 | return {}; |
| 66 | } |
| 67 | |
Patrick Venture | 1cde5f9 | 2018-11-07 08:26:47 -0800 | [diff] [blame] | 68 | } // namespace blobs |