summaryrefslogtreecommitdiff
path: root/Core/EM/OpalSecurity/OpalSecurity.h
blob: 3c78710617a26028900cb1c98acd1eab1898ec5d (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
//*************************************************************************
//*************************************************************************
//**                                                                     **
//**        (C)Copyright 1985-2011, American Megatrends, Inc.            **
//**                                                                     **
//**                       All Rights Reserved.                          **
//**                                                                     **
//**      5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093           **
//**                                                                     **
//**                       Phone: (770)-246-8600                         **
//**                                                                     **
//*************************************************************************
//*************************************************************************

//**********************************************************************
// $Header: /Alaska/SOURCE/Modules/OpalSecurity/OPALSECURITY/OpalSecurity.h 3     12/21/11 8:37p Rajkumarkc $
//
// $Revision: 3 $
//
// $Date: 12/21/11 8:37p $
//**********************************************************************
// Revision History
// ----------------
// $Log: /Alaska/SOURCE/Modules/OpalSecurity/OPALSECURITY/OpalSecurity.h $
// 
// 3     12/21/11 8:37p Rajkumarkc
// [TAG]         EIP77142
// [Category]    BUG FIX & IMPROVEMENT
// [Description] BUG FIX - Changed Little Endian format to Big Endian
//               format while sending commands.
//               IMPROVEMENT - Added support to Lock the Opal hdd if
//               it's unlocked on Bios POST.
// [Files]       IdeOpalSec.c, AhciOpalSec.c, OpalSecurity.c,
//               OpalSecurity.h, OpalSecurity.sdl
// 
// 2     8/22/11 3:02a Anandakrishnanl
// [TAG]  		EIP62912
// [Category]  	Improvement
// [Description]  	Opal Security Definitions Should be Moved to PIDEBUS.h
// from StorageSecurityProtocol.h
// StorageSecurityProtocol.h included in OPAL security driver module will
// give build error when disabled without sdl token #if
// OpalSecurity_SUPPORT properly placed in Ahcibus and IdeBus drivers. But
// Bus driver should not depend on any tokens. For this reason need to
// move OPAL_SEC_INIT_PROTOCOL_GUID in Pidebus.h
// [Files]  		IdeBus.c
// Pidebus.h
// OpalSecurity.cif
// OpalSecurity.h
// IdeOpalSec.c
// AhciOpalSec.c
// 
// 1     5/19/11 2:07a Anandakrishnanl
// Opal Security Module Initial Check In
//
//<AMI_FHDR_START>
//----------------------------------------------------------------------------
//
// Name: OpalSecurity.h
//
// Description:	This file contains the Includes, Definitions, typedefs, Variable 
// and External Declarations, Structure and function prototypes needed for the 
// OpalSecurity driver
//
//----------------------------------------------------------------------------
//<AMI_FHDR_END>

#ifndef _OpalSecurity_
#define _OpalSecurity_

#ifdef __cplusplus
extern "C" {
#endif

#include <Efi.h>
#include <Token.h>
#include <Dxe.h>
#include <AmiDxeLib.h>
#include "Protocol\PciIo.h"
#include "Protocol\DevicePath.h"
#include "protocol\DriverBinding.h"
#include "protocol\BlockIo.h"
#include "Protocol\PDiskInfo.h"
#include "Protocol\PIDEController.h"
#include "Protocol\PIDEBus.h"
#include "Protocol\StorageSecurityCommand.h"
#include "Protocol\PAhciBus.h"

//
// TCG Storage Security Protocol
//
#define SECURITY_PROTOCOL_INFORMATION                   0x00
#define SECURITY_PROTOCOL_1                             0x01
#define SECURITY_PROTOCOL_2                             0x02
#define SECURITY_PROTOCOL_SDCARD_TRUSTED_FLASH          0xED
#define SECURITY_PROTOCOL_IEEE1667                      0xEE

EFI_STATUS InstallOpalSecurityInterface(
    IN VOID    *BusInterface,
    IN BOOLEAN ModeFlag );

EFI_STATUS UnInstallOpalSecurityInterface(
    IN VOID    *BusInterface,
    IN BOOLEAN ModeFlag );

EFI_STATUS IdeSendData(
    IN EFI_STORAGE_SECURITY_COMMAND_PROTOCOL *This,
    IN UINT32                MediaId,
    IN UINT64                Timeout,
    IN UINT8                 SecurityProtocolId,
    IN UINT16                SecurityProtocolSpecificData,
    IN UINTN                 PayloadBufferSize,
    IN VOID                  *PayloadBuffer );

EFI_STATUS IdeReceiveData(
    IN EFI_STORAGE_SECURITY_COMMAND_PROTOCOL *This,
    IN UINT32                MediaId,
    IN UINT64                Timeout,
    IN UINT8                 SecurityProtocolId,
    IN UINT16                SecurityProtocolSpecificData,
    IN UINTN                 PayloadBufferSize,
    OUT VOID                 *PayloadBuffer,
    OUT UINTN		         *PayloadTransferSize
 );

EFI_STATUS AhciReceiveData(
    IN EFI_STORAGE_SECURITY_COMMAND_PROTOCOL *This,
    IN UINT32                MediaId,
    IN UINT64                Timeout,
    IN UINT8                 SecurityProtocolId,
    IN UINT16                SecurityProtocolSpecificData,
    IN UINTN                 PayloadBufferSize,
    OUT VOID                 *PayloadBuffer,
    OUT UINTN		         *PayloadTransferSize
 );

EFI_STATUS AhciSendData(
    IN EFI_STORAGE_SECURITY_COMMAND_PROTOCOL *This,
    IN UINT32                MediaId,
    IN UINT64                Timeout,
    IN UINT8                 SecurityProtocolId,
    IN UINT16                SecurityProtocolSpecificData,
    IN UINTN                 PayloadBufferSize,
    IN VOID                  *PayloadBuffer 
);

EFI_STATUS 
IssueLockOnResetCommand(
    IN EFI_STORAGE_SECURITY_COMMAND_PROTOCOL *This,
    IN VOID    *BusInterface,
    IN BOOLEAN  ModeFlag
);

EFI_STATUS 
GetAndStoreSecurityProtocolInformation(
    IN EFI_STORAGE_SECURITY_COMMAND_PROTOCOL *This,
    IN VOID    *BusInterface
);

EFI_STATUS 
GetSecurityProtocolInformation(
    IN EFI_STORAGE_SECURITY_COMMAND_PROTOCOL *This,
    IN OUT VOID                *QueryBuffer,
    IN OUT UINTN               *QueryBufferSize
);

EFI_STATUS 
IEEE67TPerReset(
    IN EFI_STORAGE_SECURITY_COMMAND_PROTOCOL *This
);

EFI_STATUS 
IssueTPerResetTcgSilo(
    IN EFI_STORAGE_SECURITY_COMMAND_PROTOCOL *This
);

EFI_STATUS 
NativeTcgTPerReset(
    IN EFI_STORAGE_SECURITY_COMMAND_PROTOCOL *This
);

typedef 
struct _SP0_TRUSTED_RECEIVE_PARAMETER_DATA { 
    UINT8      Reserved[6]; 
    UINT8      ListLengthHigh; 
    UINT8      ListLengthLow; 
    UINT8      SupportedSPList[502]; 
    UINT8      PadBytesHigh; 
    UINT8      PadBytesLow; 
}SP0_TRUSTED_RECEIVE_PARAMETER_DATA;

typedef 
struct _TCG_SILO_TYPE_IDENTIFIER { 
    UINT8      Reserved[2]; 
    UINT8      SiloTypeIdentifierHigh; 
    UINT8      SiloTypeIdentifierLow; 
}TCG_SILO_TYPE_IDENTIFIER;

typedef 
struct _STORAGE_SECURITY_COMMAND_PROTOCOL { 
// Any new member field should be added at bottom of the structure below BusInterface
    EFI_STORAGE_SECURITY_RECEIVE_DATA      ReceiveData; 
    EFI_STORAGE_SECURITY_SEND_DATA         SendData; 
    VOID                                   *BusInterface;
    SP0_TRUSTED_RECEIVE_PARAMETER_DATA     *SupportedProtocolList;
}STORAGE_SECURITY_COMMAND_PROTOCOL;

/****** DO NOT WRITE BELOW THIS LINE *******/
#ifdef __cplusplus
}
#endif

#endif

//*************************************************************************
//*************************************************************************
//**                                                                     **
//**        (C)Copyright 1985-2011, American Megatrends, Inc.            **
//**                                                                     **
//**                       All Rights Reserved.                          **
//**                                                                     **
//**      5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093           **
//**                                                                     **
//**                       Phone: (770)-246-8600                         **
//**                                                                     **
//*************************************************************************
//*************************************************************************