--- trunk/lib/Intel/AMT/RemoteControl.pm 2009/08/08 20:38:06 5 +++ trunk/lib/Intel/AMT/RemoteControl.pm 2009/08/08 21:57:47 6 @@ -1,5 +1,8 @@ package Intel::AMT::RemoteControl; +use warnings; +use strict; + our $SystemCapabilitiesSupported = { PowerCycleReset => 1, PowerDown => 2, @@ -57,7 +60,7 @@ ConfigurationDataReset => 32768, }; -our $SpecialCommand = { +our $SpecialCommands = { NOP => 0, # 0x00 ForcePXEBoot => 1, # 0x01 @@ -119,4 +122,102 @@ }; +use lib 'lib'; +use base qw/Intel::AMT::SOAP/; + +use Data::Dump qw/dump/; + +sub _soap { Intel::AMT::SOAP::_soap( 'RemoteControl', @_ ) }; + +sub SystemPowerState { + my $powerstate = _soap->GetSystemPowerState()->paramsout; + warn $powerstate; + return $powerstate; +} + +sub describe { +# warn 'describe ',dump( @_ ); + my ( $value, $map ) = @_; + my $out; + foreach my $name ( keys %$map ) { + push @$out, $name if $value & $map->{$name}; + } + push @$out, sprintf("%x", $value) unless $out; + return $out; +} + +sub Capabilities { + + my @rccaps = _soap->GetRemoteControlCapabilities()->paramsout; + + my $return = { + IanaOemNumber => $rccaps[0], + OemDefinedCapabilities => + describe( $rccaps[1], $OemDefinedCapabilitiesSupported ), + SpecialCommands => + describe( $rccaps[2], $SpecialCommandSupported ), + SystemCapabilities => + describe( $rccaps[3], $SystemCapabilitiesSupported ), + SystemFirmwareCapabilities => + describe( $rccaps[4], $SystemFirmwareCapabilitiesSupported ), + }; + + warn '# RemoteControlCapabilities ',dump( $return ); + return $return; +} + +sub run { + + my @args; + + my $BootOption; + my $SpecialCommandParameter; + + foreach my $command ( @_ ) { + + my $i; + + if ( $i = $BootOptions->{$command} ) { + if ( $BootOption ) { + $BootOption |= $i; + next; + } else { + $BootOption = $i; + $command = 'SetBootOptions'; + } + } elsif ( $i = $SpecialCommandParameters->{$command} ) { + $SpecialCommandParameter |= $i; + } elsif ( $i = $RemoteControlCommand->{$command} ) { + push @args, SOAP::Data->name( 'Command' => $i ); + } elsif ( $i = $SpecialCommands->{$command} ) { + push @args, SOAP::Data->name( 'SpecialCommand' => $i ); + } elsif ( $i = $OEMParameters->{$command} ) { + push @args, SOAP::Data->name( 'OEMParameters' => $i ); + } else { + die "can't find $command"; + } + + } + + + if ( $BootOption ) { + warn "invalid BootOptions $BootOption" unless + ( $BootOption & $BootOptionsReservedBits ); + push @args, SOAP::Data->name( 'BootOptions' => $BootOption ); + } + + if ( $SpecialCommandParameter ) { + warn "invalid SpecialCommandParameter $SpecialCommandParameter" unless + ( $SpecialCommandParameter & $SpecialCommandParametersReservedBits ); + push @args, SOAP::Data->name( 'SpecialCommandParameter' => $SpecialCommandParameter ); + } + + push @args, SOAP::Data->name( 'IanaOemNumber' => $IanaNumbers->{IntelIanaNumber} ); + warn "args ",dump( @args ); + + + _soap( @args ); + +} + 1;