nehalem sandy ivy: Check cbmem_add() result for MRC data
In theory we could run out of CBMEM space so check the entry was added. There is no interest to support builds without EARLY_CBMEM_INIT. Change-Id: I68dd7c20e3d3692331aaafa2a692c5c0dfce95d5 Signed-off-by: Kyösti Mälkki <kyosti.malkki@gmail.com> Reviewed-on: http://review.coreboot.org/6033 Tested-by: build bot (Jenkins) Reviewed-by: Aaron Durbin <adurbin@google.com>
This commit is contained in:
parent
b0cbb2cd17
commit
743a218a60
|
@ -1687,7 +1687,6 @@ static void dump_timings(struct raminfo *info)
|
||||||
*/
|
*/
|
||||||
static void save_timings(struct raminfo *info)
|
static void save_timings(struct raminfo *info)
|
||||||
{
|
{
|
||||||
#if CONFIG_EARLY_CBMEM_INIT
|
|
||||||
struct ram_training train;
|
struct ram_training train;
|
||||||
struct mrc_data_container *mrcdata;
|
struct mrc_data_container *mrcdata;
|
||||||
int output_len = ALIGN(sizeof(train), 16);
|
int output_len = ALIGN(sizeof(train), 16);
|
||||||
|
@ -1722,22 +1721,23 @@ static void save_timings(struct raminfo *info)
|
||||||
mrcdata = cbmem_add
|
mrcdata = cbmem_add
|
||||||
(CBMEM_ID_MRCDATA, output_len + sizeof(struct mrc_data_container));
|
(CBMEM_ID_MRCDATA, output_len + sizeof(struct mrc_data_container));
|
||||||
|
|
||||||
printk(BIOS_DEBUG, "Relocate MRC DATA from %p to %p (%u bytes)\n",
|
if (mrcdata != NULL) {
|
||||||
&train, mrcdata, output_len);
|
printk(BIOS_DEBUG, "Relocate MRC DATA from %p to %p (%u bytes)\n",
|
||||||
|
&train, mrcdata, output_len);
|
||||||
|
|
||||||
mrcdata->mrc_signature = MRC_DATA_SIGNATURE;
|
mrcdata->mrc_signature = MRC_DATA_SIGNATURE;
|
||||||
mrcdata->mrc_data_size = output_len;
|
mrcdata->mrc_data_size = output_len;
|
||||||
mrcdata->reserved = 0;
|
mrcdata->reserved = 0;
|
||||||
memcpy(mrcdata->mrc_data, &train, sizeof(train));
|
memcpy(mrcdata->mrc_data, &train, sizeof(train));
|
||||||
|
|
||||||
/* Zero the unused space in aligned buffer. */
|
/* Zero the unused space in aligned buffer. */
|
||||||
if (output_len > sizeof(train))
|
if (output_len > sizeof(train))
|
||||||
memset(mrcdata->mrc_data + sizeof(train), 0,
|
memset(mrcdata->mrc_data + sizeof(train), 0,
|
||||||
output_len - sizeof(train));
|
output_len - sizeof(train));
|
||||||
|
|
||||||
mrcdata->mrc_checksum = compute_ip_checksum(mrcdata->mrc_data,
|
mrcdata->mrc_checksum = compute_ip_checksum(mrcdata->mrc_data,
|
||||||
mrcdata->mrc_data_size);
|
mrcdata->mrc_data_size);
|
||||||
#endif
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if REAL
|
#if REAL
|
||||||
|
|
|
@ -54,8 +54,6 @@
|
||||||
void save_mrc_data(struct pei_data *pei_data)
|
void save_mrc_data(struct pei_data *pei_data)
|
||||||
{
|
{
|
||||||
u16 c1, c2, checksum;
|
u16 c1, c2, checksum;
|
||||||
|
|
||||||
#if CONFIG_EARLY_CBMEM_INIT
|
|
||||||
struct mrc_data_container *mrcdata;
|
struct mrc_data_container *mrcdata;
|
||||||
int output_len = ALIGN(pei_data->mrc_output_len, 16);
|
int output_len = ALIGN(pei_data->mrc_output_len, 16);
|
||||||
|
|
||||||
|
@ -64,23 +62,24 @@ void save_mrc_data(struct pei_data *pei_data)
|
||||||
(CBMEM_ID_MRCDATA,
|
(CBMEM_ID_MRCDATA,
|
||||||
output_len + sizeof(struct mrc_data_container));
|
output_len + sizeof(struct mrc_data_container));
|
||||||
|
|
||||||
printk(BIOS_DEBUG, "Relocate MRC DATA from %p to %p (%u bytes)\n",
|
if (mrcdata != NULL) {
|
||||||
pei_data->mrc_output, mrcdata, output_len);
|
printk(BIOS_DEBUG, "Relocate MRC DATA from %p to %p (%u bytes)\n",
|
||||||
|
pei_data->mrc_output, mrcdata, output_len);
|
||||||
|
|
||||||
mrcdata->mrc_signature = MRC_DATA_SIGNATURE;
|
mrcdata->mrc_signature = MRC_DATA_SIGNATURE;
|
||||||
mrcdata->mrc_data_size = output_len;
|
mrcdata->mrc_data_size = output_len;
|
||||||
mrcdata->reserved = 0;
|
mrcdata->reserved = 0;
|
||||||
memcpy(mrcdata->mrc_data, pei_data->mrc_output,
|
memcpy(mrcdata->mrc_data, pei_data->mrc_output,
|
||||||
pei_data->mrc_output_len);
|
pei_data->mrc_output_len);
|
||||||
|
|
||||||
/* Zero the unused space in aligned buffer. */
|
/* Zero the unused space in aligned buffer. */
|
||||||
if (output_len > pei_data->mrc_output_len)
|
if (output_len > pei_data->mrc_output_len)
|
||||||
memset(mrcdata->mrc_data+pei_data->mrc_output_len, 0,
|
memset(mrcdata->mrc_data+pei_data->mrc_output_len, 0,
|
||||||
output_len - pei_data->mrc_output_len);
|
output_len - pei_data->mrc_output_len);
|
||||||
|
|
||||||
mrcdata->mrc_checksum = compute_ip_checksum(mrcdata->mrc_data,
|
mrcdata->mrc_checksum = compute_ip_checksum(mrcdata->mrc_data,
|
||||||
mrcdata->mrc_data_size);
|
mrcdata->mrc_data_size);
|
||||||
#endif
|
}
|
||||||
|
|
||||||
/* Save the MRC seed values to CMOS */
|
/* Save the MRC seed values to CMOS */
|
||||||
cmos_write32(CMOS_OFFSET_MRC_SEED, pei_data->scrambler_seed);
|
cmos_write32(CMOS_OFFSET_MRC_SEED, pei_data->scrambler_seed);
|
||||||
|
|
Loading…
Reference in New Issue