The Pedigree Project  0.1
include/pedigree/kernel/machine/Timer.h
1 /*
2  * Copyright (c) 2008-2014, Pedigree Developers
3  *
4  * Please see the CONTRIB file in the root of the source tree for a full
5  * list of contributors.
6  *
7  * Permission to use, copy, modify, and distribute this software for any
8  * purpose with or without fee is hereby granted, provided that the above
9  * copyright notice and this permission notice appear in all copies.
10  *
11  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18  */
19 
20 #ifndef KERNEL_MACHINE_TIMER_H
21 #define KERNEL_MACHINE_TIMER_H
22 
23 #include "pedigree/kernel/processor/types.h"
24 #include "pedigree/kernel/time/Time.h"
25 
26 class TimerHandler;
27 
32 class Timer
33 {
34  public:
37  virtual size_t getYear() = 0;
40  virtual uint8_t getMonth() = 0;
43  virtual uint8_t getDayOfMonth() = 0;
46  virtual uint8_t getDayOfWeek() = 0;
49  virtual uint8_t getHour() = 0;
52  virtual uint8_t getMinute() = 0;
55  virtual uint8_t getSecond() = 0;
58  virtual uint64_t getNanosecond() = 0;
59 
62  virtual uint64_t getTickCount() = 0;
65  virtual uint64_t getTickCountNano()
66  {
67  return getTickCount() * 1000U;
68  }
69 
71  virtual Time::Timestamp getUnixTimestamp();
72 
73  virtual bool registerHandler(TimerHandler *handler) = 0;
74  virtual bool unregisterHandler(TimerHandler *handler) = 0;
75 
80  virtual void
81  addAlarm(class Event *pEvent, size_t alarmSecs, size_t alarmUsecs = 0) = 0;
84  virtual void removeAlarm(class Event *pEvent) = 0;
90  virtual size_t removeAlarm(class Event *pEvent, bool bRetZero) = 0;
91 
98  virtual void synchronise(bool tohw = false)
99  {
100  }
101 
102  protected:
104  inline Timer()
105  {
106  }
108  inline virtual ~Timer()
109  {
110  }
111 
112  private:
115  Timer(const Timer &);
118  Timer &operator=(const Timer &);
119 };
120 
123 #endif
virtual uint64_t getTickCountNano()
virtual uint8_t getMinute()=0
virtual void removeAlarm(class Event *pEvent)=0
Timer & operator=(const Timer &)
virtual void synchronise(bool tohw=false)
Synchronises the timer with the hardware. Useful for updating the fields returned by get*...
virtual uint8_t getHour()=0
virtual uint8_t getDayOfWeek()=0
virtual Time::Timestamp getUnixTimestamp()
Definition: Timer.cc:23
virtual uint64_t getTickCount()=0
virtual size_t getYear()=0
virtual uint8_t getMonth()=0
virtual uint64_t getNanosecond()=0
Definition: Event.h:48
virtual uint8_t getDayOfMonth()=0
virtual void addAlarm(class Event *pEvent, size_t alarmSecs, size_t alarmUsecs=0)=0
virtual uint8_t getSecond()=0