From fullermd@over-yonder.net  Thu May  1 08:22:50 2014
Return-Path: <fullermd@over-yonder.net>
Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115])
	(using TLSv1 with cipher ADH-AES256-SHA (256/256 bits))
	(No client certificate requested)
	by hub.freebsd.org (Postfix) with ESMTPS id CFD3C116
	for <FreeBSD-gnats-submit@freebsd.org>; Thu,  1 May 2014 08:22:50 +0000 (UTC)
Received: from thyme.infocus-llc.com (server.infocus-llc.com [206.156.254.44])
	(using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits))
	(Client CN "*.infocus-llc.com", Issuer "*.infocus-llc.com" (not verified))
	by mx1.freebsd.org (Postfix) with ESMTPS id A9C4C1CFB
	for <FreeBSD-gnats-submit@freebsd.org>; Thu,  1 May 2014 08:22:50 +0000 (UTC)
Received: from draco.over-yonder.net (c-75-65-60-66.hsd1.ms.comcast.net [75.65.60.66])
	(using TLSv1 with cipher ADH-CAMELLIA256-SHA (256/256 bits))
	(No client certificate requested)
	by thyme.infocus-llc.com (Postfix) with ESMTPSA id 8C5C837B513
	for <FreeBSD-gnats-submit@freebsd.org>; Thu,  1 May 2014 03:22:49 -0500 (CDT)
Received: by draco.over-yonder.net (Postfix, from userid 100)
	id 3gK8jP19jQz2T7; Thu,  1 May 2014 03:22:49 -0500 (CDT)
Message-Id: <3gK8jP19jQz2T7@draco.over-yonder.net>
Date: Thu,  1 May 2014 03:22:49 -0500 (CDT)
From: Matthew D.Fuller <fullermd@over-yonder.net>
Reply-To: Matthew D.Fuller <fullermd@over-yonder.net>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: [PATCH] [newcons] Implement KDMKTONE ioctl
X-Send-Pr-Version: 3.114
X-GNATS-Notify:

>Number:         189170
>Category:       kern
>Synopsis:       [PATCH] [vt] Implement KDMKTONE ioctl
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    ray
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu May 01 08:30:00 UTC 2014
>Closed-Date:    Tue May 13 09:38:09 UTC 2014
>Last-Modified:  Tue May 13 09:38:09 UTC 2014
>Originator:     Matthew D. Fuller
>Release:        FreeBSD 9.1-STABLE amd64
>Organization:
>Environment:
System: FreeBSD draco.over-yonder.net 9.1-STABLE FreeBSD 9.1-STABLE #0 r251584: Sun Jun 9 14:23:33 CDT 2013 root@draco.over-yonder.net:/usr/obj/usr/src/sys/DRACO amd64


	
>Description:
	newcons has KDMKTONE ioctl stubbed out, which means that things that
	try to sound the bell (like X) wind up doing nothing.  And working
	with X is a big part of the push for newcons, so it should do so  :)

>How-To-Repeat:
	
>Fix:


Index: sys/dev/vt/vt_core.c
===================================================================
--- sys/dev/vt/vt_core.c	(revision 264991)
+++ sys/dev/vt/vt_core.c	(working copy)
@@ -1636,7 +1636,11 @@
 #endif
 		return (0);
 	case KDMKTONE:      	/* sound the bell */
-		/* TODO */
+		if(*(int*)data)
+			sysbeep(1193182 / ((*(int*)data)&0xffff),
+			        (((*(int*)data)>>16)&0xffff)*hz/1000);
+		else
+			vtterm_bell(tm);
 		return (0);
 	case KIOCSOUND:     	/* make tone (*data) hz */
 		/* TODO */

>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->ray 
Responsible-Changed-By: linimon 
Responsible-Changed-When: Sun May 4 03:12:08 UTC 2014 
Responsible-Changed-Why:  
Over to maintainer. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=189170 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: kern/189170: commit references a PR
Date: Tue,  6 May 2014 13:52:17 +0000 (UTC)

 Author: ray
 Date: Tue May  6 13:52:13 2014
 New Revision: 265442
 URL: http://svnweb.freebsd.org/changeset/base/265442
 
 Log:
   Implement KDMKTONE ioctl.
   
   Submitted by:	Matthew D.Fuller <fullermd@over-yonder.net> (original version)
   MFC:		7 days
   PR:		kern/189170
   
   Sponsored by:	The FreeBSD Foundation
 
 Modified:
   head/sys/dev/vt/vt_core.c
 
 Modified: head/sys/dev/vt/vt_core.c
 ==============================================================================
 --- head/sys/dev/vt/vt_core.c	Tue May  6 13:46:36 2014	(r265441)
 +++ head/sys/dev/vt/vt_core.c	Tue May  6 13:52:13 2014	(r265442)
 @@ -1732,9 +1732,17 @@ skip_thunk:
  		td->td_frame->tf_rflags &= ~PSL_IOPL;
  #endif
  		return (0);
 -	case KDMKTONE:      	/* sound the bell */
 -		/* TODO */
 +	case KDMKTONE: {      	/* sound the bell */
 +		int freq, period;
 +
 +		freq = 1193182 / ((*(int*)data) & 0xffff);
 +		period = (((*(int*)data)>>16) & 0xffff) * hz / 1000;
 +		if(*(int*)data)
 +			sysbeep(freq, period);
 +		else
 +			vtterm_bell(tm);
  		return (0);
 +	}
  	case KIOCSOUND:     	/* make tone (*data) hz */
  		/* TODO */
  		return (0);
 _______________________________________________
 svn-src-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
 

From: Henry Hu <henry.hu.sh@gmail.com>
To: bug-followup@freebsd.org, fullermd@over-yonder.net
Cc: ray@freebsd.org
Subject: Re: kern/189170: [PATCH] [vt] Implement KDMKTONE ioctl
Date: Tue, 6 May 2014 17:26:45 -0400

 --047d7b47286ed1737f04f8c1e836
 Content-Type: text/plain; charset=UTF-8
 
 Is there a possible flaw in the committed version?
 
 In the original version, if *data is 0, it would not be used. However, in
 the committed version, *data is first used in
   freq = 1193182 / ((*(int*)data) & 0xffff);
 then checked for 0. If it is 0, the above statement may cause
 divide-by-zero error.
 
 
 -- 
 Cheers,
 Henry
 
 --047d7b47286ed1737f04f8c1e836
 Content-Type: text/html; charset=UTF-8
 Content-Transfer-Encoding: quoted-printable
 
 <div dir=3D"ltr"><div>Is there a possible flaw in the committed version?<br=
 ><br>In the original version, if *data is 0, it would not be used. However,=
  in the committed version, *data is first used in<br>=C2=A0 freq =3D 119318=
 2 / ((*(int*)data) &amp; 0xffff);<br>
 
 </div>then checked for 0. If it is 0, the above statement may cause divide-=
 by-zero error. <br><div><br clear=3D"all"><div><br>-- <br>Cheers,<br>Henry
 </div></div></div>
 
 --047d7b47286ed1737f04f8c1e836--

From: "Matthew D. Fuller" <fullermd@over-yonder.net>
To: Henry Hu <henry.hu.sh@gmail.com>
Cc: bug-followup@freebsd.org, ray@freebsd.org
Subject: Re: kern/189170: [PATCH] [vt] Implement KDMKTONE ioctl
Date: Tue, 6 May 2014 23:12:07 -0500

 > Is there a possible flaw in the committed version?
 
 Technically, probably not more than the original patch.  (x & 0xffff)
 can still be zero even if (x) is nonzero, after all.  It's definitely
 more a POC than a polished silk purse.
 
 I think ideally, it should all be handled in vtterm_bell(), which
 should be adjusted to take pitch/duration like sc_bell() does on the
 syscons side.  But I ran out of time to investigate that well before
 digging up what else might need adjusting for that, so I just
 submitted what I had...
 
 
 -- 
 Matthew Fuller     (MF4839)   |  fullermd@over-yonder.net
 Systems/Network Administrator |  http://www.over-yonder.net/~fullermd/
            On the Internet, nobody can hear you scream.

From: Aleksandr Rybalko <ray@ddteam.net>
To: "Matthew D. Fuller" <fullermd@over-yonder.net>
Cc: Henry Hu <henry.hu.sh@gmail.com>, bug-followup@freebsd.org,
 ray@freebsd.org
Subject: Re: kern/189170: [PATCH] [vt] Implement KDMKTONE ioctl
Date: Wed, 7 May 2014 17:01:18 +0300

 On Tue, 6 May 2014 23:12:07 -0500
 "Matthew D. Fuller" <fullermd@over-yonder.net> wrote:
 
 > > Is there a possible flaw in the committed version?
 > 
 > Technically, probably not more than the original patch.  (x & 0xffff)
 > can still be zero even if (x) is nonzero, after all.  It's definitely
 > more a POC than a polished silk purse.
 > 
 > I think ideally, it should all be handled in vtterm_bell(), which
 > should be adjusted to take pitch/duration like sc_bell() does on the
 > syscons side.  But I ran out of time to investigate that well before
 > digging up what else might need adjusting for that, so I just
 > submitted what I had...
 > 
 > 
 > -- 
 > Matthew Fuller     (MF4839)   |  fullermd@over-yonder.net
 > Systems/Network Administrator |  http://www.over-yonder.net/~fullermd/
 >            On the Internet, nobody can hear you scream.
 
 Hi guys!
 
 It's done in r265546.
 
 Many thanks for your help!
 
 WBW
 -- 
 Aleksandr Rybalko <ray@ddteam.net>
State-Changed-From-To: open->closed 
State-Changed-By: ray 
State-Changed-When: Tue May 13 09:37:30 UTC 2014 
State-Changed-Why:  
fixed. 


http://www.freebsd.org/cgi/query-pr.cgi?pr=189170 
>Unformatted:
