~ubuntu-branches/ubuntu/karmic/libsmbios/karmic

« back to all changes in this revision

Viewing changes to libraries/smi/SmiFactory.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jose Luis Tallon
  • Date: 2007-04-22 13:04:55 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20070422130455-t40zo63zf23cip6t
Tags: 0.13.6-1
* New upstream version
  - Adds complete support for EFI (i.e. intel-based Macs)

* Fixed FTBFS with gcc4.3 (missing includes) (Closes: #418621)

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
#define LIBSMBIOS_SOURCE
20
20
#include "SmiImpl.h"
21
21
#include "FactoryImpl2.h"
 
22
#include "TokenImpl.h"
22
23
 
23
24
// message.h should be included last.
24
25
#include "smbios/message.h"
63
64
            strategyPtr = new SmiMockStrategy(getParameterString("smiFile"));
64
65
 
65
66
 
 
67
        // used for automatic setup of magic io stuff 
 
68
        u16 cmdIOAddress = 0;
 
69
        u8  cmdIOCode = 0;
 
70
        smbios::TokenTableFactory *ttFactory = 0;
 
71
        smbios::ITokenTable *tokenTable = 0;
 
72
 
66
73
        switch( type )
67
74
        {
 
75
        case DELL_CALLING_INTERFACE_SMI_RAW:
 
76
            ret = new DellCallingInterfaceSmiImpl(strategyPtr);
 
77
            break;
 
78
 
68
79
        case DELL_CALLING_INTERFACE_SMI:
69
80
            ret = new DellCallingInterfaceSmiImpl(strategyPtr);
 
81
            // automatically set up cmd io port/magic
 
82
            // step 1: get token table
 
83
            ttFactory = smbios::TokenTableFactory::getFactory() ;
 
84
            tokenTable = ttFactory->getSingleton();
 
85
            // step 2: iterate through token table
 
86
            for(
 
87
                smbios::ITokenTable::iterator token = tokenTable->begin();
 
88
                token != tokenTable->end();
 
89
                ++token )
 
90
            {
 
91
                // Step 3: go until we get to the first one that will dynamic cast 
 
92
                //         into a TokenDA
 
93
                try{
 
94
                    if( token->getTokenClass() != "TokenDA" )
 
95
                        continue;
 
96
 
 
97
                    // Step 4: then set cmd io stuff
 
98
                    dynamic_cast<smbios::ISmiToken *>(&*token)->getSmiDetails(&cmdIOAddress, &cmdIOCode, static_cast<u8*>(0));
 
99
                    ret->setCommandIOMagic( cmdIOAddress, cmdIOCode );
 
100
                    break;
 
101
                } catch(...){
 
102
                }
 
103
            }
 
104
 
 
105
            if( ! (cmdIOAddress && cmdIOCode))
 
106
                throw SmiExceptionImpl(_("Could not automatically setup up magic io"));
 
107
 
70
108
            break;
71
109
        default:
72
110
            throw InvalidSmiModeImpl(_("Unknown smi factory mode requested"));