home *** CD-ROM | disk | FTP | other *** search
- Xref: sparky comp.unix.internals:2149 comp.unix.sys5.r4:1355
- Newsgroups: comp.unix.internals,comp.unix.sys5.r4
- Path: sparky!uunet!dsiinc!bwong
- From: bwong@dsiinc.com (Bruce F. Wong)
- Subject: Re: kernel memory allocation with alignment
- Message-ID: <1993Jan20.222252.43@dsiinc.com>
- Organization: Distributed Systems International, Inc.
- Date: Wed, 20 Jan 1993 22:22:52 GMT
- Lines: 50
-
- Greetings,
-
- A few weeks ago I posted the following:
-
- >I'm writing a streams device driver for 386 UNIX SVR4 and I need 512
- >bytes of DMAable memory that is aligned to a 512 byte boundary (i.e.
- >the starting address is a multiple of 512). How is this done ? None
- >of the kernel memory allocators take an alignment argument. Please
- >send all responses via e-mail and I will post a summary if I get
- >enough useful information. Thanks.
-
- This article contains the summary of replys and also what I plan to
- do.
-
- Most of the suggestions were like the following:
-
- >From: uunet!westford.ccur.com!zimmermk (Karl Zimmerman)
- > allocate 1024 bytes. Somewhere in there are 512 bytes aligned to
- >a 512-byte boundary. To find it, take the returned pointer, add 511, and
- >mask off the least-significant 9 bits.
-
- The suggestion that sent me in the direction of the solution I plan to
- use is:
-
- >From: uunet!gcx1.ssd.csd.harris.com!donh (Don Holzworth)
- >If you are going to get data from a device, you are probably going
- >to want to use allocb. If allocb doesn't give you the proberly aligned
- >memory, specify 512 bytes more than you need and set the message block
- >pointer to the aligned address. I think that you actually do get
- >the data aligned on a 1K boundary, though. You could run a few
- >tests to see.
-
- I ran some tests on ESIX 4.0.3 and confirmed that allocb will return
- space that is aligned according to its size (I tried 256, 512, 1K, 2K,
- and 4K). The allocb(D3DK) manual entry doesn't mention this. It also
- doesn't mention if the buffer is DMAable (i.e. my bus master network
- controller card can access the buffer if I pass it the physical
- address of the buffer). I'm assuming that they are DMAable based on
- the last paragraph in Intro(D2DK):
-
- "Drivers do no have to worry about making kernel buffers
- addressable to their DMA controllers. The kernel will make sure
- that any kernel buffer addresses passed to a driver entry point
- will be addressable by the driver's hardware."
-
- Thank you for the suggestions.
- --
- Bruce F. Wong Distributed Systems International, Inc.
- bwong@dsiinc.com 531 West Roosevelt Road, Suite 2
- Tel:708-665-4639 Fax:708-665-4706 Wheaton, IL 60187-5057
-