Blame view
common/cmd_cache.c
2.76 KB
3863585bb
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
/* * (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 */ #include <common.h> #include <command.h> |
d0c4c3385
|
29 |
#include <linux/compiler.h> |
3863585bb
|
30 |
|
d0c4c3385
|
31 |
static int parse_argv(const char *); |
23498935f
|
32 |
void __weak invalidate_icache_all(void) |
d0c4c3385
|
33 |
{ |
23498935f
|
34 35 36 |
/* please define arch specific invalidate_icache_all */ puts("No arch specific invalidate_icache_all available! "); |
d0c4c3385
|
37 |
} |
3863585bb
|
38 |
|
54841ab50
|
39 |
int do_icache ( cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
3863585bb
|
40 41 42 |
{ switch (argc) { case 2: /* on / off */ |
d0c4c3385
|
43 |
switch (parse_argv(argv[1])) { |
3863585bb
|
44 45 46 47 |
case 0: icache_disable(); break; case 1: icache_enable (); break; |
23498935f
|
48 |
case 2: invalidate_icache_all(); |
d0c4c3385
|
49 |
break; |
3863585bb
|
50 51 52 53 54 55 56 57 |
} /* FALL TROUGH */ case 1: /* get status */ printf ("Instruction Cache is %s ", icache_status() ? "ON" : "OFF"); return 0; default: |
4c12eeb8b
|
58 |
return CMD_RET_USAGE; |
3863585bb
|
59 60 61 |
} return 0; } |
23498935f
|
62 |
void __weak flush_dcache_all(void) |
d0c4c3385
|
63 |
{ |
23498935f
|
64 65 66 |
puts("No arch specific flush_dcache_all available! "); /* please define arch specific flush_dcache_all */ |
d0c4c3385
|
67 |
} |
54841ab50
|
68 |
int do_dcache ( cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
3863585bb
|
69 70 71 |
{ switch (argc) { case 2: /* on / off */ |
d0c4c3385
|
72 |
switch (parse_argv(argv[1])) { |
3863585bb
|
73 74 75 76 |
case 0: dcache_disable(); break; case 1: dcache_enable (); break; |
23498935f
|
77 |
case 2: flush_dcache_all(); |
d0c4c3385
|
78 |
break; |
3863585bb
|
79 80 81 82 83 84 85 86 |
} /* FALL TROUGH */ case 1: /* get status */ printf ("Data (writethrough) Cache is %s ", dcache_status() ? "ON" : "OFF"); return 0; default: |
4c12eeb8b
|
87 |
return CMD_RET_USAGE; |
3863585bb
|
88 89 90 91 |
} return 0; } |
d0c4c3385
|
92 |
static int parse_argv(const char *s) |
3863585bb
|
93 |
{ |
d0c4c3385
|
94 95 96 |
if (strcmp(s, "flush") == 0) { return (2); } else if (strcmp(s, "on") == 0) { |
3863585bb
|
97 98 99 100 101 102 |
return (1); } else if (strcmp(s, "off") == 0) { return (0); } return (-1); } |
8bde7f776
|
103 |
|
0d4983930
|
104 105 |
U_BOOT_CMD( icache, 2, 1, do_icache, |
2fb2604d5
|
106 |
"enable or disable instruction cache", |
d0c4c3385
|
107 108 109 |
"[on, off, flush] " " - enable, disable, or flush instruction cache" |
8bde7f776
|
110 |
); |
0d4983930
|
111 112 |
U_BOOT_CMD( dcache, 2, 1, do_dcache, |
2fb2604d5
|
113 |
"enable or disable data cache", |
d0c4c3385
|
114 115 116 |
"[on, off, flush] " " - enable, disable, or flush data (writethrough) cache" |
8bde7f776
|
117 |
); |