在平台头文件通常有
#ifdef CONFIG_ENABLE_MMU
#define virt_to_phys(x) virt_to_phy_smdkc110(x)
#else
#define virt_to_phys(x) (x)
#endif
这里居然是虚拟地址转换成物理地址,没有物理地址转换成虚拟地址的东西?
在do_movi 函数里面有
if (addr >= 0xc0000000)
addr = virt_to_phys(addr);
在do_bootm函数也有
addr = virt_to_phys(addr);
从
这个定义
#ifdef CONFIG_ENABLE_MMU
#define virt_to_phys(x) virt_to_phy_smdkc110(x)
#else
#define virt_to_phys(x) (x)
#endif
可以解释,即使我在关掉MMU的情况下,不改默认的启动环境变量,照样也能正常启动内核,因为在上面的两个关键函数里面都转换成最终的物理地址了!
#define CONFIG_BOOTCOMMAND "movi read kernel C0008000; movi read rootfs 30A00000 180000; bootm C0008000 30A00000"
看看 virt_to_phy_smdkc110(x)
这个怎么来的吧。
#ifdef CONFIG_ENABLE_MMU #ifdef CONFIG_MCP_SINGLE ulong virt_to_phy_smdkc110(ulong addr) { if ((0xc0000000 <= addr) && (addr < 0xd0000000)) return (addr - 0xc0000000 + 0x20000000); else printf("The input address don't need "\ "a virtual-to-physical translation : %08lx\n", addr); return addr; } #else ulong virt_to_phy_smdkc110(ulong addr) { if ((0xc0000000 <= addr) && (addr < 0xd0000000)) return (addr - 0xc0000000 + 0x30000000); else if ((0x30000000 <= addr) && (addr < 0x50000000)) return addr; else printf("The input address don't need "\ "a virtual-to-physical translation : %08lx\n", addr); return addr; } #endif #endif