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