🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: comp.unix.internals
1 messages
1 total messages Started by Bruce F. Wong Wed, 20 Jan 1993 22:22
Re: kernel memory allocation with alignment
#2601
Author: Bruce F. Wong
Date: Wed, 20 Jan 1993 22:22
50 lines
2582 bytes
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
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads