#if (CONFIG_COMMANDS & CFG_CMD_CACHE)
static int on_off (const char *s)
{ //这个函数解析参数,判断是打开cache,还是关闭cache
if (strcmp(s, "on") == 0) { //参数为“on”
return (1);
} else if (strcmp(s, "off") == 0) { //参数为“off”
return (0);
}
return (-1);
}
int do_icache ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
{ //对指令cache的操作函数
switch (argc) {
case 2: /* 参数个数为1,则执行打开或者关闭指令cache操作 */
switch (on_off(argv[1])) {
case 0: icache_disable(); //打开指令cache
break;
case 1: icache_enable (); //关闭指令cache
break;
}
/* FALL TROUGH */
case 1: /* 参数个数为0,则获取指令cache状态*/
printf ("Instruction Cache is %s\n",
icache_status() ? "ON" : "OFF");
return 0;
default: //其他缺省情况下,打印命令使用说明
printf ("Usage:\n%s\n", cmdtp->usage);
return 1;
}
return 0;
}
……
U_Boot_CMD( //通过宏定义命令
icache, 2, 1, do_icache, //命令为icache,命令执行函数为do_icache()
"icache - enable or disable instruction cache\n", //帮助信息
"[on, off]\n"
" - enable or disable instruction cache\n"
);
……
#endif
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请
点击举报。