[coreboot-gerrit] Patch set updated for coreboot: 4a41fd6 Add a lib function to read SPD from a file
Dave Frodin (dave.frodin@se-eng.com)
gerrit at coreboot.org
Tue Dec 17 14:24:25 CET 2013
Dave Frodin (dave.frodin at se-eng.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/4533
-gerrit
commit 4a41fd60a72f2d43dbe5819b7427b98ed08f831f
Author: Dave Frodin <dave.frodin at se-eng.com>
Date: Sat Dec 14 11:21:26 2013 -0700
Add a lib function to read SPD from a file
This allows mainboards with solder-down memory and without
a solder-down SPD EEPROM to have their SPD settings read
from a file.
Change-Id: I3fb351f4b84cf290e3f4374bcee8a038bccf7eed
Signed-off-by: Dave Frodin <dave.frodin at se-eng.com>
---
src/include/lib.h | 3 +++
src/lib/Makefile.inc | 1 +
src/lib/spd_from_file.c | 60 +++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 64 insertions(+)
diff --git a/src/include/lib.h b/src/include/lib.h
index 2f27149..60af053 100644
--- a/src/include/lib.h
+++ b/src/include/lib.h
@@ -55,4 +55,7 @@ void cache_as_ram_main(void);
void cache_as_ram_main(unsigned long bist, unsigned long cpu_init_detectedx);
#endif
+/* Defined in src/lib/spd_from_file.c */
+int read_spd_from_file(unsigned char *infoptr);
+
#endif /* __LIB_H__ */
diff --git a/src/lib/Makefile.inc b/src/lib/Makefile.inc
index 92ec663..0148326 100644
--- a/src/lib/Makefile.inc
+++ b/src/lib/Makefile.inc
@@ -50,6 +50,7 @@ romstage-$(CONFIG_CONSOLE_SERIAL8250MEM) += uart8250mem.c
romstage-$(CONFIG_CONSOLE_NE2K) += ne2k.c
romstage-$(CONFIG_SPKMODEM) += spkmodem.c
romstage-$(CONFIG_USBDEBUG_IN_ROMSTAGE) += usbdebug.c
+romstage-$(CONFIG_READ_SPD_FROM_FILE) += spd_from_file.c
ifeq ($(CONFIG_EARLY_CBMEM_INIT),y)
romstage-$(CONFIG_COLLECT_TIMESTAMPS) += timestamp.c
diff --git a/src/lib/spd_from_file.c b/src/lib/spd_from_file.c
new file mode 100755
index 0000000..100f460
--- /dev/null
+++ b/src/lib/spd_from_file.c
@@ -0,0 +1,60 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright (C) 2013 Sage Electronic Engineering, LLC
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <lib.h>
+#include <console/console.h>
+
+int read_spd_from_file(unsigned char *spd_ptr)
+{
+ unsigned short index, crc = 0;
+ int i, j, jmax;
+ #include CONFIG_PATH_TO_SPD_FILE
+
+ /* read the bytes from the table */
+ for (index = 0; index < 128; index++)
+ spd_ptr[index] = ddr3_fake_spd[index];
+
+ /* If CRC bytes are zeroes, calculate and store the CRC of the fake table */
+ if ((spd_ptr[126] == 0) && (spd_ptr[127] == 0)) {
+ /* should the CRC be done on bytes 0-116 or 0-125 ? */
+ if (spd_ptr[0] & 0x80)
+ jmax = 117;
+ else
+ jmax = 126;
+
+ for (j = 0; j < jmax; j++) {
+ crc = crc ^ ((unsigned short)spd_ptr[j] << 8);
+ for (i = 0; i < 8; i++) {
+ if (crc & 0x8000)
+ crc = (crc << 1) ^ 0x1021;
+ else
+ crc = (crc << 1);
+ }
+ }
+ spd_ptr[126] = (unsigned char)(crc & 0xff);
+ spd_ptr[127] = (unsigned char)(crc >> 8);
+ }
+ printk(BIOS_SPEW, "\nDump the SPD");
+ for (index = 0; index < 128; index++) {
+ if((index&0x0F)==0x00) printk(BIOS_SPEW, "\n%02x: ",index);
+ printk(BIOS_SPEW, "%02x ", spd_ptr[index]);
+ }
+ printk(BIOS_SPEW, "\n");
+ return 0;
+}
More information about the coreboot-gerrit
mailing list