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
95class Time : public Device
96{
97 public:
98
104 Time(const u32 inode);
105
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 */
Input/Output operations specific to the ARM architecture.
Definition ARMIO.h:40
Abstract device class interface.
Definition Device.h:36
Abstract Input/Output buffer.
Definition IOBuffer.h:38
System Time server.
Definition Time.h:96
Arch::IO m_io
Port I/O object.
Definition Time.h:154
virtual FileSystem::Result read(IOBuffer &buffer, Size &size, const Size offset)
Read time.
Definition Time.cpp:38
virtual FileSystem::Result initialize()
Initialize the time device.
Definition Time.cpp:33
unsigned char readCMOS(unsigned char addr)
Returns the value stored at the given address from the CMOS.
Definition Time.cpp:94
unsigned bcd2bin(unsigned char val)
Convert from binary coded decimal to binary form.
Definition Time.cpp:100
unsigned int u32
Unsigned 32-bit number.
Definition Types.h:53
unsigned int Size
Any sane size indicator cannot go negative.
Definition Types.h:128
Result
Result code for filesystem Actions.
Definition FileSystem.h:53