aboutsummaryrefslogtreecommitdiff
path: root/pw_system/public/pw_system
diff options
context:
space:
mode:
Diffstat (limited to 'pw_system/public/pw_system')
-rw-r--r--pw_system/public/pw_system/config.h15
-rw-r--r--pw_system/public/pw_system/file_manager.h61
-rw-r--r--pw_system/public/pw_system/file_service.h22
-rw-r--r--pw_system/public/pw_system/target_hooks.h2
-rw-r--r--pw_system/public/pw_system/trace_service.h25
-rw-r--r--pw_system/public/pw_system/transfer_handlers.h37
-rw-r--r--pw_system/public/pw_system/transfer_service.h27
7 files changed, 189 insertions, 0 deletions
diff --git a/pw_system/public/pw_system/config.h b/pw_system/public/pw_system/config.h
index 0d04158cb..b4024ca89 100644
--- a/pw_system/public/pw_system/config.h
+++ b/pw_system/public/pw_system/config.h
@@ -68,6 +68,21 @@
#define PW_SYSTEM_LOGGING_RPC_HDLC_ADDRESS PW_SYSTEM_DEFAULT_RPC_HDLC_ADDRESS
#endif // PW_SYSTEM_LOGGING_RPC_HDLC_ADDRESS
+// PW_SYSTEM_ENABLE_TRACE_SERVICE specifies if the trace RPC service is enabled.
+//
+// Defaults to 1.
+#ifndef PW_SYSTEM_ENABLE_TRACE_SERVICE
+#define PW_SYSTEM_ENABLE_TRACE_SERVICE 1
+#endif // PW_SYSTEM_ENABLE_TRACE_SERVICE
+
+// PW_SYSTEM_ENABLE_TRANSFER_SERVICE specifies if the transfer RPC service is
+// enabled.
+//
+// Defaults to 1.
+#ifndef PW_SYSTEM_ENABLE_TRANSFER_SERVICE
+#define PW_SYSTEM_ENABLE_TRANSFER_SERVICE 1
+#endif // PW_SYSTEM_ENABLE_TRANSFER_SERVICE
+
// PW_SYSTEM_ENABLE_THREAD_SNAPSHOT_SERVICE specifies if the thread snapshot
// RPC service is enabled.
//
diff --git a/pw_system/public/pw_system/file_manager.h b/pw_system/public/pw_system/file_manager.h
new file mode 100644
index 000000000..a061cd5a3
--- /dev/null
+++ b/pw_system/public/pw_system/file_manager.h
@@ -0,0 +1,61 @@
+// Copyright 2023 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
+//
+// https://www.apache.org/licenses/LICENSE-2.0
+//
+// 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.
+#pragma once
+
+#include "pw_persistent_ram/flat_file_system_entry.h"
+#include "pw_system/config.h"
+#include "pw_system/transfer_handlers.h"
+
+namespace pw::system {
+
+class FileManager {
+ public:
+ // Each transfer handler ID corresponds 1:1 with a transfer handler and
+ // filesystem element pair. The ID must be unique and increment from 0 to
+ // ensure no gaps in the FileManager handler & filesystem arrays.
+ // NOTE: the enumerators should never have values defined, to ensure they
+ // increment from zero and kNumFileSystemEntries is correct
+ enum TransferHandlerId : uint32_t {
+#if PW_SYSTEM_ENABLE_TRACE_SERVICE
+ kTraceTransferHandlerId,
+#endif
+ kNumFileSystemEntries
+ };
+
+ FileManager();
+
+ std::array<transfer::Handler*, kNumFileSystemEntries>& GetTransferHandlers() {
+ return transfer_handlers_;
+ }
+ std::array<file::FlatFileSystemService::Entry*, kNumFileSystemEntries>&
+ GetFileSystemEntries() {
+ return file_system_entries_;
+ }
+
+ private:
+#if PW_SYSTEM_ENABLE_TRACE_SERVICE
+ TracePersistentBufferTransfer trace_data_handler_;
+ persistent_ram::FlatFileSystemPersistentBufferEntry<
+ PW_TRACE_BUFFER_SIZE_BYTES>
+ trace_data_filesystem_entry_;
+#endif
+
+ std::array<transfer::Handler*, kNumFileSystemEntries> transfer_handlers_;
+ std::array<file::FlatFileSystemService::Entry*, kNumFileSystemEntries>
+ file_system_entries_;
+};
+
+FileManager& GetFileManager();
+
+} // namespace pw::system
diff --git a/pw_system/public/pw_system/file_service.h b/pw_system/public/pw_system/file_service.h
new file mode 100644
index 000000000..1610bff01
--- /dev/null
+++ b/pw_system/public/pw_system/file_service.h
@@ -0,0 +1,22 @@
+// Copyright 2023 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
+//
+// https://www.apache.org/licenses/LICENSE-2.0
+//
+// 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.
+#pragma once
+
+#include "pw_rpc/server.h"
+
+namespace pw::system {
+
+void RegisterFileService(rpc::Server& rpc_server);
+
+} // namespace pw::system
diff --git a/pw_system/public/pw_system/target_hooks.h b/pw_system/public/pw_system/target_hooks.h
index 58460ca8b..19628c2ad 100644
--- a/pw_system/public/pw_system/target_hooks.h
+++ b/pw_system/public/pw_system/target_hooks.h
@@ -21,6 +21,8 @@ const thread::Options& LogThreadOptions();
const thread::Options& RpcThreadOptions();
+const thread::Options& TransferThreadOptions();
+
const thread::Options& WorkQueueThreadOptions();
// This will run once after pw::system::Init() completes. This callback must
diff --git a/pw_system/public/pw_system/trace_service.h b/pw_system/public/pw_system/trace_service.h
new file mode 100644
index 000000000..7c16c0e38
--- /dev/null
+++ b/pw_system/public/pw_system/trace_service.h
@@ -0,0 +1,25 @@
+// Copyright 2023 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
+//
+// https://www.apache.org/licenses/LICENSE-2.0
+//
+// 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.
+#pragma once
+
+#include "pw_rpc/server.h"
+#include "pw_system/transfer_handlers.h"
+
+namespace pw::system {
+
+void RegisterTraceService(rpc::Server& rpc_server, uint32_t transfer_id);
+
+TracePersistentBuffer& GetTraceData();
+
+} // namespace pw::system
diff --git a/pw_system/public/pw_system/transfer_handlers.h b/pw_system/public/pw_system/transfer_handlers.h
new file mode 100644
index 000000000..f82308559
--- /dev/null
+++ b/pw_system/public/pw_system/transfer_handlers.h
@@ -0,0 +1,37 @@
+// Copyright 2023 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
+//
+// https://www.apache.org/licenses/LICENSE-2.0
+//
+// 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.
+#pragma once
+
+#include "pw_persistent_ram/persistent_buffer.h"
+#include "pw_trace_tokenized/config.h"
+#include "pw_transfer/transfer.h"
+
+namespace pw::system {
+
+using TracePersistentBuffer =
+ persistent_ram::PersistentBuffer<PW_TRACE_BUFFER_SIZE_BYTES>;
+
+class TracePersistentBufferTransfer : public transfer::ReadOnlyHandler {
+ public:
+ TracePersistentBufferTransfer(uint32_t id,
+ TracePersistentBuffer& persistent_buffer);
+
+ Status PrepareRead() final;
+
+ private:
+ TracePersistentBuffer& persistent_buffer_;
+ stream::MemoryReader reader_;
+};
+
+} // namespace pw::system
diff --git a/pw_system/public/pw_system/transfer_service.h b/pw_system/public/pw_system/transfer_service.h
new file mode 100644
index 000000000..64a60b99c
--- /dev/null
+++ b/pw_system/public/pw_system/transfer_service.h
@@ -0,0 +1,27 @@
+// Copyright 2023 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
+//
+// https://www.apache.org/licenses/LICENSE-2.0
+//
+// 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.
+#pragma once
+
+#include "pw_rpc/server.h"
+#include "pw_transfer/transfer_thread.h"
+
+namespace pw::system {
+
+void RegisterTransferService(rpc::Server& rpc_server);
+
+void InitTransferService();
+
+transfer::TransferThread& GetTransferThread();
+
+} // namespace pw::system