2 * U-boot - cmd_cache_dump.c
4 * Copyright (c) 2007-2008 Analog Devices Inc.
6 * Licensed under the GPL-2 or later.
13 #include <asm/blackfin.h>
14 #include <asm/mach-common/bits/mpu.h>
16 static int check_limit(const char *type, size_t start_limit, size_t end_limit, size_t start, size_t end)
18 if (start >= start_limit && start <= end_limit && \
19 end <= end_limit && end >= start_limit && \
23 printf("%s limit violation: %zu <= (user:%zu) <= (user:%zu) <= %zu\n",
24 type, start_limit, start, end, end_limit);
28 int do_icache_dump(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
30 int cache_status = icache_status();
35 uint32_t cmd_base, tag, cache_upper, cache_lower;
37 size_t way, way_start = 0, way_end = 3;
38 size_t sbnk, sbnk_start = 0, sbnk_end = 3;
39 size_t set, set_start = 0, set_end = 31;
43 way_start = way_end = simple_strtoul(argv[1], NULL, 10);
45 sbnk_start = sbnk_end = simple_strtoul(argv[2], NULL, 10);
47 set_start = set_end = simple_strtoul(argv[3], NULL, 10);
51 if (check_limit("way", 0, 3, way_start, way_end) || \
52 check_limit("subbank", 0, 3, sbnk_start, sbnk_end) || \
53 check_limit("set", 0, 31, set_start, set_end))
56 puts("Way:Subbank:Set: [valid-tag lower upper] {invalid-tag lower upper}...\n");
58 for (way = way_start; way <= way_end; ++way) {
59 for (sbnk = sbnk_start; sbnk <= sbnk_end; ++sbnk) {
60 for (set = set_start; set <= set_end; ++set) {
61 printf("%zu:%zu:%2zu: ", way, sbnk, set);
62 for (dw = 0; dw < 4; ++dw) {
72 /* first read the tag */
73 bfin_write_ITEST_COMMAND(cmd_base | 0x0);
75 tag = bfin_read_ITEST_DATA0();
76 printf("%c%08x ", (tag & 0x1 ? ' ' : '{'), tag);
78 /* grab the data at this loc */
79 bfin_write_ITEST_COMMAND(cmd_base | 0x4);
81 cache_lower = bfin_read_ITEST_DATA0();
82 cache_upper = bfin_read_ITEST_DATA1();
83 printf("%08x %08x%c ", cache_lower, cache_upper, (tag & 0x1 ? ' ' : '}'));
96 U_BOOT_CMD(icache_dump, 4, 0, do_icache_dump,
97 "icache_dump - dump current instruction cache\n",
98 "[way] [subbank] [set]");
100 int do_dcache_dump(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
102 u32 way, bank, subbank, set;
104 u32 dmem_ctl = bfin_read_DMEM_CONTROL();
106 for (bank = 0; bank < 2; ++bank) {
107 if (!(dmem_ctl & (1 << (DMC1_P - bank))))
110 for (way = 0; way < 2; ++way)
111 for (subbank = 0; subbank < 4; ++subbank) {
112 printf("%i:%i:%i:\t", bank, way, subbank);
113 for (set = 0; set < 64; ++set) {
118 /* retrieve a cache tag */
119 bfin_write_DTEST_COMMAND(
126 status = bfin_read_DTEST_DATA0();
128 /* construct the address using the tag */
129 addr = (status & 0xFFFFC800) | (subbank << 12) | (set << 5);
132 if (set && !(set % 4))
134 printf("%c%08x%c%08x%c ", (status & 0x1 ? '[' : '{'), status, (status & 0x2 ? 'd' : ' '), addr, (status & 0x1 ? ']' : '}'));
143 U_BOOT_CMD(dcache_dump, 4, 0, do_dcache_dump,
144 "dcache_dump - dump current data cache\n",
145 "[bank] [way] [subbank] [set]");