blob: bc06ac17a59e494ea2837d7e1a5fedce4e935bfb [file] [log] [blame]
// Copyright 2021 The Pigweed Authors
// Licensed under the Apache License, Version 2.0 (the "License"); you may not
// use this file except in compliance with the License. You may obtain a copy of
// the License at
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
// License for the specific language governing permissions and limitations under
// the License.
#include "pw_system/init.h"
#include "pw_log/log.h"
#include "pw_rpc/echo_service_nanopb.h"
#include "pw_system/target_hooks.h"
#include "pw_system/work_queue.h"
#include "pw_system_private/log.h"
#include "pw_system_private/rpc.h"
#include "pw_thread/detached_thread.h"
namespace pw::system {
namespace {
rpc::EchoService echo_service;
void InitImpl() {
PW_LOG_INFO("System init");
// Setup logging.
const Status status = GetLogThread().OpenUnrequestedLogStream(
kDefaultChannelId, GetRpcServer(), GetLogService());
if (!status.ok()) {
PW_LOG_ERROR("Error opening unrequested log streams %d",
PW_LOG_INFO("Registering RPC services");
PW_LOG_INFO("Starting threads");
// Start threads.
thread::DetachedThread(system::LogThreadOptions(), GetLogThread());
thread::DetachedThread(system::RpcThreadOptions(), GetRpcDispatchThread());
} // namespace
void Init() {
thread::DetachedThread(system::WorkQueueThreadOptions(), GetWorkQueue());
} // namespace pw::system