Main Page | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

CmosRW_LinuxIO.cpp

Go to the documentation of this file.
00001 /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
00002  * vim:expandtab:autoindent:tabstop=4:shiftwidth=4:filetype=c:cindent:textwidth=0:
00003  *
00004  * Copyright (C) 2005 Dell Inc.
00005  *  by Michael Brown <Michael_E_Brown@dell.com>
00006  * Licensed under the Open Software License version 2.1
00007  *
00008  * Alternatively, you can redistribute it and/or modify
00009  * it under the terms of the GNU General Public License as published
00010  * by the Free Software Foundation; either version 2 of the License,
00011  * or (at your option) any later version.
00012 
00013  * This program is distributed in the hope that it will be useful, but
00014  * WITHOUT ANY WARRANTY; without even the implied warranty of
00015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00016  * See the GNU General Public License for more details.
00017  */
00018 
00019 // compat header should always be first header if including system headers
00020 #define LIBSMBIOS_SOURCE
00021 #include "smbios/compat.h"
00022 
00023 #include <sys/io.h>
00024 
00025 #include "CmosRWImpl.h"
00026 
00027 using namespace std;
00028 
00029 namespace cmos
00030 {
00031 
00032     //
00033     // CmosRWIo functions
00034     //
00035 
00036     // REGULAR CONSTRUCTOR
00037     CmosRWIo::CmosRWIo ()
00038             : ICmosRW(), Suppressable()
00039     {}
00040 
00041     // COPY CONSTRUCTOR
00042     CmosRWIo::CmosRWIo (const CmosRWIo &)
00043             : ICmosRW(), Suppressable()
00044     {}
00045 
00046     // OVERLOADED ASSIGNMENT
00047     CmosRWIo & CmosRWIo::operator = (const CmosRWIo &)
00048     {
00049         return *this;
00050     }
00051 
00052     // TODO: need to throw exception on problem with iopl
00053     //
00054     u8 CmosRWIo::readByte (u32 indexPort, u32 dataPort, u32 offset) const
00055     {
00056         if(iopl(3) < 0)
00057             throw smbios::InternalErrorImpl("iopl() failed. probably not root.");
00058         outb_p (offset, indexPort);
00059         return (inb_p (dataPort));
00060     }
00061 
00062     // TODO: need to throw exception on problem with iopl
00063     //
00064     void CmosRWIo::writeByte (u32 indexPort, u32 dataPort, u32 offset, u8 byte) const
00065     {
00066         if(iopl(3) < 0)
00067             throw smbios::InternalErrorImpl("iopl() failed. probably not root.");
00068         outb_p (offset, indexPort);
00069         outb_p (byte, dataPort);
00070 
00071         if(! isNotifySuppressed() )
00072         {
00073             // writers are responsible for only writing changed values
00074             // otherwise we get to see how fast Linux can do an 
00075             // infinite loop. :-)
00076             notify(); 
00077         }
00078     }
00079 
00080 }

Generated on Wed Apr 11 16:25:10 2007 for SMBIOS Library by doxygen 1.3.5