<p>Arthur Heymans has uploaded this change for <strong>review</strong>.</p><p><a href="https://review.coreboot.org/20379">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">[WIP]arch/x86: Add function to play a sound through PC speaker<br><br>inspired by http://wiki.osdev.org/PC_Speaker (todo archive the link)<br><br>Change-Id: Iec31101892b109c52db279cc3a1c7f4c143a0f7b<br>Signed-off-by: Arthur Heymans <arthur@aheymans.xyz><br>---<br>M src/arch/x86/Makefile.inc<br>A src/arch/x86/include/arch/pit.h<br>A src/arch/x86/pit.c<br>3 files changed, 62 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/79/20379/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">diff --git a/src/arch/x86/Makefile.inc b/src/arch/x86/Makefile.inc<br>index 5f184c5..ae7f5b6 100644<br>--- a/src/arch/x86/Makefile.inc<br>+++ b/src/arch/x86/Makefile.inc<br>@@ -215,6 +215,7 @@<br> romstage-$(CONFIG_X86_TOP4G_BOOTMEDIA_MAP) += mmap_boot.c<br> romstage-y += postcar_loader.c<br> romstage-$(CONFIG_COLLECT_TIMESTAMPS) += timestamp.c<br>+romstage-y += pit.c<br> <br> ifneq ($(CONFIG_ROMCC),y)<br> <br>@@ -341,6 +342,7 @@<br> ramstage-$(CONFIG_COOP_MULTITASKING) += thread_switch.S<br> ramstage-$(CONFIG_COLLECT_TIMESTAMPS) += timestamp.c<br> ramstage-$(CONFIG_HAVE_ACPI_RESUME) += wakeup.S<br>+ramstage-y += pit.c<br> <br> smm-y += memcpy.c<br> smm-y += memmove.c<br>diff --git a/src/arch/x86/include/arch/pit.h b/src/arch/x86/include/arch/pit.h<br>new file mode 100644<br>index 0000000..6286bbf<br>--- /dev/null<br>+++ b/src/arch/x86/include/arch/pit.h<br>@@ -0,0 +1,21 @@<br>+/*<br>+ * This file is part of the coreboot project.<br>+ *<br>+ * 2017 Arthur Heymans <arthur@aheymans.xyz><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 __INCLUDE_ARCH_PIT__<br>+#define __INCLUDE_ARCH_PIT__<br>+<br>+void play_sound(u32 frequency, u8 seconds);<br>+<br>+#endif /* __INCLUDE_ARCH_PIT__ */<br>diff --git a/src/arch/x86/pit.c b/src/arch/x86/pit.c<br>new file mode 100644<br>index 0000000..b90767e<br>--- /dev/null<br>+++ b/src/arch/x86/pit.c<br>@@ -0,0 +1,39 @@<br>+/*<br>+ * This file is part of the coreboot project.<br>+ *<br>+ * 2017 Arthur Heymans <arthur@aheymans.xyz><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 <arch/io.h><br>+#include <delay.h><br>+#include <arch/pit.h><br>+<br>+<br>+void play_sound(u32 frequency, u8 seconds)<br>+{<br>+        u32 div;<br>+     u8 reg8;<br>+<br>+  div = 1193180 / frequency;<br>+   outb(0xb6, 0x43);<br>+    outb((u8) (div), 0x42);<br>+      outb((u8) (div >> 8), 0x42);<br>+<br>+        reg8 = inb(0x61);<br>+    if (reg8!= (reg8 | 3))<br>+               outb(reg8 | 3, 0x61);<br>+<br>+     udelay(1000 * seconds);<br>+      <br>+     reg8 = inb(0x61) & ~3;<br>+   outb(reg8, 0x61);<br>+}<br></pre><p>To view, visit <a href="https://review.coreboot.org/20379">change 20379</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/20379"/><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: Iec31101892b109c52db279cc3a1c7f4c143a0f7b </div>
<div style="display:none"> Gerrit-Change-Number: 20379 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Arthur Heymans <arthur@aheymans.xyz> </div>