summaryrefslogtreecommitdiff
path: root/ReferenceCode/Chipset/SystemAgent/MemoryInit/Pei/Source/Api/MrcBdat.c
blob: 7670487bae3a0260ae063fb8df3b5acb84ca3ae7 (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
/** @file
  Copies the memory related timing and configuration information into the
  Compatible BIOS data (BDAT) table.

@copyright
  Copyright (c) 2010 - 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.
**/

#include "MrcTypes.h"
#include "MrcApi.h"
#include "MrcGlobal.h"
#include "MrcOem.h"
#include "MrcSpdProcessing.h"
#include "McAddress.h"

#ifdef BDAT_SUPPORT
#define TBD                       0
#define CRC_SEED                  0
#define CRC_XOR_MASK              0x1021
#define MAX_UINT8_VALUE           (((1UL) << CHAR_BITS) - 1)
#define HOST_BRIDGE_BUS           0
#define HOST_BRIDGE_DEVICE        0
#define HOST_BRIDGE_FUNCTION      0
#define HOST_BRIDGE_OFFSET_DEVID  0
#define HOST_BRIDGE_OFFSET_REVID  8
#define CopyMem                   MrcOemMemoryCpy
#define GetCrc16                  GetDimmCrc

typedef U8  UINT8;
typedef U16 UINT16;

/**
  @brief
  Finds the window value for the given DQ value and if it is less than the
    current value, then save the end point values.

    @param[in, out] Rank1         - Pointer to the first rank training value (left or low).
    @param[in, out] Rank2         - Pointer to the second rank training value (right or high).
    @param[in, out] CurrentWindow - The current window value.
    @param[in] Value1        - The first training value (left or low).
    @param[in] Value2        - The second training value (right or high).

    @retval Nothing.
**/
void
ConvertDq2Rank (
  IN OUT UINT8        *Rank1,
  IN OUT UINT8        *Rank2,
  IN OUT UINT8        *CurrentWindow,
  IN     const UINT8  Value1,
  IN     const UINT8  Value2
  )
{
  UINT8 Window;  // The calculated window value.

  Window = MAX (Value1, Value2) - MIN (Value1, Value2);
  if (Window < *CurrentWindow) {
    *CurrentWindow  = Window;
    *Rank1          = Value1;
    *Rank2          = Value2;
  } // if
  return;
}

/**
@brief
  Initialize the memory rank margin area of the RMT_STRUCTURE.

  @param[in] MrcData - The MRC "global data".
  @param[in, out] RmtRankMargin - Pointer to the start of the rank margin information in the RMT table.
  @param[in] RmtDq         - Pointer to the start of the dq margin information in the RMT table.

  @retval Nothing.
**/
void
MrcFillRmtRankMargin (
  IN     const MrcParameters  *MrcData,
  IN OUT RmtRankMargin        *RmtRankMargin,
  IN     RmtDqMargin          *RmtDq
  )
{
  RmtDqMargin *RmtDqMargin;         // Pointer to the current DQ margin in the RMT structure.
  UINT8       Dq;                   // DQ number in the rank.
  UINT8       DqEnd;
  UINT8       SmallestWindowRxDq;   // The smallest of the Rx DQ windows.
  UINT8       SmallestWindowTxDq;   // The smallest of the Tx DQ windows.
  UINT8       SmallestWindowRxVref; // The smallest of the Rx Vref windows.
  UINT8       SmallestWindowTxVref; // The smallest of the Tx Vref windows.

  SmallestWindowRxDq   = (UINT8) MAX_UINT8_VALUE;
  SmallestWindowTxDq   = (UINT8) MAX_UINT8_VALUE;
  SmallestWindowRxVref = (UINT8) MAX_UINT8_VALUE;
  SmallestWindowTxVref = (UINT8) MAX_UINT8_VALUE;
  DqEnd                = (MrcData->SysOut.Outputs.EccSupport) ? MAX_DQ : (MAX_DQ - MAX_BITS);
  for (Dq = 0; Dq < DqEnd; Dq++) {
    RmtDqMargin = &RmtDq[Dq];
    ConvertDq2Rank (
      &RmtRankMargin->RxDqLeft,
      &RmtRankMargin->RxDqRight,
      &SmallestWindowRxDq,
      RmtDqMargin->RxDqLeft,
      RmtDqMargin->RxDqRight
      );
    ConvertDq2Rank (
      &RmtRankMargin->TxDqLeft,
      &RmtRankMargin->TxDqRight,
      &SmallestWindowTxDq,
      RmtDqMargin->TxDqLeft,
      RmtDqMargin->TxDqRight
      );
    ConvertDq2Rank (
      &RmtRankMargin->RxVrefLow,
      &RmtRankMargin->RxVrefHigh,
      &SmallestWindowRxVref,
      RmtDqMargin->RxVrefLow,
      RmtDqMargin->RxVrefHigh
      );
    ConvertDq2Rank (
      &RmtRankMargin->TxVrefLow,
      &RmtRankMargin->TxVrefHigh,
      &SmallestWindowTxVref,
      RmtDqMargin->TxVrefLow,
      RmtDqMargin->TxVrefHigh
      );
  } // Dq loop
  return;
}

/**
@brief
  Initialize the memory DQ area of the RMT_STRUCTURE.

  @param[in, out] RmtDq   - Pointer to the start of the DQ information in the RMT table.
  @param[in] Channel - Specific Channel
  @param[in] Dimm    - Specific Dimm
  @param[in] Rank    - Specific Rank
  @param[in] MrcData - The MRC "global data".

  @retval Nothing.
**/
void
MrcFillRmtDqMargin (
  IN OUT RmtDqMargin          *RmtDq,
  IN     const UINT8          Controller,
  IN     const UINT8          Channel,
  IN     const UINT8          Dimm,
  IN     const UINT8          Rank,
  IN     const MrcParameters  *MrcData
  )
{
  const MrcOutput       *Outputs;
  const MrcChannelOut   *ChannelOut;
  const MrcDqTimeMargin *RxDqMargin;      // Pointer to the output portion of the MRC global data area.
  const MrcDqTimeMargin *TxDqMargin;      // Pointer to the output portion of the MRC global data area.
  const MrcDqVrefMargin *RxVrefDqMargin;  // Pointer to the output portion of the MRC global data area.
  const MrcDqVrefMargin *TxVrefDqMargin;  // Pointer to the output portion of the MRC global data area.
  RmtDqMargin           *RmtDqMargin;     // Pointer to the current DQ margin in the RMT structure.
  UINT8                 RankInChannel;
  UINT8                 Sdram;
  UINT8                 Dq;               // DQ number in the rank.
  UINT8                 DqEnd;
  UINT8                 Bit;

  Outputs       = &MrcData->SysOut.Outputs;
  ChannelOut    = &Outputs->Controller[Controller].Channel[Channel];
  RankInChannel = (Dimm * MAX_RANK_IN_DIMM) + Rank;
  DqEnd         = (Outputs->EccSupport) ? MAX_DQ : (MAX_DQ - MAX_BITS);
  for (Dq = 0; Dq < DqEnd; Dq++) {
    Sdram                   = Dq / CHAR_BITS;
    Bit                     = Dq % CHAR_BITS;
    RxDqMargin              = &ChannelOut->RxDqPb[RankInChannel][Sdram][Bit];
    TxDqMargin              = &ChannelOut->TxDqPb[RankInChannel][Sdram][Bit];
    RxVrefDqMargin          = &ChannelOut->RxDqVrefPb[RankInChannel][Sdram][Bit];
    TxVrefDqMargin          = &ChannelOut->TxDqVrefPb[RankInChannel][Sdram][Bit];
    RmtDqMargin             = &RmtDq[Dq];
    RmtDqMargin->RxDqLeft   = RxDqMargin->Left;
    RmtDqMargin->RxDqRight  = RxDqMargin->Right;
    RmtDqMargin->TxDqLeft   = TxDqMargin->Left;
    RmtDqMargin->TxDqRight  = TxDqMargin->Right;
    RmtDqMargin->RxVrefLow  = RxVrefDqMargin->Low;
    RmtDqMargin->RxVrefHigh = RxVrefDqMargin->High;
    RmtDqMargin->TxVrefLow  = TxVrefDqMargin->Low;
    RmtDqMargin->TxVrefHigh = TxVrefDqMargin->High;
  } // Dq loop
  return;
}

/**
@brief
  Initialize the memory rank training area of the RMT_STRUCTURE.

  @param[in, out] RmtRankTraining - Pointer to the start of the rank training information in the RMT table.
  @param[in] Channel         - Specific Channel
  @param[in] Dimm            - Specific Dimm
  @param[in] Rank            - Specific Rank
  @param[in] MrcData         - The MRC "global data".

  @retval Nothing.
**/
void
MrcFillRmtRankTraining (
  IN OUT RmtRankTraining      *RmtRankTraining,
  IN     const UINT8          Controller,
  IN     const UINT8          Channel,
  IN     const UINT8          Dimm,
  IN     const UINT8          Rank,
  IN     const MrcParameters  *MrcData
  )
{
  const MrcOutput     *Outputs;     // Pointer to the output portion of the MRC global data area.
  const MrcChannelOut *ChannelOut;  // Pointer to the channel portion of the MRC global data area.
  UINT8               Index;
  UINT8               RankInChannel;
  UINT8               Sdram;
  UINT8               Strobe;

  Outputs       = &MrcData->SysOut.Outputs;
  ChannelOut    = &Outputs->Controller[Controller].Channel[Channel];
  RankInChannel = (Dimm * MAX_RANK_IN_DIMM) + Rank;
  for (Strobe = 0; Strobe < MAX_STROBE; Strobe++) {
    Sdram = Strobe / 2;
    RmtRankTraining->RecEnDelay[Strobe] = ChannelOut->RcvEn[RankInChannel][Sdram];
    RmtRankTraining->WlDelay[Strobe]    = ChannelOut->WlDelay[RankInChannel][Sdram];
    RmtRankTraining->RxDqDelay[Strobe]  = (Strobe % 2)
                                        ? ChannelOut->RxDqsN[RankInChannel][Sdram]
                                        : ChannelOut->RxDqsP[RankInChannel][Sdram];
    RmtRankTraining->TxDqDelay[Strobe]  = ((U8) (ChannelOut->TxDq[RankInChannel][Sdram] >> 6)) & 7;
  } // Strobe loop
  RmtRankTraining->ClkDelay = ChannelOut->ClkPiCode[RankInChannel];
  RmtRankTraining->CtlDelay = ChannelOut->CtlPiCode[RankInChannel];
  for (Index = 0; Index < (sizeof (RmtRankTraining->CmdDelay) / sizeof (RmtRankTraining->CmdDelay[0])); Index++) {
    RmtRankTraining->CmdDelay[Index] = TBD;  // Need to implement code.
  } // Index loop
  RmtRankTraining->IoLatency = ChannelOut->IoLatency[RankInChannel];
  RmtRankTraining->Roundtrip = ChannelOut->RTLatency[RankInChannel];
  return;
}

/**
@brief
  Initialize the memory rank area of the RMT_STRUCTURE.

  @param[in, out] RmtRank  - Pointer to the start of the rank information in the RMT table.
  @param[in] MrcData  - The MRC "global data".
  @param[in] Channel  - Current channel number.
  @param[in] Dimm     - Current dimm number.

  @retval Nothing.
**/
void
MrcFillRmtRankStructure (
  IN OUT RmtRankList         *RmtRank,
  IN     const MrcParameters *MrcData,
  IN     UINT8               Controller,
  IN     UINT8               Channel,
  IN     UINT8               Dimm
)
{
  const MrcOutput     *Outputs;          // Pointer to the output portion of the MRC global data area.
  const MrcChannelOut *ChannelOut;       // Pointer to the DIMM output portion of the MRC global data area.
  const MrcDimmOut    *DimmOut;          // Pointer to the DIMM output portion of the MRC global data area.
  RmtRankList         *RmtRankLists;     // Pointer to the current rank list in the RMT structure.
  RmtRankTraining     *RmtRankTraining;  // Pointer to the current rank training in the RMT structure.
  UINT8               Rank;              // Rank count for sequencing.
  UINT8               RankInChannel;     // Rank number in a channel.

  Outputs    = &MrcData->SysOut.Outputs;
  ChannelOut = &Outputs->Controller[Controller].Channel[Channel];
  DimmOut    = &ChannelOut->Dimm[Dimm];
  for (Rank = 0; (Rank < MAX_RANK_IN_DIMM) && (Rank < DimmOut->RankInDIMM); Rank++) {
    RmtRankLists                    = &RmtRank[Rank];
    RmtRankTraining                 = &RmtRankLists->RankTraining;
    RankInChannel                   = (Dimm * MAX_RANK_IN_DIMM) + Rank;
    RmtRankLists->RankEnabled       = TRUE;
    RmtRankLists->RankMarginEnabled = TRUE;
    RmtRankLists->DqMarginEnabled   = TRUE;
    MrcFillRmtDqMargin (&RmtRankLists->DqMargin[0], Controller, Channel, Dimm, Rank, MrcData);
    MrcFillRmtRankMargin (MrcData, &RmtRankLists->RankMargin, &RmtRankLists->DqMargin[0]);
    MrcFillRmtRankTraining (&RmtRankLists->RankTraining, Controller, Channel, Dimm, Rank, MrcData);
    CopyMem (
      (UINT8 *) &RmtRankLists->RankMRS.ModeRegister[0],
      (UINT8 *) &DimmOut->Rank[Rank].MR[0],
      sizeof (RmtRankMrs)
      );
    RmtRankLists->RankMargin.CmdLeft      = ChannelOut->Command[RankInChannel].Left;
    RmtRankLists->RankMargin.CmdRight     = ChannelOut->Command[RankInChannel].Right;
    RmtRankLists->RankMargin.CmdVrefLow   = ChannelOut->Command[RankInChannel].Low;
    RmtRankLists->RankMargin.CmdVrefHigh  = ChannelOut->Command[RankInChannel].High;
    RmtRankLists->RankMargin.RecvenLeft   = ChannelOut->ReceiveEnable[RankInChannel].Left;
    RmtRankLists->RankMargin.RecvenRight  = ChannelOut->ReceiveEnable[RankInChannel].Right;
    RmtRankLists->RankMargin.WrLevelLeft  = ChannelOut->WriteLevel[RankInChannel].Left;
    RmtRankLists->RankMargin.WrLevelRight = ChannelOut->WriteLevel[RankInChannel].Right;
  }  // Rank loop
  return;
}

/**
@brief
  Initialize the memory dimm area of the RMT_STRUCTURE.

  @param[in, out] RmtDimm - Pointer to the start of the dimm information in the RMT table.
  @param[in] MrcData - The MRC "global data".
  @param[in] Channel - Current channel number.

  @retval Nothing.
**/
void
MrcFillRmtDimmStructure (
  IN OUT RmtDimmList         *RmtDimm,
  IN     const MrcParameters *MrcData,
  IN     UINT8               Controller,
  IN     UINT8               Channel
  )
{
  const MrcInput      *Inputs;              // Pointer to the input portion of the MRC global data area.
  const MrcDimmIn     *DimmIn;              // Pointer to the DIMM input portion of the MRC global data area.
  const MrcSpd        *SpdIn;               // Pointer to the SPD input portion of the MRC global data area.
  const MrcOutput     *Outputs;             // Pointer to the output portion of the MRC global data area.
  const MrcChannelOut *ChannelOut;          // Pointer to the channel output portion of the MRC global data area.
  const MrcDimmOut    *DimmOut;             // Pointer to the DIMM output portion of the MRC global data area.
  RmtDimmList         *RmtDimmList;         // Pointer to the current DIMM in the RMT structure.
  RmtSpd              *RmtSpdList;          // Pointer to the current SPD in the RMT structure.
  UINT8               Dimm;                 // Dimm count for sequencing.

  Inputs     = &MrcData->SysIn.Inputs;
  Outputs    = &MrcData->SysOut.Outputs;
  ChannelOut = &Outputs->Controller[Controller].Channel[Channel];
  for (Dimm = 0; Dimm < MAX_DIMMS_IN_CHANNEL; Dimm++) {
    DimmOut = &ChannelOut->Dimm[Dimm];
    if (DimmOut->Status == DIMM_PRESENT) {
      RmtDimmList               = &RmtDimm[Dimm];
      RmtSpdList                = &RmtDimmList->SpdBytes;
      DimmIn                    = &Inputs->Controller[Controller].Channel[Channel].Dimm[Dimm];
      SpdIn                     = &DimmIn->Spd;
      RmtDimmList->DimmEnabled  = TRUE;
      CopyMem ((UINT8 *) &RmtSpdList->SpdData[0], (UINT8 *) SpdIn, 128);
#if (defined SUPPORT_XMP && SUPPORT_XMP == SUPPORT)
      CopyMem (&RmtSpdList->SpdData[128], ((UINT8 *) SpdIn) + 128, 128);
#endif // (defined SUPPORT_XMP && SUPPORT_XMP == SUPPORT)
      CopyMem ((UINT8 *) &RmtSpdList->SpdValid, (UINT8 *) &DimmIn->SpdValid, sizeof (RmtDimmList->SpdBytes.SpdValid));

      //
      // Initialize the memory rank area of the RMT_STRUCTURE.
      //
      MrcFillRmtRankStructure (&RmtDimmList->RankList[0], MrcData, Controller, Channel, Dimm);
    } // end if
  } // Dimm loop
  return;
}

/**
@brief
  Initialize the memory channel area of the RMT_STRUCTURE.

  @param[in, out] RmtChannel - Pointer to the start of the channel information in the RMT table.
  @param[in] MrcData     - The MRC "global data".

  @retval Nothing.
**/
void
MrcFillRmtChannelStructure (
  IN OUT RmtChannelList      *RmtChannel,
  IN     const MrcParameters *MrcData,
  IN     const UINT8         Controller
  )
{
  const MrcOutput *Outputs;             // Pointer to the output portion of the MRC global data area.
  RmtChannelList  *RmtChannelList;      // Pointer to the current channel in the RMT structure.
  UINT8           Channel;              // Channel count for sequencing.

  Outputs = &MrcData->SysOut.Outputs;
  for (Channel = 0; Channel < MAX_CHANNEL; Channel++) {
    if (Outputs->Controller[Controller].Channel[Channel].Status == CHANNEL_PRESENT) {
      RmtChannelList                  = &RmtChannel[Channel];
      RmtChannelList->ChannelEnabled  = TRUE;
      RmtChannelList->NumDimmSlot     = MAX_DIMMS_IN_CHANNEL;

      //
      // Initialize the memory DIMM area of the RMT_STRUCTURE.
      //
      MrcFillRmtDimmStructure (&RmtChannelList->DimmList[0], MrcData, Controller, Channel);
    } // end if
  } // Channel loop
  return;
}

/**
@brief
  Initialize the memory controller area of the RMT_STRUCTURE.

  @param[in, out] RmtController - Pointer to the start of the controller information in the RMT table.
  @param[in] MrcData        - The MRC "global data".

  @retval Nothing.
**/
void
MrcFillRmtControllerStructure (
  IN OUT RmtControllerList   *RmtController,
  IN     const MrcParameters *MrcData
  )
{
  const MrcInput    *Inputs;
  const MrcOutput   *Outputs;
  RmtControllerList *RmtControllerList;
  UINT8             Controller;
  MrcVddSelect      VddVoltage;

  Inputs     = &MrcData->SysIn.Inputs;
  Outputs    = &MrcData->SysOut.Outputs;
  VddVoltage = Outputs->VddVoltage[Inputs->MemoryProfile];
  for (Controller = 0; Controller < MAX_CONTROLLERS; Controller++) {
    if (Outputs->Controller[Controller].Status == CONTROLLER_PRESENT) {
      RmtControllerList                       = &RmtController[Controller];
      RmtControllerList->ControllerEnabled    = TRUE;
      RmtControllerList->ControllerDeviceId   = Outputs->Controller[Controller].DeviceId;
      RmtControllerList->ControllerRevisionId = Outputs->Controller[Controller].RevisionId;
      RmtControllerList->MemoryFrequency      = (UINT16) (Outputs->Frequency / 10);
      RmtControllerList->MemoryVoltage        = (UINT16) VddVoltage;
      //
      // Step unit = piStep * (tCK / 2048)
      //
      RmtControllerList->PiStep               = (UINT8) PI_STEP;
      RmtControllerList->RecvenStep           = (UINT8) PI_STEP;
      RmtControllerList->WrLevelStep          = (UINT8) PI_STEP;
      if (VddVoltage > 0) {
        //
        // Step unit = __VrefStep * Vdd / 100
        //
        RmtControllerList->RxVrefStep  = (UINT16) RX_VREF (VddVoltage);
        RmtControllerList->TxVrefStep  = (UINT16) TX_VREF (VddVoltage);
        RmtControllerList->CaVrefStep  = (UINT16) CA_VREF (VddVoltage);
      } else {
        RmtControllerList->RxVrefStep  = 0;
        RmtControllerList->TxVrefStep  = 0;
        RmtControllerList->CaVrefStep  = 0;
      }
      //
      // Initialize the memory channel area of the RMT_STRUCTURE.
      //
      MrcFillRmtChannelStructure (&RmtControllerList->ChannelList[0], MrcData, Controller);
    } // Controller loop
  }

  return;
}

/**
@brief
  Fill the compatible data structure RMT with the information provided by
  the memory initialization code.

  @param[in, out] MrcData - Constant pointer to the Mrc data structure which conatins the Rmt structure to fill.

  @retval Nothing.
**/
MrcStatus
MrcFillRmtStructure (
  IN OUT MrcParameters *const MrcData
  )
{
  const UINT8       RmtHeaderSign[] = {'B', 'D', 'A', 'T', 'H', 'E', 'A', 'D'};
  const MrcVersion  *Version;             // Pointer to the output portion of the MRC global data area.
  RmtData           *Rmt;
  RmtHeader         *RmtHeader;           // Pointer to the header data area in the RMT structure.
  RmtSystem         *RmtSystem;           // Pointer to the system data area in the RMT structure.
  const MrcInput    *Inputs;
  MrcOutput         *Outputs;

  Inputs  = &MrcData->SysIn.Inputs;
  Outputs = &MrcData->SysOut.Outputs;
  if (Inputs->RmtBdatEnable) {
    //
    // Initialize the header area of the RMT_STRUCTURE.
    //
    Rmt       = &MrcData->Rmt;
    RmtHeader = &Rmt->RmtHeader;
    CopyMem (&RmtHeader->BiosDataSignature[0], (UINT8 *) RmtHeaderSign, sizeof (RmtHeader->BiosDataSignature));
    RmtHeader->BiosDataStructSize           = sizeof (RmtData);
    RmtHeader->Version.S[PRIMARY_OFFSET]    = RMT_PRIMARY_VERSION;
    RmtHeader->Version.S[SECONDARY_OFFSET]  = RMT_SECONDARY_VERSION;
    RmtHeader->OemOffset                    = OEM_OFFSET;
    RmtHeader->Reserved1 = (Inputs->BaseTime.Hours << 16) | (Inputs->BaseTime.Minutes << 8) | Inputs->BaseTime.Seconds;
    RmtHeader->Reserved2 = (Inputs->BaseTime.Year << 16) | (Inputs->BaseTime.Month << 8) | Inputs->BaseTime.DayOfMonth;

    //
    // Initialize the system area of the RMT_STRUCTURE.
    //
    Version                               = &Outputs->Version;
    RmtSystem                             = &Rmt->RmtSystem;
    RmtSystem->RefCodeRevision.c.Major    = Version->Major;
    RmtSystem->RefCodeRevision.c.Minor    = Version->Minor;
    RmtSystem->RefCodeRevision.c.Revision = Version->Rev;
    RmtSystem->RefCodeRevision.c.Build    = Version->Build;
    RmtSystem->MaxController              = MAX_CONTROLLERS;
    RmtSystem->MaxChannel                 = MAX_CHANNEL;
    RmtSystem->MaxDimm                    = MAX_DIMMS_IN_CHANNEL;
    RmtSystem->MaxRankDimm                = MAX_RANK_IN_DIMM;
    RmtSystem->MaxStrobe                  = MAX_STROBE;
    RmtSystem->MaxDq                      = MAX_DQ;
    RmtSystem->MarginLoopCount            = Outputs->DQPatLC;
    //
    // Initialize the memory controller area of the RMT_STRUCTURE.
    //
    MrcFillRmtControllerStructure (&RmtSystem->ControllerList[0], MrcData);

    //
    // Initialize the CRC of the RMT_STRUCTURE.
    // Ensure that the CRC calculation is the last field initialized.
    //
    GetCrc16 ((const UINT8 *const) Rmt, sizeof (RmtData), &Rmt->RmtHeader.Crc16);
    MrcOemMmioWrite (NCDECS_CR_SCRATCHPAD_NCU_2_REG, (U32) Rmt, Inputs->MchBarBaseAddress);
  } // end if
  return mrcSuccess;
}
#endif // BDAT_SUPPORT