1 /*
2 * Copyright (C) 2024 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 #include "src/trace_processor/importers/etm/frame_decoder.h"
18
19 #include "perfetto/base/status.h"
20 #include "src/trace_processor/util/status_macros.h"
21
22 namespace perfetto::trace_processor::etm {
23
Init()24 base::Status FrameDecoder::Init() {
25 RETURN_IF_ERROR(error_logger_.ToStatus(frame_decoder_.Init()));
26 PERFETTO_CHECK(frame_decoder_.getErrLogAttachPt()->attach(&error_logger_) ==
27 OCSD_OK);
28 RETURN_IF_ERROR(error_logger_.ToStatus(
29 frame_decoder_.Configure(OCSD_DFRMTR_FRAME_MEM_ALIGN)));
30 frame_decoder_.SetDemuxStatsBlock(&demux_stats_);
31 return base::OkStatus();
32 }
33
TraceDataIn(const ocsd_datapath_op_t op,const ocsd_trc_index_t index,const uint32_t data_block_size,const uint8_t * data_block,uint32_t * num_bytes_processed)34 base::StatusOr<bool> FrameDecoder::TraceDataIn(const ocsd_datapath_op_t op,
35 const ocsd_trc_index_t index,
36 const uint32_t data_block_size,
37 const uint8_t* data_block,
38 uint32_t* num_bytes_processed) {
39 auto resp = frame_decoder_.TraceDataIn(op, index, data_block_size, data_block,
40 num_bytes_processed);
41 return error_logger_.ToErrorOrKeepGoing(resp);
42 }
43
Attach(uint8_t cs_trace_id,ITrcDataIn * data_in)44 base::Status FrameDecoder::Attach(uint8_t cs_trace_id, ITrcDataIn* data_in) {
45 return error_logger_.ToStatus(
46 frame_decoder_.getIDStreamAttachPt(cs_trace_id)->attach(data_in));
47 }
48
49 } // namespace perfetto::trace_processor::etm
50