| // Copyright 2019 The Fuchsia Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| |
| #ifndef SRC_DEVICES_INTERNAL_DRIVERS_FRAGMENT_PROXY_PROTOCOL_H_ |
| #define SRC_DEVICES_INTERNAL_DRIVERS_FRAGMENT_PROXY_PROTOCOL_H_ |
| |
| #include <fuchsia/hardware/platform/device/c/banjo.h> |
| |
| namespace fragment { |
| |
| // Maximum transfer size we can proxy. |
| static constexpr size_t kProxyMaxTransferSize = 4096; |
| |
| /// Header for RPC requests. |
| struct ProxyRequest { |
| uint32_t txid; |
| uint32_t proto_id; |
| }; |
| |
| /// Header for RPC responses. |
| struct ProxyResponse { |
| uint32_t txid; |
| zx_status_t status; |
| }; |
| |
| // ZX_PROTOCOL_PDEV proxy support. |
| enum class PdevOp { |
| GET_MMIO, |
| GET_INTERRUPT, |
| GET_BTI, |
| GET_SMC, |
| GET_DEVICE_INFO, |
| GET_BOARD_INFO, |
| }; |
| |
| struct PdevProxyRequest { |
| ProxyRequest header; |
| PdevOp op; |
| uint32_t index; |
| uint32_t flags; |
| }; |
| |
| struct PdevProxyResponse { |
| ProxyResponse header; |
| zx_off_t offset; |
| size_t size; |
| uint32_t flags; |
| pdev_device_info_t device_info; |
| pdev_board_info_t board_info; |
| }; |
| |
| // Maximum metadata size that can be returned via PDEV_DEVICE_GET_METADATA. |
| static constexpr uint32_t PROXY_MAX_METADATA_SIZE = |
| (kProxyMaxTransferSize - sizeof(PdevProxyResponse)); |
| |
| struct rpc_pdev_metadata_rsp_t { |
| PdevProxyResponse pdev; |
| uint8_t metadata[PROXY_MAX_METADATA_SIZE]; |
| }; |
| |
| // ZX_PROTOCOL_GPIO proxy support. |
| enum class GpioOp { |
| CONFIG_IN, |
| CONFIG_OUT, |
| SET_ALT_FUNCTION, |
| READ, |
| WRITE, |
| GET_INTERRUPT, |
| RELEASE_INTERRUPT, |
| SET_POLARITY, |
| SET_DRIVE_STRENGTH, |
| GET_DRIVE_STRENGTH, |
| }; |
| |
| struct GpioProxyRequest { |
| ProxyRequest header; |
| GpioOp op; |
| uint32_t flags; |
| uint32_t polarity; |
| uint64_t alt_function; |
| uint8_t value; |
| uint64_t ds_ua; |
| }; |
| |
| struct GpioProxyResponse { |
| ProxyResponse header; |
| uint8_t value; |
| uint64_t out_actual_ds_ua; |
| }; |
| |
| // ZX_PROTOCOL_HDMI proxy support. |
| enum class HdmiOp { |
| CONNECT, |
| }; |
| |
| struct HdmiProxyRequest { |
| ProxyRequest header; |
| HdmiOp op; |
| }; |
| |
| struct HdmiProxyResponse { |
| ProxyResponse header; |
| }; |
| |
| // ZX_PROTOCOL_CODEC proxy support. |
| enum class CodecOp { |
| GET_CHANNEL, |
| }; |
| |
| struct CodecProxyRequest { |
| ProxyRequest header; |
| CodecOp op; |
| }; |
| |
| struct CodecProxyResponse { |
| ProxyResponse header; |
| }; |
| |
| // ZX_PROTOCOL_DAI proxy support. |
| enum class DaiOp { |
| GET_CHANNEL, |
| }; |
| |
| struct DaiProxyRequest { |
| ProxyRequest header; |
| DaiOp op; |
| }; |
| |
| struct DaiProxyResponse { |
| ProxyResponse header; |
| }; |
| |
| // ZX_PROTOCOL_SYSMEM proxy support. |
| enum class SysmemOp { |
| CONNECT, |
| REGISTER_HEAP, |
| REGISTER_SECURE_MEM, |
| UNREGISTER_SECURE_MEM, |
| }; |
| |
| struct SysmemProxyRequest { |
| ProxyRequest header; |
| SysmemOp op; |
| uint64_t heap; |
| }; |
| |
| enum class SpiOp { |
| TRANSMIT, |
| RECEIVE, |
| EXCHANGE, |
| }; |
| |
| struct SpiProxyRequest { |
| ProxyRequest header; |
| SpiOp op; |
| size_t length; |
| }; |
| |
| struct SpiProxyResponse { |
| ProxyResponse header; |
| }; |
| |
| // ZX_PROTOCOL_GOLDFISH_SYNC proxy support. |
| enum class GoldfishSyncOp { |
| CREATE_TIMELINE, |
| }; |
| |
| struct GoldfishSyncProxyRequest { |
| ProxyRequest header; |
| GoldfishSyncOp op; |
| }; |
| |
| struct GoldfishSyncProxyResponse { |
| ProxyResponse header; |
| }; |
| |
| // ZX_PROTOCOL_GOLDFISH_ADDRESS_SPACE proxy support. |
| enum class GoldfishAddressSpaceOp { |
| OPEN_CHILD_DRIVER, |
| }; |
| |
| struct GoldfishAddressSpaceProxyRequest { |
| ProxyRequest header; |
| GoldfishAddressSpaceOp op; |
| uint32_t type; |
| }; |
| |
| struct GoldfishAddressSpaceProxyResponse { |
| ProxyResponse header; |
| }; |
| |
| enum class DsiOp { |
| CONNECT, |
| }; |
| |
| struct DsiProxyRequest { |
| ProxyRequest header; |
| DsiOp op; |
| }; |
| |
| } // namespace fragment |
| |
| #endif // SRC_DEVICES_INTERNAL_DRIVERS_FRAGMENT_PROXY_PROTOCOL_H_ |