|
hello, maybe it's a little bit too late but better now then never. Here is my code to initialize the mmu of the at91sam9xe to be able to use the d-cache. It's mainly based on the atmel example "basic-dhrystone-project" but extended by also chaching the SDRAM:
//------------------------------------------------------------------------------ /// MMU Initialization /// \param pTranslationTable Translation table adresse //------------------------------------------------------------------------------ static void InitMMU(unsigned int *pTranslationTable) { int i; int addSRAM; int addSDRAM;
// Program the TTB TRACE_DEBUG("TTB = 0x%X\n\r", (unsigned int)pTranslationTable);
CP15_WriteTTB((unsigned int)pTranslationTable);
// Program the domain access register CP15_WriteDomainAccessControl(0xC0000000); // domain 15: access are not checked
// Reset table entries for (i = 0; i < 4096; i++) { pTranslationTable[i] = 0; } // Program level 1 page table entry // Vector adress pTranslationTable[0x0] = (0x00000000)| // Physical Address ( 1 << 10)| // Access in supervisor mode (15 << 5)| // Domain ( 1 << 4)| ( 0 << 3)| // No D cache 0x2; // Set as 1 Mbyte section // SRAM adress (with D cache) addSRAM = (SRAM_ADDRESS >> 20); TRACE_DEBUG("addSRAM = 0x%X\n\r", addSRAM); TRACE_DEBUG("SRAM_ADDRESS = 0x%X\n\r", SRAM_ADDRESS); ASSERT( addSRAM < 0xFFF, "PRobleme SRAM"); pTranslationTable[addSRAM] = (SRAM_ADDRESS)| // Physical Address ( 1 << 10)| // Access in supervisor mode (15 << 5)| // Domain ( 1 << 4)| ( 1 << 3)| // D cache 0x2; // Set as 1 Mbyte section
for (i = 0; i <= 0x1F; i++) { // SDRAM adress (with D cache) addSDRAM = (AT91C_EBI_SDRAM + (i * 0x00100000) >> 20); pTranslationTable[addSDRAM] = (AT91C_EBI_SDRAM + (i * 0x00100000))| // Physical Address ( 1 << 10)| // Access in supervisor mode (15 << 5)| // Domain ( 1 << 4)| ( 1 << 3)| // D cache 0x2; // Set as 1 Mbyte section }
// Peripherals adress pTranslationTable[0xFFF] = (0xFFF00000)| // Physical Address ( 1 << 10)| // Access in supervisor mode (15 << 5)| // Domain ( 1 << 4)| ( 0 << 3)| // No D cache 0x2; // Set as 1 Mbyte section }
regards gerhard
|