Advertisement
Guest User

Untitled

a guest
Jan 19th, 2016
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.93 KB | None | 0 0
  1.   // Populate the pagetable
  2.   int n;
  3.   for(n=0;n<4096;n++)
  4.   {
  5.     if(n==0)
  6.     {
  7.       // SRAM.  Outer and inner write back, write allocate.
  8.       //                                      BASE      TEX       AP        CB      SECTION
  9.       *(volatile uint32_t *)(0x4000 + n*4) = (n<<20) | (1<<12) | (3<<10) | (3<<2) | 2;
  10.     } else if (n>=0x400 && n<0xc00) {
  11.       // DRAM. Outer and inner non-cacheable.
  12.       *(volatile uint32_t *)(0x4000 + n*4) = (n<<20) | (1<<12) | (3<<10) | (0<<2) | 2;
  13.     } else {
  14.       // Other stuff. Non-shared device.
  15.       *(volatile uint32_t *)(0x4000 + n*4) = (n<<20) | (2<<12) | (3<<10) | (0<<2) | 2;
  16.     }
  17.   }
  18.  
  19.   // Set up the pagetable
  20.   asm("ldr r8, =0x4000; mcr p15, 0, r8, c2, c0, 0" : : : "r8");
  21.   asm("mov r8, #0x3; mcr p15, 0, r8, c3, c0, 0" : : : "r8");
  22.  
  23.   // Enable MMU
  24.   asm(
  25.     "mrc p15, 0, r9, c1, c0, 0;"
  26.     "orr r9, r9, #0x1;"
  27.     "mcr p15, 0, r9, c1, c0, 0;"
  28.     : : : "r9");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement