1 // Copyright 2024 The Pigweed Authors 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); you may not 4 // use this file except in compliance with the License. You may obtain a copy of 5 // the License at 6 // 7 // https://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 // License for the specific language governing permissions and limitations under 13 // the License. 14 #pragma once 15 16 #include "pw_snapshot_protos/snapshot.pwpb.h" 17 18 struct pw_cpu_exception_State; 19 20 // device_handler facade to a device specific backend. 21 namespace pw::system::device_handler { 22 23 // Trigger an immediate reboot. 24 void RebootSystem(); 25 26 // Populate a snapshot with device specific metadata, such as cpu architecture. 27 // Custom application information such as project name may also be provided. 28 void CapturePlatformMetadata( 29 snapshot::pwpb::Metadata::StreamEncoder& metadata_encoder); 30 31 // Populate a snapshot with architecture specific CPU state generated by a 32 // CPU exception. 33 Status CaptureCpuState( 34 const pw_cpu_exception_State& cpu_state, 35 snapshot::pwpb::Snapshot::StreamEncoder& snapshot_encoder); 36 37 // Captures the main system thread as part of a snapshot 38 Status CaptureMainStackThread( 39 const pw_cpu_exception_State& cpu_state, 40 thread::proto::pwpb::SnapshotThreadInfo::StreamEncoder& encoder); 41 42 // Captures all threads in the system as part of a snapshot 43 Status CaptureThreads( 44 uint32_t running_thread_stack_pointer, 45 thread::proto::pwpb::SnapshotThreadInfo::StreamEncoder& encoder); 46 47 } // namespace pw::system::device_handler 48