summaryrefslogtreecommitdiff
path: root/ReferenceCode/ME/At/AtAm/Dxe/AtHi.h
blob: ee03cf8e6fe7973486844c1c7b32da439d867e25 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
/** @file
  Definition of AT Host Interface (ATHI) Protocol messages between the
  AT Service and HOST Applications.

@copyright
  Copyright (c) 2007 - 2012 Intel Corporation. All rights
  reserved This software and associated documentation (if any)
  is furnished under a license and may only be used or copied in
  accordance with the terms of the license. Except as permitted
  by such license, no part of this software or documentation may
  be reproduced, stored in a retrieval system, or transmitted in
  any form or by any means without the express written consent
  of Intel Corporation.

  This file contains an 'Intel Peripheral Driver' and uniquely
  identified as "Intel Reference Module" and is
  licensed for Intel CPUs and chipsets under the terms of your
  license agreement with Intel or your vendor.  This file may
  be modified by the user, subject to additional terms of the
  license agreement
**/
#ifndef _AT_HI_H
#define _AT_HI_H

#include "MeLib.h"

#define AT_COMMAND         0
#define AT_RESPONSE        1

#define AT_ME_RULE_ID      0xd0000
#define AT_ME_RULE_GROUP   0x03
#define AT_ME_RULE_COMMAND 0x02

#pragma pack(1)
///
/// ATHI Protocol Identifier
///
/// AT Host Interface protocol GUID
///
#define ATHI_PROTOCOL_GUID \
  { \
    0x3C4852D6, 0xD47B, 0x4f46, 0xB0, 0x5E, 0xB5, 0xED, 0xC1, 0xAA, 0x43, 0x0A \
  }

#define ATHI_PROTOCOL_FIXED_GUID \
  { \
    0xfa8f55e8, 0xab22, 0x42dd, 0xb9, 0x16, 0x7d, 0xce, 0x39, 0x00, 0x25, 0x74 \
  }

///
/// AT Host Interface protocol version (for ME FW internal use)
///
#define ATHI_PROTOCOL_VERSION_ME      1

///
/// AT Host Interface protocol major version
///
#define ATHI_PROTOCOL_VERSION_MAJOR   5

///
/// AT Host Interface protocol minor version
///
#define ATHI_PROTOCOL_VERSION_MINOR   0

///
/// ATHI Framing Structures
/// Defines the ATHI header and creates a type name.
///
/// Refer to AtHiHeader.dot "ATHI Header"
///
typedef struct _ATHI_HEADER {
  ///
  /// The version number for the ATHI protocol.
  ///
  struct {
    ///
    /// The major version number. The major version number shall advance if
    /// and only if backwards compatibility is broken by a change to the
    /// protocol. If ME firmware doesn't specifically support the version
    /// number supplied in the header, an error shall be returned.
    ///
    UINT8 Major;

    ///
    /// The minor version number. All minor versions under a given major
    /// version shall be backwards compatible with prevision minor versions
    /// under that major version. If the version number supplied in the
    /// header is higher than the minor version number supported by ME
    /// firmware, an error shall be returned.

    UINT8 Minor;
  } Version;

  ///
  /// Specifies the command or response in the message.
  ///
  struct {
    ///
    /// The operation with which the command is associated.
    ///
    UINT16  Code : 7;

    ///
    /// Command/Response indicator:
    /// 0 The message contains a command.
    /// 1 The message contains a response.
    ///
    UINT16  IsResponse : 1;

    ///
    /// The functional category of the command
    ///
    /// See _ATHI_CMD_GROUP
    ///
    UINT16  Category : 8;
  } Command;

  ///
  /// The length in bytes of the message. The length applies to the message
  /// body (excludes the header and signature fields).
  ///
  UINT32  Length;
} ATHI_HEADER;

///
/// Maximum blob data size.
///
#define AT_BLOB_LENGTH_MAX 256

///
/// Structure that defines the format of the Blob to be stored and retrieved
/// for the ISV software.
///
typedef struct _AT_BLOB {
  ///
  /// The length of the data to be securely stored
  ///
  UINT32  Length;

  ///
  /// The data to be securely stored
  ///
  UINT8   Value[AT_BLOB_LENGTH_MAX];
} AT_BLOB;

#define AT_NONCE_LENGTH  16  ///< Maximum nonce length.

///
/// Type definition for a nonce. To prevent replay of commands, a nonce
/// shall be added to each command message. A nonce is a value that is used
/// once. Ideally, each nonce value should not be used more than once during
/// the lifetime of the AT laptop computer. However, a nonce generation function
/// that guarantees a very low probability of nonce values being repeated shall
/// suffice.
///

typedef UINT8 AT_NONCE[AT_NONCE_LENGTH];

///
/// Command Completion Codes. Each response message contains a completion code
/// that indicates whether the command completed successfully, and the nature
/// of the failure if it did not.
///
typedef enum _ATHI_COMPLETION_CODE
{
  ///
  /// The command completed successfully.
  ///
  ATHI_COMPCODE_SUCCESS          = 0,

  ///
  /// The command failed due to an internal error.
  ///
  ATHI_COMPCODE_INTERNAL_FAILURE,

  ///
  /// The command is not recognized, or is recognized but not supported.
  ///
  ATHI_COMPCODE_INVALID_OPERATION,

  ///
  /// A parameter value does not satisfy the requirements of the command.
  ///
  ATHI_COMPCODE_INVALID_PARAM    = 6,

  ///
  /// The value of the length field in the message header is outside the
  /// supported range for the command.
  ///
  ATHI_COMPCODE_INVALID_MSG_LEN,

  ///
  /// The command failed, but no information about the nature of the failure is available.
  ///
  ATHI_COMPCODE_GENERAL_FAILURE,

  ///
  /// Maximum value for a completion code.
  ///
  ATHI_COMPCODE_MAXIMUM
} ATHI_COMPLETION_CODE;

///
/// Useful definitions for basic commands (commands without a body)
///

///
/// Type name for an unsigned command message that has no body (header only).
///
typedef ATHI_HEADER  ATHI_BASIC_CMD;

///
/// Definition and type name for a basic response. The basic response has a
/// header and a minimal body (just the Completion Code).
///
typedef struct _ATHI_BASIC_RSP {
  ATHI_HEADER          Header;         ///< Message header

  ATHI_COMPLETION_CODE CompletionCode; ///< Completion code
} ATHI_BASIC_RSP;

///
/// AT Command Groups
///

/// Related ATHI commands are grouped into several categories. Each command
/// code contains the code of its category. See #ATHI_HEADER.
///
typedef enum _ATHI_CMD_GROUP
{
  ATHI_CMD_GROUP_RESERVED        = 0, ///< Reserved

  ///
  /// Commands related to the ME's theft protection capabilities.
  ///
  /// See _ATHI_THEFT_DETECT_GRP_CMD
  ///
  ATHI_CMD_GROUP_THEFT_DETECTION,

  ///
  /// Commands related to non-volatile data storage services provided to
  /// the FDE/FLE software present on the AT laptop computer.
  ///
  /// See _ATHI_DATA_STORE_GRP_CMD
  ///
  ATHI_CMD_GROUP_DATA_STORAGE,

  ///
  /// Commands related to securely recovering the AT laptop computer for
  /// AT disablement actions.
  ///
  /// See _ATHI_RECOVERY_GRP_CMD
  ///
  ATHI_CMD_GROUP_RECOVERY,

  ///
  /// Commands related to ATHI infrastructure.
  ///
  /// See _ATHI_GENERAL_GRP_CMD
  ///
  ATHI_CMD_GROUP_GENERAL,

  ///
  /// Event notifications serve to inform the ME AT Service when an
  /// event occurs in the PBA or AT server.
  ///
  /// See _ATHI_NOTIFICATION_GRP_CMD
  ///
  ATHI_CMD_GROUP_NOTIFICATIONS,

  ///
  /// 3G NIC commands allow BIOS to initialize and request Radio
  /// status from FW
  ///
  /// See _ATHI_3G_NIC_GRP_CMD
  ///
  ATHI_CMD_GROUP_3G_NIC,

  ///
  /// Boundary check.
  ///
  ATHI_CMD_GROUP_MAX
} ATHI_CMD_GROUP;

///
/// ATHI THEFT DETECTION Group Commands
///

/// Theft detection commands control and configure the theft protection
/// capabilities of the ME AT Service.
///
typedef enum _ATHI_THEFT_DETECT_GRP_CMD
{
  ///
  /// Returns the AT state of the monitored system.
  ///
  /// See ATHI_GET_STATE_CMD
  ///
  ATHI_THEFT_DETECT_GRP_GET_STATE_CMD,

  ///
  /// Returns the state of the specified timer.
  ///
  /// See ATHI_GET_TIMER_INFO_CMD
  ///
  ATHI_THEFT_DETECT_GRP_GET_TIMER_INFO_CMD,

  ///
  /// Resets the specified timer to its configured reset interval.
  ///
  /// See ATHI_RESET_TIMER_CMD
  ///
  ATHI_THEFT_DETECT_GRP_RST_TIMER_CMD,

  ///
  /// Configures the actions that the ME AT Service shall take if the
  /// specified event occurs.
  ///
  /// See ATHI_SET_POLICY_CMD
  ///
  ATHI_THEFT_DETECT_GRP_SET_POLICY_CMD,

  ///
  /// Returns the actions that the ME AT Service shall take if the
  /// specified event occurs.
  ///
  /// See ATHI_GET_POLICY_CMD
  ///
  ATHI_THEFT_DETECT_GRP_GET_POLICY_CMD,

  ///
  /// Sets the reset interval for the specified timer. The timer counts down
  /// and expires if it reaches 0.
  ///
  /// See ATHI_SET_TIMER_INTERVAL_CMD
  ///
  ATHI_THEFT_DETECT_GRP_SET_TIMER_INTERVAL_CMD,

  ///
  /// Asserts that the AT laptop is stolen. The ME AT Service shall proceed
  /// immediately to the Stolen state, executing all actions in the
  /// AssertStolenPolicy.
  ///
  /// See ATHI_ASSERT_STOLEN_CMD
  ///
  ATHI_THEFT_DETECT_GRP_ASSERT_STOLEN_CMD,

  ///
  /// Same as the AssertStolen command but not signed.
  ///
  /// See ATHI_ASSERT_STOLEN_CMD
  ///
  ATHI_THEFT_DETECT_GRP_UNSIGNED_ASSERT_STOLEN_CMD,

  ///
  /// Returns the AT current state in unsigned mode.
  ///
  /// See GET_STATE_UNSIGNED
  ///
  ATHI_THEFT_DETECT_GRP_GET_STATE_UNSIGNED,

  ///
  /// Boundary check.
  ///
  ATHI_THEFT_DETECT_GRP_MAX
} ATHI_THEFT_DETECT_GRP_CMD;

///
/// This flag indicates that AT is in the STOLEN state and the policies are set
/// to "do nothing". The mask must be applied to the AT state rule.
///
/// NOTE: This flag is only cleared when the FW receives an AssertStolen
/// message.
///
#define AT_PSEUDO_STOLEN_STATE_MASK  0x00000080

///
/// Enumeration of AT theft triggers IDs
///
typedef enum _AT_THEFT_TRIGGER
{
  ///
  /// None.
  ///
  AT_THEFT_TRIGGER_NA                              = 0,

  ///
  /// Theft trigger identifier for disable timer expiration
  ///
  AT_THEFT_TRIGGER_DISABLE_TIMER_EXPIRATION,

  ///
  /// Theft trigger identifier for command driven disablement.
  ///
  AT_THEFT_TRIGGER_ASSERT_STOLEN,

  ///
  /// Theft trigger identifier for PBA logon failure exceeded threshold.
  ///
  AT_THEFT_TRIGGER_THRESHOLD_EXCEEDED,

  ///
  /// Theft trigger identifier for platform attack detection.
  ///
  AT_THEFT_TRIGGER_ATTACK_DETECTED,

  ///
  /// Bounday check.
  ///
  AT_THEFT_TRIGGER_MAX
} AT_THEFT_TRIGGER;

///
/// Enumeration of AT timer types.
///
typedef enum _AT_TIMER_ID
{
  ///
  /// Reserved.
  ///
  AT_TID_RSVD                                      = 0,

  ///
  /// The disable timer is a variation on the watchdog timer. It is periodically
  /// reset by ISV software to indicate that the system is behaving as expected.
  /// If it is not reset before it expires, the ME AT Service shall execute the
  /// protective actions configured in its disable timer policy.
  /// The first line of defense when the system begins to exhibit behavior that
  /// indicates it has been stolen is the ISV software, which may invoke the
  /// ATHI SetPolicy function to protect the platform.
  /// The disable timer is designed to protect the system if the ISV software
  /// is disabled. In this case, the ISV software will be unable to reset the
  /// disable timer before it expires, and the ME AT Service will take the
  /// configured protective actions.
  ///
  AT_TID_DISABLE_TIMER,

  ///
  /// The unlock timer used when the AT laptop computer is locked. The ME AT Service
  /// sets the recovery timer when it sees that the AT state is Stolen during
  /// the host boot flow. If the user doesn't successfully complete the
  /// platform_enable_flow recovery flow before the unlock timer expires,
  /// the ME AT Service shall power down the platform immediately.
  /// The variable UnlockTimerInterval shall be configurable within a range
  /// that is long enough to facilitate a bona fide recovery attempt, but short
  /// enough to prevent exploitation of the platform by a thief that does not
  /// have the recovery credential.
  ///
  AT_TID_UNLOCK_TIMER,

  ///
  /// The grace timer allows the user of a AT laptop computer time to take
  /// actions to cause a ResetTimer command to be issued by the AT service.
  /// The grace period shall be applied if and only if the ME AT service
  /// determines that the Disable Timer logically expired while the AT
  /// laptop computer was in Sx (sleeping).
  ///
  AT_TID_GRACE_TIMER,

  ///
  /// The PBA Logon Timer shall be used to count down the allotted time for
  /// PBA Logon. The ME AT Service shall start a PBA Logon Timer upon
  /// transition from S4/S5 to S0. If the ME AT Service receives a property
  /// authenticated PBA Logon notification message  before the PBA Logon Timer
  /// expires, it shall stop the timer and allow operation to continue normally.
  /// If instead the PBA Logon Timer expires before the ME AT Service has
  /// received a properly authenticated PBA Logon notification message, the
  /// ME AT Service shall power down the system immediately, but shall not
  /// transition to the Stolen state.
  ///
  AT_TID_PBA_LOGON_TIMER,

  ///
  /// The activity timer is used to extend the period of the Disable Timer in
  /// the event that a ATHI client has recently invoked a ATHI command when
  /// the Disable Timer expires. The intent is to allow the client to complete
  /// a command flow that may include a ResetTimer command.
  /// The AT activity timer shall be reset each time a ATHI command is completed.
  /// The interval of the AT activity timer shall be 30 seconds. This interval
  /// shall not be externally configurable.
  ///
  AT_TID_ACTIVITY_TIMER,

  ///
  /// Bounday check.
  ///
  AT_TID_MAX
} AT_TIMER_ID;

///
/// A timer with an interval of -1 means that the timer is disabled. Applies to
/// AT_TIMER_CONFIG and AT_TIMER_INFO.
///
#define AT_TIMER_DISABLED  0xFFFFFFFF

///
/// Maximum timer value besides the disabled timer value. This value is due to
/// the maximum timer value allowed by the FW resources.
///
#define AT_TIMER_MAX (AT_TIMER_DISABLED / 1024)

///
/// Remaining grace timer in which the user is not assumed not to be able to
/// complete a TimerResetCmd due to OS context loading from S3 -> S0.
///
/// Value is 30 seconds.
///
#define AT_LOW_GRACE_THRESHOLD 30

///
/// Minumium DISABLE timer value (in seconds)
///
#define AT_TMR_DISABLE_MIN 60

///
/// Minumium DISABLE timer value (in seconds)
///
#define AT_TMR_DISABLE_MAX AT_TIMER_DISABLED

///
// Minumium UNLOCK timer value (in seconds)
///
#define AT_TMR_UNLOCK_MIN  60

///
/// Minumium UNLOCK timer value (in seconds)
///
#define AT_TMR_UNLOCK_MAX  AT_TIMER_MAX

///
/// Minumium GRACE timer value (in seconds)
///
#define AT_TMR_GRACE_MIN 60

///
/// Minumium GRACE timer value (in seconds)
///
#define AT_TMR_GRACE_MAX AT_TIMER_MAX

///
// Minumium PBALOGON timer value (in seconds)
///
#define AT_TMR_PBALOGON_MIN  60

///
/// Minumium PBALOGON timer value (in seconds)
///
#define AT_TMR_PBALOGON_MAX  AT_TIMER_DISABLED

///
/// Structure that contains the configuration and state information for
/// a specified timer.
///
typedef struct _AT_TIMER_INFO {
  ///
  /// Identifies the timer that shall be configured. See #AT_TIMER_ID.
  ///
  UINT8   Id;

  ///
  /// Padding for now
  ///
  UINT8   Reserved[3];

  ///
  /// The interval configured in the timer, in seconds.
  ///
  UINT32  Interval;

  ///
  /// The number of ticks remaining in the current timer countdown.
  ///
  UINT32  TimeLeft;
} AT_TIMER_INFO;

///
/// Structure defining the PBAM Configuration.
///
typedef struct _AT_POLICY_PBA_CONFIG {
  UINT8 RunAfterPost : 1;
  UINT8 IsInstalled : 1;
  UINT8 Reserved : 6;
} AT_POLICY_PBA_CONFIG;

///
/// Optional union defining the PBAM Configuration.
///
typedef union _AT_POLICY_PBA_CONFIG_U {
  UINT8                 Value;
  AT_POLICY_PBA_CONFIG  Bits;
} AT_POLICY_PBA_CONFIG_U;

///
/// Enumeration of the platform lock state
///
typedef enum _AT_PLATFORM_LOCKSTATE
{
  AT_PLATFORM_LOCKSTATE_NOTLOCKED = 0,
  AT_PLATFORM_LOCKSTATE_LOCKED,
  AT_PLATFORM_LOCKSTATE_MAX
} AT_PLATFORM_LOCKSTATE;

//
// Command definition structures
//

///
/// The GetATState command. Returns the AT state of the laptop computer.
///
/// Sender:        AT AM  | PBA
/// Signing Key:   None   | None
///
/// Refer to AtHiGetStateCmd.dot "GetState command"
///
/// See ATHI_GET_STATE_RSP
///
typedef ATHI_BASIC_CMD ATHI_GET_STATE_CMD;

///
// The GetATState response.
///
/// Refer to AtHiGetStateRsp.dot "GetState response"
///
///
typedef struct _ATHI_GET_STATE_RSP {
  ATHI_HEADER          Header;
  ATHI_COMPLETION_CODE CompletionCode;
  AT_STATE_INFO        StateInfo;
} ATHI_GET_STATE_RSP;

///
/// The GetTimerInfo command. Returns configuration and state information about
/// the specified timer.
///
/// Sender:        PBA
/// Signing Key:   PBASK
///
/// Refer to AtHiGetTimerInfoCmd.dot "GetTimerInfo command"
///
/// See ATHI_GET_TIMER_INFO_RSP
///
typedef struct _ATHI_GET_TIMER_INFO_CMD {
  ATHI_HEADER  Header;
  UINT8        TimerId;
} ATHI_GET_TIMER_INFO_CMD;

///
/// ATHI_GET_TIMER_INFO response.
///
/// Refer to AtHiGetTimerInfoRsp.dot "GetTimerInfo response"
///
typedef struct _ATHI_GET_TIMER_INFO_RSP {
  ATHI_HEADER          Header;
  ATHI_COMPLETION_CODE CompletionCode;
  AT_TIMER_INFO        TimerInfo;
} ATHI_GET_TIMER_INFO_RSP;

///
/// ATHI RECOVERY Group Commands
///
typedef enum _ATHI_RECOVERY_GRP_CMD
{
  ///
  /// SetCredential stores the recovery credential in non-volatile storage,
  /// where it is used for validation purposes when the credential is presented
  /// by a user during recovery flow.
  ///
  /// See #ATHI_SET_CREDENTIAL_CMD
  ///
  ATHI_RECOVERY_GRP_SET_CREDENTIAL_CMD,
  ///
  /// AuthenticateRecoveryCredential presents the a credential to the ME AT
  /// Service for validation during the recovery flow.
  ///
  /// See ATHI_AUTHENTICATE_CREDENTIAL_CMD
  ///
  ATHI_RECOVERY_GRP_AUTH_CREDENTIAL_CMD,
  ///
  /// The ComputeHash command computes a specified hash of input data. Maximum
  /// size of the digest value shall be 384 bits (48 bytes). This command may
  /// be used to preprocess authentication tokens if the specified hash
  /// algorithm is not supported by the requester.
  ///
  /// See ATHI_COMPUTE_HASH_CMD
  ///
  ATHI_RECOVERY_GRP_COMPUTE_HASH_CMD,
  ///
  /// The DeAssertStolen command is used to recovery the platfrom from stolen state
  /// by PBAM or AT server
  /// See ATHI_DEASSERT_STOLEN_CMD
  ///
  ATHI_RECOVERY_GRP_DEASSERT_STOLEN_CMD,
  ///
  /// The GetIsvId command exports the identity of the service provider (ISV)
  /// that activated the AT service
  /// See ATHI_GET_ISVID_CMD
  ///
  ATHI_RECOVERY_GRP_GET_ISVID_CMD,
  ///
  /// Bounday check.
  ///
  ATHI_RECOVERY_GRP_MAX
} ATHI_RECOVERY_GRP_CMD;

///
/// This enumeration defines the credential types.
///
typedef enum _AT_CREDENTIAL_TYPE
{
  ///
  // Reserved.
  ///
  AT_CREDENTIAL_TYPE_RSVD                          = 0,

  ///
  // User defined recovery passphrase
  ///
  AT_CREDENTIAL_TYPE_USER_PASSPHRASE,

  ///
  /// Server generated random token
  ///
  AT_CREDENTIAL_TYPE_SRTK,

  ///
  /// Server suspend token
  ///
  AT_CREDENTIAL_TYPE_SSTK,

  ///
  /// Base key
  ///
  AT_CREDENTIAL_TYPE_BK,

  ///
  /// Boundary check.
  ///
  AT_CREDENTIAL_TYPE_MAX
} AT_CREDENTIAL_TYPE;

///
// This enumeration defines the salt IDs.
///
typedef enum _AT_HASH_ALGO_ID
{
  ///
  /// Reserved.
  ///
  AT_HASH_ALGO_ID_RSVD                             = 0,

  ///
  /// SHA-1 algorithm (160-bit output)
  ///
  AT_HASH_ALGO_ID_SHA1,

  ///
  /// Boundary check
  ///
  AT_HASH_ALGO_ID_MAX
} AT_HASH_ALGO_ID;

///
/// Defines the maximum length of a user passpharse recovery hash (will be 32 in 2009).
///
#define AT_USR_PASS_HASH_LENGTH_MAX  20

///
/// Defines the maximum length of a SRTK recovery token
///
#define AT_SRTK_LENGTH_MAX  32

///
/// Maximium credential length.
///
#define AT_CREDENTIAL_VALUE_LENGTH_MAX AT_SRTK_LENGTH_MAX

#define AT_PASSWORD_LENGTH             64

///
/// Structure that defines a credential for storage, validation, and export operations.
///
typedef struct _AT_CREDENTIAL {
  ///
  /// The credential type
  ///
  AT_CREDENTIAL_TYPE Type;

  ///
  /// The credential length
  ///
  UINT32              Length;

  ///
  /// The credential value
  ///
  UINT8               Value[1]; /// Need a pointer but cannot make a zero length array
} AT_CREDENTIAL;

///
/// The AuthenticateCredential command. Sets the value of the specified
/// credential in the ME AT Service.
///
/// Sender:        AT AM
/// Signing Key:   None
///
/// Refer to AtHiAuthenticateCredentialCmd.dot "AuthenticateCredential command"
///
/// See ATHI_AUTHENTICATE_CREDENTIAL_RSP
///
typedef struct _ATHI_AUTHENTICATE_CREDENTIAL_CMD {
  ATHI_HEADER    Header;
  AT_CREDENTIAL  Credential;
} ATHI_AUTHENTICATE_CREDENTIAL_CMD;

///
/// The AuthenticateCredential response.
///
/// Refer to AtHiAuthenticateCredentialRsp.dot "AuthenticateCredential response"
///
typedef struct _ATHI_AUTHENTICATE_CREDENTIAL_RSP {
  ATHI_HEADER          Header;
  ATHI_COMPLETION_CODE CompletionCode;
  UINT8                Authenticated;
} ATHI_AUTHENTICATE_CREDENTIAL_RSP;

///
/// Definition for the maximum hash output size.
///
#define AT_MAX_HASH_OUTPUT_SIZE  48

///
/// The ComputeHash command. Computes a specified hash of input data. Maximum
/// size of the digest value shall be 384 bits (48 bytes).
///
/// Sender:        AT AM
/// Signing Key:   None
///
/// Refer to AtHiComputeHashCmd.dot "ComputeHash command"
///
/// See ATHI_COMPUTE_HASH_RSP
///
typedef struct _ATHI_COMPUTE_HASH_CMD {
  ATHI_HEADER  Header;

  ///
  /// see AT_HASH_ALGO_ID for values
  ///
  UINT8        Algorithm;
  UINT8        InputLength;
  UINT8        InputBuffer[AT_MAX_HASH_OUTPUT_SIZE];
} ATHI_COMPUTE_HASH_CMD;

///
/// The ComputeHash response.
///
/// Refer to AtHiComputeHashRsp.dot "ComputeHash response"
///
///
typedef struct _ATHI_COMPUTE_HASH_RSP {
  ATHI_HEADER          Header;
  ATHI_COMPLETION_CODE CompletionCode;

  ///
  /// see AT_HASH_ALGO_ID for values
  ///
  UINT8                OutputLength;
  UINT8                OutputBuffer[AT_MAX_HASH_OUTPUT_SIZE];
} ATHI_COMPUTE_HASH_RSP;

///
/// The DeassertStolen command. Recover the laptop from stolen state. The ME AT
/// Service shall proceed immediately to the NotStolen state.
///
/// Sender:        ISV SW
/// Signing Key:   PBASK, TSSK
///
/// Refer to AtHiDeassertStolenCmd.dot "DeassertStolen command"
///
/// See ATHI_DEASSERT_STOLEN_RSP
///
typedef ATHI_BASIC_CMD ATHI_DEASSERT_STOLEN_CMD;

typedef ATHI_BASIC_RSP ATHI_DEASSERT_STOLEN_RSP;

///
/// The GetIsvId command exports the identity of the service provider (ISV) that
/// activated the AT service. This allows for system recovery in cases where the user
/// may not be sure who to contact when he/she is unable to recover the system locally.
/// Note that this command is allowed only while the system in the STOLEN state
///
/// Sender:        AT AM
/// Signing Key:   None
///
/// See ATHI_GET_ISVID_RSP
///
typedef ATHI_BASIC_CMD ATHI_GET_ISVID_CMD;

typedef struct _ATHI_GET_ISVID_RSP {
  ATHI_HEADER           Header;
  ATHI_COMPLETION_CODE  CompletionCode;
  UINT32                IsvId;
} ATHI_GET_ISVID_RSP;

///
/// ATHI General Group Commands
///
typedef enum _ATHI_GENERAL_GRP_CMD
{
  ///
  /// GetNonce returns a nonce generated by the ME AT Service. The purpose of
  /// this nonce is to prevent replay of AT command messages.
  ///
  /// See ATHI_GET_NONCE_CMD
  ///
  ATHI_GENERAL_GRP_GET_NONCE_CMD,

  ///
  /// GetATCapabilities requests that the ME AT Service return the
  /// capabilities it has implemented.
  ///
  /// See ATHI_GET_AT_CAPABILITIES_CMD
  ///
  ATHI_GENERAL_GRP_GET_AT_CAPABILITIES_CMD,

  ///
  /// The SetPublicKey command saves the specified public key of an RSA
  /// key-pair for use by the ME AT Service.
  ///
  /// See ATHI_GET_PUBLIC_KEY_CMD
  ///
  ATHI_GENERAL_GRP_SET_PUBLIC_KEY_CMD,

  ///
  /// The GetPublicKey command returns the specified public key of an RSA
  /// key-pair owned by the ME AT Service.
  ///
  /// See ATHI_GET_PUBLIC_KEY_CMD
  ///
  ATHI_GENERAL_GRP_GET_PUBLIC_KEY_CMD,

  ///
  /// The GetEventHistory command retrieves entries from the AT Event History
  /// in the ME.
  ///
  /// See ATHI_GET_EVENT_HISTORY_CMD
  ///
  ATHI_GENERAL_GRP_GET_EVENT_HISTORY_CMD,

  ///
  /// The ClearEventHistory command deletes all entries from the AT Event
  /// History in the ME.
  ///
  /// See ATHI_CLEAR_EVENT_HISTORY_CMD
  ///
  ATHI_GENERAL_GRP_CLEAR_EVENT_HISTORY_CMD,

  ///
  /// The SetSysTime command synchronizes the time between the FW with the
  /// AT server.
  ///
  /// See ATHI_SET_SYS_TIME_CMD
  ///
  ATHI_GENERAL_GRP_SET_SYS_TIME_CMD,

  ///
  /// The Set Supend Mode command requests FW transition
  /// into or out of Suspend Mode.
  ///

  ATHI_GENERAL_GRP_SET_SUSPEND_CMD                 = 8,

  ///
  /// Bounday check.
  ///
  ATHI_GENERAL_GRP_MAX
} ATHI_GENERAL_GRP_CMD;

///
/// ATHI 3G WWAN Commands
///
typedef enum _ATHI_3G_NIC_GRP_CMD
{ ///
  /// 3G NIC Init Command tells FW to intialize the NIC radio
  ///
  ATHI_3G_NIC_GRP_INIT_CMD                         = 3,

  ///
  /// The 3G NIC Query Command asks FW about the status of the NIC radio
  ///
  ATHI_3G_NIC_GRP_QUERY_CMD,

  ///
  /// Bounday check.
  ///
  ATHI_3G_NIC_GRP_MAX
} ATHI_3G_NIC_GRP_CMD;

///
/// The GetNonce command. Requests that the ME AT Service generate and return
/// a nonce to be used in a subsequent ATHI command. The nonce prevents
/// replay of a command.
///
/// Sender:        ISV SW
/// Signing Key:   Any
///
/// Refer to AtHiGetNonceCmd.dot "GetNonce command"
///
/// See ATHI_GET_NONCE_RSP
///
typedef ATHI_BASIC_CMD ATHI_GET_NONCE_CMD;

///
/// The GetNonce response.
///
/// Refer to AtHiGetNonceRsp.dot "GetNonce response"
///
typedef struct _ATHI_GET_NONCE_RSP {
  ATHI_HEADER          Header;
  ATHI_COMPLETION_CODE CompletionCode;
  AT_NONCE             Nonce;
} ATHI_GET_NONCE_RSP;

///
/// ATHI NOTIFICATION Group Commands
///
typedef enum _ATHI_NOTIFICATION_GRP_CMD
{
  ///
  /// A PBA sends a PBALogon notification message to notify the ME AT service
  /// of a successful user logon.
  ///
  /// See ATHI_PBA_LOGON
  ///
  ATHI_NOTIFICATION_GRP_PBA_LOGON,

  ///
  /// Bounday check.
  ///
  ATHI_NOTIFICATION_GRP_MAX
} ATHI_NOTIFICATION_GRP_CMD;

///
/// PBALogon notification. Notifies the ME AT service of a successful user logon.
///
/// Sender:        PBA
/// Signing Key:   PBASK
///
/// Refer to AtHiPbaLogonNotify.dot "PBALogon notification"
///
/// See ATHI_GET_NONCE_RSP
///
typedef ATHI_BASIC_CMD ATHI_PBA_LOGON_NOTIFY;

///
/// The GetNonce response.
///
/// Refer to AtHiPbaLogonAck.dot "PBALogon ack"
///
typedef ATHI_BASIC_RSP ATHI_PBA_LOGON_ACK;

///
/// ATHI DATA STORAGE Group Commands
///
typedef enum _ATHI_DATA_STORE_GRP_CMD
{
  ///
  /// SetBlob stores data in the ME AT FDE/FLE ISV non-volatile storage area.
  ///
  /// See #ATHI_SET_BLOB_CMD.
  ///
  ATHI_DATA_STORE_GRP_SET_BLOB_CMD,

  ///
  /// GetBlob returns the data stored in the ME AT FDE/FLE ISV non-volatile
  /// storage area.
  ///
  /// See ATHI_GET_BLOB_CMD.
  ///
  ATHI_DATA_STORE_GRP_GET_BLOB_CMD,

  ///
  /// Stores a vendor string the ME's non-volatile storage area.
  ///
  /// See ATHI_SET_VENDOR_STRING_CMD
  ///
  ATHI_DATA_STORE_GRP_SET_VENDOR_STRING_CMD,

  ///
  /// Retrieves the vendor string from the ME's non-volatile storage area.
  ///
  /// See ATHI_GET_VENDOR_STRING_CMD
  ///
  ATHI_DATA_STORE_GRP_GET_VENDOR_STRING_CMD,

  ///
  /// Bounday check.
  ///
  ATHI_DATA_STORE_GRP_MAX
} ATHI_DATA_STORE_GRP_CMD;

///
/// This enumeration defines the vendor string identifiers.
///
typedef enum _AT_VENDOR_STRING_ID
{
  ///
  /// Reserved.
  ///
  AT_VENDOR_STRING_ID_RSVD                         = 0,

  ///
  /// User defined recovery passphrase
  ///
  AT_VENDOR_STRING_ID_RECOVERY_HELP,
  ///
  /// AT_VENDOR_STRING_ID_RECOVERY_HELP,
  ///

  ///
  /// Server generated random token
  ///
  AT_CUSTOM_RECOVERY_ID_CONFIGURATIONS,

  ///
  /// Boundary check.
  ///
  AT_VENDOR_STRING_ID_MAX
} AT_VENDOR_STRING_ID;

///
/// Maximum blob data size.
///
#define AT_VENDOR_STRING_LENGTH_MAX  256

///
/// The SetVendorString command. Stores a vendor string the ME's
/// non-volatile storage area.
///
/// Sender:        ISV SW
/// Signing Key:   TSSK
///
/// See ATHI_SET_VENDOR_STRING_RSP
///
typedef struct _ATHI_SET_VENDOR_STRING_CMD {
  ATHI_HEADER  Header;
  UINT8        Id;
  UINT8        Reserved[3];
  AT_BLOB      String;
} ATHI_SET_VENDOR_STRING_CMD;

///
/// The SetVendorString response.
///
typedef ATHI_BASIC_RSP ATHI_SET_VENDOR_STRING_RSP;

///
/// The GetVendorString command. Retrieves the vendor string data from the ME's
/// non-volatile storage area.
///
/// Sender:        ISV SW
/// Signing Key:   None
///
/// See ATHI_GET_VENDOR_STRING_RSP
///
typedef struct _ATHI_GET_VENDOR_STRING_CMD {
  ATHI_HEADER  Header;
  UINT8        Id;
} ATHI_GET_VENDOR_STRING_CMD;

///
/// The GetVendorString response.
///
/// Sender:        ISV SW
/// Signing Key:   None
///
///
typedef struct _ATHI_GET_VENDOR_STRING_RSP {
  ATHI_HEADER          Header;
  ATHI_COMPLETION_CODE CompletionCode;
  AT_BLOB              String;
} ATHI_GET_VENDOR_STRING_RSP;

///
/// The SendAssertStolen Request
///
/// Sender:        ISV SW
/// Signing Key:   None
///
///
typedef struct _ATHI_ASSERT_STOLEN_CMD {
  ATHI_HEADER  Header;
  UINT32       DelayTime;
} ATHI_ASSERT_STOLEN_CMD;

///
/// The SendAssertStolen response.
///
typedef ATHI_BASIC_RSP ATHI_ASSERT_STOLEN_RSP;

///
/// The Set Supend State Request Message
///
/// Sender:        BIOS
/// Signing Key:   SSTK One Time Token
///
///
typedef struct _ATHI_SET_SUSPEND_STATE_CMD {
  ATHI_HEADER    Header;
  UINT32         TransitionState;  /// 0=Exit, 1=Enter
  AT_CREDENTIAL  Credential;
} ATHI_SET_SUSPEND_STATE_CMD;

///
/// The Set Supend State Response Message
///
/// Sender:        FW
/// Signing Key:   None
///
///
typedef struct _ATHI_SET_SUSPEND_STATE_RSP {
  ATHI_HEADER  Header;
  UINT32       CompletionCode;
} ATHI_SET_SUSPEND_STATE_RSP;

///
/// The Initialize WWAN Recovery Request Message
///
/// Sender:        BIOS
/// Signing Key:   None
///
///
typedef struct _ATHI_INIT_WWAN_RECOV_CMD {
  ATHI_HEADER  Header;
} ATHI_INIT_WWAN_RECOV_CMD;

///
/// The Initialize WWAN Recovery Response Message
///
/// Sender:        FW
/// Signing Key:   None
///
///
typedef struct _ATHI_INIT_WWAN_RECOV_RSP {
  ATHI_HEADER  Header;
  UINT32       CompletionCode;
} ATHI_INIT_WWAN_RECOV_RSP;

///
/// The Initialize WWAN Status Request Message
///
/// Sender:        BIOS
/// Signing Key:   None
///
///
typedef struct _ATHI_WWAN_STATUS_CMD {
  ATHI_HEADER  Header;
} ATHI_WWAN_STATUS_CMD;

///
/// The Initialize WWAN Status Response Message
///
/// Sender:        FW
/// Signing Key:   None
///
///
typedef struct _ATHI_WWAN_STATUS_RSP {
  ATHI_HEADER  Header;
  UINT32       CompletionCode;
  UINT8        RadioStatus;
  UINT8        NetworkStatus;
} ATHI_WWAN_STATUS_RSP;

#pragma pack()

#endif // _AT_HI_H