From owner-freebsd-drivers@FreeBSD.ORG Thu Nov 24 03:20:43 2005 Return-Path: X-Original-To: freebsd-drivers@freebsd.org Delivered-To: freebsd-drivers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id AA22916A41F for ; Thu, 24 Nov 2005 03:20:43 +0000 (GMT) (envelope-from mayong@mail.com) Received: from webmail-outgoing.us4.outblaze.com (webmail-outgoing.us4.outblaze.com [205.158.62.67]) by mx1.FreeBSD.org (Postfix) with ESMTP id E718343D55 for ; Thu, 24 Nov 2005 03:20:42 +0000 (GMT) (envelope-from mayong@mail.com) Received: from unknown (unknown [192.168.9.180]) by webmail-outgoing.us4.outblaze.com (Postfix) with QMQP id E08E61800283 for ; Thu, 24 Nov 2005 03:20:41 +0000 (GMT) X-OB-Received: from unknown (205.158.62.81) by wfilter.us4.outblaze.com; 24 Nov 2005 03:20:41 -0000 Received: by ws1-2.us4.outblaze.com (Postfix, from userid 1001) id CE1F31F50DE; Thu, 24 Nov 2005 03:20:41 +0000 (GMT) Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="iso-8859-1" MIME-Version: 1.0 From: "Yong Ma" To: "M. Warner Losh" Date: Wed, 23 Nov 2005 22:20:41 -0500 Received: from [159.226.5.225] by ws1-2.us4.outblaze.com with http for mayong@mail.com; Wed, 23 Nov 2005 22:20:41 -0500 X-Originating-Ip: 159.226.5.225 X-Originating-Server: ws1-2.us4.outblaze.com Message-Id: <20051124032041.CE1F31F50DE@ws1-2.us4.outblaze.com> Cc: freebsd-drivers@freebsd.org Subject: Re: timer_list for FreeBSD? X-BeenThere: freebsd-drivers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Writing device drivers for FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Nov 2005 03:20:43 -0000 ----- Original Message ----- From: "M. Warner Losh" To: mayong@mail.com Subject: Re: timer_list for FreeBSD? Date: Wed, 23 Nov 2005 09:50:44 -0700 (MST) >=20 > In message: <20051123092444.D826E164293@ws1-4.us4.outblaze.com> > "Yong Ma" writes: > : In my work I send some data to the card and wait for a result in a > : loop.but sometimes it can't get it ,so the driver run and run and > : can't get out of the loop.I need something like timer_list in Linux > : with which I can decide the max time the loop will run.I searched it > : in the source code but found little about that.Anyone can help? >=20 > Typically this sort of thing is done in FreeBSD in a more ad-hoc way: >=20 > /* > * Wait at most 1ms for the busy bit to flip. Datasheet > * says it will take up to 250us, so add a sane margin of > * error in case they are wrong. Note: GetStatus takes 1us > * to perform the i/o. > */ > limit =3D 1000; > while ((GetStatus() & BusyBit) && limit-- > 0) > continue; >=20 > There's no easy API that will let you limit it to a fixed time. The > above typically is sufficient for 'don't loop forever' so nothing > fancier has been created. >=20 > Warner Thank you! I tryed to make it with sleep(),but failed: =20 ... #include ... sec=3D10; //wait for ten seconds while(GetStatus() && sec-->0){ dosomething(); sleep(1); } ... complied successfully and made the xxx.ko,but when kldload ./xxx.ko it tol= d me can't load,I don't know why! Yong --=20 ___________________________________________________ Play 100s of games for FREE! http://games.mail.com/