blob: d89f6cef3083bfd4584479459916f72a7240e059 [file] [log] [blame]
// Copyright 2021 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 "example_driver.h"
#include "greeter.h"
namespace example_driver {
zx::result<> ExampleDriver::Start() {
// Initialize the driver compat service context.
compat::Context::ConnectAndCreate(
&context(), dispatcher(), fit::bind_member<&ExampleDriver::InitializeCompatService>(this));
return zx::ok();
}
// Complete driver initialization using the driver compat service.
void ExampleDriver::InitializeCompatService(
zx::result<std::shared_ptr<compat::Context>> compat_result) {
if (!compat_result.is_ok()) {
FDF_SLOG(ERROR, "Failed to create compat context.",
KV("status", compat_result.status_string()));
node().reset();
return;
}
compat_context_ = std::move(*compat_result);
child_ = compat::DeviceServer(std::string(name()), 0, compat_context_->TopologicalPath(name()));
// Say hello
FDF_SLOG(INFO, example_driver::greeting(name()).c_str());
FDF_SLOG(INFO, example_driver::greeting(child_->topological_path()).c_str());
}
} // namespace example_driver
FUCHSIA_DRIVER_RECORD_CPP_V2(driver::Record<example_driver::ExampleDriver>);