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
16namespace platform_bus {
17
18class ProxyClient;
19using ProxyClientType = ddk::Device<ProxyClient>;
20
21class ProxyClient : public ProxyClientType,
22                    public ddk::PlatformProxyProtocol<ProxyClient> {
23public:
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 RegisterProtocol(uint32_t proto_id, const void* protocol);
35     zx_status_t Proxy(platform_proxy_args_t* args);
36
37private:
38    DISALLOW_COPY_ASSIGN_AND_MOVE(ProxyClient);
39
40    uint32_t proto_id_;
41    fbl::RefPtr<PlatformProxy> proxy_;
42};
43
44} // namespace platform_bus
45