summaryrefslogtreecommitdiff
path: root/Core/EM/Nvme/NvmeSmm/NvmeDef.h
blob: 3bcc08380a8e64051d6d45f935525e5ee092315a (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
//**********************************************************************
//**********************************************************************
//**                                                                  **
//**        (C)Copyright 1985-2014, American Megatrends, Inc.         **
//**                                                                  **
//**                       All Rights Reserved.                       **
//**                                                                  **
//**         5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093     **
//**                                                                  **
//**                       Phone: (770)-246-8600                      **
//**                                                                  **
//**********************************************************************
//**********************************************************************
//**********************************************************************
// $Header: /Alaska/SOURCE/Modules/NVMe/NvmeSmm/NvmeDef.h 1     9/04/14 7:54a Anandakrishnanl $
//
// $Revision: 1 $
//
// $Date: 9/04/14 7:54a $
//**********************************************************************
// Revision History
// ----------------
// $Log: /Alaska/SOURCE/Modules/NVMe/NvmeSmm/NvmeDef.h $
// 
// 1     9/04/14 7:54a Anandakrishnanl
// [TAG]  		EIP180861
// [Category]  	Improvement
// [Description]  	Legacy Boot support in Aptio 4.x Nvme driver
// [Files]  		NvmeSmm.cif
// NvmeSmm.mak
// NvmeSmm.dxs
// NvmeSmm.sdl
// NvmeSmm.c
// NvmeSmm.h
// NvmeDef.h
// 
//**********************************************************************
//**********************************************************************
//<AMI_FHDR_START>
//
// Name:        NvmeDef.h
//
// Description: Nvme Smm and Non Smm interface Definitions
//
//<AMI_FHDR_END>
//**********************************************************************

#ifndef _AMI_NVME_DEF_H_
#define _AMI_NVME_DEF_H_

#ifdef __cplusplus
extern "C" {
#endif

#define NVME_DATA_EBDA_OFFSET 0x104

#define NVME_API_MASS_DEVICE_REQUEST    0x27

//----------------------------------------------------------------------------
//      NVME Mass Storage Related Data Structures and Equates
//----------------------------------------------------------------------------
#define NVME_EMU_NONE            0
#define NVME_EMU_FLOPPY_ONLY     1
#define NVME_EMU_HDD_ONLY        2
#define NVME_EMU_FORCED_FDD      3

// Error returned from API handler
#define     NVME_SUCCESS                0x000
#define     NVME_PARAMETER_ERROR        0x010
#define     NVME_NOT_SUPPORTED          0x020
#define     NVME_INVALID_FUNCTION       0x0F0
#define     NVME_ERROR                  0x0FF

#pragma pack(1)

/**
    This is a URP (NVME Request Packet) structure for the BIOS
    API call Controller Info
    
    @param  TransferBufferAddress
    @param  NVMEBaseAddress
    @param  PciBus
    @param  PciDevice
    @param  PciFunc
    @param  Port
    @param  DeviceDetected
    @param  DeviceAddress
    @param  NumHeads
    @param  LBANumHeads
    @param  NumCylinders
    @param  LBANumCyls
    @param  NumSectors
    @param  LBANumSectors
    @param  MaxLBA
    @param  BlockSize
    @param  StorageType
    @param  PNM[27]
    @param  NVMEDevice
    @param  NVMEManufactureId[NVME_MANUFACTUREID_LENGTH]

**/

typedef struct {
    UINT32      TransferBufferAddress;
    UINT64      NVMEBaseAddress;
    UINT8       PciBus;
    UINT8       PciDevice;
    UINT8       PciFunc;
    UINT8       Port;
    BOOLEAN     DeviceDetected;
    UINT8       DeviceAddress;
    UINT8       NumHeads;
    UINT8       LBANumHeads;
    UINT16      NumCylinders;
    UINT16      LBANumCyls;
    UINT8       NumSectors;
    UINT8       LBANumSectors;
    UINT64      MaxLBA;
    UINT16      BlockSize;
    UINT8       StorageType;
    UINT8       PNM[27];
    BOOLEAN     NVMEDevice;
    UINT8       NVMEManufactureId[NVME_MANUFACTUREID_LENGTH];
} CONTROLLER_INFO;

/**
    This is a URP (NVME Request Packet) structure for the BIOS
    API call Reset NVME

    @param  DeviceAddress
**/

typedef struct {
    UINT8       DeviceAddress;
} RESET_NVME;


/**
    This is a URP (NVME Request Packet) structure for the BIOS
    API call Read 

    @param  DeviceAddress
    @param  Port
    @param  LBA
    @param  NumBlks
    @param  BufferAddress

**/

typedef struct {
    UINT8       DeviceAddress;
    UINT8       Port;
    UINT64      LBA;            // Starting LBA address
    UINT16      NumBlks;        // Number of blocks to read
    UINT32      BufferAddress;  // Far buffer pointer
} READ_DATA;


/**
    This is a URP (NVME Request Packet) structure for the BIOS
    API call Device Geometry

    @param  DeviceAddress
    @param  NumHeads
    @param  NumCylinders
    @param  NumSectors
    @param  LBANumHeads
    @param  LBANumCyls
    @param  LBANumSectors
    @param  BlockSize
    @param  MediaType
    @param  MaxLBA
    @param  Int13FunctionNo
    @param  BpbMediaDesc

**/
typedef struct {
    UINT8       DeviceAddress;
    UINT8       NumHeads;
    UINT16      NumCylinders;
    UINT8       NumSectors;
    UINT8       LBANumHeads;
    UINT16      LBANumCyls;
    UINT8       LBANumSectors;
    UINT16      BlockSize;
    UINT8       MediaType;
    UINT64      MaxLBA;
    UINT8       Int13FunctionNo;
    UINT8       BpbMediaDesc;
} DEVICE_GEO;


/**
    This is a union data type of all the API related data

    @param  Reset
    @param  ControllerInfo
    @param  Read
    @param  DeviceGeo
**/

typedef union {
    RESET_NVME              Reset;
    CONTROLLER_INFO         ControllerInfo;
    READ_DATA               Read;
    DEVICE_GEO              DeviceGeo;
} NVME_API_DATA;


/**
    This structure is the URP structure

    @param  bFuncNumber
    @param  bSubFunc
    @param  bRetValue
    @param  ApiData

  @note Fields:Name       Type        Description
              --------------------------------------------------
              bFuncNumber UINT8       Function number of the URP
              bSubFunc    UINT8       Sub-func number of the URP
              bRetValue   UINT8       Return value
              ApiData     API_DATA    Refer structure definition
**/

typedef struct {
    UINT8           bFuncNumber;
    UINT8           bSubFunc;
    UINT8           bRetValue;
    NVME_API_DATA   ApiData;
} NVME_STRUC;

#pragma pack()

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

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