I would like to know how this piece of code aligns pointer to 64-bit boundary? I found this code in uboot cpu/mpc85xx/ether_fcc.c. Here the underlying ethernet controller mand开发者_如何转开发ates buffer pointer to be aligned to 64-bit boundary.
uint cbd_bufaddr;
volatile uchar *NetRxPackets[PKTBUFSRX];
cbd_bufaddr = (uint)NetRxPackets[i];
I believe the below check is mandatory to ensure that the pointer is 64-bit aligned, but I don't see it anywhere in uboot code .
if (cbd_bufaddr % 8 != 0)
cbd_bufaddr += 8 - cbd_bufaddr % 8;
I would really appreciate , if someone can point out if I am missing something obvious?
Nothing in that original code guarantees anything about alignment. Your first code block just pulls a pointer out of the NetRxPackets
array and sticks it into cbd_bufaddr
. There's no indication from the code you've provided that the pointers inside that array have any alignment restrictions. You'll need to show us the code that initializes that array for us to tell you more about what's going on.
精彩评论