FreeNOS
Time.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2020 Niek Linnenbank
3  * Copyright (C) 2009 Coen Bijlsma
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 #ifndef __SERVER_TIME_TIME_H
20 #define __SERVER_TIME_TIME_H
21 
22 #include <FreeNOS/System.h>
23 #include <Macros.h>
24 #include <Types.h>
25 #include <Device.h>
26 
36 #define RTC_PORT(x) (0x70 + (x))
37 
39 #define RTC_SECONDS 0
40 
42 #define RTC_MINUTES 2
43 
45 #define RTC_HOURS 4
46 
48 #define RTC_DAY_OF_WEEK 6
49 
51 #define RTC_DAY_OF_MONTH 7
52 
54 #define RTC_MONTH 8
55 
62 #define RTC_YEAR 9
63 
65 #define CMOS_YEARS_OFFS 2000
66 
68 #define RTC_STATUS_A 10
69 
71 #define RTC_STATUS_B 11
72 
74 #define RTC_UIP 0x80
75 
77 #define RTC_DLS 0x01
78 
80 #define RTC_24H 0x02
81 
83 #define RTC_BCD 0x04
84 
95 class Time : public Device
96 {
97  public:
98 
104  Time(const u32 inode);
105 
111  virtual FileSystem::Result initialize();
112 
123  virtual FileSystem::Result read(IOBuffer & buffer,
124  Size & size,
125  const Size offset);
126 
127  private:
128 
140  unsigned char readCMOS(unsigned char addr);
141 
149  unsigned bcd2bin(unsigned char val);
150 
151  private:
152 
155 };
156 
162 #endif /* __SERVER_TIME_TIME_H */
Device.h
Macros.h
Types.h
Time::initialize
virtual FileSystem::Result initialize()
Initialize the time device.
Definition: Time.cpp:33
ARMIO
Input/Output operations specific to the ARM architecture.
Definition: ARMIO.h:39
Time::bcd2bin
unsigned bcd2bin(unsigned char val)
Convert from binary coded decimal to binary form.
Definition: Time.cpp:100
Device
Abstract device class interface.
Definition: Device.h:35
Time::Time
Time(const u32 inode)
Constructor.
Definition: Time.cpp:27
IOBuffer
Abstract Input/Output buffer.
Definition: IOBuffer.h:37
u32
unsigned int u32
Unsigned 32-bit number.
Definition: Types.h:53
Size
unsigned int Size
Any sane size indicator cannot go negative.
Definition: Types.h:128
Time::read
virtual FileSystem::Result read(IOBuffer &buffer, Size &size, const Size offset)
Read time.
Definition: Time.cpp:38
Time
System Time server.
Definition: Time.h:95
FileSystem::Result
Result
Result code for filesystem Actions.
Definition: FileSystem.h:52
Time::readCMOS
unsigned char readCMOS(unsigned char addr)
Returns the value stored at the given address from the CMOS.
Definition: Time.cpp:94
Time::m_io
Arch::IO m_io
Port I/O object.
Definition: Time.h:154