• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* $NoKeywords */
2 /**
3  * @file
4  *
5  * Iscp.h
6  *
7  * Contains common ISCP-related structures and defines.
8  *
9  * @xrefitem bom "File Content Label" "Release Content"
10  * @e project: FDK
11  * @e sub-project: UEFI
12  * @e version: $Revision: 338015 $ @e date: $Date: 2016-04-04 10:40:16 -0500 (Mon, 04 Apr 2016) $
13  *
14  */
15 /*****************************************************************************
16 *
17 *  Copyright 2013 - 2016 ADVANCED MICRO DEVICES, INC.  All Rights Reserved.
18 *
19 *  This program and the accompanying materials are licensed and made available
20 *  under the terms and conditions of the BSD License which accompanies this
21 *  distribution. The full text of the license may be found at
22 *  http://opensource.org/licenses/bsd-license.php
23 *
24 *  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
25 *  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR
26 *  IMPLIED.
27 *
28 ***************************************************************************/
29 
30 //#########################################################################
31 //#########################################################################
32 //#########################################################################
33 //        NOTE: This file shared between SCP and UEFI, make sure all     //
34 //              changes are reflected in both copies.                    //
35 //#########################################################################
36 //#########################################################################
37 //#########################################################################
38 
39 #ifndef ISCP_H_
40 #define ISCP_H_
41 
42 #ifdef __cplusplus
43   extern "C" {
44   #endif
45 
46 /*----------------------------------------------------------------------------------------
47  *                             M O D U L E S    U S E D
48  *----------------------------------------------------------------------------------------
49  */
50   #include "SocConfiguration.h"
51   #include "IscpConfig.h"
52   #include "CoreState.h"
53   #include "MemSetup.h"
54   #include "MemIscp.h"
55   #include "UartLineSettings.h"
56   #include "CpuIscp.h"
57   #include "NetworkAddress.h"
58 
59 /*----------------------------------------------------------------------------------------
60  *                  T Y P E D E F S     A N D     S T R U C T U R E S
61  *----------------------------------------------------------------------------------------
62  */
63 
64 // *** NOTE: This controls the size of a queue in SRAM. This is the
65 // maximum number of elements that will fit, without changing the
66 // overall SRAM layout.
67 #define ISCP_ECC_EVENT_QUEUE_SIZE    8
68 
69   /// Types of ECC errors
70   typedef enum _ECC_FAIL_TYPE {
71     ECC_FAIL_NO_ERROR = 0,            ///< ECC No Error
72     ECC_FAIL_CORRECTABLE,             ///< ECC Multiple Correctable Error
73     ECC_FAIL_CORRECTABLE_MULTIPLE,    ///< ECC Correctable Multiple Error
74     ECC_FAIL_UNCORRECTABLE,           ///< ECC Correctable Error
75     ECC_FAIL_UNCORRECTABLE_MULTIPLE,  ///< ECC Uncorrectable Multiple Error
76     ECC_FAIL_PARITY,                  ///< ECC Parity Error
77     ECC_FAIL_END                      ///< End of ECC Fail Types
78   } ECC_FAIL_TYPE;
79 
80   /// ISCP ECC error events
81   typedef struct _ISCP_ECC_EVENT_DETAILS {
82     UINT64 Address;            ///< Address
83     UINT64 PhysicalAddress;    ///< DRAM Physical Address
84     UINT64 Data;               ///< Data
85     UINT32 Channel;            ///< DRAM Channel
86     UINT32 SourceId;           ///< Scource ID
87     UINT32 Syndrome;           ///< ECC Syndrome
88     UINT32 Type;               ///< Restricted to ECC_FAIL_TYPE values
89     UINT32 Module;             ///< DRAM Module
90     UINT32 Bank;               ///< DRAM Bank
91     UINT32 Row;                ///< DRAM Row
92     UINT32 Column;             ///< DRAM Column
93   } ISCP_ECC_EVENT_DETAILS;
94 
95   /// ISCP Block Transfer Memory Buffer
96   typedef struct {
97     UINT64  BuffAddress;                      ///< 64-Bit Communication Buffer Address
98     UINT64  BufferSize;                       ///< 64-Bit Communication Buffer Size
99   } BLOCK_TRANSFER_BUFFER;
100 
101   /// ISCP Data Window
102   typedef struct {
103     union {
104       UINT8   szData[248];                       ///< 8-bit ISCP data array
105       BLOCK_TRANSFER_BUFFER BlockTransferBuffer; ///< ISCP Memory block Transfer Buffer structure
106     } Data;
107   } DATA_WINDOW;
108 
109   /// ISCP Communication Block. This structure must fit within the 4K SRAM area.
110   typedef struct {
111     UINT32  Signature;                        ///< Command Signature
112     UINT8   BlockLength;                      ///< Block Length of the entire message
113     UINT8   RequestCode;                      ///< Request Code - Operation Requested by the recipient
114     UINT8   ResponseCode;                     ///< Response Code - Response Code from recipient
115     UINT8   DataLength;                       ///< Data Length - Length in bytes of data
116                                               ///< being transmitted, zero if MEMORY_BUFFER is used
117     DATA_WINDOW   DataWin;                    ///< Data Window Union (This completes the 256 byte header)
118     UINT8   ExtraPayload[3072];               ///< Reserved for large payloads (A maximum of 3K)
119     ISCP_ECC_EVENT_DETAILS FatalEccEvent;     ///< Only one fatal ECC error event needed (56 bytes)
120     ISCP_ECC_EVENT_DETAILS EccEventList[ISCP_ECC_EVENT_QUEUE_SIZE];   ///< List of ECC error events (448 bytes, which nearly finishes the 4K area)
121     UINT8   HeadIndex;                        ///< Index of first ECC event, when head == tail queue is empty
122     UINT8   TailIndex;                        ///< Index of empty queue entry, to be filled next.
123     UINT8   Overflow;                         ///< Indicates a queue overflow, saturates at 0xFF
124   } ISCP_COMM_BLOCK __attribute__ ((__aligned__ (64)));
125 
126   /// Memory info HOB structure
127   typedef struct {
128     UINT32  Version;                          ///< Version of HOB structure
129     UINT32  NumberOfDescriptor;               ///< Number of memory range descriptor
130     AMD_MEMORY_RANGE_DESCRIPTOR  Ranges;      ///< Memory ranges
131   } ISCP_MEMORY_INFO;
132 
133   /// SMBIOS Memory Buffer structure
134   typedef struct {
135     ISCP_TYPE16_SMBIOS_INFO      T16;         ///< SMBIOS Type 16 Record Data
136     ISCP_TYPE17_SMBIOS_INFO      T17[2][2];   ///< SMBIOS Type 17 Record Data
137     ISCP_TYPE19_SMBIOS_INFO      T19;         ///< SMBIOS Type 19 Record Data
138   } AMD_SMBIOS_MEM_BUFFER;
139 
140   /// SMBIOS CPU Buffer structure
141   typedef struct {
142     ISCP_TYPE4_SMBIOS_INFO       T4[1];       ///< SMBIOS Type 4 Record Data
143     ISCP_TYPE7_SMBIOS_INFO       T7L1[1];     ///< SMBIOS Type 7 Level 1 Cache Record Data
144     ISCP_TYPE7_SMBIOS_INFO       T7L2[1];     ///< SMBIOS Type 7 Level 2 Cache Record Data
145     ISCP_TYPE7_SMBIOS_INFO       T7L3[1];     ///< SMBIOS Type 7 Level 3 Cache Record Data
146   } AMD_SMBIOS_CPU_BUFFER;
147 
148   /// SMBIOS Buffer structure
149   typedef struct {
150     AMD_SMBIOS_MEM_BUFFER        SmbiosMemBuffer;  ///< SMBIOS Memory Buffer
151     AMD_SMBIOS_CPU_BUFFER        SmbiosCpuBuffer;  ///< SMBIOS CPU Buffer
152   } ISCP_SMBIOS_INFO;
153 
154   /// NV Data structure
155   typedef struct {
156     UINT32  Version;                          ///< Version of NV data structure
157     UINT32  FvOffset;                         ///< Offset from the base of the UEFI image
158     UINT32  FvSize;                           ///< Firmware Volume Data Size to be written, read, or erased
159     UINT8   FvData[64*1024];                  ///< Firmware Volume Data block
160   } ISCP_OEM_NV_INFO;
161 
162   /// Firmware Fuse Buffer structure
163   typedef struct {
164     UINT32              Version;              ///< Version of Fuse Info Buffer structure
165     SocConfiguration    SocConfiguration;     ///< Fuse Structure to be passed to UEFI
166   } ISCP_FUSE_INFO;
167 
168   /// Firmware CPU Reset Buffer structure
169   typedef struct {
170     UINT32            Version;                ///< Version of CPU reset Buffer structure
171     UINT32            CoreNum;                ///< The core number we want data for, e.g. 0,1,2,..
172     SocCoreStatus     CoreStatus;             ///< Core Status Structure
173   } ISCP_CPU_RESET_INFO;
174 
175   /// Firmware MAC Address structure
176   typedef struct {
177     UINT32    Version;                        ///< Version of MAC address Info Buffer structure
178     UINT8     MacAddress0[6];                 ///< MAC Address 0 10Gb Ethernet port 0
179     UINT8     MacAddress1[6];                 ///< MAC Address 1 10Gb Ethernet port 1
180     UINT8     MacAddress2[6];                 ///< MAC Address 2 1Gb Ethernet
181   } ISCP_MAC_INFO;
182 
183   /// ISCP RTC Time structure (Based on subset of EFI_TIME structure)
184   typedef struct {
185     UINT32      Version;                      ///< Version of RTC Info Buffer structure
186     UINT16      Year;                         ///< Year: 2000 - 20XX
187     UINT8       Month;                        ///< Month:  1 - 12
188     UINT8       Day;                          ///< Day:  1 - 31
189     UINT8       Hour;                         ///< Hour: 0 - 23
190     UINT8       Minute;                       ///< Minute: 0 - 59
191     UINT8       Second;                       ///< Second: 0 - 59
192     UINT8       Pad;                          ///< Padding to made structure 32-bit aligned
193   } ISCP_RTC_INFO;
194 
195   /// ISCP PCIE Reset structure
196   typedef struct {
197     UINT32      Version;                      ///< Version of PCIE reset Buffer structure
198     UINT8       ResetSeq;                     ///< Sequence of Reset
199     UINT16      SVID;                         ///< VRM value / Voltage
200   } ISCP_PCIE_RESET_INFO;
201 
202   /// ISCP Ready To Boot structure
203   typedef struct {
204     UINT32         Version;                   ///< Version of Ready To Boot
205     UINT8          ReadyToBoot;               ///< Signal Ready To Boot Event
206   } ISCP_READY_TO_BOOT_INFO;
207 
208   /// ISCP BMC IP Address structure
209   typedef struct {
210     UINT32         Version;                   ///< Version of BMC IP Address
211     ISCP_BMC_IPV4_ADDRESS  Ipv4Address;       ///< BMC IPv4 Address Structure
212     ISCP_BMC_IPV6_ADDRESS  Ipv6Address;       ///< BMC IPv6 Address Structure
213   } ISCP_BMC_IP_ADDRESS_INFO;
214 
215   /// EEPROM info structure
216   typedef struct {
217     UINT32  Version;                          ///< Version of EEPROM Info structure
218     UINT32  EepromOffset;                     ///< EEPROM Offset from the base of the UEFI image
219     UINT32  EepromSize;                       ///< EEPROM Data Size to be written, read, or erased
220     UINT32  EepromArea;                       ///< EEPROM Area to be affected by read, write,erase commands
221     UINT8   EepromData[64*1024];              ///< EEPROm Data block [64K]
222   } ISCP_EEPROM_INFO;
223 
224   /// UART info structure. The legal values for these fields are in UartLineSettings.h and are
225   /// shared between the SCP and UEFI.
226   typedef struct {
227     UINT32  Version;                          ///< Version of UART Info structure
228     UART_LINE_SETTINGS  A57UartConfig;        ///< A57 UART Config
229   } ISCP_UART_INFO;
230 
231   /// Override Command structure
232   typedef struct {
233     UINT32         Version;                   ///< Version of Override Command structure
234     UINT8          Command;                   ///< Override command
235   } ISCP_OVERRIDE_CMD_INFO;
236 
237   /// SATA1 reset structure
238   typedef struct {
239     UINT32         Version;                   ///< Version of SATA en/disable structure
240     UINT8          State;                     ///< Enable/Disable state
241   } ISCP_SATA1_RESET_INFO;
242 
243   /// BMC presence structure
244   typedef struct {
245     UINT32         Version;                   ///< Version of BMC presence structure
246     UINT8          BmcPresent;                ///< BMC presence
247   } ISCP_BMC_PRESENCE_INFO;
248 
249   /// BERT Region structure
250   typedef struct {
251     UINT32 IscpVersion;                       ///< Version of BERT Region structure
252     UINT64 RegionPhysAddr;                    ///< ACPI v6.0: Table 18-319 [Boot Error Region]
253     UINT32 RegionLength;                      ///< ACPI v6.0: Table 18-319 [Boot Error Region Length]
254   } ISCP_BERT_REGION_INFO;
255 
256   /// SCP Doorbell Record structure
257   typedef struct {
258         UINT32 IscpVersion;                       ///< Version of Doorbell Info structure
259         UINT32 ToggleRateMilliSec;                ///< Doorbell Toggle Rate
260   } ISCP_SCP_DOORBELL_INFO;
261 
262 /*----------------------------------------------------------------------------------------
263  *                   D E F I N I T I O N S    A N D    M A C R O S
264  *----------------------------------------------------------------------------------------
265  */
266 #define ISCP_TIMEOUT                (1000000)
267 
268 // Request Codes
269 #define ISCP_TRANSACTION_SUCCESS    (0x00)
270 
271 #define ISCP_REQ_MEMORY             (0x03)
272 #define ISCP_RETRIEVE_SETUP         (0x04)
273 #define ISCP_STORE_SETUP            (0x05)
274 #define ISCP_FUSE_BLOB              (0x07)
275 #define ISCP_CPU_RETRIEVE_ID        (0x09)
276 #define ISCP_CPU_RESET              (0x0A)
277 #define ISCP_REQ_OEM_NV             (0x0B)
278 #define ISCP_STORE_OEM_NV           (0x0C)
279 #define ISCP_ERASE_OEM_NV           (0x0D)
280 #define ISCP_GET_MAC_ADDRESS        (0x0E)
281 #define ISCP_SET_MAC_ADDRESS        (0x0F)
282 #define ISCP_REQ_RTC                (0x10)
283 #define ISCP_SET_RTC                (0x11)
284 #define ISCP_GET_SMBIOS             (0x12)
285 #define ISCP_RESET_PCIE             (0x13)
286 #define ISCP_READY_TO_BOOT          (0x14)
287 #define ISCP_GET_BMC_IP             (0x15)
288 #define ISCP_RETRIEVE_VERSION       (0x16)
289 #define ISCP_STORE_EEPROM           (0x17)
290 #define ISCP_REQ_EEPROM             (0x18)
291 #define ISCP_ERASE_EEPROM           (0x19)
292 #define ISCP_MEM_SETUP              (0x1A)
293 #define ISCP_SEND_UART_CONFIG       (0x1C)
294 #define ISCP_OVERRIDE_CMD           (0x1D)
295 #define ISCP_SATA1_GET              (0x1E)
296 #define ISCP_SATA1_SET              (0x1F)
297 #define ISCP_BMC_PRESENT            (0x20)
298 #define ISCP_RETRIEVE_BERT_RECORD   (0x21)
299 #define ISCP_SUBMIT_BERT_RECORD     (0x22)
300 #define ISCP_POWER_OFF              (0xAA)
301 #define ISCP_SYSTEM_RESET           (0xBB)
302 
303 // Response Codes
304 #define ISCP_TRANSACTION_SUCCESS    (0x00)
305 #define ISCP_UNSUCCESSFUL           (0x01)
306 #define ISCP_INVALID                (0x02)
307 #define ISCP_SIGNATURE_NOT_FOUND    (0x03)
308 #define ISCP_NOT_SUPPORTED          (0x04)
309 #define ISCP_INVALID_BLOCK_LENGTH   (0x05)
310 #define ISCP_INVALID_REQUEST_CODE   (0x06)
311 #define ISCP_INVALID_DATA_LENGTH    (0x07)
312 #define ISCP_NV_WRITE_FAIL          (0x0A)
313 #define ISCP_NV_READ_FAIL           (0x0B)
314 #define ISCP_NV_ERASE_FAIL          (0x0C)
315 #define ISCP_SETUP_READ_FAIL        (0x0D)
316 #define ISCP_SETUP_WRITE_FAIL       (0x0E)
317 #define ISCP_EE_WRITE_FAIL          (0x0F)
318 #define ISCP_EE_READ_FAIL           (0x10)
319 #define ISCP_EE_ERASE_FAIL          (0x11)
320 #define ISCP_SMBIOS_FAIL            (0x12)
321 #define ISCP_INVALID_RESPONSE_CODE  (0xFF)
322 
323 // ISCP Signatures
324 #define BOOT_CORE_SIG               (0x524F4342)   //"BCOR" spelled backwards - Boot Core
325 #define BERT_SIG                    (0x54524542)   //"BERT" spelled backwards - BERT Error Block Buffer Address
326 #define BMC_PRESENT_SIG             (0x50434D42)   //"BMCP" spelled backwards - BMC Present
327 #define BMC_IP_ADDR_SIG             (0x50494D42)   //"BMIP" spelled backwards - BMC IP Address
328 #define CPU_MP_SIG                  (0x4D555043)   //"CPUM" spelled backwards - CPU Reset
329 #define DOORBELL_SIG                (0x4C454244)   //"DBEL" spelled backwards - Doorbell
330 #define EEPROM_SIG                  (0x52504545)   //"EEPR" spelled backwards - EEPROM
331 #define FUSE_BLOB_SIG               (0x45535546)   //"FUSE" spelled backwards - Fuse blob
332 #define HOBS_SIG                    (0x53424F48)   //"HOBS" spelled backwards - Memory HOBs buffer
333 #define GET_MAC_ADDR_SIG            (0x4143414D)   //"MACA" spelled backwards - Get MAC Address
334 #define OEM_NV_SIG                  (0x564E454F)   //"OENV" spelled backwards - OEM NV Storage save and retrieval actions
335 #define OVERRIDE_CMD_SIG            (0x4452564F)   //"OVRD" spelled backwards - Override Command
336 #define PCIE_SIG                    (0x45494350)   //"PCIE" spelled backwards - PCIE Reset
337 #define READY2BOOT_SIG              (0x54425452)   //"RTBT" spelled backwards - Ready-To-Boot
338 #define RTC_SIG                     (0x4B435452)   //"RTCK" spelled backwards - Real-Time-Clock
339 #define SATA1_GET_SIG               (0x47544153)   //"SATG" spelled backwards - SATA 1 get state
340 #define SATA1_SET_SIG               (0x53544153)   //"SATS" spelled backwards - SATA 1 set state
341 #define SETUP_SIG                   (0x55544553)   //"SETU" spelled backwards - BIOS Setup
342 #define SHUTDOWN_SIG                (0x4E444853)   //"SHDN" spelled backwards - System Shutdown
343 #define SET_MAC_ADDR_SIG            (0x43414D53)   //"SMAC" spelled backwards - Set MAC Address
344 #define SMBIOS_SIG                  (0x534D4253)   //"SMBS" spelled backwards - SMBIOS
345 #define UART_SIG                    (0x54524155)   //"UART" spelled backwards - UART Config
346 
347 
348 #define ISCP_BERT_REGION_INFO_VERSION               (0x00000001ul)    ///< Ver: 00.00.00.01
349 
350 #ifdef THESE_SHOULD_BE_USED_ON_BOTH_SIDES
351 #define ISCP_BMC_PRESENT_INFO_VERSION               (0x00000001ul)    ///< Ver: 00.00.00.01
352 #endif
353 
354 #define ISCP_BMC_IP_ADDR_INFO_VERSION               (0x00000001ul)    ///< Ver: 00.00.00.01
355 #define ISCP_CPU_RESET_INFO_VERSION                 (0x00000001ul)    ///< Ver: 00.00.00.01
356 
357 #ifdef THESE_SHOULD_BE_USED_ON_BOTH_SIDES
358 #define ISCP_DOORBELL_INFO_VERSION                  (0x00000001ul)    ///< Ver: 00.00.00.01
359 #endif
360 
361 #define ISCP_EEPROM_VERSION                         (0x00000001ul)    ///< Ver: 00.00.00.01
362 #define ISCP_FUSE_INFO_VERSION                      (0x00000001ul)    ///< Ver: 00.00.00.01
363 #define ISCP_MEMORY_INFO_VERSION                    (0x00000001ul)    ///< Ver: 00.00.00.01
364 #define ISCP_MAC_INFO_VERSION                       (0x00000002ul)    ///< Ver: 00.00.00.02
365 #define ISCP_OEM_NV_VERSION                         (0x00000001ul)    ///< Ver: 00.00.00.01
366 
367 #ifdef THESE_SHOULD_BE_USED_ON_BOTH_SIDES
368 #define ISCP_OVERRIDE_CMD_INFO_VERSION              (0x00000001ul)    ///< Ver: 00.00.00.01
369 #endif
370 
371 #define ISCP_PCIE_RESET_INFO_VERSION                (0x00000001ul)    ///< Ver: 00.00.00.01
372 
373 #ifdef THESE_SHOULD_BE_USED_ON_BOTH_SIDES
374 #define ISCP_READY2BOOT_INFO_VERSION                (0x00000001ul)    ///< Ver: 00.00.00.01
375 #endif
376 
377 #define ISCP_RTC_INFO_VERSION                       (0x00000001ul)    ///< Ver: 00.00.00.01
378 
379 #ifdef THESE_SHOULD_BE_USED_ON_BOTH_SIDES
380 #define ISCP_SATA1_RESET_INFO_VERSION               (0x00000001ul)    ///< Ver: 00.00.00.01
381 #endif
382 
383 #define ISCP_UART_CONFIG_INFO_VERSION               (0x00000001ul)    ///< Ver: 00.00.00.01
384 
385 #define ISCP_COMM_BLK_MAX_SIZE                      (0x100)           ///< Max length of ISCP communication block, 256 bytes
386 #define MAX_NUMBER_OF_EXTENDED_MEMORY_DESCRIPTOR    (2)
387 #define MAX_SIZEOF_AMD_MEMORY_INFO_HOB_BUFFER       (sizeof (ISCP_MEM_HOB) +  \
388           (MAX_NUMBER_OF_EXTENDED_MEMORY_DESCRIPTOR * sizeof (AMD_MEMORY_RANGE_DESCRIPTOR)))
389 #define MAX_SIZEOF_AMD_SETUP_BUFFER                 (sizeof (ISCP_SETUP_INFO))
390 #define MAX_SIZEOF_AMD_SMBIOS_BUFFER                (sizeof (AMD_ISCP_SMBIOS_INFO))
391 
392 #define FOREVER                         for (;;)
393 #define USE_DRAM_BUFFER                 (0x00)
394 #define ISCP_BLOCK_LENGTH               (0x08)
395 
396   #ifdef __cplusplus
397   }
398 #endif
399 
400 #endif /* ISCP_H_ */
401