blob: df4aa7656b41bc5993079c287e9081c9c94df526 [file] [log] [blame]
Ben Tynerb481d902020-03-05 10:24:23 -06001#pragma once
2
3#include <libpdbg.h>
4
Ben Tyner3fb52e52020-03-31 10:10:07 -05005#include <attn/attn_config.hpp>
6
7#include <bitset>
8
Ben Tynerb481d902020-03-05 10:24:23 -06009namespace attn
10{
11
12/** @brief attention handler configuration flags */
13inline constexpr uint32_t enableBreakpoints = 1;
14
15/**
16 * @brief These objects contain information about an active attention.
17 *
18 * An Attention object is created for each active attention. These objects
19 * carry with them various configuration and status information as well
20 * the attention handler function to call for handling the attention. Each
21 * Attention object also carries a priority value. This priority is used
22 * to determine which attention event(s) to handle when there are more than
23 * one active event.
24 */
25class Attention
26{
27 public:
28 /** @brief types of attentions to be handled (by priority low to high) */
29 enum AttentionType
30 {
Patrick Williams27dd6362023-05-10 07:51:20 -050031 Special = 0,
Ben Tynerb481d902020-03-05 10:24:23 -060032 Checkstop = 1,
Patrick Williams27dd6362023-05-10 07:51:20 -050033 Vital = 2
Ben Tynerb481d902020-03-05 10:24:23 -060034 };
35
36 /** @brief Default constructor. */
37 Attention() = delete;
38
39 /** @brief Main constructors */
40 Attention(AttentionType i_type, int (*i_handler)(Attention*),
Ben Tyner3fb52e52020-03-31 10:10:07 -050041 pdbg_target* i_target, Config* i_config);
Ben Tynerb481d902020-03-05 10:24:23 -060042
43 /** @brief Destructor */
44 ~Attention() = default;
45
46 /** @brief Get attention priority */
47 int getPriority() const;
48
Ben Tyner3fb52e52020-03-31 10:10:07 -050049 /* @brief Get config object */
50 Config* getConfig() const;
Ben Tynerb481d902020-03-05 10:24:23 -060051
52 /* @brief Call attention handler function */
53 int handle();
54
Ben Tyner792f32f2020-06-02 08:50:47 -050055 /* @brief Get attention handler target */
56 pdbg_target* getTarget() const;
57
Ben Tynerb481d902020-03-05 10:24:23 -060058 /** @brief Copy constructor. */
59 Attention(const Attention&) = default;
60
61 /** @brief Assignment operator. */
62 Attention& operator=(const Attention&) = default;
63
64 /** @brief less than operator */
65 bool operator<(const Attention& right) const;
66
67 private:
68 AttentionType iv_type; // attention type
69 int (*iv_handler)(Attention*); // handler function
70 pdbg_target* iv_target; // handler function target
Ben Tyner3fb52e52020-03-31 10:10:07 -050071 Config* iv_config; // configuration flags
Ben Tynerb481d902020-03-05 10:24:23 -060072};
73
74} // namespace attn