blob: 3f9b99f912562f539202714a576ff7800b4d2866 [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 Venture1cde5f92018-11-07 08:26:47 -080021#include <vector>
22
23namespace blobs
24{
25
Patrick Venture0d2a8132018-11-09 11:34:21 -080026bool PciDataHandler::open()
27{
Patrick Venture0fbabf22018-11-09 11:54:12 -080028 /* TODO: For the ASPEED P2A driver, this method will enable the memory
29 * region to use.
30 */
31 return false;
32}
33
34bool PciDataHandler::close()
35{
36 /* TODO: Turn off the P2A bridge and region to disable host-side access.
Patrick Venture0d2a8132018-11-09 11:34:21 -080037 */
38 return false;
39}
40
Patrick Venture1cde5f92018-11-07 08:26:47 -080041std::vector<std::uint8_t> PciDataHandler::copyFrom(std::uint32_t length)
42{
43 /* TODO: implement this. */
44 return {};
45}
46
Patrick Venture74304642019-01-17 09:31:04 -080047bool PciDataHandler::writeMeta(const std::vector<std::uint8_t>& configuration)
Patrick Venture8c535332018-11-08 15:58:00 -080048{
49 /* PCI handler doesn't require configuration write, only read. */
50 return false;
51}
52
Patrick Venture74304642019-01-17 09:31:04 -080053std::vector<std::uint8_t> PciDataHandler::readMeta()
Patrick Venture8c535332018-11-08 15:58:00 -080054{
55 /* PCI handler does require returning a configuration from read. */
56 struct PciConfigResponse reply;
Patrick Ventureb0c84d02018-11-09 12:00:31 -080057 reply.address = regionAddress;
Patrick Venture8c535332018-11-08 15:58:00 -080058
59 std::vector<std::uint8_t> bytes;
60 bytes.resize(sizeof(reply));
Patrick Venturea8a99ae2018-11-09 11:14:58 -080061 std::memcpy(bytes.data(), &reply, sizeof(reply));
Patrick Venture8c535332018-11-08 15:58:00 -080062
63 return bytes;
64}
65
Patrick Venture1cde5f92018-11-07 08:26:47 -080066} // namespace blobs