FreeNOS
Public Member Functions | Private Member Functions | Private Attributes
Time Class Reference

System Time server. More...

#include <Time.h>

Inheritance diagram for Time:
Device File

Public Member Functions

 Time (const u32 inode)
 Constructor. More...
 
virtual FileSystem::Result initialize ()
 Initialize the time device. More...
 
virtual FileSystem::Result read (IOBuffer &buffer, Size &size, const Size offset)
 Read time. More...
 
- Public Member Functions inherited from Device
 Device (const u32 inode, const FileSystem::FileType type)
 Constructor. More...
 
virtual ~Device ()
 Destructor. More...
 
virtual const StringgetIdentifier () const
 Get unique device identifier. More...
 
virtual FileSystem::Result interrupt (const Size vector)
 Called when an interrupt has been triggered for this device. More...
 
- Public Member Functions inherited from File
 File (const u32 inode, const FileSystem::FileType type=FileSystem::RegularFile, const UserID uid=ZERO, const GroupID gid=ZERO)
 Constructor function. More...
 
virtual ~File ()
 Destructor function. More...
 
u32 getInode () const
 Get inode number. More...
 
FileSystem::FileType getType () const
 Retrieve our filetype. More...
 
virtual FileSystem::Result write (IOBuffer &buffer, Size &size, const Size offset)
 Write bytes to the file. More...
 
virtual FileSystem::Result status (FileSystem::FileStat &st)
 Retrieve file statistics. More...
 
virtual bool canRead () const
 Check if the File has data ready for reading. More...
 
virtual bool canWrite () const
 Check if the File can be written to. More...
 

Private Member Functions

unsigned char readCMOS (unsigned char addr)
 Returns the value stored at the given address from the CMOS. More...
 
unsigned bcd2bin (unsigned char val)
 Convert from binary coded decimal to binary form. More...
 

Private Attributes

Arch::IO m_io
 Port I/O object. More...
 

Additional Inherited Members

- Protected Attributes inherited from Device
String m_identifier
 Unique identifier for this Device. More...
 
- Protected Attributes inherited from File
const u32 m_inode
 Inode number. More...
 
const FileSystem::FileType m_type
 Type of this file. More...
 
UserID m_uid
 Owner of the file. More...
 
GroupID m_gid
 Group of the file. More...
 
FileSystem::FileModes m_access
 Access permissions. More...
 
Size m_size
 Size of the file, in bytes. More...
 

Detailed Description

System Time server.

This server is responsible for maintaining the global system time via the CMOS. A lot of this code comes from the linux kernel source, particularly from the file arch/x86/kernel/rtc.c.

See also
http://git.kernel.org/?p=linux/kernel/git/stable/linux-2.6.30.y.git;a=blob_plain;f=arch/x86/kernel/rtc.c;hb=HEAD

Definition at line 95 of file Time.h.

Constructor & Destructor Documentation

◆ Time()

Time::Time ( const u32  inode)

Constructor.

Parameters
inodeInode number

Definition at line 27 of file Time.cpp.

References Device::m_identifier.

Member Function Documentation

◆ bcd2bin()

unsigned Time::bcd2bin ( unsigned char  val)
private

Convert from binary coded decimal to binary form.

Parameters
valThe value to convert.
Returns
A binary integer.

Definition at line 100 of file Time.cpp.

Referenced by read().

◆ initialize()

FileSystem::Result Time::initialize ( )
virtual

Initialize the time device.

Returns
Result code

Reimplemented from Device.

Definition at line 33 of file Time.cpp.

References FileSystem::Success.

◆ read()

FileSystem::Result Time::read ( IOBuffer buffer,
Size size,
const Size  offset 
)
virtual

Read time.

Parameters
bufferInput/Output buffer to output bytes to.
sizeMaximum number of bytes to read on input. On output, the actual number of bytes read.
offsetOffset inside the file to start reading.
Returns
Result code

Reimplemented from File.

Definition at line 38 of file Time.cpp.

References bcd2bin(), CMOS_YEARS_OFFS, mktime(), readCMOS(), RTC_BCD, RTC_DAY_OF_MONTH, RTC_HOURS, RTC_MINUTES, RTC_MONTH, RTC_SECONDS, RTC_STATUS_A, RTC_STATUS_B, RTC_UIP, RTC_YEAR, snprintf(), FileSystem::Success, and IOBuffer::write().

◆ readCMOS()

unsigned char Time::readCMOS ( unsigned char  addr)
private

Returns the value stored at the given address from the CMOS.

Parameters
addrThe address to read from the CMOS
Returns
The value at the given address.
Note
I almost copied this code completely from the linux source from the file arch/x86/kernel/rtc.h so you should also take a look over there how they do it.

Definition at line 94 of file Time.cpp.

References m_io, and RTC_PORT.

Referenced by read().

Field Documentation

◆ m_io

Arch::IO Time::m_io
private

Port I/O object.

Definition at line 154 of file Time.h.

Referenced by readCMOS().


The documentation for this class was generated from the following files: