/[Intel-AMT]/trunk/lib/Intel/AMT/RemoteControl.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Contents of /trunk/lib/Intel/AMT/RemoteControl.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 13 - (show annotations)
Sun Aug 9 15:51:00 2009 UTC (14 years, 7 months ago) by dpavlin
File size: 5975 byte(s)
ForcePXEBoot which works on AMT 3.2.1 and doesn't on 4.0.3

1 package Intel::AMT::RemoteControl;
2
3 use warnings;
4 use strict;
5
6 our $SystemCapabilitiesSupported = {
7 PowerCycleReset => 1,
8 PowerDown => 2,
9 PowerUp => 4,
10 Reset => 8,
11 };
12
13 our $RemoteControlCommand = {
14
15 Reset => 16, # 0x10
16 PowerUp => 17, # 0x11
17 PowerDown => 18, # 0x12
18 PowerCycleReset => 19, # 0x13
19 SetBootOptions => 33, # 0x21
20
21 };
22
23
24 # Reserved bits for checking correctness of the Boot Options settings
25 our $BootOptionsReservedBits = 1817;
26
27 # bootOptions = LockPowerButton | LockKeyboard | FirmwareVerbosityVerbose
28 our $BootOptions = {
29
30 LockPowerButton => 2, # 1 << 1
31 LockResetButton => 4, # 1 << 2
32 LockKeyboard => 32, # 1 << 5
33 LockSleepButton => 64, # 1 << 6
34 UserPasswordBypass => 2048, # 1 << 11
35 ForceProgressEvents => 4096, # 1 << 12
36
37 # only one from the Firmware verbosity options can be used
38 VerbositySystemDefault => 0, # system default
39 VerbosityQuiet => 8192, # 1 << 13 minimal screen activity
40 VerbosityVerbose => 16384, # 1 << 14 all messages appear on the screen
41 VerbosityBlank => 24576, # 3 << 13 blank, no messages appear on the screen.
42
43 ConfigurationDataReset => 32768, # 1 << 14
44
45 };
46
47 our $SystemFirmwareCapabilitiesSupported = {
48 VerbosityBlank => 1,
49
50 LockPowerButton => 2,
51 LockResetButton => 4,
52 LockKeyboard => 32,
53 LockSleepButton => 64,
54 UserPasswordBypass => 2048,
55 ForcedProgressEvents => 4096,
56
57 VerbosityVerbose => 8192,
58 VerbosityQuiet => 16384,
59
60 ConfigurationDataReset => 32768,
61 };
62
63 our $SpecialCommands = {
64
65 NOP => 0, # 0x00
66 ForcePXEBoot => 1, # 0x01
67 ForceHardDriveBoot => 2, # 0x02
68 ForceHardDriveSafeModeBoot => 3, # 0x03
69 ForceDiagnosticsBoot => 4, # 0x04
70 ForceCDorDVDBoot => 5, # 0x05
71 # 06h-0BFh Reserved for future ASF definition
72 IntelOemCommand => 193, # 0x0C1
73 # 0C1h-0FFh Reserved FOR OEM
74
75 };
76
77 our $OEMParameters = {
78
79 UndefinedOEMParameter => 0,
80 UseSol => 1, # 1 << 1
81
82 };
83
84 our $SpecialCommandSupported = {
85 ForcePXEBoot => 256,
86 ForceHardDriveBoot => 512,
87 ForceHardDriveSafeModeBoot => 1024,
88 ForceDiagnosticsBoot => 2048,
89 ForceCDorDVDBoot => 4096,
90 };
91
92 our $OemDefinedCapabilitiesSupported = {
93
94 IDER => 1,
95 SOL => 2,
96 BiosReflash => 4,
97 BiosSetup => 8,
98 BiosPause => 16,
99
100 };
101
102 # specialCommParam = UseIderCD | ReflashBios
103
104 our $SpecialCommandParameters = {
105
106 UndefinedSpecialCommandParameter => 0,
107 UseIderFloppy => 1, # use floppy as IDER boot device
108 ReflashBios => 4, # 1 << 2
109 BiosSetup => 8, # 1 << 3
110 BiosPause => 16, # 1 << 4
111 UseIderCD => 257, # 1 | (1 << 8) use CD/DVD as IDER boot device
112
113 };
114
115 # Reserved bits for checking correctness of the Special Parameters settings
116 our $SpecialCommandParametersReservedBits = 65248;
117
118 our $IanaNumbers = {
119
120 IntelIanaNumber => 343,
121 ASFIanaNumber => 4542,
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 _soap( @args );
219
220 }
221
222 sub boot {
223 run qw/Reset/;
224 }
225
226 sub sol_boot {
227 run qw/Reset IntelOemCommand UseSol/;
228 }
229
230 sub sol_boot_biossetup {
231 run qw/Reset IntelOemCommand UseSol BiosSetup/;
232 }
233
234 sub ider_floppy_boot {
235 run qw/Reset IntelOemCommand UseIderFloppy/;
236 }
237
238 sub ider_cd_boot {
239 run qw/Reset IntelOemCommand UseIderCD/
240 }
241
242 sub sol_ider_cd_boot {
243 run qw/Reset IntelOemCommand UseSol UseIderCD/;
244 }
245
246 sub sol_ider_floppy_boot {
247 run qw/Reset IntelOemCommand UseSol UseIderFloppy/;
248 }
249
250 sub pxe_boot {
251 run qw/SetBootOptions ForcePXEBoot/;
252 }
253
254 1;

  ViewVC Help
Powered by ViewVC 1.1.26