1 // Copyright 2017 The Fuchsia Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #pragma once 6 7 #include <ddktl/device.h> 8 #include <ddktl/protocol/platform/proxy.h> 9 #include <fbl/ref_ptr.h> 10 #include <fbl/vector.h> 11 #include <lib/zx/channel.h> 12 #include <lib/zx/handle.h> 13 14 #include "platform-proxy.h" 15 16 namespace platform_bus { 17 18 class ProxyClient; 19 using ProxyClientType = ddk::Device<ProxyClient>; 20 21 class ProxyClient : public ProxyClientType, 22 public ddk::PlatformProxyProtocol<ProxyClient, ddk::base_protocol> { 23 public: ProxyClient(uint32_t proto_id,zx_device_t * parent,fbl::RefPtr<PlatformProxy> proxy)24 explicit ProxyClient(uint32_t proto_id, zx_device_t* parent, fbl::RefPtr<PlatformProxy> proxy) 25 : ProxyClientType(parent), proto_id_(proto_id), proxy_(proxy) {} 26 27 static zx_status_t Create(uint32_t proto_id, zx_device_t* parent, 28 fbl::RefPtr<PlatformProxy> proxy); 29 30 // Device protocol implementation. 31 void DdkRelease(); 32 33 // Platform proxy protocol implementation. 34 zx_status_t PlatformProxyRegisterProtocol(uint32_t proto_id, const void* protocol, 35 size_t protocol_size); 36 zx_status_t PlatformProxyProxy( 37 const void* req_buffer, size_t req_size, const zx_handle_t* req_handle_list, 38 size_t req_handle_count, void* out_resp_buffer, size_t resp_size, size_t* out_resp_actual, 39 zx_handle_t* out_resp_handle_list, size_t resp_handle_count, 40 size_t* out_resp_handle_actual); 41 42 private: 43 DISALLOW_COPY_ASSIGN_AND_MOVE(ProxyClient); 44 45 uint32_t proto_id_; 46 fbl::RefPtr<PlatformProxy> proxy_; 47 }; 48 49 } // namespace platform_bus 50