libsmbios_c library
ICmosRW.h
Go to the documentation of this file.
1 // vim:expandtab:autoindent:tabstop=4:shiftwidth=4:filetype=c:
2 /*
3  * Copyright (C) 2005 Dell Inc.
4  * by Michael Brown <Michael_E_Brown@dell.com>
5  * Licensed under the Open Software License version 2.1
6  *
7  * Alternatively, you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published
9  * by the Free Software Foundation; either version 2 of the License,
10  * or (at your option) any later version.
11 
12  * This program is distributed in the hope that it will be useful, but
13  * WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
15  * See the GNU General Public License for more details.
16  */
17 
18 
19 #ifndef ICMOSRW_H
20 #define ICMOSRW_H
21 
22 // compat header should always be first header
23 #include "smbios/compat.h"
24 
25 // types.h should be first user-defined header.
26 #include "smbios/types.h"
27 
28 #include "smbios/IFactory.h"
29 #include "smbios/IException.h"
30 
31 // abi_prefix should be last header included before declarations
33 
34 namespace cmos
35 {
37 
39  // Exceptions
40  DECLARE_EXCEPTION( CmosException );
41  DECLARE_EXCEPTION_EX( InvalidCmosRWMode, cmos, CmosException );
42 
43  // forward declarations.
44  class ICmosRW;
45 
46  class CmosRWFactory : public virtual factory::IFactory
47  {
48  public:
49  static CmosRWFactory *getFactory();
50  virtual ~CmosRWFactory() throw();
51  virtual ICmosRW *getSingleton( ) = 0; // returns singleton
52  virtual ICmosRW *makeNew( ) = 0; // not for use
53  protected:
54  CmosRWFactory();
55  };
56 
57  class ICmosRW
58  {
59  public:
60  explicit ICmosRW();
61  virtual u8 readByte( u32 indexPort, u32 dataPort, u32 offset ) const = 0;
62  virtual void writeByte( u32 indexPort, u32 dataPort, u32 offset, u8 byte ) const = 0;
63  virtual ~ICmosRW();
64  private:
65  ICmosRW( const ICmosRW &source );
66  void operator = (const ICmosRW &source );
67  };
68 
82  void readByteArray( const ICmosRW &cmos, u32 indexPort, u32 dataPort, u32 offset, u8* target, u32 count);
96  void writeByteArray( const ICmosRW &cmos, u32 indexPort, u32 dataPort, u32 offset, const u8* source, u32 count);
97 
98 }
99 
100 // always should be last thing in header file
102 
103 #endif /* ICMOSRW_H */
void readByteArray(const ICmosRW &cmos, u32 indexPort, u32 dataPort, u32 offset, u8 *target, u32 count)
virtual ~ICmosRW()
Definition: ICmosRW.h:46
void writeByteArray(const ICmosRW &cmos, u32 indexPort, u32 dataPort, u32 offset, const u8 *source, u32 count)
virtual void writeByte(u32 indexPort, u32 dataPort, u32 offset, u8 byte) const =0
static CmosRWFactory * getFactory()
virtual ~CmosRWFactory()
DECLARE_EXCEPTION(CmosException)
Abstract base class for the cmos read write operations.
virtual ICmosRW * makeNew()=0
DECLARE_EXCEPTION_EX(InvalidCmosRWMode, cmos, CmosException)
unsigned int u32
Definition: types.h:35
virtual u8 readByte(u32 indexPort, u32 dataPort, u32 offset) const =0
virtual ICmosRW * getSingleton()=0
unsigned char u8
Definition: types.h:27
Base class for all Abstract Factories.
Definition: IFactory.h:39
Definition: ICmosRW.h:57