[comp.sys.apollo] Writing a Device Driver for AEGIS

fu@eecs.nwu.edu (Chih-Hua Fu) (11/12/88)

	I am planning to put Metrabyte's PDMA-16, a high speed 16 bit parallel 
digital interface card with DMA, into the APOLLO Domain 3000 AT-compatible bus.
Then, I will write a device driver to access a memory bank device through the
APOLLO's DMA channel. However, I have some questions:

1. Is APOLLO's AT-compatible bus *REALLY* compatible? Can any interface working
   in the IBM PC-AT be directly inserted into the APOLLO's AT-compatible bus
   without any problems ?

2. In the AEGIS operating system, the GPI/O library supports PBU-$DMA_START
   and  PBU_$DMA_STOP for DMA. However, the buffer must be page aligned. 
   One option is to have the user pass page aligned buffers. This can be done
   relatively easily by the user and avoids the overhead of one copy (since
   the DMA can be done directly to the user supplied buffer). 
   
   However, for ease of use, I would like the ability to have the user supply
   a non page aligned buffer and my driver to handle it by grabbing a page
   aligned buffer from somewhere in the kernel and do the DMA on this buffer.
   Then the kernel buffer can be copied into the user supplied buffer.
   In most BSD UNIX systems you can usually get a page aligned buffer in
   the kernel by getting an mbuf or raiding some other page aligned memory
   buffer pool. How do you do it in AEGIS ? How can my driver get a
   page aligned buffer that can be returned to the kernel pool once the copy
   into user space is done.

3. I do not have the manual about the APOLLO's AT-compatible bus protocol.
   Some documents say "Refer to the Domain 3000 Technical reference (008778)".
   Does that manual describe the bus in detail ?

4. This is my first experience with writing a device driver. If you have any
   hints about writing device drivers for AEGIS or things that I should be 
   watching out for, please drop me a note.


Your help is very much appreciated. Thank you.

Chih-Hua Fu,
Electrical Engineering and Computer Science,
Northwestern University.

Internet: fu@eecs.nwu.edu
Uucp: {att, chinet, oddjob}!nucsrl!fu

krowitz@RICHTER.MIT.EDU (David Krowitz) (11/15/88)

Some notes from my own struggles with DMA on the DN3000 ...

1) the buffer does not necessarily have to be page alligned. The actual
   working requirement is that the interrupt routine (and the actuall DMA
   operation), must not cause a page fault. As long as the DMA does not cross
   a page boundry and the page is wired into physical memory, you are OK.
   You can perform DMA to an arbitrary buffer by simply breaking up the
   operation into chunks which each fit within a single page.

2) Some of the routines which wire pages in memory may be the cause
   of the page allignment requirement. You can allign a buffer by putting
   it in a seperate data section (in Pascal, you would use the extension
   to the VAR statement to specify a new section) and then using the
   -ALIGN PAGE option with the binder. You can also simply allocate a
   buffer which is 1024 bytes larger than what you really need, and
   then calculate where the first page break would be (ie. if PTR points
   to you buffer, then (again in Pascal) the page aligned buffer can be
   found with NEW_PTR := NEW_POINTER_TYPE(((INTEGER32(PTR) DIV 1024)+1)*1024),
   which gives you the first page break after the start of the buffer --
   note that all of the arithmetic is 32-bit integer operations)

3) At least some of the earlier DN3000's have a problem with their DMA
   hardware. Running two DMA devices at the same time will cause them to
   interfere with each other's I/O. This is why the hard disk and the
   cartridge tape drives don't use DMA on the DN3000. The floppy disk does use
   DMA, and I can not write floppies while my printer interface is sending
   data to the printer. Later model DN3000's are supposed to have this fixed.

4) You might be able to use the pub_$wire_buffer_special call to get your
   buffer wired into physical memory with physcially consecutive pages.
   This would allow you to do DMA to the entire buffer without having to
   worry about crossing a page boundry. I haven't tested this yet, though.


 -- David Krowitz

krowitz@richter.mit.edu   (18.83.0.109)
krowitz%richter@eddie.mit.edu
krowitz%richter@athena.mit.edu
krowitz%richter.mit.edu@mitvma.bitnet
(in order of decreasing preference)