SMBIOS Library
RbuImpl.h
Go to the documentation of this file.
1 /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2  * vim:expandtab:autoindent:tabstop=4:shiftwidth=4:filetype=c:cindent:textwidth=0:
3  *
4  * Copyright (C) 2005 Dell Inc.
5  * by Michael Brown <Michael_E_Brown@dell.com>
6  * Licensed under the Open Software License version 2.1
7  *
8  * Alternatively, you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published
10  * by the Free Software Foundation; either version 2 of the License,
11  * or (at your option) any later version.
12 
13  * This program is distributed in the hope that it will be useful, but
14  * WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16  * See the GNU General Public License for more details.
17  */
18 
19 #ifndef RBUIMPL_H
20 #define RBUIMPL_H
21 
22 // compat header should always be first header if including system headers
23 #include "smbios/compat.h"
24 
25 #include "smbios/DellRbu.h"
26 #include "FactoryImpl2.h"
27 #include "ExceptionImpl.h"
28 #include "smbios/RbuLowLevel.h"
29 
30 # if defined(DEBUG_RBU)
31 # define DCOUT(line) do { cout << line; } while(0)
32 # define DCERR(line) do { cerr << line; } while(0)
33 # else
34 # define DCOUT(line) do {} while(0)
35 # define DCERR(line) do {} while(0)
36 # endif
37 
38 namespace rbu
39 {
40  DEFINE_EXCEPTION_EX( RbuNotSupportedImpl, rbu, RbuNotSupported );
41  DEFINE_EXCEPTION_EX( InvalidHdrFileImpl, rbu, InvalidHdrFile );
42  DEFINE_EXCEPTION_EX( UnsupportedSystemForHdrFileImpl, rbu, UnsupportedSystemForHdrFile );
43  DEFINE_EXCEPTION_EX( HdrFileIOErrorImpl, rbu, HdrFileIOError );
44  DEFINE_EXCEPTION_EX( RbuDriverIOErrorImpl, rbu, RbuDriverIOError );
45 
46  class RbuFactoryImpl : public factory::TFactory<RbuFactory>
47  {
48  public:
50  virtual ~RbuFactoryImpl() throw();
51  virtual IRbuHdr *makeNew( std::string filename );
52  };
53 
54 
55  class RbuHdr : public virtual IRbuHdr
56  {
57  public:
58  // CONSTRUCTORS, DESTRUCTOR, and ASSIGNMENT
59  explicit RbuHdr(std::string filename);
60 
61  // CONSTRUCTORS, DESTRUCTOR, and ASSIGNMENT
62  virtual ~RbuHdr ();
63 
64  virtual std::ostream & streamify(std::ostream & cout ) const;
65 
66  virtual std::string getBiosVersion() const;
67  virtual void getHdrVersion(unsigned int &major, unsigned int &minor) const;
68  virtual const u32 *getSystemIdList() const;
69  virtual void doUpdate() const;
70  virtual FILE *getFh() const;
71 
72  protected:
73  // No-arg constructor not legal for this class for regular users
74  RbuHdr ();
75 
76  private:
77  RbuHdr (const RbuHdr &source);
78  FILE *hdrFh;
80  u32 sysIdList[NUM_SYS_ID_IN_HDR + 1]; // zero terminated array of system ids.
81  };
82 
84  void activateRbuToken();
85  void cancelRbuToken();
86  void checksumPacket(rbu_packet *pkt, size_t size);
87  void createPacket(char *buffer, size_t bufSize, size_t imageSize);
88 }
89 
90 #endif /* RBUIMPL_H */