blob: b82d16a07e5969c81bd1e0aa64766cb23da2f89d [file] [log] [blame]
Patrick Venture22e38752018-11-21 08:52:49 -08001/*
2 * Copyright 2018 Google Inc.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
Patrick Venture1cde5f92018-11-07 08:26:47 -080017#include "pci_handler.hpp"
18
19#include <cstdint>
Patrick Venturea8a99ae2018-11-09 11:14:58 -080020#include <cstring>
Patrick Venturebc40c612019-04-30 16:48:19 -070021#include <string>
Patrick Venture1cde5f92018-11-07 08:26:47 -080022#include <vector>
23
24namespace blobs
25{
26
Patrick Venturebc40c612019-04-30 16:48:19 -070027const std::string PciDataHandler::p2aControlPath = "/dev/aspeed-p2a-ctrl";
28
Patrick Venture0d2a8132018-11-09 11:34:21 -080029bool PciDataHandler::open()
30{
Patrick Venture0fbabf22018-11-09 11:54:12 -080031 /* TODO: For the ASPEED P2A driver, this method will enable the memory
32 * region to use.
33 */
34 return false;
35}
36
37bool PciDataHandler::close()
38{
39 /* TODO: Turn off the P2A bridge and region to disable host-side access.
Patrick Venture0d2a8132018-11-09 11:34:21 -080040 */
41 return false;
42}
43
Patrick Venture1cde5f92018-11-07 08:26:47 -080044std::vector<std::uint8_t> PciDataHandler::copyFrom(std::uint32_t length)
45{
46 /* TODO: implement this. */
47 return {};
48}
49
Patrick Venture74304642019-01-17 09:31:04 -080050bool PciDataHandler::writeMeta(const std::vector<std::uint8_t>& configuration)
Patrick Venture8c535332018-11-08 15:58:00 -080051{
52 /* PCI handler doesn't require configuration write, only read. */
53 return false;
54}
55
Patrick Venture74304642019-01-17 09:31:04 -080056std::vector<std::uint8_t> PciDataHandler::readMeta()
Patrick Venture8c535332018-11-08 15:58:00 -080057{
58 /* PCI handler does require returning a configuration from read. */
59 struct PciConfigResponse reply;
Patrick Ventureb0c84d02018-11-09 12:00:31 -080060 reply.address = regionAddress;
Patrick Venture8c535332018-11-08 15:58:00 -080061
62 std::vector<std::uint8_t> bytes;
63 bytes.resize(sizeof(reply));
Patrick Venturea8a99ae2018-11-09 11:14:58 -080064 std::memcpy(bytes.data(), &reply, sizeof(reply));
Patrick Venture8c535332018-11-08 15:58:00 -080065
66 return bytes;
67}
68
Patrick Venture1cde5f92018-11-07 08:26:47 -080069} // namespace blobs