Enable FIQ interrupt handling on BCM mailboxes. Each CPU core has four of them and...
[AROS.git] / arch / arm-native / kernel / mmu.c
blob183c4c7f7d9d146846b057bc33fe305869e83107
1 /*
2 Copyright � 2013, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #include <inttypes.h>
7 #include <aros/kernel.h>
8 #include <aros/libcall.h>
9 #include <hardware/bcm2708_boot.h>
10 #include <stddef.h>
11 #include <string.h>
13 #include <proto/exec.h>
14 #include <proto/kernel.h>
16 #include "kernel_intern.h"
17 #include "mmu.h"
19 void core_MMUUpdatePageTables(void)
21 static pde_t *pde = BOOTMEMADDR(bm_pde);
23 /* Invalidate caches */
24 asm volatile("mcr p15, 0, %[r], c8, c7, 0" : : [r] "r" (0x0)); //Invalidate entire unified TLB
25 asm volatile("mcr p15, 0, %[r], c8, c6, 0" : : [r] "r" (0x0)); //Invalidate entire data TLB
26 asm volatile("mcr p15, 0, %[r], c8, c5, 0" : : [r] "r" (0x0)); //Invalidate entire instruction TLB
27 asm volatile("mcr p15, 0, %[r], c7, c5, 6" : : [r] "r" (0x0)); //Invalidate entire branch prediction array
28 asm volatile("mcr p15, 0, %[r], c7, c5, 0" : : [r] "r" (0x0)); //Invalidate icache
30 /* setup_ttbr0/1 */
31 asm volatile("mcr p15, 0, %[addr], c2, c0, 1" : : [addr] "r" (pde));
32 /* setup_ttbrc */
33 asm volatile("mcr p15, 0, %[n], c2, c0, 2" : : [n] "r" (7));
36 void core_SetupMMU(struct TagItem *msg)
38 unsigned int page;
39 register unsigned int control;
41 core_MMUUpdatePageTables();
43 /* Set the domain access control to all-supervisor */
44 asm volatile("mcr p15, 0, %[r], c3, c0, 0" : : [r] "r" (~0));
46 /* Enable L1 caches (I-cache and D-cache) and MMU.*/
47 asm volatile("mrc p15, 0, %[control], c1, c0, 0" : [control] "=r" (control));
48 control |= ( ENABLE_I_CACHE | ENABLE_D_CACHE | ENABLE_MMU );
49 asm volatile ("mcr p15, 0, %[r], c7, c10, 4" : : [r] "r" (0)); /* dsb */
50 asm volatile ("mcr p15, 0, %0, c1, c0, 0" : : "r" (control) : "cc" );
51 asm volatile ("mcr p15, 0, %[r], c7, c5, 4" : : [r] "r" (0)); /* isb */
53 D(bug("[Kernel] core_SetupMMU: Done\n"));
56 void core_ProtPage(intptr_t addr, char p, char rw, char us)
58 D(bug("[Kernel] Marking page 0x%p as read-only\n", addr));
60 core_MMUUpdatePageTables();
63 void core_ProtKernelArea(intptr_t addr, intptr_t length, char p, char rw, char us)
65 D(bug("[Kernel] Protecting area 0x%p - 0x%p\n", addr, addr + length - 1));
66 while (length > 0)
68 core_ProtPage(addr, p, rw, us);
69 addr += 4096;
70 length -= 4096;