1 /* 2 * Copyright (C) 2017 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_PLATFORM_HOST_LINK_H_ 18 #define CHRE_PLATFORM_HOST_LINK_H_ 19 20 #include <stdint.h> 21 22 #include "chre/target_platform/host_link_base.h" 23 #include "chre/util/non_copyable.h" 24 25 namespace chre { 26 27 struct HostMessage; 28 typedef HostMessage MessageToHost; 29 30 /** 31 * Abstracts the platform-specific communications link between CHRE and the host 32 * processor 33 */ 34 class HostLink : public HostLinkBase, 35 public NonCopyable { 36 public: 37 /** 38 * Flush (or purge) any messages sent by the given app ID that are currently 39 * pending delivery to the host. At the point that this function is called, it 40 * is guaranteed that no new messages will be generated from this nanoapp. 41 * 42 * This function must impose strict ordering constraints, such that after it 43 * returns, it is guaranteed that HostCommsManager::onMessageToHostComplete 44 * will not be invoked for the app with the given ID. 45 */ 46 void flushMessagesSentByNanoapp(uint64_t appId); 47 48 /** 49 * Enqueues a message for sending to the host. Once sending the message is 50 * complete (success or failure), the platform implementation must invoke 51 * HostCommsManager::onMessageToHostComplete (can be called from any thread). 52 * 53 * @param message A non-null pointer to the message 54 * 55 * @return true if the message was successfully queued 56 */ 57 bool sendMessage(const MessageToHost *message); 58 }; 59 60 } // namespace chre 61 62 #endif // CHRE_PLATFORM_HOST_LINK_H_ 63