[comp.unix.aix] Hard delays in device drivers

kjl@epps.kodak.com (Ken Lebowitz) (05/15/91)

O.K. - I'm doing my first device driver for the RS/6000.  I'm trying
to find out how to insert a time delay for a few microseconds into my
device initialization routine.  On SunOS (*shudder*) there's a
"DELAY()" macro which does this.  Does anybody out there know how to
accomplish the same thing for AIX?

Thanks,

--
Ken Lebowitz
Atex, Inc., Billerica, MA
A Kodak Company

massa@aurora.cis.upenn.edu (Mike Massa) (05/16/91)

In article <5393@atexnet.Atex.Kodak.COM> kjl@atex.kodak.com writes:
>O.K. - I'm doing my first device driver for the RS/6000.  I'm trying
>to find out how to insert a time delay for a few microseconds into my
>device initialization routine.  On SunOS (*shudder*) there's a
>"DELAY()" macro which does this.  Does anybody out there know how to
>accomplish the same thing for AIX?
>

The delay() kernel service will suspend a process for some number of timer
ticks (resolution = 0.01 sec). If you need finer resolution, you could
start a timer with tstart(), put the process to sleep with e_sleep(), 
and have the timeout handler function call e_wakeup() to restart your process 
and then exit. You specify the timeout time in nanoseconds with tstart(), 
although I don't know what the resolution is. Quite frankly, the latter is an 
awful lot of work if you can afford to wait a hundreth of a second. If you do 
use tstart() look closely at the timerbuf structure, the argument to the 
timeout handler is a *timerbuf_t, not the argument you specify in the 
timerbuf.

-- 
Mike Massa                            
University of Pennsylvania                         
Distributed Systems Laboratory

marc@mercutio.ultra.com (Marc Kwiatkowski {Host Software-AIX}) (05/16/91)

In article <5393@atexnet.Atex.Kodak.COM> kjl@epps.kodak.com (Ken Lebowitz) writes:
>   O.K. - I'm doing my first device driver for the RS/6000.  I'm trying
>   to find out how to insert a time delay for a few microseconds into my
>   device initialization routine.  On SunOS (*shudder*) there's a
>   "DELAY()" macro which does this.  Does anybody out there know how to
>   accomplish the same thing for AIX?

From TFM
	
	void delay (ticks)
	int ticks;

	Parameter
	ticks     specifies the number of timer ticks that must occur before
	          process is reactivated.  Many timer ticks can occur
		  per second.

	blah blah blah.

I don't mean to be snide, but if you can't find this documentation,
heaven help you when you get to physio, dma, shared-memory, devsw,
kernel locks, etc.  I'd acquaint myself with InfoExplorer. Read
the following titles, "Calls and Subroutines Reference: Kernel
Extensions", "Kernel Extensions and Device Support Programming
Concepts".  The inaugural issue of AIXpert also has a good
article on device drivers by Sam Drake.  Also, "The IBM
RISC System/6000 POWERstation and POWERserver Hardware Technical
Reference - General Information Manual" - sorry no order number -
is essential for IOCC architecture, POS/VPD configuration, etc.
Finally, there are a number of samples, of limited usefulness,
in /usr/lpp/bos/samples.

Hope this helps.


--
	------------------------------------------------------------------
	Marc P. Kwiatkowski			Ultra Network Technologies
	Internet: marc@ultra.com		101 Daggett Drive
	uucp: ...!ames!ultra!marc		San Jose, CA 95134 USA
	telephone: 408 922 0100 x249

	Ignore the following signature.
-- 
	------------------------------------------------------------------
	Marc P. Kwiatkowski			Ultra Network Technologies
	Internet: marc@ultra.com		101 Daggett Drive
	uucp: ...!ames!ultra!marc		San Jose, CA 95134 USA