From: xianghui ren Date: Thu, 6 Dec 2007 17:00:07 +0800 Subject: [U-Boot-Users] this is my understanding of pciauto_region_align function, is it right? Message-ID: List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de void pciauto_region_align(struct pci_region *res, unsigned long size) { res->bus_lower = ((res->bus_lower - 1) | (size - 1)) + 1; } The above function is to do address align with size. Belows is my explanation with example: According to PCI specification, size must be the power of 2, assume Size is 0x100, then size-1 = 0xFF; (res->bus_lower - 1) | (size - 1) = 0x??????FF; ((res->bus_lower - 1) | (size - 1)) + 1=0x??????00; So, the result is aligned with size of 0x100. Now let analyse "res->bus_lower", we must divide it into two aspects: 1. res->bus_lower = 0x??????0? because or operate with 0x??????FF, substracting 1 is not important. 2. res->bus_lower = 0x??????00 Obviously, the address is aligned with size of 0x100, so doing substract 1 is necessary, then the result of ((res->bus_lower - 1) | (size - 1)) + 1 is the same with the original value of res->bus_lower. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.denx.de/pipermail/u-boot/attachments/20071206/cf71f7b8/attachment.htm