EXTRA_CFLAGS += -DCONFIG_KEXEC -Wall
 
 obj-m += kexec_load.o
-kexec_load-objs := kexec.o machine_kexec.o idmap.o sys.o core.o relocate_kernel.o \
+kexec_load-objs := kexec.o machine_kexec.o mmu.o sys.o core.o relocate_kernel.o \
        proc-v7.o tlb-v7.o cache-v7.o abort-ev7.o pabort-v7.o copypage-v6.o driver_sys.o
 
 all:
 
 #include <linux/kernel.h>
 
+#include "tlbflush.h"
 #include <asm/cputype.h>
 #include <asm/pgalloc.h>
 #include <asm/pgtable.h>
         * "borrowed".
         */
        identity_mapping_add(current->active_mm->pgd, 0, TASK_SIZE);
-       local_flush_tlb_all();
+       my_local_flush_tlb_all();
 }
 
 
 extern void setup_mm_for_reboot(char mode);
 
+extern void v7_flush_kern_cache_all(void);
+
 extern unsigned long kexec_start_address;
 extern unsigned long kexec_indirection_page;
 extern unsigned long kexec_mach_type;
        printk(KERN_DEBUG "CPU %u will stop doing anything useful since another CPU has crashed\n",
               smp_processor_id());
        crash_save_cpu(®s, smp_processor_id());
-       flush_cache_all();
+       v7_flush_kern_cache_all();
 
        atomic_dec(&waiting_for_crash_ipi);
        while (1)
        unsigned long reboot_code_buffer_phys;
        void *reboot_code_buffer;
 
-
        page_list = image->head & PAGE_MASK;
 
        /* we need both effective and real address here */
        local_irq_disable();
        local_fiq_disable();
        setup_mm_for_reboot(0); /* mode is not used, so just pass 0*/
-       flush_cache_all();
+       v7_flush_kern_cache_all();
 #ifdef CONFIG_OUTER_CACHE
        outer_flush_all();
        outer_disable();
 #ifdef CONFIG_OUTER_CACHE
        outer_inv_all();
 #endif
-       flush_cache_all();
+       //v7_flush_kern_cache_all();
        cpu_reset(reboot_code_buffer_phys);
 }
 
 #include <linux/nodemask.h>
 #include <linux/ioport.h>
 
+#include "tlbflush.h"
 #include <asm/cputype.h>
 #include <asm/mach-types.h>
 #include <asm/sections.h>
        pgd_t *pgd;
        int i;
 
-       if (current->mm && current->mm->pgd)
-               pgd = current->mm->pgd;
-#if 0
-       else
-               pgd = init_mm.pgd;
-#else
-       else
-       {
-               struct mm_struct *initmm = (struct mm_struct *)0xc05672a0;
-               pgd = initmm->pgd;
-       }
-#warning FIXME init_mm is no longer exported
-#endif
+       pgd = current->mm->pgd;
 
        base_pmdval = PMD_SECT_AP_WRITE | PMD_SECT_AP_READ | PMD_TYPE_SECT;
 
                pmd[1] = __pmd(pmdval + (1 << (PGDIR_SHIFT - 1)));
                flush_pmd_entry(pmd);
        }
+       my_local_flush_tlb_all();
 }
 
 ENDPROC(cpu_v7_proc_init)
 
 ENTRY(cpu_v7_proc_fin)
+       stmfd   sp!, {lr}
+       bl      v7_flush_kern_cache_all
        mrc     p15, 0, r0, c1, c0, 0           @ ctrl register
        bic     r0, r0, #0x1000                 @ ...i............
        bic     r0, r0, #0x0006                 @ .............ca.
        mcr     p15, 0, r0, c1, c0, 0           @ disable caches
+       mcr     p15, 0, ip, c8, c7, 0           @ invalidate I & D TLBs
+       ldmfd   sp!, {pc}
        mov     pc, lr
 ENDPROC(cpu_v7_proc_fin)
 
 
 
        .globl relocate_new_kernel
 relocate_new_kernel:
+       /* Disable MMU */
+       mov     ip, #0
+#ifdef CONFIG_MMU
+       mcr     p15, 0, ip, c8, c7, 0           @ invalidate I & D TLBs
+#endif
+       mrc     p15, 0, ip, c1, c0, 0           @ ctrl register
+       bic     ip, ip, #0x000f                 @ ............wcam
+       bic     ip, ip, #0x1100                 @ ...i...s........
+       mcr     p15, 0, ip, c1, c0, 0           @ ctrl register
 
        ldr     r0,kexec_indirection_page
        ldr     r1,kexec_start_address
 
 
        blocking_notifier_call_chain(¬ifier_head, SYS_RESTART, cmd);
        system_state = SYSTEM_RESTART;
-//     device_shutdown();
-//     sysdev_shutdown();
+       //device_shutdown();
+       //sysdev_shutdown();
 }
 
 /*
 
 
 #define tlb_flag(f)    ((always_tlb_flags & (f)) || (__tlb_flag & possible_tlb_flags & (f)))
 
-static inline void local_flush_tlb_all(void)
+static inline void my_local_flush_tlb_all(void)
 {
        const int zero = 0;
        const unsigned int __tlb_flag = __cpu_tlb_flags;