Subject: How do I allocate physically contiguous RAM?
To: None <port-mac68k@NetBSD.ORG, tech-kern@NetBSD.ORG, scottr@og.org>
From: Dave Huang <khym@bga.com>
List: tech-kern
Date: 10/29/1997 12:37:28
[ This is on the mac68k port, BTW... ]

I'm trying to write an ethernet driver, and would like to get a 32K
chunk or so of page-aligned, physically contiguous memory (for DMA
porpoises). Is there an easy way to do this? I took a look at the
bus_dma stuff, but it looks like it's unimplemented on mac68k. I doubt
if I have the skills to implement the bus_dma interface, so I'm
looking for another way :)

I'm currently using malloc() to allocate the DMA buffers and
physaccess() to mark the memory as non-cacheable, which seems to work,
but after a bit of network activity, I did get a suspicious page fault
that looked like the ethernet receive DMA blasting some memory that
belonged to something else. If I allocate a chunk of 8*NBPG bytes with
malloc(), are they guaranteed to be contiguous?

Also, where should I look for info on writing a network device driver?
In particular, I'm looking for info on these "mbuf chain" things, and
what the IFF_OACTIVE bit is supposed to mean, exactly. Any other
useful info would help though :)

Thanks!

Name: Dave Huang     |   Mammal, mammal / their names are called /
INet: khym@bga.com   |   they raise a paw / the bat, the cat /
FurryMUCK: Dahan     |   dolphin and dog / koala bear and hog -- TMBG
Dahan: Hani G Y+C 21 Y++ L+++ W- C++ T++ A+ E+ S++ V++ F- Q+++ P+ B+ PA+ PL++