OpenCores
URL https://opencores.org/ocsvn/riscv_vhdl/riscv_vhdl/trunk

Subversion Repositories riscv_vhdl

[/] [riscv_vhdl/] [trunk/] [debugger/] [src/] [common/] [coreservices/] [ireset.h] - Blame information for rev 5

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 5 sergeykhbr
/**
2
 * @file
3
 * @copyright  Copyright 2017 GNSS Sensor Ltd. All right reserved.
4
 * @author     Sergey Khabarov - sergeykhbr@gmail.com
5
 * @brief      Generic reset interface.
6
 */
7
 
8
#ifndef __DEBUGGER_PLUGIN_IRESET_H__
9
#define __DEBUGGER_PLUGIN_IRESET_H__
10
 
11
#include <inttypes.h>
12
#include <iface.h>
13
#include <attribute.h>
14
 
15
namespace debugger {
16
 
17
static const char *IFACE_RESET_LISTENER = "IResetListener";
18
 
19
class IResetListener : public IFace {
20
 public:
21
    IResetListener() : IFace(IFACE_RESET_LISTENER) {}
22
 
23
    virtual void reset(bool active) = 0;
24
};
25
 
26
static const char *const IFACE_RESET = "IReset";
27
 
28
class IReset : public IFace {
29
 public:
30
    IReset() : IFace(IFACE_RESET) {
31
        resetListeners_.make_list(0);
32
    }
33
 
34
    virtual void registerResetListener(IFace *listener) {
35
        AttributeType item;
36
        item.make_iface(listener);
37
        resetListeners_.add_to_list(&item);
38
    }
39
 
40
    virtual void unregisterResetListener(IFace *listener) {
41
        for (unsigned i = 0; i < resetListeners_.size(); i++) {
42
            if (listener == resetListeners_[i].to_iface()) {
43
                resetListeners_.remove_from_list(i);
44
                return;
45
            }
46
        }
47
    }
48
 
49
    void reset(bool active) {
50
        IResetListener *l;
51
        for (unsigned i = 0; i < resetListeners_.size(); i++) {
52
            l = static_cast<IResetListener *>(resetListeners_[i].to_iface());
53
            l->reset(active);
54
        }
55
    }
56
 
57
    virtual void powerOnPressed() = 0;
58
    virtual void powerOnReleased() = 0;
59
 
60
 protected:
61
    AttributeType resetListeners_;
62
};
63
 
64
}  // namespace debugger
65
 
66
#endif  // __DEBUGGER_PLUGIN_IRESET_H__

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.