1 /* 2 * Copyright (C) 2023 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 #pragma once 18 19 #include <lib/coverage/common/cov_shm.h> 20 #include <lib/tipc/tipc.h> 21 #include <lib/tipc/tipc_srv.h> 22 #include <stddef.h> 23 24 __BEGIN_CDECLS 25 26 #define FLAG_NONE 0x0 27 #define FLAG_RUN 0x1 28 #define FLAG_TOGGLE_CLEAR 0x2 29 30 typedef uint8_t counter_t; 31 32 struct control { 33 /* Written by controller, read by instrumented TA */ 34 uint64_t cntrl_flags; 35 uint64_t read_buffer_cnt; 36 37 /* Written by instrumented TA, read by controller */ 38 uint64_t write_buffer_start_count; 39 uint64_t write_buffer_complete_count; 40 }; 41 42 struct cov_ctx { 43 handle_t coverage_srv; 44 size_t idx; 45 struct cov_shm mailbox; 46 struct cov_shm data; 47 size_t record_len; 48 bool skip_mailbox; 49 }; 50 51 /** 52 * setup_mailbox() - Mailbox setup with the help of coverage aggregator 53 * @ports: List of ports for which mailbox has to be setup 54 * @num_ports: Number of ports 55 */ 56 int setup_mailbox(const struct tipc_port* ports, uint32_t num_ports); 57 58 /** 59 * setup_shm() - SHM from NS is passed onto the TA via coverage aggregator 60 */ 61 int setup_shm(void); 62 63 /* 64 * dump_shm() - Coverage information is dumped into the shared memory after 65 looking at the control flags 66 */ 67 void dump_shm(void); 68 __END_CDECLS 69