Sound Open Firmware
Loading...
Searching...
No Matches
agent.h
Go to the documentation of this file.
1/* SPDX-License-Identifier: BSD-3-Clause
2 *
3 * Copyright(c) 2017 Intel Corporation. All rights reserved.
4 *
5 * Author: Liam Girdwood <liam.r.girdwood@linux.intel.com>
6 */
7
8#ifndef __SOF_LIB_AGENT_H__
9#define __SOF_LIB_AGENT_H__
10
11#include <rtos/atomic.h>
12#include <sof/lib/memory.h>
13#include <sof/lib/perf_cnt.h>
14#include <rtos/task.h>
15#include <rtos/sof.h>
16
17#include <stdbool.h>
18#include <stdint.h>
19
20struct sof;
21
22/* simple agent */
23struct sa {
24 uint64_t last_check; /* time of last activity checking */
25 uint64_t panic_timeout; /* threshold of panic */
26 uint64_t warn_timeout; /* threshold of warning */
27#if CONFIG_PERFORMANCE_COUNTERS
28 struct perf_cnt_data pcd;
29#endif
30 struct task work;
31 atomic_t panic_cnt;
33};
34
35#if CONFIG_HAVE_AGENT
36
41static inline void sa_set_panic_on_delay(bool enabled)
42{
43 struct sa *sa = sof_get()->sa;
44
45 if (enabled)
46 atomic_add(&sa->panic_cnt, 1);
47 else
48 atomic_sub(&sa->panic_cnt, 1);
49
50 /* enable panic only if no refs */
52
53}
54
55void sa_init(struct sof *sof, uint64_t timeout);
56void sa_exit(struct sof *sof);
57
58#else
59
60static inline void sa_init(struct sof *sof, uint64_t timeout) { }
61static inline void sa_exit(struct sof *sof) { }
62static inline void sa_set_panic_on_delay(bool enabled) { }
63
64#endif
65
66#endif /* __SOF_LIB_AGENT_H__ */
static void sa_exit(struct sof *sof)
Definition agent.h:61
static void sa_set_panic_on_delay(bool enabled)
Definition agent.h:62
static void sa_init(struct sof *sof, uint64_t timeout)
Definition agent.h:60
#define atomic_read(p)
Definition atomic.h:17
Simple performance counters.
struct sof * sof_get(void)
Definition perf_cnt.h:19
Definition agent.h:23
struct task work
Definition agent.h:30
bool panic_on_delay
emits panic on delay if true
Definition agent.h:32
atomic_t panic_cnt
ref counter for panic_on_delay property
Definition agent.h:31
uint64_t last_check
Definition agent.h:24
uint64_t panic_timeout
Definition agent.h:25
uint64_t warn_timeout
Definition agent.h:26
General firmware context.
Definition sof.h:44
struct sa * sa
Definition sof.h:55
Task used by schedulers.
Definition task.h:56