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 <trusty/line-coverage/coverage.h> 20 #include <array> 21 #include <memory> 22 #include <vector> 23 #include <set> 24 25 #define TIPC_DEV "/dev/trusty-ipc-dev0" 26 #define TEST_SRV_PORT "com.android.trusty.sancov.test.srv" 27 #define TEST_SRV_MODULE "srv.syms.elf" 28 29 #define UUID_STR_SIZE (37) 30 31 #define FLAG_NONE 0x0 32 #define FLAG_RUN 0x1 33 #define FLAG_TOGGLE_CLEAR 0x2 34 35 struct control { 36 /* Written by controller, read by instrumented TA */ 37 uint64_t cntrl_flags; 38 uint64_t read_buffer_cnt; 39 40 /* Written by instrumented TA, read by controller */ 41 uint64_t write_buffer_start_count; 42 uint64_t write_buffer_complete_count; 43 }; 44 45 namespace android { 46 namespace trusty { 47 namespace controller { 48 49 class Controller { 50 public: 51 public: 52 void run(std::string output_dir); 53 54 private: 55 std::vector<std::unique_ptr<line_coverage::CoverageRecord>>record_list_; 56 std::set<struct uuid>uuid_set_; 57 std::vector<std::string>uuid_list_; 58 std::vector<uint64_t> counters; 59 int coverage_srv_fd; 60 61 void connectCoverageServer(); 62 void setUpShm(); 63 }; 64 65 } // namespace controller 66 } // namespace trusty 67 } // namespace android 68