blob: 678613c629a3c750e8af30eeaccf54ca4483e194 [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.
#include "device.h"
#include "fuchsia/sysmem/c/fidl.h"
#include "lib/fidl-async-2/fidl_server.h"
#include "lib/fidl-async-2/simple_binding.h"
#include "logging.h"
#include "logical_buffer_collection.h"
namespace sysmem_driver {
// An instance of this class serves an Allocator connection. The lifetime of
// the instance is 1:1 with the Allocator channel.
// Because Allocator is essentially self-contained and handling the server end
// of a channel, most of Allocator is private.
class Allocator : public FidlServer<Allocator,
SimpleBinding<Allocator, fuchsia_sysmem_Allocator_ops_t,
vLog> {
// Public for std::unique_ptr<Allocator>:
friend class FidlServer;
Allocator(Device* parent_device);
static const fuchsia_sysmem_Allocator_ops_t kOps;
zx_status_t AllocateNonSharedCollection(zx_handle_t buffer_collection_request_param);
zx_status_t AllocateSharedCollection(zx_handle_t token_request);
zx_status_t BindSharedCollection(zx_handle_t token, zx_handle_t buffer_collection);
zx_status_t ValidateBufferCollectionToken(zx_koid_t token_server_koid, fidl_txn_t* txn);
zx_status_t SetDebugClientInfo(const char* name_data, size_t name_size, uint64_t id);
Device* parent_device_ = nullptr;
std::optional<LogicalBufferCollection::ClientInfo> client_info_;
} // namespace sysmem_driver