diff options
Diffstat (limited to 'src/northbridge/intel')
-rw-r--r-- | src/northbridge/intel/common/mrc_cache.c | 32 | ||||
-rw-r--r-- | src/northbridge/intel/common/mrc_cache.h | 1 | ||||
-rw-r--r-- | src/northbridge/intel/haswell/raminit.c | 24 | ||||
-rw-r--r-- | src/northbridge/intel/nehalem/raminit.c | 23 | ||||
-rw-r--r-- | src/northbridge/intel/sandybridge/raminit.c | 25 | ||||
-rw-r--r-- | src/northbridge/intel/sandybridge/raminit_mrc.c | 25 |
6 files changed, 38 insertions, 92 deletions
diff --git a/src/northbridge/intel/common/mrc_cache.c b/src/northbridge/intel/common/mrc_cache.c index 82b1005a7a..4c3ee5d43c 100644 --- a/src/northbridge/intel/common/mrc_cache.c +++ b/src/northbridge/intel/common/mrc_cache.c @@ -250,3 +250,35 @@ struct mrc_data_container *find_current_mrc_cache(void) // 0. compare MRC data to last mrc-cache block (exit if same) return find_current_mrc_cache_local(cache_base, cache_size); } + +struct mrc_data_container * +store_current_mrc_cache(void *data, unsigned length) +{ + struct mrc_data_container *mrcdata; + int output_len = ALIGN(length, 16); + + /* Save the MRC S3 restore data to cbmem */ + mrcdata = cbmem_add + (CBMEM_ID_MRCDATA, + output_len + sizeof(struct mrc_data_container)); + + if (!mrcdata) + return NULL; + + printk(BIOS_DEBUG, "Relocate MRC DATA from %p to %p (%u bytes)\n", + data, mrcdata, output_len); + + mrcdata->mrc_signature = MRC_DATA_SIGNATURE; + mrcdata->mrc_data_size = output_len; + mrcdata->reserved = 0; + memcpy(mrcdata->mrc_data, data, length); + + /* Zero the unused space in aligned buffer. */ + if (output_len > length) + memset(mrcdata->mrc_data+length, 0, output_len - length); + + mrcdata->mrc_checksum = compute_ip_checksum(mrcdata->mrc_data, + mrcdata->mrc_data_size); + + return mrcdata; +} diff --git a/src/northbridge/intel/common/mrc_cache.h b/src/northbridge/intel/common/mrc_cache.h index 408a420a1a..1fb6667669 100644 --- a/src/northbridge/intel/common/mrc_cache.h +++ b/src/northbridge/intel/common/mrc_cache.h @@ -13,5 +13,6 @@ struct mrc_data_container { } __attribute__ ((packed)); struct mrc_data_container *find_current_mrc_cache(void); +struct mrc_data_container *store_current_mrc_cache(void *data, unsigned length); #endif /* NORTHBRIDGE_INTEL_COMMON_MRC_CACHE_H */ diff --git a/src/northbridge/intel/haswell/raminit.c b/src/northbridge/intel/haswell/raminit.c index 4644f05e59..464f7c8694 100644 --- a/src/northbridge/intel/haswell/raminit.c +++ b/src/northbridge/intel/haswell/raminit.c @@ -31,30 +31,8 @@ void save_mrc_data(struct pei_data *pei_data) { - struct mrc_data_container *mrcdata; - int output_len = ALIGN(pei_data->mrc_output_len, 16); - /* Save the MRC S3 restore data to cbmem */ - mrcdata = cbmem_add - (CBMEM_ID_MRCDATA, - output_len + sizeof(struct mrc_data_container)); - - 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_data_size = output_len; - mrcdata->reserved = 0; - memcpy(mrcdata->mrc_data, pei_data->mrc_output, - pei_data->mrc_output_len); - - /* Zero the unused space in aligned buffer. */ - if (output_len > pei_data->mrc_output_len) - memset(mrcdata->mrc_data+pei_data->mrc_output_len, 0, - output_len - pei_data->mrc_output_len); - - mrcdata->mrc_checksum = compute_ip_checksum(mrcdata->mrc_data, - mrcdata->mrc_data_size); + store_current_mrc_cache(pei_data->mrc_output, pei_data->mrc_output_len); } static void prepare_mrc_cache(struct pei_data *pei_data) diff --git a/src/northbridge/intel/nehalem/raminit.c b/src/northbridge/intel/nehalem/raminit.c index a5a627672a..0549de766a 100644 --- a/src/northbridge/intel/nehalem/raminit.c +++ b/src/northbridge/intel/nehalem/raminit.c @@ -1688,8 +1688,6 @@ static void dump_timings(struct raminfo *info) static void save_timings(struct raminfo *info) { struct ram_training train; - struct mrc_data_container *mrcdata; - int output_len = ALIGN(sizeof(train), 16); int channel, slot, rank, lane, i; train = info->training; @@ -1717,26 +1715,7 @@ static void save_timings(struct raminfo *info) printk (BIOS_SPEW, "[6e8] = %x\n", train.reg_6e8); /* Save the MRC S3 restore data to cbmem */ - mrcdata = cbmem_add - (CBMEM_ID_MRCDATA, output_len + sizeof(struct mrc_data_container)); - - if (mrcdata != NULL) { - 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_data_size = output_len; - mrcdata->reserved = 0; - memcpy(mrcdata->mrc_data, &train, sizeof(train)); - - /* Zero the unused space in aligned buffer. */ - if (output_len > sizeof(train)) - memset(mrcdata->mrc_data + sizeof(train), 0, - output_len - sizeof(train)); - - mrcdata->mrc_checksum = compute_ip_checksum(mrcdata->mrc_data, - mrcdata->mrc_data_size); - } + store_current_mrc_cache(&train, sizeof(train)); } #if REAL diff --git a/src/northbridge/intel/sandybridge/raminit.c b/src/northbridge/intel/sandybridge/raminit.c index 1ed77ebd44..6bb77b2c6a 100644 --- a/src/northbridge/intel/sandybridge/raminit.c +++ b/src/northbridge/intel/sandybridge/raminit.c @@ -3938,31 +3938,10 @@ static void final_registers(ramctr_timing * ctrl) | 0xc); } -static void save_timings(ramctr_timing * ctrl) +static void save_timings(ramctr_timing *ctrl) { - struct mrc_data_container *mrcdata; - int output_len = ALIGN(sizeof (*ctrl), 16); - /* Save the MRC S3 restore data to cbmem */ - mrcdata = cbmem_add - (CBMEM_ID_MRCDATA, - output_len + sizeof(struct mrc_data_container)); - - printk(BIOS_DEBUG, "Relocate MRC DATA from %p to %p (%u bytes)\n", - ctrl, mrcdata, output_len); - - mrcdata->mrc_signature = MRC_DATA_SIGNATURE; - mrcdata->mrc_data_size = output_len; - mrcdata->reserved = 0; - memcpy(mrcdata->mrc_data, ctrl, sizeof (*ctrl)); - - /* Zero the unused space in aligned buffer. */ - if (output_len > sizeof (*ctrl)) - memset(mrcdata->mrc_data+sizeof (*ctrl), 0, - output_len - sizeof (*ctrl)); - - mrcdata->mrc_checksum = compute_ip_checksum(mrcdata->mrc_data, - mrcdata->mrc_data_size); + store_current_mrc_cache(ctrl, sizeof(*ctrl)); } static void restore_timings(ramctr_timing * ctrl) diff --git a/src/northbridge/intel/sandybridge/raminit_mrc.c b/src/northbridge/intel/sandybridge/raminit_mrc.c index c26f012ff3..8754e4295c 100644 --- a/src/northbridge/intel/sandybridge/raminit_mrc.c +++ b/src/northbridge/intel/sandybridge/raminit_mrc.c @@ -52,32 +52,9 @@ void save_mrc_data(struct pei_data *pei_data) { u16 c1, c2, checksum; - struct mrc_data_container *mrcdata; - int output_len = ALIGN(pei_data->mrc_output_len, 16); /* Save the MRC S3 restore data to cbmem */ - mrcdata = cbmem_add - (CBMEM_ID_MRCDATA, - output_len + sizeof(struct mrc_data_container)); - - if (mrcdata != NULL) { - 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_data_size = output_len; - mrcdata->reserved = 0; - memcpy(mrcdata->mrc_data, pei_data->mrc_output, - pei_data->mrc_output_len); - - /* Zero the unused space in aligned buffer. */ - if (output_len > pei_data->mrc_output_len) - memset(mrcdata->mrc_data+pei_data->mrc_output_len, 0, - output_len - pei_data->mrc_output_len); - - mrcdata->mrc_checksum = compute_ip_checksum(mrcdata->mrc_data, - mrcdata->mrc_data_size); - } + store_current_mrc_cache(pei_data->mrc_output, pei_data->mrc_output_len); /* Save the MRC seed values to CMOS */ cmos_write32(CMOS_OFFSET_MRC_SEED, pei_data->scrambler_seed); |