20#include "pedigree/kernel/Log.h"
21#include "pedigree/kernel/machine/Device.h"
22#include "pedigree/kernel/machine/Machine.h"
23#include "pedigree/kernel/machine/Timer.h"
24#include "pedigree/kernel/machine/TimerHandler.h"
25#include "pedigree/kernel/processor/IoBase.h"
26#include "pedigree/kernel/processor/state_forward.h"
27#include "pedigree/kernel/processor/types.h"
28#include "pedigree/kernel/time/Time.h"
29#include "pedigree/kernel/utilities/String.h"
30#include "pedigree/kernel/utilities/Vector.h"
31#include "pedigree/kernel/utilities/utility.h"
33#include "modules/Module.h"
35enum Ib700TimeEntries {
60 virtual bool initialise();
66 virtual void timer(uint64_t delta);
71 uint64_t m_RefreshRemaining;
78 if (p->addresses().count() > 0) {
79 if (p->addresses()[0]->m_Name.compare(
"ib700-base")) {
81 if (pNewChild->initialise()) {
82 g_Watchdogs.pushBack(pNewChild);
83 return static_cast<Device*
>(pNewChild);
85 ERROR(
"IB700 initialisation failed!");
94 auto c = pedigree_std::make_callable(f);
101 auto f = [](
Device* device) {
102 for (
auto watchdog : g_Watchdogs) {
103 if (device == watchdog) {
107 watchdog->shutdown();
108 return new Device(device);
114 auto c = pedigree_std::make_callable(f);
119MODULE_INFO(
"ib700_wdt", &entry, &exit);
121Ib700Watchdog::Ib700Watchdog(
Device* pDev)
125 m_RefreshRemaining(Time::Multiplier::Second) {
129Ib700Watchdog::~Ib700Watchdog() {
133void Ib700Watchdog::shutdown() {
135 if (!m_pTimer->unregisterHandler(
this)) {
136 FATAL(
"IB700 watchdog could not drain its timer callback");
148bool Ib700Watchdog::initialise() {
159 if (t && t->registerHandler(
this)) {
164 m_pBase->
write8(Seconds10, 2);
166 !t->
armHandler(
this, Time::getTicks() + Time::Multiplier::Second)) {
178 str.assign(
"ib700_wdt", 10);
182 if (delta < m_RefreshRemaining) {
183 m_RefreshRemaining -= delta;
185 !m_pTimer->
armHandler(
this, Time::getTicks() + m_RefreshRemaining)) {
186 FATAL(
"IB700 watchdog could not rearm its timer callback");
192 m_RefreshRemaining = Time::Multiplier::Second;
193 m_pBase->
write8(Seconds10, 2);
195 !m_pTimer->
armHandler(
this, Time::getTicks() + m_RefreshRemaining)) {
196 FATAL(
"IB700 watchdog could not rearm its timer callback");
static void foreach(Callback callback, Device *root=0)
virtual Vector< Address * > & addresses()
virtual void setSpecificType(String str)
virtual void timer(uint64_t delta)
virtual void getName(String &str)
Abstrace base class for hardware I/O capabilities.
virtual void write8(uint8_t value, size_t offset=0)=0
virtual Timer * getTimer()=0
virtual bool supportsDeadlines() const
virtual bool armHandler(TimerHandler *, uint64_t)
A vector / dynamic array.