<p>Nico Huber has uploaded this change for <strong>review</strong>.</p><p><a href="https://review.coreboot.org/29054">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">arch/x86: Implement common CF9 reset<br><br>It's very common across many x86 silicon vendors, so place it in<br>`arch/x86/`.<br><br>Use the "system reset" as board_reset().<br><br>Change-Id: I06c27afa31e5eecfdb7093c02f703bdaabf0594c<br>Signed-off-by: Nico Huber <nico.h@gmx.de><br>---<br>M src/arch/x86/Kconfig<br>M src/arch/x86/Makefile.inc<br>A src/arch/x86/cf9_reset.c<br>A src/arch/x86/include/cf9_reset.h<br>4 files changed, 109 insertions(+), 0 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://review.coreboot.org:29418/coreboot refs/changes/54/29054/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/src/arch/x86/Kconfig b/src/arch/x86/Kconfig</span><br><span>index 46e0c2d..ff26a15 100644</span><br><span>--- a/src/arch/x86/Kconfig</span><br><span>+++ b/src/arch/x86/Kconfig</span><br><span>@@ -315,3 +315,10 @@</span><br><span>       bool</span><br><span>         default n</span><br><span>    depends on ARCH_X86</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+config HAVE_CF9_RESET</span><br><span style="color: hsl(120, 100%, 40%);">+  bool</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+config HAVE_CF9_RESET_PREPARE</span><br><span style="color: hsl(120, 100%, 40%);">+ bool</span><br><span style="color: hsl(120, 100%, 40%);">+  depends on HAVE_CF9_RESET</span><br><span>diff --git a/src/arch/x86/Makefile.inc b/src/arch/x86/Makefile.inc</span><br><span>index 7f85b6a..730bc83 100644</span><br><span>--- a/src/arch/x86/Makefile.inc</span><br><span>+++ b/src/arch/x86/Makefile.inc</span><br><span>@@ -43,6 +43,12 @@</span><br><span> pci$(stripped_vgabios_id).rom-file := $(call strip_quotes,$(CONFIG_VGA_BIOS_FILE))</span><br><span> pci$(stripped_vgabios_id).rom-type := optionrom</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+verstage-$(CONFIG_HAVE_CF9_RESET) += cf9_reset.c</span><br><span style="color: hsl(120, 100%, 40%);">+bootblock-$(CONFIG_HAVE_CF9_RESET) += cf9_reset.c</span><br><span style="color: hsl(120, 100%, 40%);">+romstage-$(CONFIG_HAVE_CF9_RESET) += cf9_reset.c</span><br><span style="color: hsl(120, 100%, 40%);">+ramstage-$(CONFIG_HAVE_CF9_RESET) += cf9_reset.c</span><br><span style="color: hsl(120, 100%, 40%);">+postcar-$(CONFIG_HAVE_CF9_RESET) += cf9_reset.c</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> ###############################################################################</span><br><span> # common support for early assembly includes</span><br><span> ###############################################################################</span><br><span>diff --git a/src/arch/x86/cf9_reset.c b/src/arch/x86/cf9_reset.c</span><br><span>new file mode 100644</span><br><span>index 0000000..6f903c9</span><br><span>--- /dev/null</span><br><span>+++ b/src/arch/x86/cf9_reset.c</span><br><span>@@ -0,0 +1,56 @@</span><br><span style="color: hsl(120, 100%, 40%);">+/*</span><br><span style="color: hsl(120, 100%, 40%);">+ * This file is part of the coreboot project.</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * Copyright 2017 Google, Inc.</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * This program is free software; you can redistribute it and/or modify</span><br><span style="color: hsl(120, 100%, 40%);">+ * it under the terms of the GNU General Public License as published by</span><br><span style="color: hsl(120, 100%, 40%);">+ * the Free Software Foundation; version 2 of the License.</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * This program is distributed in the hope that it will be useful,</span><br><span style="color: hsl(120, 100%, 40%);">+ * but WITHOUT ANY WARRANTY; without even the implied warranty of</span><br><span style="color: hsl(120, 100%, 40%);">+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the</span><br><span style="color: hsl(120, 100%, 40%);">+ * GNU General Public License for more details.</span><br><span style="color: hsl(120, 100%, 40%);">+ */</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+#include <arch/io.h></span><br><span style="color: hsl(120, 100%, 40%);">+#include <arch/cache.h></span><br><span style="color: hsl(120, 100%, 40%);">+#include <cf9_reset.h></span><br><span style="color: hsl(120, 100%, 40%);">+#include <console/console.h></span><br><span style="color: hsl(120, 100%, 40%);">+#include <halt.h></span><br><span style="color: hsl(120, 100%, 40%);">+#include <reset.h></span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+void do_system_reset(void)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+  outb(SYS_RST, RST_CNT);</span><br><span style="color: hsl(120, 100%, 40%);">+       outb(RST_CPU | SYS_RST, RST_CNT);</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+void do_full_reset(void)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+   outb(FULL_RST | SYS_RST, RST_CNT);</span><br><span style="color: hsl(120, 100%, 40%);">+    outb(FULL_RST | RST_CPU | SYS_RST, RST_CNT);</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+void system_reset(void)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+ printk(BIOS_INFO, "%s() called!\n", __func__);</span><br><span style="color: hsl(120, 100%, 40%);">+      cf9_reset_prepare();</span><br><span style="color: hsl(120, 100%, 40%);">+  dcache_clean_all();</span><br><span style="color: hsl(120, 100%, 40%);">+   do_system_reset();</span><br><span style="color: hsl(120, 100%, 40%);">+    halt();</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+void full_reset(void)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+        printk(BIOS_INFO, "%s() called!\n", __func__);</span><br><span style="color: hsl(120, 100%, 40%);">+      cf9_reset_prepare();</span><br><span style="color: hsl(120, 100%, 40%);">+  dcache_clean_all();</span><br><span style="color: hsl(120, 100%, 40%);">+   do_full_reset();</span><br><span style="color: hsl(120, 100%, 40%);">+      halt();</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+void do_board_reset(void)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+    system_reset();</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span>diff --git a/src/arch/x86/include/cf9_reset.h b/src/arch/x86/include/cf9_reset.h</span><br><span>new file mode 100644</span><br><span>index 0000000..c0dcc92</span><br><span>--- /dev/null</span><br><span>+++ b/src/arch/x86/include/cf9_reset.h</span><br><span>@@ -0,0 +1,40 @@</span><br><span style="color: hsl(120, 100%, 40%);">+/*</span><br><span style="color: hsl(120, 100%, 40%);">+ * This file is part of the coreboot project.</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * Copyright (C) 2017 Intel Corp.</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * This program is free software; you can redistribute it and/or modify</span><br><span style="color: hsl(120, 100%, 40%);">+ * it under the terms of the GNU General Public License as published by</span><br><span style="color: hsl(120, 100%, 40%);">+ * the Free Software Foundation; version 2 of the License.</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * This program is distributed in the hope that it will be useful,</span><br><span style="color: hsl(120, 100%, 40%);">+ * but WITHOUT ANY WARRANTY; without even the implied warranty of</span><br><span style="color: hsl(120, 100%, 40%);">+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the</span><br><span style="color: hsl(120, 100%, 40%);">+ * GNU General Public License for more details.</span><br><span style="color: hsl(120, 100%, 40%);">+ */</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+#ifndef X86_CF9_RESET_H</span><br><span style="color: hsl(120, 100%, 40%);">+#define X86_CF9_RESET_H</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+/* Reset control port */</span><br><span style="color: hsl(120, 100%, 40%);">+#define RST_CNT                       0xcf9</span><br><span style="color: hsl(120, 100%, 40%);">+#define FULL_RST         (1 << 3)</span><br><span style="color: hsl(120, 100%, 40%);">+#define RST_CPU                 (1 << 2)</span><br><span style="color: hsl(120, 100%, 40%);">+#define SYS_RST                 (1 << 1)</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+/* Implement the bare reset, i.e. write to cf9. */</span><br><span style="color: hsl(120, 100%, 40%);">+void do_system_reset(void);</span><br><span style="color: hsl(120, 100%, 40%);">+void do_full_reset(void);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+/* Called by functions below before reset. */</span><br><span style="color: hsl(120, 100%, 40%);">+#if IS_ENABLED(CONFIG_HAVE_CF9_RESET_PREPARE)</span><br><span style="color: hsl(120, 100%, 40%);">+void cf9_reset_prepare(void);</span><br><span style="color: hsl(120, 100%, 40%);">+#else</span><br><span style="color: hsl(120, 100%, 40%);">+static inline void cf9_reset_prepare(void) {}</span><br><span style="color: hsl(120, 100%, 40%);">+#endif</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+/* Prepare for reset, run do_*_reset(), halt. */</span><br><span style="color: hsl(120, 100%, 40%);">+__noreturn void system_reset(void);</span><br><span style="color: hsl(120, 100%, 40%);">+__noreturn void full_reset(void);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+#endif /* X86_CF9_RESET_H */</span><br><span></span><br></pre><p>To view, visit <a href="https://review.coreboot.org/29054">change 29054</a>. To unsubscribe, or for help writing mail filters, 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/29054"/><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: I06c27afa31e5eecfdb7093c02f703bdaabf0594c </div>
<div style="display:none"> Gerrit-Change-Number: 29054 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Nico Huber <nico.h@gmx.de> </div>