开发者

in what condition phys_base is not 0?

开发者 https://www.devze.com 2023-04-12 16:10 出处:网络
phy开发者_C百科s_base is referenced in kernnel source code __phys_addr() arch/x86/mm/physaddr.c and crash also use it as a machine dependent parameter e.g. --machdep phys_base=0x200000

phy开发者_C百科s_base is referenced in kernnel source code __phys_addr() arch/x86/mm/physaddr.c and crash also use it as a machine dependent parameter e.g. --machdep phys_base=0x200000

unsigned long __phys_addr(unsigned long x)
{
    if (x >= __START_KERNEL_map) {
        x -= __START_KERNEL_map;
        VIRTUAL_BUG_ON(x >= KERNEL_IMAGE_SIZE);
        x += phys_base;
    } else {
        VIRTUAL_BUG_ON(x < PAGE_OFFSET);
        x -= PAGE_OFFSET;
        VIRTUAL_BUG_ON(!phys_addr_valid(x));
    }
    return x;
}
EXPORT_SYMBOL(__phys_addr);

can you help to explain in what condition it is not 0, how it is defined/determined and why.

UPDATE: the debut of "phys_base" can be found here


It is not necessarily 0, because on some CPU architecture, the physical address is used to access things that are not memory. The way for the cpu to know what kind of interface or bus to use is by divivding the memory map.

I don't know the x86 architecture, but on ARM for example, you can have things like this :

  • from 0x00000000 to 0x0fffffff, external flash is accessed.
  • from 0x10000000 to 0x1000ffff, internal memory mapped register are accessed
  • from 0x80000000 to 0x9fffffff, sdram or ddr is accessed.

In this case, phys_base would be 0x80000000. So it is determined by the cpu or the chipset on x86. See this for an example memory map.

0

精彩评论

暂无评论...
验证码 换一张
取 消