在看完MMU例程之后,我在原来程序的基础上把一级页表改成了两级页表,用一个粗页和一个小页将0x30000000~0x33FFFFFF映射到了0xB0000000~0xB3FFFFFF,但是程序无法编译,提示memset函数没有定义,这是怎么回事?
我只修改了create_page_table这一个函数。修改的程序如下:
- void create_page_table(void)
- {
- /*
- * 用于段描述符的一些宏定义
- */
- #define MMU_FULL_ACCESS (3 << 10) /* 访问权限 */
- #define MMU_DOMAIN (0 << 5) /* 属于哪个域 */
- #define MMU_SPECIAL (1 << 4) /* 必须是1 */
- #define MMU_CACHEABLE (1 << 3) /* cacheable */
- #define MMU_BUFFERABLE (1 << 2) /* bufferable */
- #define MMU_SECtiON (2) /* 表示这是段描述符 */
- #define MMU_SECDESC (MMU_FULL_ACCESS | MMU_DOMAIN | MMU_SPECIAL |
- MMU_SECTION)
- #define MMU_SECDESC_WB (MMU_FULL_ACCESS | MMU_DOMAIN | MMU_SPECIAL |
- MMU_CACHEABLE | MMU_BUFFERABLE | MMU_SECTION)
- #define MMU_SECTION_SIZE 0x00100000
- unsigned long virtuladdr, physicaladdr;
- unsigned long *mmu_tlb_base = (unsigned long *)0x30000000;
- unsigned long *mmu_tlb_1s_base[64] = {0};
- unsigned int i;
- unsigned int j;
- /*
- * Steppingstone的起始物理地址为0,第一部分程序的起始运行地址也是0,
- * 为了在开启MMU后仍能运行第一部分的程序,
- * 将0~1M的虚拟地址映射到同样的物理地址
- */
- virtuladdr = 0;
- physicaladdr = 0;
- *(mmu_tlb_base + (virtuladdr >> 20)) = (physicaladdr & 0xFFF00000) |
- MMU_SECDESC_WB;
- /*
- * 0x56000000是GPIO寄存器的起始物理地址,
- * GPFCON和GPFDAT这两个寄存器的物理地址0x56000050、0x56000054,
- * 为了在第二部分程序中能以地址0xA0000050、0xA0000054来操作GPFCON、GPFDAT,
- * 把从0xA0000000开始的1M虚拟地址空间映射到从0x56000000开始的1M物理地址空间
- */
- virtuladdr = 0xA0000000;
- physicaladdr = 0x56000000;
- *(mmu_tlb_base + (virtuladdr >> 20)) = (physicaladdr & 0xFFF00000) |
- MMU_SECDESC;
- /*
- * SDRAM的物理地址范围是0x30000000~0x33FFFFFF,
- * 将虚拟地址0xB0000000~0xB3FFFFFF映射到物理地址0x30000000~0x33FFFFFF上,
- * 总共64M,涉及64个段描述符
- */
- /* 修改了这段程序 */
- virtuladdr = 0xB0000000;
- physicaladdr = 0x30000000;
- for (i=0; i<64; i++)
- {
- mmu_tlb_1s_base = (unsigned long *)(0x30004C00 + i * 0x100);
- }
- for (i=0; i<64; i++)
- {
- *(mmu_tlb_base + (virtuladdr >> 20)) = ((unsigned long)mmu_tlb_1s_base & 0xFFFFFC00) | (0 << 5) | (1 << 4) | 1;
- for (j=0; j<256; j++)
- {
- *(mmu_tlb_1s_base + ((virtuladdr & 0x000FF000) >> 12)) = (physicaladdr & 0xFFFFF000) | (0xFF << 4) | 2;
- virtuladdr += 0x1000;
- physicaladdr += 0x1000;
- }
- }
- }
复制代码