⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cache.c

📁 tkernel操作系统的源代码,是一位日本教授领导开发的,占有很大市场
💻 C
字号:
/* *---------------------------------------------------------------------- *    T-Kernel * *    Copyright (C) 2004 by Ken Sakamura. All rights reserved. *    T-Kernel is distributed under the T-License. *---------------------------------------------------------------------- * *    Version:   1.01.00 *    Released by T-Engine Forum(http://www.t-engine.org) at 2004/6/28. * *---------------------------------------------------------------------- *//* *	cache.c (SH7727) *	Cache Operation */#include <basic.h>#include <tk/tkernel.h>/* * Size of cache per way */#define	CACHESIZE	0x1000/* * Flush 1 way cache *	Flush 1 page of cache (4 KB) including the address specified  *	by the logical address 'laddr.' * *	Execute cache control using the shadow image in P2 area because *	the program must be in the non-cache area. *	Therefore do not call "_flush_cache_" directly. *	Call by the address stored in '_FlushCacheP2_.' */LOCAL void _flush_cache_( VP laddr ){	register UW	ent	asm("r1");	register UW	tag	asm("r2");	tag = (UW)laddr & 0x1ffff000;	for ( ent = 0x000; ent < 0x1000; ent += 0x010 ) {		*(_UW*)(0xf0000008 | ent) = (tag | ent) & 0xfffffc00;	}}LOCAL FP _FlushCacheP2_ = (FP)((UW)&_flush_cache_ + 0x20000000);#define	FlushCacheP2(laddr)	(*_FlushCacheP2_)(laddr)/* * Cache flush *	Flush cache between 'laddr' and 'len' bytes areas. *	Writeback and disable cache */EXPORT void FlushCache( VP laddr, INT len ){	B	*top, *end;	UINT	imask;	top = (B*)((UW)laddr & ~(CACHESIZE-1));	end = (B*)laddr + len;	while ( top < end ) {		DI(imask);		FlushCacheP2(top);		EI(imask);		top += CACHESIZE;	}}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -