1 /* 2 * Copyright (C) 2020 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 #define TLOG_TAG "coverage-srv" 18 19 #include "coverage.h" 20 21 #include <lib/coverage/common/cov_shm.h> 22 #include <lib/tipc/tipc_srv.h> 23 #include <lk/err_ptr.h> 24 #include <trusty_log.h> 25 main(void)26int main(void) { 27 int rc; 28 struct tipc_hset* hset; 29 struct srv_state state; 30 31 hset = tipc_hset_create(); 32 if (IS_ERR(hset)) { 33 TLOGE("failed (%d) to create handle set\n", PTR_ERR(hset)); 34 return PTR_ERR(hset); 35 } 36 state.hset = hset; 37 38 list_initialize(&state.coverage_record_list); 39 40 rc = cov_shm_alloc(&state.mailbox, MAX_NUM_APPS); 41 if (rc != NO_ERROR) { 42 TLOGE("failed to allocate shared memory for mailbox\n"); 43 return ERR_NO_MEMORY; 44 } 45 46 rc = coverage_aggregator_init(&state); 47 if (rc != NO_ERROR) { 48 TLOGE("failed (%d) to initialize coverage aggregator service\n", rc); 49 return rc; 50 } 51 52 rc = coverage_client_init(&state); 53 if (rc != NO_ERROR) { 54 TLOGE("failed (%d) to initialize coverage client service\n", rc); 55 return rc; 56 } 57 58 return tipc_run_event_loop(hset); 59 } 60