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

📄 cmd_cache.c

📁 source code of armboot for s3c4510
💻 C
字号:
/* * (C) Copyright 2000 * Wolfgang Denk, DENX Software Engineering, wd@denx.de. * * See file CREDITS for list of people who contributed to this * project. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of * the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, * MA 02111-1307 USA *//* * Cache support: switch on or off, get status  choish 20020829 */#include <armboot.h>#include <command.h>#if defined(CONFIG_S3C2500) || defined(CONFIG_S3C2510)#define DCACHE_ON (1<<2)     // dcaceh enable choish 20020827#define ICACHE_ON (1<<12)     // icache enable  choish 20020827//#if (CONFIG_COMMANDS & CFG_CMD_CACHE)static int on_off (const char*);// CP15 r1 Resister read function   choish 20020827static unsigned long read_cp15r1(void) {    unsigned long value;    __asm__ __volatile__(	"mrc     p15, 0, %0, c1, c0, 0   @ read control reg\n"	: "=r" (value)	:	: "memory");    printf("cp15 register : %08lx\n", value);    return value;}void Cache_init(bd_t * bd){  const char *is;   const char *ds;  is = bd->bi_icache; 	 switch (on_off(is)) {				case 0:						 _ICache_Flush();					 _ICache_Disable();										 					break;				case 1:	            					 _ICache_Enable();					 _ICache_Flush();				     				     					break;			}#ifdef VIADBG 	 	printf ("Instruction Cache is %s\n", icache_status() ? "ON" : "OFF");#endif 	 		ds = bd->bi_dcache;		switch (on_off(ds)) {				case 0:					_DCache_Flush();			 		_DCache_Disable();			 		break;				case 1:			 		_DCache_Enable();			 		_DCache_Flush();			 		break;			}#ifdef VIADBG		printf ("Data (writethrough) Cache is %s\n",dcache_status() ? "ON" : "OFF");#endif}int icache_status(void){  	return (read_cp15r1() & ICACHE_ON) != 0;}int dcache_status(void){  	return (read_cp15r1() & DCACHE_ON) != 0;}#endifstatic int on_off (const char *s){	if (strcmp(s, "on") == 0) {		return (1);	} else if (strcmp(s, "off") == 0) {		return (0);	}	return (-1);}

⌨️ 快捷键说明

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