Thanks for your replay. I use gdb to find out that the buffer address is
not 16-byte aligned. This leads to a question as to how to align a
statically allocated data structure properly. Using union seems to be able
to align you on a long boundary (or even long long?), but that is not 16
byte aligned.

union {
        my_data_structure_t xyz;
        long pad;
}

The natural alignment seems to work only on primitive data types. If you
define:

unsigned char sector_buf[512];

It will not always be aligned on a 512 byte boundary, even 16-byte
alignment is not guaranteed.  Is there a way to achieve this?


-Zhihui


On Fri, 24 Aug 2001, Julian Elischer wrote:

> Zhihui Zhang wrote:
> > 
> > I write a program that writes into a raw device directly. Although the
> > program runs OK, the system prints messages like:
> > 
> > ata0-master: non aligned DMA transfer attempted
> make sure your DMA buffer is alligned on a 64 byte boundary...
> (a page would be best)
> and that you are transferring an exact bultiple of 512 bytes.
> 
> The DMA hardware on some macines cannot handle a buffer on less than 16 byte
> allignment, (some on odd allignment,.. (it's a bit hardware dependent).
> 
> so be safe and allign your buffers.
> 
> 
> when it detects it cannot do it, i used PIO instead, so your data is still
> transferred...
> 
> > 
> > What exactly happens here? Is there any problem in my program?
> > 
> > Thanks.
> > 
> > -Zhihui
> > 
> > To Unsubscribe: send mail to [EMAIL PROTECTED]
> > with "unsubscribe freebsd-hackers" in the body of the message
> 
> -- 
> +------------------------------------+       ______ _  __
> |   __--_|\  Julian Elischer         |       \     U \/ / hard at work in 
> |  /       \ [EMAIL PROTECTED]     +------>x   USA    \ a very strange
> | (   OZ    )                                \___   ___ | country !
> +- X_.---._/    presently in San Francisco       \_/   \\
>           v
> 



To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message

Reply via email to