在平台標頭檔通常有
#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_SINGLEulong virt_to_phy_smdkc110(ulong addr){if ((0xc0000000 <= addr) && (addr < 0xd0000000))return (addr - 0xc0000000 + 0x20000000);elseprintf("The input address don't need "\"a virtual-to-physical translation : %08lx\n", addr);return addr;}#elseulong virt_to_phy_smdkc110(ulong addr){if ((0xc0000000 <= addr) && (addr < 0xd0000000))return (addr - 0xc0000000 + 0x30000000);else if ((0x30000000 <= addr) && (addr < 0x50000000))return addr;elseprintf("The input address don't need "\"a virtual-to-physical translation : %08lx\n", addr);return addr;}#endif#endif