<p>Arthur Heymans has uploaded this change for <strong>review</strong>.</p><p><a href="https://review.coreboot.org/21151">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">[WIP,UNTESTED]cpu/amdk8: Depreciate LATE_CBMEM_INIT<br><br>Change-Id: Ief7dd6d6f450fb8ed9dd4d36b099f3c0072b6b2e<br>Signed-off-by: Arthur Heymans <arthur@aheymans.xyz><br>---<br>M src/cpu/amd/model_fxx/Makefile.inc<br>A src/cpu/amd/model_fxx/ram_calc.c<br>A src/cpu/amd/model_fxx/ram_calc.h<br>M src/northbridge/amd/amdk8/Kconfig<br>M src/northbridge/amd/amdk8/northbridge.c<br>5 files changed, 104 insertions(+), 44 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://review.coreboot.org:29418/coreboot refs/changes/51/21151/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">diff --git a/src/cpu/amd/model_fxx/Makefile.inc b/src/cpu/amd/model_fxx/Makefile.inc<br>index 4d8153a..31eeeb7 100644<br>--- a/src/cpu/amd/model_fxx/Makefile.inc<br>+++ b/src/cpu/amd/model_fxx/Makefile.inc<br>@@ -5,5 +5,7 @@<br> ramstage-y += model_fxx_update_microcode.c<br> ramstage-y += processor_name.c<br> ramstage-$(CONFIG_HAVE_ACPI_TABLES) += powernow_acpi.c<br>+romstage-y += ram_calc.c<br>+ramstage-y += ram_calc.c<br> <br> cpu_microcode_bins += 3rdparty/blobs/cpu/amd/model_fxx/microcode.bin<br>diff --git a/src/cpu/amd/model_fxx/ram_calc.c b/src/cpu/amd/model_fxx/ram_calc.c<br>new file mode 100644<br>index 0000000..34f1ebb<br>--- /dev/null<br>+++ b/src/cpu/amd/model_fxx/ram_calc.c<br>@@ -0,0 +1,79 @@<br>+/*<br>+ * This file is part of the coreboot project.<br>+ *<br>+ * Copyright (C) 2015 Timothy Pearson <tpearson@raptorengineeringinc.com>, Raptor Engineering<br>+ * Copyright (C) 2007 Advanced Micro Devices, Inc.<br>+ *<br>+ * This program is free software; you can redistribute it and/or modify<br>+ * it under the terms of the GNU General Public License as published by<br>+ * the Free Software Foundation; version 2 of the License.<br>+ *<br>+ * This program is distributed in the hope that it will be useful,<br>+ * but WITHOUT ANY WARRANTY; without even the implied warranty of<br>+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the<br>+ * GNU General Public License for more details.<br>+ */<br>+<br>+#include <cpu/cpu.h><br>+#include <cpu/x86/msr.h><br>+#include <cpu/amd/mtrr.h><br>+<br>+#include <arch/io.h><br>+#include <device/device.h><br>+#include <device/pci.h><br>+<br>+#include <cbmem.h><br>+<br>+#include "ram_calc.h"<br>+<br>+uint64_t get_uma_memory_size(uint64_t topmem)<br>+{<br>+     uint64_t uma_size = 0;<br>+<br>+#if IS_ENABLED(CONFIG_GFXUMA)<br>+#if !IS_ENABLED(CONFIG_BOARD_ASROCK_939A785GMH) && \<br>+     !IS_ENABLED(CONFIG_BOARD_AMD_MAHOGANY)<br>+<br>+    switch (topmem) {<br>+    case 0x10000000:        /* 256M system memory */<br>+             uma_memory_size = 0x2000000;    /* 32M recommended UMA */<br>+            break;<br>+<br>+    case 0x18000000:        /* 384M system memory */<br>+             uma_memory_size = 0x4000000;    /* 64M recommended UMA */<br>+            break;<br>+<br>+    case 0x20000000:        /* 512M system memory */<br>+             uma_memory_size = 0x4000000;    /* 64M recommended UMA */<br>+            break;<br>+<br>+    default:                /* 1GB and above system memory */<br>+            uma_memory_size = 0x8000000;    /* 128M recommended UMA */<br>+           break;<br>+       }<br>+#else<br>+    /* refer to UMA Size Consideration in 780 BDG. */<br>+    switch (topmem) {<br>+    case 0x10000000:        /* 256M system memory */<br>+             uma_memory_size = 0x4000000;    /* 64M recommended UMA */<br>+            break;<br>+<br>+    case 0x20000000:        /* 512M system memory */<br>+             uma_memory_size = 0x8000000;    /* 128M recommended UMA */<br>+           break;<br>+<br>+    default:                /* 1GB and above system memory */<br>+            uma_memory_size = 0x10000000;   /* 256M recommended UMA */<br>+           break;<br>+       }<br>+#endif<br>+#endif<br>+  return uma_size;<br>+}<br>+<br>+void *cbmem_top(void)<br>+{<br>+  uint32_t topmem = rdmsr(TOP_MEM).lo;<br>+<br>+      return (void *) topmem - get_uma_memory_size(topmem);<br>+}<br>diff --git a/src/cpu/amd/model_fxx/ram_calc.h b/src/cpu/amd/model_fxx/ram_calc.h<br>new file mode 100644<br>index 0000000..b780fe2<br>--- /dev/null<br>+++ b/src/cpu/amd/model_fxx/ram_calc.h<br>@@ -0,0 +1,21 @@<br>+/*<br>+ * This file is part of the coreboot project.<br>+ *<br>+ * Copyright (C) 2015 Timothy Pearson <tpearson@raptorengineeringinc.com>, Raptor Engineering<br>+ *<br>+ * This program is free software; you can redistribute it and/or modify<br>+ * it under the terms of the GNU General Public License as published by<br>+ * the Free Software Foundation; version 2 of the License.<br>+ *<br>+ * This program is distributed in the hope that it will be useful,<br>+ * but WITHOUT ANY WARRANTY; without even the implied warranty of<br>+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the<br>+ * GNU General Public License for more details.<br>+ */<br>+<br>+#ifndef _AMD_MODEL_FXX_RAM_CALC_H_<br>+#define _AMD_MODEL_FXX_RAM_CALC_H_<br>+<br>+uint64_t get_uma_memory_size(uint64_t topmem);<br>+<br>+#endif<br>diff --git a/src/northbridge/amd/amdk8/Kconfig b/src/northbridge/amd/amdk8/Kconfig<br>index 83f70c9..0acd5d7 100644<br>--- a/src/northbridge/amd/amdk8/Kconfig<br>+++ b/src/northbridge/amd/amdk8/Kconfig<br>@@ -19,7 +19,6 @@<br>        select HAVE_DEBUG_SMBUS<br>       select HAVE_DEBUG_CAR<br>         select HYPERTRANSPORT_PLUGIN_SUPPORT<br>- select LATE_CBMEM_INIT<br> <br> if NORTHBRIDGE_AMD_AMDK8<br> <br>diff --git a/src/northbridge/amd/amdk8/northbridge.c b/src/northbridge/amd/amdk8/northbridge.c<br>index 2a92ca2..140c53d 100644<br>--- a/src/northbridge/amd/amdk8/northbridge.c<br>+++ b/src/northbridge/amd/amdk8/northbridge.c<br>@@ -36,6 +36,7 @@<br> #include <cpu/amd/model_fxx_rev.h><br> <br> #include <cpu/amd/amdk8_sysconf.h><br>+#include <cpu/amd/model_fxx/ram_calc.h><br> <br> struct amdk8_sysconf_t sysconf;<br> <br>@@ -807,51 +808,12 @@<br> }<br> #endif<br> <br>-#include <cbmem.h><br>-<br> static void setup_uma_memory(void)<br> {<br> #if IS_ENABLED(CONFIG_GFXUMA)<br>        uint32_t topmem = (uint32_t) bsp_topmem();<br> <br>-#if !IS_ENABLED(CONFIG_BOARD_ASROCK_939A785GMH) && \<br>- !IS_ENABLED(CONFIG_BOARD_AMD_MAHOGANY)<br>-<br>-    switch (topmem) {<br>-    case 0x10000000:        /* 256M system memory */<br>-             uma_memory_size = 0x2000000;    /* 32M recommended UMA */<br>-            break;<br>-<br>-    case 0x18000000:        /* 384M system memory */<br>-             uma_memory_size = 0x4000000;    /* 64M recommended UMA */<br>-            break;<br>-<br>-    case 0x20000000:        /* 512M system memory */<br>-             uma_memory_size = 0x4000000;    /* 64M recommended UMA */<br>-            break;<br>-<br>-    default:                /* 1GB and above system memory */<br>-            uma_memory_size = 0x8000000;    /* 128M recommended UMA */<br>-           break;<br>-       }<br>-#else<br>-    /* refer to UMA Size Consideration in 780 BDG. */<br>-    switch (topmem) {<br>-    case 0x10000000:        /* 256M system memory */<br>-             uma_memory_size = 0x4000000;    /* 64M recommended UMA */<br>-            break;<br>-<br>-    case 0x20000000:        /* 512M system memory */<br>-             uma_memory_size = 0x8000000;    /* 128M recommended UMA */<br>-           break;<br>-<br>-    default:                /* 1GB and above system memory */<br>-            uma_memory_size = 0x10000000;   /* 256M recommended UMA */<br>-           break;<br>-       }<br>-#endif<br>-<br>-        uma_memory_base = topmem - uma_memory_size;     /* TOP_MEM1 */<br>+       uma_memory_base = topmem - get_uma_memory_size(topmem); /* TOP_MEM1 */<br>        printk(BIOS_INFO, "%s: uma size 0x%08llx, memory start 0x%08llx\n",<br>                     __func__, uma_memory_size, uma_memory_base);<br> #endif<br>@@ -1000,10 +962,7 @@<br>      }<br> <br> #if IS_ENABLED(CONFIG_GFXUMA)<br>- set_late_cbmem_top(uma_memory_base);<br>  uma_resource(dev, 7, uma_memory_base >> 10, uma_memory_size >> 10);<br>-#else<br>-      set_late_cbmem_top(ramtop);<br> #endif<br>  assign_resources(dev->link_list);<br> <br></pre><p>To view, visit <a href="https://review.coreboot.org/21151">change 21151</a>. To unsubscribe, visit <a href="https://review.coreboot.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://review.coreboot.org/21151"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: coreboot </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>
<div style="display:none"> Gerrit-Change-Id: Ief7dd6d6f450fb8ed9dd4d36b099f3c0072b6b2e </div>
<div style="display:none"> Gerrit-Change-Number: 21151 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Arthur Heymans <arthur@aheymans.xyz> </div>