1 |
package Intel::AMT::RemoteControl; |
package Intel::AMT::RemoteControl; |
2 |
|
|
3 |
|
use warnings; |
4 |
|
use strict; |
5 |
|
|
6 |
our $SystemCapabilitiesSupported = { |
our $SystemCapabilitiesSupported = { |
7 |
PowerCycleReset => 1, |
PowerCycleReset => 1, |
8 |
PowerDown => 2, |
PowerDown => 2, |
60 |
ConfigurationDataReset => 32768, |
ConfigurationDataReset => 32768, |
61 |
}; |
}; |
62 |
|
|
63 |
our $SpecialCommand = { |
our $SpecialCommands = { |
64 |
|
|
65 |
NOP => 0, # 0x00 |
NOP => 0, # 0x00 |
66 |
ForcePXEBoot => 1, # 0x01 |
ForcePXEBoot => 1, # 0x01 |
122 |
|
|
123 |
}; |
}; |
124 |
|
|
125 |
|
use lib 'lib'; |
126 |
|
use base qw/Intel::AMT::SOAP/; |
127 |
|
|
128 |
|
use Data::Dump qw/dump/; |
129 |
|
|
130 |
|
sub _soap { Intel::AMT::SOAP::_soap( 'RemoteControl', @_ ) }; |
131 |
|
|
132 |
|
sub SystemPowerState { |
133 |
|
my $powerstate = _soap->GetSystemPowerState()->paramsout; |
134 |
|
warn $powerstate; |
135 |
|
return $powerstate; |
136 |
|
} |
137 |
|
|
138 |
|
sub describe { |
139 |
|
# warn 'describe ',dump( @_ ); |
140 |
|
my ( $value, $map ) = @_; |
141 |
|
my $out; |
142 |
|
foreach my $name ( keys %$map ) { |
143 |
|
push @$out, $name if $value & $map->{$name}; |
144 |
|
} |
145 |
|
push @$out, sprintf("%x", $value) unless $out; |
146 |
|
return $out; |
147 |
|
} |
148 |
|
|
149 |
|
sub Capabilities { |
150 |
|
|
151 |
|
my @rccaps = _soap->GetRemoteControlCapabilities()->paramsout; |
152 |
|
|
153 |
|
my $return = { |
154 |
|
IanaOemNumber => $rccaps[0], |
155 |
|
OemDefinedCapabilities => |
156 |
|
describe( $rccaps[1], $OemDefinedCapabilitiesSupported ), |
157 |
|
SpecialCommands => |
158 |
|
describe( $rccaps[2], $SpecialCommandSupported ), |
159 |
|
SystemCapabilities => |
160 |
|
describe( $rccaps[3], $SystemCapabilitiesSupported ), |
161 |
|
SystemFirmwareCapabilities => |
162 |
|
describe( $rccaps[4], $SystemFirmwareCapabilitiesSupported ), |
163 |
|
}; |
164 |
|
|
165 |
|
warn '# RemoteControlCapabilities ',dump( $return ); |
166 |
|
return $return; |
167 |
|
} |
168 |
|
|
169 |
|
sub run { |
170 |
|
|
171 |
|
my @args; |
172 |
|
|
173 |
|
my $BootOption; |
174 |
|
my $SpecialCommandParameter; |
175 |
|
|
176 |
|
foreach my $command ( @_ ) { |
177 |
|
|
178 |
|
my $i; |
179 |
|
|
180 |
|
if ( $i = $BootOptions->{$command} ) { |
181 |
|
if ( $BootOption ) { |
182 |
|
$BootOption |= $i; |
183 |
|
next; |
184 |
|
} else { |
185 |
|
$BootOption = $i; |
186 |
|
$command = 'SetBootOptions'; |
187 |
|
} |
188 |
|
} elsif ( $i = $SpecialCommandParameters->{$command} ) { |
189 |
|
$SpecialCommandParameter |= $i; |
190 |
|
} elsif ( $i = $RemoteControlCommand->{$command} ) { |
191 |
|
push @args, SOAP::Data->name( 'Command' => $i ); |
192 |
|
} elsif ( $i = $SpecialCommands->{$command} ) { |
193 |
|
push @args, SOAP::Data->name( 'SpecialCommand' => $i ); |
194 |
|
} elsif ( $i = $OEMParameters->{$command} ) { |
195 |
|
push @args, SOAP::Data->name( 'OEMParameters' => $i ); |
196 |
|
} else { |
197 |
|
die "can't find $command"; |
198 |
|
} |
199 |
|
|
200 |
|
} |
201 |
|
|
202 |
|
|
203 |
|
if ( $BootOption ) { |
204 |
|
warn "invalid BootOptions $BootOption" unless |
205 |
|
( $BootOption & $BootOptionsReservedBits ); |
206 |
|
push @args, SOAP::Data->name( 'BootOptions' => $BootOption ); |
207 |
|
} |
208 |
|
|
209 |
|
if ( $SpecialCommandParameter ) { |
210 |
|
warn "invalid SpecialCommandParameter $SpecialCommandParameter" unless |
211 |
|
( $SpecialCommandParameter & $SpecialCommandParametersReservedBits ); |
212 |
|
push @args, SOAP::Data->name( 'SpecialCommandParameter' => $SpecialCommandParameter ); |
213 |
|
} |
214 |
|
|
215 |
|
push @args, SOAP::Data->name( 'IanaOemNumber' => $IanaNumbers->{IntelIanaNumber} ); |
216 |
|
warn "args ",dump( @args ); |
217 |
|
|
218 |
|
|
219 |
|
_soap( @args ); |
220 |
|
|
221 |
|
} |
222 |
|
|
223 |
1; |
1; |