blob: 63109f5e028b24f66810f2206c14e7e63c415c9d [file] [log] [blame]
// 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 MSD_IMG_CONNECTION_H
#define MSD_IMG_CONNECTION_H
#include <memory>
#include "magma_util/macros.h"
#include "msd.h"
typedef struct _PVRSRV_DEVICE_NODE_ PVRSRV_DEVICE_NODE;
typedef struct _CONNECTION_DATA_ CONNECTION_DATA;
class MsdImgConnection : public msd_connection_t
{
public:
class Owner
{
public:
virtual PVRSRV_DEVICE_NODE* device_node() = 0;
};
// If the current thread is currently servicing a bridge request or other
// operation on a connection, this will return a pointer to that connection.
static MsdImgConnection* GetCurrentConnection();
virtual ~MsdImgConnection();
MsdImgConnection(Owner* owner, msd_client_id_t client_id);
bool Init();
static MsdImgConnection* Cast(msd_connection_t* msd_connection)
{
DASSERT(msd_connection);
DASSERT(msd_connection->magic_ == kMagic);
return static_cast<MsdImgConnection*>(msd_connection);
}
static MsdImgConnection* Cast(void* void_connection)
{
DASSERT(void_connection);
auto msd_connection = static_cast<MsdImgConnection*>(void_connection);
DASSERT(msd_connection->magic_ == kMagic);
return msd_connection;
}
Owner* owner() const { return owner_; }
msd_client_id_t client_id() const { return client_id_; }
char* client_name() { return client_name_; }
private:
static const uint32_t kMagic = 'icon';
Owner* owner_;
msd_client_id_t client_id_;
CONNECTION_DATA* connection_data_ = nullptr;
char client_name_[32];
};
#endif // MSD_IMG_CONNECTION_H