1 /* 2 * Copyright (C) 2022 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 #ifndef CHRE_SIMULATION_TEST_EVENT_H_ 18 #define CHRE_SIMULATION_TEST_EVENT_H_ 19 20 #include "chre/event.h" 21 22 /** 23 * First possible value for CHRE_EVENT_SIMULATION_TEST events. These events are 24 * reserved for utility events that can be used by any simulation test. 25 */ 26 #define CHRE_EVENT_SIMULATION_TEST_FIRST_EVENT CHRE_EVENT_FIRST_USER_VALUE 27 28 /** 29 * Produce an event ID in the block of IDs reserved for CHRE simulation test 30 * events. 31 * 32 * @param offset Index into simulation test event ID block; valid range is [0, 33 * 0xFFF]. 34 * 35 * @defgroup CHRE_SIMULATION_TEST_EVENT_ID 36 * @{ 37 */ 38 #define CHRE_SIMULATION_TEST_EVENT_ID(offset) \ 39 (CHRE_EVENT_SIMULATION_TEST_FIRST_EVENT + (offset)) 40 41 /** 42 * First possible value for CHRE_EVENT_SPECIFIC_SIMULATION_TEST events. Each 43 * simulation test can define specific events for its use case. 44 */ 45 #define CHRE_EVENT_SPECIFIC_SIMULATION_TEST_FIRST_EVENT \ 46 CHRE_EVENT_FIRST_USER_VALUE + 0x1000 47 48 /** 49 * Produce an event ID in the block of IDs reserved for events belonging to a 50 * specific CHRE simulation test. 51 * 52 * @param offset Index into the event ID block of a specific simulation test; 53 * valid range is [0, 0xFFF]. 54 * 55 * @defgroup CHRE_SIMULATION_TEST_EVENT_ID 56 * @{ 57 */ 58 #define CHRE_SPECIFIC_SIMULATION_TEST_EVENT_ID(offset) \ 59 (CHRE_EVENT_SPECIFIC_SIMULATION_TEST_FIRST_EVENT + (offset)) 60 61 /** 62 * Produce an event ID in the block of IDs reserved for events belonging to a 63 * specific CHRE simulation test. 64 * 65 * @param offset Index into the event ID block of a specific simulation test; 66 * valid range is [0, 0xFFF]. 67 * 68 * @defgroup CHRE_SIMULATION_TEST_EVENT_ID 69 * @{ 70 */ 71 #define CREATE_CHRE_TEST_EVENT(name, offset) \ 72 constexpr uint16_t name = CHRE_SPECIFIC_SIMULATION_TEST_EVENT_ID(offset) 73 74 #define CHRE_EVENT_TEST_EVENT CHRE_EVENT_FIRST_USER_VALUE + 0x2000 75 76 /** 77 * Events used to communicate to and from the test nanoapps. 78 */ 79 struct TestEvent { 80 uint16_t type; 81 void *data = nullptr; 82 }; 83 84 #endif // CHRE_SIMULATION_TEST_EVENT_H_