将物理地址addr修整为页边界地址(页的上边界)
#define PAGE_ALIGN(addr) (((addr)+PAGE_SIZE-1)&PAGE_MASK)
|------------|<-- PAGE_ALGN(addr)
| |
| |
| |
| |<-- addr
| |
| |
| |
| |
|------------|
one page(4K)
#define PAGE_SHIFT 12
#define PAGE_SIZE (1UL << PAGE_SHIFT)
#define PAGE_MASK (~(PAGE_SIZE-1))
PAGE_MASK = ~(1 0000 0000 0000 - 1) = ~(1111 1111 1111) = 0000 0000 0000
PAGE_SIZE = 1 0000 0000 0000 = 2^12 = 4K
如addr为0x22000001 。。PAGE_ALIGN(addr)=(0x22000001+4096-1)&0xfffff000
=(0x22000001+0xfff)&0xfffff000=0x22001000&0xfffff000
=0x22001000;
同样,比如addr为0x22000003,PAGE_ALIGN(addr)后仍然是0x22001000;
就是和下一个页对齐,一个页为4k。起始地址为0x xxxxx 000;
阅读(5945) | 评论(0) | 转发(0) |