From owner-freebsd-drivers@FreeBSD.ORG Wed Nov 23 16:51: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 A822416A41F for ; Wed, 23 Nov 2005 16:51:43 +0000 (GMT) (envelope-from imp@bsdimp.com) Received: from harmony.bsdimp.com (vc4-2-0-87.dsl.netrack.net [199.45.160.85]) by mx1.FreeBSD.org (Postfix) with ESMTP id 9725F43D82 for ; Wed, 23 Nov 2005 16:51:08 +0000 (GMT) (envelope-from imp@bsdimp.com) Received: from localhost (localhost.village.org [127.0.0.1] (may be forged)) by harmony.bsdimp.com (8.13.3/8.13.3) with ESMTP id jANGoPTx090996; Wed, 23 Nov 2005 09:50:25 -0700 (MST) (envelope-from imp@bsdimp.com) Date: Wed, 23 Nov 2005 09:50:44 -0700 (MST) Message-Id: <20051123.095044.88000142.imp@bsdimp.com> To: mayong@mail.com From: "M. Warner Losh" In-Reply-To: <20051123092444.D826E164293@ws1-4.us4.outblaze.com> References: <20051123092444.D826E164293@ws1-4.us4.outblaze.com> X-Mailer: Mew version 3.3 on Emacs 21.3 / Mule 5.0 (SAKAKI) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-2.0 (harmony.bsdimp.com [127.0.0.1]); Wed, 23 Nov 2005 09:50:25 -0700 (MST) 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: Wed, 23 Nov 2005 16:51:43 -0000 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? Typically this sort of thing is done in FreeBSD in a more ad-hoc way: /* * 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 = 1000; while ((GetStatus() & BusyBit) && limit-- > 0) continue; 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. Warner