Patrick Venture | 22e3875 | 2018-11-21 08:52:49 -0800 | [diff] [blame] | 1 | /* |
| 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 Venture | 1cde5f9 | 2018-11-07 08:26:47 -0800 | [diff] [blame] | 17 | #include "pci_handler.hpp" |
| 18 | |
| 19 | #include <cstdint> |
Patrick Venture | a8a99ae | 2018-11-09 11:14:58 -0800 | [diff] [blame] | 20 | #include <cstring> |
Patrick Venture | 1cde5f9 | 2018-11-07 08:26:47 -0800 | [diff] [blame] | 21 | #include <vector> |
| 22 | |
| 23 | namespace blobs |
| 24 | { |
| 25 | |
Patrick Venture | 0d2a813 | 2018-11-09 11:34:21 -0800 | [diff] [blame] | 26 | bool PciDataHandler::open() |
| 27 | { |
Patrick Venture | 0fbabf2 | 2018-11-09 11:54:12 -0800 | [diff] [blame] | 28 | /* TODO: For the ASPEED P2A driver, this method will enable the memory |
| 29 | * region to use. |
| 30 | */ |
| 31 | return false; |
| 32 | } |
| 33 | |
| 34 | bool PciDataHandler::close() |
| 35 | { |
| 36 | /* TODO: Turn off the P2A bridge and region to disable host-side access. |
Patrick Venture | 0d2a813 | 2018-11-09 11:34:21 -0800 | [diff] [blame] | 37 | */ |
| 38 | return false; |
| 39 | } |
| 40 | |
Patrick Venture | 1cde5f9 | 2018-11-07 08:26:47 -0800 | [diff] [blame] | 41 | std::vector<std::uint8_t> PciDataHandler::copyFrom(std::uint32_t length) |
| 42 | { |
| 43 | /* TODO: implement this. */ |
| 44 | return {}; |
| 45 | } |
| 46 | |
Patrick Venture | 7430464 | 2019-01-17 09:31:04 -0800 | [diff] [blame] | 47 | bool PciDataHandler::writeMeta(const std::vector<std::uint8_t>& configuration) |
Patrick Venture | 8c53533 | 2018-11-08 15:58:00 -0800 | [diff] [blame] | 48 | { |
| 49 | /* PCI handler doesn't require configuration write, only read. */ |
| 50 | return false; |
| 51 | } |
| 52 | |
Patrick Venture | 7430464 | 2019-01-17 09:31:04 -0800 | [diff] [blame] | 53 | std::vector<std::uint8_t> PciDataHandler::readMeta() |
Patrick Venture | 8c53533 | 2018-11-08 15:58:00 -0800 | [diff] [blame] | 54 | { |
| 55 | /* PCI handler does require returning a configuration from read. */ |
| 56 | struct PciConfigResponse reply; |
Patrick Venture | b0c84d0 | 2018-11-09 12:00:31 -0800 | [diff] [blame] | 57 | reply.address = regionAddress; |
Patrick Venture | 8c53533 | 2018-11-08 15:58:00 -0800 | [diff] [blame] | 58 | |
| 59 | std::vector<std::uint8_t> bytes; |
| 60 | bytes.resize(sizeof(reply)); |
Patrick Venture | a8a99ae | 2018-11-09 11:14:58 -0800 | [diff] [blame] | 61 | std::memcpy(bytes.data(), &reply, sizeof(reply)); |
Patrick Venture | 8c53533 | 2018-11-08 15:58:00 -0800 | [diff] [blame] | 62 | |
| 63 | return bytes; |
| 64 | } |
| 65 | |
Patrick Venture | 1cde5f9 | 2018-11-07 08:26:47 -0800 | [diff] [blame] | 66 | } // namespace blobs |