lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <200802091448.04439.rjw@sisk.pl>
Date:	Sat, 9 Feb 2008 14:48:03 +0100
From:	"Rafael J. Wysocki" <rjw@...k.pl>
To:	"H. Peter Anvin" <hpa@...or.com>
Cc:	Pavel Machek <pavel@....cz>,
	kernel list <linux-kernel@...r.kernel.org>,
	Linux-pm mailing list <linux-pm@...ts.osdl.org>,
	Sam Ravnborg <sam@...nborg.org>
Subject: Re: [rft] s2ram wakeup moves to .c, could fix few machines

On Saturday, 9 of February 2008, H. Peter Anvin wrote:
> Rafael J. Wysocki wrote:
> > 
> > Consolidated patch is appended.  I'll test it tomorrow on x86-64.
> > 
> > I'd like to add the cleaned up beeping code to it and perhaps try to push it
> > for -mm testing without any further changes.  We can still do more cleanups in
> > followup patches.
> > 
> 
> The other thing to figure out is to what extent we can clean up the 
> conditionals in the video mode code by refactoring.  All they really do 
> here is save space by removing functionality not needed for wakeup, 
> because I didn't know how much space was realistic.

OK, I have an idea.

For now, below is a patch that adds your beeping code to wakemain.c (on top of
the previous one). ;-)

Rafael

---
 arch/x86/kernel/acpi/realmode/wakemain.c |   69 ++++++++++++++++++++++++++++---
 1 file changed, 63 insertions(+), 6 deletions(-)

Index: linux-2.6/arch/x86/kernel/acpi/realmode/wakemain.c
===================================================================
--- linux-2.6.orig/arch/x86/kernel/acpi/realmode/wakemain.c
+++ linux-2.6/arch/x86/kernel/acpi/realmode/wakemain.c
@@ -3,20 +3,77 @@
 
 extern volatile struct wakeup_header wakeup_header;
 
+static void udelay(int loops)
+{
+	while (loops--)
+		io_delay();	/* Approximately 1 us */
+}
+
+static void beep(unsigned int hz)
+{
+	u8 enable;
+
+	if (!hz) {
+		enable = 0x00;		/* Turn off speaker */
+	} else {
+		u16 div = 1193181/hz;
+
+		outb(0xb6, 0x43);	/* Ctr 2, squarewave, load, binary */
+		io_delay();
+		outb(div, 0x42);	/* LSB of counter */
+		io_delay();
+		outb(div >> 8, 0x42);	/* MSB of counter */
+		io_delay();
+
+		enable = 0x03;		/* Turn on speaker */
+	}
+	inb(0x61);		/* Dummy read of System Control Port B */
+	io_delay();
+	outb(enable, 0x61);	/* Enable timer 2 output to speaker */
+	io_delay();
+}
+
+#define DOT_HZ		880
+#define DASH_HZ		587
+#define US_PER_DOT	125000
+
+/* Okay, this is totally silly, but it's kind of fun. */
+static void send_morse(const char *pattern)
+{
+	char s;
+
+	while ((s = *pattern++)) {
+		switch (s) {
+		case '.':
+			beep(DOT_HZ);
+			udelay(US_PER_DOT);
+			beep(0);
+			udelay(US_PER_DOT);
+			break;
+		case '-':
+			beep(DASH_HZ);
+			udelay(US_PER_DOT * 3);
+			beep(0);
+			udelay(US_PER_DOT);
+			break;
+		default:	/* Assume it's a space */
+			udelay(US_PER_DOT * 3);
+			break;
+		}
+	}
+}
+
 void main(void)
 {
 	/* Kill machine if structures are wrong */
 	if (wakeup_header.real_magic != 0x12345678)
 		while(1);
 
-	if (wakeup_header.realmode_flags & 4) {
-		asm volatile("inb	$97, %al; 		outb	%al, $0x80; 		movb	$3, %al; 		outb	%al, $97; 		outb	%al, $0x80; 		movb	$-74, %al; 		outb	%al, $67; 		outb	%al, $0x80; 		movb	$-119, %al; 		outb	%al, $66; 		outb	%al, $0x80; 		movb	$15, %al; 		outb	%al, $66");
-	}
+	if (wakeup_header.realmode_flags & 4)
+		send_morse("...-");
 
-	if (wakeup_header.realmode_flags & 1) {
+	if (wakeup_header.realmode_flags & 1)
 		asm volatile("lcallw   $0xc000,$3");
-//		("movw    %cs, %ax;	movw    %ax, %ds;	movw	%ax, %es; movw    %ax, %ss");
-	}
 
 	if (wakeup_header.realmode_flags & 2) {
 		/* Need to call BIOS */
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ