From 313c480904c0c2442c6c71fc8df4d825d0834b72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20Fr=C3=B6schle?= Date: Thu, 1 Aug 2013 16:01:35 +0000 Subject: [PATCH] started MMU implementation in C --- BaS_gcc/Makefile | 2 +- BaS_gcc/include/mmu.h | 22 ++++++++++++++++++++++ BaS_gcc/sources/mmu.S | 3 +-- BaS_gcc/sources/mmu.c | 26 ++++++++++++++++++++++++++ 4 files changed, 50 insertions(+), 3 deletions(-) create mode 100644 BaS_gcc/include/mmu.h create mode 100644 BaS_gcc/sources/mmu.c diff --git a/BaS_gcc/Makefile b/BaS_gcc/Makefile index 5317878..f631135 100644 --- a/BaS_gcc/Makefile +++ b/BaS_gcc/Makefile @@ -66,6 +66,7 @@ CSRCS= \ $(SRCDIR)/BaS.c \ $(SRCDIR)/cache.c \ $(SRCDIR)/mmc.c \ + $(SRCDIR)/mmu.c \ $(SRCDIR)/unicode.c \ $(SRCDIR)/ff.c \ $(SRCDIR)/sd_card.c \ @@ -79,7 +80,6 @@ CSRCS= \ ASRCS= \ $(SRCDIR)/startcf.S \ $(SRCDIR)/printf_helper.S \ - $(SRCDIR)/mmu.S \ $(SRCDIR)/exceptions.S \ $(SRCDIR)/supervisor.S \ $(SRCDIR)/illegal_instruction.S \ diff --git a/BaS_gcc/include/mmu.h b/BaS_gcc/include/mmu.h new file mode 100644 index 0000000..710b0cb --- /dev/null +++ b/BaS_gcc/include/mmu.h @@ -0,0 +1,22 @@ +/* + * mmu.h + * + * Created on: 01.08.2013 + * Author: froesm1 + */ + +#ifndef _MMU_H_ +#define _MMU_H_ + +#define STD_MMUTR (MCF_MMU_MMUTR_SG | MCF_MMU_MMUTR_V) +#define MMUORD_D (MCF_MMU_MMUOR_ACC | MCF_MMU_MMUOR_UAA) +#define MMUORD_I (MCF_MMU_MMUOR_ITLB | MCF_MMU_MUOR_ACC | MCF_MMU_MMUOR_UAA) + +#define WRITETHROUGH_MMUDR (MCF_MMU_MMUDR_SZ(00) | MCF_MMU_MMUDR_CM(00) | MCF_MMU_MMUDR_R | MCF_MMU_MMUDR_W | MCF_MMU_MMUDR_X) +#define COPYBACK_MMUDR (MCF_MMU_MMUDR_SZ(00) | MCF_MMU_MMUDR_CM(01) | MCF_MMU_MMUDR_R | MCF_MMU_MMUDR_W | MCF_MMU_MMUDR_X) +#define NOCACHE_PRECISE_MMUDR (MCF_MMU_MMUDR_SZ(00) | MCF_MMU_MMUDR_CM(10) | MCF_MMU_MMUDR_R | MCF_MMU_MMUDR_W | MCF_MMU_MMUDR_X) + +extern void mmu_init(void); +extern void mmutr_miss(void) __attribute__((interrupt)); + +#endif /* _MMU_H_ */ diff --git a/BaS_gcc/sources/mmu.S b/BaS_gcc/sources/mmu.S index 312d785..8b0ca55 100644 --- a/BaS_gcc/sources/mmu.S +++ b/BaS_gcc/sources/mmu.S @@ -138,7 +138,7 @@ _mmu_init: move.l d0,_video_tlb // set page as video page clr.l _video_sbt // clear time -#ifdef _NOT_USED_ + //------------------------------------------------------------------------------------- // Make the TOS (in SDRAM) read-only move.l #__TOS+std_mmutr,d0 @@ -147,7 +147,6 @@ _mmu_init: move.l d1,MCF_MMU_MMUDR move.l d2,MCF_MMU_MMUOR // setzen read only ?????? noch nicht move.l d3,MCF_MMU_MMUOR // setzen -#endif /* _NOT_USED_ */ // 00f0'0000 locked move.l #0x00f00000|std_mmutr,d0 diff --git a/BaS_gcc/sources/mmu.c b/BaS_gcc/sources/mmu.c new file mode 100644 index 0000000..f34302c --- /dev/null +++ b/BaS_gcc/sources/mmu.c @@ -0,0 +1,26 @@ +/* + * mmu.c + * + * Created on: 01.08.2013 + * Author: froesm1 + */ + + +#include +#include "mmu.h" + +void mmu_init(void) +{ + /* + * set ASID and shadow register + */ + __asm__ __volatile__("clr.l d0\n\t" + "movec d0,ASID\n\t" + "move.l d0,_rt_asid\n\t"); + +} + + +__attribute__((interrupt)) void mmutr_miss(void) +{ +}