sof/xtos/include/rtos/wait.h

68 lines
1.6 KiB
C
Raw Normal View History

/* SPDX-License-Identifier: BSD-3-Clause
*
* Copyright(c) 2016 Intel Corporation. All rights reserved.
*
* Author: Liam Girdwood <liam.r.girdwood@linux.intel.com>
*/
/*
* Simple wait for event completion and signaling with timeouts.
*/
#ifndef __XTOS_RTOS_WAIT_H__
#define __XTOS_RTOS_WAIT_H__
#include <stddef.h>
#include <stdint.h>
#if !CONFIG_LIBRARY
#include <arch/lib/wait.h>
#include <rtos/interrupt.h>
#include <rtos/timer.h>
#include <rtos/spinlock.h>
#include <sof/trace/trace.h>
#include <user/trace.h>
Use '-imacros config.h' instead of explicit #include <config.h> Using -imacros on the compiler command line instead of explicitly including config.h is not just less tedious in the future: - it also makes sure configuration always comes first and is never accidentally missed by an earlier #include - it makes sure all translation units get the (same) configuration - it lets parent projects like Zephyr override the config.h name To test this I ran ./scripts/xtensa-build-all.sh -a -r, compared binaries before and after this change and found no output difference. Full disclosure: this required a few unrelated tricks not submitted here like a .tarball-version file, commenting out __DATE__ and __TIME__ in a few places, running strip-determinism on the .a files because our crosstool-ng reference is not cutting-edge, etc. As Tigerlake is not built by default it required a couple more hacks to compile. Blank lines are left instead of the former #include lines so even debug objects are the same. Only defconfigs were tested. On the other hand, this commit was _not_ performed by a script but by changing the name of the generated file and clicking on and fixing every build failure. This proves that every removed #include was actually required by one or more tested defconfigs and that the added -imacros flag does affect the compilation of all the modified files. There is no #include config.h left: they were all in use in at least one _defconfig. I think comparing all binaries produced by ./scripts/xtensa-build-all.sh -r -a provides extensive enough coverage but note this was tested only with the crosstool-ng toolchain described in the SOF documentation. The obsolete[*] xt-xcc front-end is gcc-based and the newer xt-clang front-end is (surprise) clang-based. clang (copies many gcc options and) does support -imacros so I don't expect any issue with either xt-xcc or xt-clang. In the worst case, I do not expect any compiler front end to _silently_ discard any unknown command line flag nor to ignore a missing or misnamed config.h file. [*] https://github.com/zephyrproject-rtos/zephyr/issues/3165 Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2020-06-12 13:47:37 +08:00
extern struct tr_ctx wait_tr;
static inline void wait_for_interrupt(int level)
{
LOG_MODULE_DECLARE(wait, CONFIG_SOF_LOG_LEVEL);
tr_dbg(&wait_tr, "WFE");
#if CONFIG_DEBUG_LOCKS
if (lock_dbg_atomic)
tr_err_atomic(&wait_tr, "atm");
#endif
platform_wait_for_interrupt(level);
tr_dbg(&wait_tr, "WFX");
}
/**
* \brief Waits at least passed number of clocks.
* \param[in] number_of_clks Minimum number of clocks to wait.
*/
void wait_delay(uint64_t number_of_clks);
/**
* \brief Waits at least passed number of milliseconds.
* \param[in] ms Minimum number of milliseconds to wait.
*/
void wait_delay_ms(uint64_t ms);
/**
* \brief Waits at least passed number of microseconds.
* \param[in] us Minimum number of microseconds to wait.
*/
void wait_delay_us(uint64_t us);
#else
static inline void wait_delay(uint64_t number_of_clks) {}
static inline void wait_delay_ms(uint64_t ms) {}
static inline void wait_delay_us(uint64_t us) {}
#endif
int poll_for_register_delay(uint32_t reg, uint32_t mask,
uint32_t val, uint64_t us);
#endif /* __XTOS_RTOS_WAIT_H__ */