blob: 87edeb847784f030692567a151283db56fc05d17 [file] [log] [blame]
/*
* Copyright (C) 2020 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef CHRE_PLATFORM_AOC_SYSTEM_TIMER_BASE_H_
#define CHRE_PLATFORM_AOC_SYSTEM_TIMER_BASE_H_
#include <cstdint>
#include "chre/platform/assert.h"
#include "chre/util/time_impl.h"
#include "efw/include/timer.h"
#include "FreeRTOS.h"
#include "task.h"
namespace chre {
/**
* The AOC platform base class for the SystemTimer. The AOC implementation uses
* a EFW timer.
*/
class SystemTimerBase {
protected:
//! The timer handle that is generated by Timer::EventAdd.
void *mTimerHandle;
//! Tracks whether the timer has been initialized correctly.
bool mInitialized = false;
//! A static method that is invoked by the underlying EFW timer.
static bool systemTimerNotifyCallback(void *context);
//! A FreeRTOS Thread to dispatch timer callbacks
static TaskHandle_t mTimerCbDispatchThreadHandle;
//! This function implements the timer callback dispatch thread.
// It blocks until it's woken up by the underlying system timer's ISR,
// then executes the CHRE timer callback from the dispatch thread context.
static void timerCallbackDispatch(void *context);
};
} // namespace chre
#endif // CHRE_PLATFORM_AOC_SYSTEM_TIMER_BASE_H_