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