www.pudn.com > mizi_vivi.rar > mmu.c
/* * mmu-pxa250.c * * Copyright (C) 2001 MIZI Research, Inc. * * Author: Yong-iL Joh* Date : $Date: 2002/08/02 05:12:42 $ * * $Revision: 1.8 $ * Note: - mmu_init()¿¡¼ putstr()°ú °°Àº Ãâ·Â¹®À» »ç¿ëÇÏÁö ¸¶¼¼¿ä. Mon May 28 2002 Yong-iL Joh - initial based on mmu-s3c2400.c Mon Jul 22 2002 Janghoon Lyu - »õ·Î ÀÛ¼ºÇÕ´Ï´Ù. * * This file is subject to the terms and conditions of the GNU General Public * License. See the file COPYING in the main directory of this archive * for more details. */ #include "config.h" #include "machine.h" #include "mmu.h" #include "vivi_string.h" static unsigned long *mmu_tlb_base = (unsigned long *)MMU_TABLE_BASE; extern void cpu_xscale_cache_clean_invalidate_all(void); extern void cpu_xscale_tlb_invalidate_all(void); extern void __xscale_setup(void); void cache_clean_invalidate(void) { cpu_xscale_cache_clean_invalidate_all(); } void tlb_invalidate(void) { cpu_xscale_tlb_invalidate_all(); } void mmu_init(void) { __xscale_setup(); } static inline void mem_mapping_linear(void) { unsigned long pageoffset, sectionNumber; #ifdef CONFIG_DEBUG putstr_hex("mmu table base address = 0x", (unsigned long)mmu_tlb_base); #endif /* 4G ¿µ¿ªÀ» 1:1·Î ¸ÅÇÎ. not cacacheable, not bufferable */ for (sectionNumber = 0; sectionNumber < 4096; sectionNumber++) { pageoffset = (sectionNumber << 20); (*(volatile unsigned long *)(mmu_tlb_base + (pageoffset >> 20))) = pageoffset | MMU_SECDESC; } /* make dram cacheable */ for (pageoffset = DRAM_BASE; pageoffset < (DRAM_BASE+DRAM_SIZE); pageoffset += SZ_1M) { (*(volatile unsigned long *)(mmu_tlb_base + (pageoffset >> 20))) = pageoffset | MMU_SECDESC | MMU_CACHEABLE; } } static inline void nor_flash_mapping(void) { unsigned long cached_addr = FLASH_BASE; unsigned long uncached_addr = FLASH_UNCACHED_BASE; /* Make flash cacheable */ for (cached_addr = FLASH_BASE, uncached_addr = FLASH_UNCACHED_BASE; cached_addr < (FLASH_BASE + FLASH_SIZE); cached_addr += SZ_1M, uncached_addr += SZ_1M) { (*(volatile unsigned long *)(mmu_tlb_base + (cached_addr >> 20))) = cached_addr | MMU_SECDESC | MMU_CACHEABLE; (*(volatile unsigned long *)(mmu_tlb_base + (uncached_addr >> 20))) = cached_addr | MMU_SECDESC; } } static void nor_flash_remapping(void) { #ifdef CONFIG_DEBUG putstr_hex("Map Flash virtual section to DRAM at 0x", VIVI_RAM_BASE); #endif /* point first 1MB of flash virtual addresses to its cacheable image in DRAM */ (*(volatile unsigned long *)(mmu_tlb_base + (FLASH_UNCACHED_BASE >> 20))) = VIVI_ROM_BASE | MMU_SECDESC; (*(volatile unsigned long *)(mmu_tlb_base + (VIVI_ROM_BASE >> 20))) = VIVI_RAM_BASE | MMU_SECDESC | MMU_CACHEABLE; } static void copy_vivi_to_ram(void) { #ifdef CONFIG_DEBUG putstr_hex("Evacuating 1MB of Flash to DRAM at 0x", VIVI_RAM_BASE); #endif memcpy((void *)VIVI_RAM_BASE, (void *)VIVI_ROM_BASE, VIVI_RAM_SIZE); } void mem_map_init(void) { copy_vivi_to_ram(); mem_mapping_linear(); nor_flash_mapping(); nor_flash_remapping(); cache_clean_invalidate(); tlb_invalidate(); } /* | $Id: mmu.c,v 1.8 2002/08/02 05:12:42 tolkien Exp $ | | Local Variables: | mode: c | mode: font-lock | version-control: t | delete-old-versions: t | End: | | -*- End-Of-File -*- */