summaryrefslogtreecommitdiff
path: root/src/northbridge/intel/common
diff options
context:
space:
mode:
authorPatrick Rudolph <siro@das-labor.org>2016-05-29 17:05:06 +0200
committerMartin Roth <martinroth@google.com>2016-06-12 12:27:32 +0200
commitbb9c90a2074ac0138a4d1083bf0d9f52a39b47d5 (patch)
tree364fb78606771e633c2829d5a0cdcb8147a22137 /src/northbridge/intel/common
parent70e03fea5bd3448058abe5d03764c17326a2c017 (diff)
nb/intel: Factor out common MRC code
Remove code duplication and use the common function store_current_mrc_cache instead. No functionality is changed. Tested on Sandybridge Lenovo T520. Change-Id: I4aa5463f1b1d5e1afbe44b4bfc659524d86204db Signed-off-by: Patrick Rudolph <siro@das-labor.org> Reviewed-on: https://review.coreboot.org/15074 Reviewed-by: Aaron Durbin <adurbin@chromium.org> Tested-by: build bot (Jenkins)
Diffstat (limited to 'src/northbridge/intel/common')
-rw-r--r--src/northbridge/intel/common/mrc_cache.c32
-rw-r--r--src/northbridge/intel/common/mrc_cache.h1
2 files changed, 33 insertions, 0 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 */