]> rtime.felk.cvut.cz Git - l4.git/blob - l4/pkg/rtc/server/src/rtc.h
Update
[l4.git] / l4 / pkg / rtc / server / src / rtc.h
1 /**
2  * \file
3  * \brief   Shared header file
4  *
5  * \date
6  * \author  Adam Lackorzynski <adam@os.inf.tu-dresden.de> */
7
8 /*
9  * (c) 2014
10  *
11  * This file is part of TUD:OS and distributed under the terms of the
12  * GNU General Public License 2.
13  * Please see the COPYING-GPL-2 file for details.
14  */
15 #pragma once
16
17 #include <sys/cdefs.h>
18 #include <l4/sys/l4int.h>
19 #include <l4/cxx/hlist>
20
21 struct Rtc : cxx::H_list_item_t<Rtc>
22 {
23   virtual int set_time(l4_uint64_t nsec_offset_1970) = 0;
24   virtual int get_time(l4_uint64_t *nsec_offset_1970) = 0;
25   virtual bool probe() = 0;
26   virtual ~Rtc() = 0;
27
28   static Rtc* find_rtc()
29   {
30     for (auto o = _rtcs.begin(); o != _rtcs.end(); ++o)
31       {
32         if (o->probe())
33           return *o;
34       }
35
36     return 0;
37   }
38
39   Rtc() { _rtcs.add(this); }
40
41 private:
42   static cxx::H_list_t<Rtc> _rtcs;
43 };
44
45 inline Rtc::~Rtc() {}