2022-06-26 18:24:07 -05:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0-or-later */
|
|
|
|
|
2006-06-02 05:36:31 -05:00
|
|
|
/***************************************************************************
|
|
|
|
* Copyright (C) 2005 by Dominic Rath *
|
|
|
|
* Dominic.Rath@gmx.de *
|
|
|
|
***************************************************************************/
|
2012-02-05 06:03:04 -06:00
|
|
|
|
2006-07-17 09:13:27 -05:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
|
|
|
|
2006-06-02 05:36:31 -05:00
|
|
|
#include "armv4_5_cache.h"
|
2009-12-03 06:14:28 -06:00
|
|
|
#include <helper/log.h>
|
2006-06-02 05:36:31 -05:00
|
|
|
|
2009-11-13 10:41:22 -06:00
|
|
|
int armv4_5_identify_cache(uint32_t cache_type_reg, struct armv4_5_cache_common *cache)
|
2006-06-02 05:36:31 -05:00
|
|
|
{
|
|
|
|
int size, assoc, M, len, multiplier;
|
|
|
|
|
|
|
|
cache->ctype = (cache_type_reg & 0x1e000000U) >> 25;
|
|
|
|
cache->separate = (cache_type_reg & 0x01000000U) >> 24;
|
|
|
|
|
|
|
|
size = (cache_type_reg & 0x1c0000) >> 18;
|
|
|
|
assoc = (cache_type_reg & 0x38000) >> 15;
|
|
|
|
M = (cache_type_reg & 0x4000) >> 14;
|
|
|
|
len = (cache_type_reg & 0x3000) >> 12;
|
|
|
|
multiplier = 2 + M;
|
|
|
|
|
2012-02-05 06:03:04 -06:00
|
|
|
if ((assoc != 0) || (M != 1)) /* assoc 0 and M 1 means cache absent */ {
|
2006-06-02 05:36:31 -05:00
|
|
|
/* cache is present */
|
|
|
|
cache->d_u_size.linelen = 1 << (len + 3);
|
|
|
|
cache->d_u_size.associativity = multiplier << (assoc - 1);
|
|
|
|
cache->d_u_size.nsets = 1 << (size + 6 - assoc - len);
|
|
|
|
cache->d_u_size.cachesize = multiplier << (size + 8);
|
2012-02-05 06:03:04 -06:00
|
|
|
} else {
|
2006-06-02 05:36:31 -05:00
|
|
|
/* cache is absent */
|
|
|
|
cache->d_u_size.linelen = -1;
|
|
|
|
cache->d_u_size.associativity = -1;
|
|
|
|
cache->d_u_size.nsets = -1;
|
|
|
|
cache->d_u_size.cachesize = -1;
|
|
|
|
}
|
|
|
|
|
2012-02-05 06:03:04 -06:00
|
|
|
if (cache->separate) {
|
2006-06-02 05:36:31 -05:00
|
|
|
size = (cache_type_reg & 0x1c0) >> 6;
|
|
|
|
assoc = (cache_type_reg & 0x38) >> 3;
|
|
|
|
M = (cache_type_reg & 0x4) >> 2;
|
|
|
|
len = (cache_type_reg & 0x3);
|
|
|
|
multiplier = 2 + M;
|
2009-05-10 14:02:07 -05:00
|
|
|
|
2012-02-05 06:03:04 -06:00
|
|
|
if ((assoc != 0) || (M != 1)) /* assoc 0 and M 1 means cache absent */ {
|
2006-06-02 05:36:31 -05:00
|
|
|
/* cache is present */
|
|
|
|
cache->i_size.linelen = 1 << (len + 3);
|
|
|
|
cache->i_size.associativity = multiplier << (assoc - 1);
|
|
|
|
cache->i_size.nsets = 1 << (size + 6 - assoc - len);
|
|
|
|
cache->i_size.cachesize = multiplier << (size + 8);
|
2012-02-05 06:03:04 -06:00
|
|
|
} else {
|
2006-06-02 05:36:31 -05:00
|
|
|
/* cache is absent */
|
|
|
|
cache->i_size.linelen = -1;
|
|
|
|
cache->i_size.associativity = -1;
|
|
|
|
cache->i_size.nsets = -1;
|
|
|
|
cache->i_size.cachesize = -1;
|
|
|
|
}
|
2012-02-05 06:03:04 -06:00
|
|
|
} else
|
2006-06-02 05:36:31 -05:00
|
|
|
cache->i_size = cache->d_u_size;
|
2009-05-10 14:02:07 -05:00
|
|
|
|
2006-06-02 05:36:31 -05:00
|
|
|
return ERROR_OK;
|
|
|
|
}
|
|
|
|
|
2019-03-31 21:42:23 -05:00
|
|
|
int armv4_5_handle_cache_info_command(struct command_invocation *cmd, struct armv4_5_cache_common *armv4_5_cache)
|
2006-06-02 05:36:31 -05:00
|
|
|
{
|
2012-02-05 06:03:04 -06:00
|
|
|
if (armv4_5_cache->ctype == -1) {
|
helper/command: change prototype of command_print/command_print_sameline
To prepare for handling TCL return values consistently, all calls
to command_print/command_print_sameline should switch to CMD as
first parameter.
Change prototype of command_print() and command_print_sameline()
to pass CMD instead of CMD_CTX.
Since the first parameter is currently not used, the change can be
done though scripts without manual coding.
This patch is created using the command:
sed -i PATTERN $(find src/ doc/ -type f)
with all the following patters:
's/\(command_print(cmd\)->ctx,/\1,/'
's/\(command_print(CMD\)_CTX,/\1,/'
's/\(command_print(struct command_\)context \*context,/\1invocation *cmd,/'
's/\(command_print_sameline(cmd\)->ctx,/\1,/'
's/\(command_print_sameline(CMD\)_CTX,/\1,/'
's/\(command_print_sameline(struct command_\)context \*context,/\1invocation *cmd,/'
This change is inspired by http://openocd.zylin.com/1815 from Paul
Fertser but is now done through scripting.
Change-Id: I3386d8f96cdc477e7a2308dd18269de3bed04385
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Signed-off-by: Paul Fertser <fercerpav@gmail.com>
Reviewed-on: http://openocd.zylin.com/5081
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2019-04-03 03:37:24 -05:00
|
|
|
command_print(cmd, "cache not yet identified");
|
2006-06-02 05:36:31 -05:00
|
|
|
return ERROR_OK;
|
|
|
|
}
|
2009-05-10 14:02:07 -05:00
|
|
|
|
helper/command: change prototype of command_print/command_print_sameline
To prepare for handling TCL return values consistently, all calls
to command_print/command_print_sameline should switch to CMD as
first parameter.
Change prototype of command_print() and command_print_sameline()
to pass CMD instead of CMD_CTX.
Since the first parameter is currently not used, the change can be
done though scripts without manual coding.
This patch is created using the command:
sed -i PATTERN $(find src/ doc/ -type f)
with all the following patters:
's/\(command_print(cmd\)->ctx,/\1,/'
's/\(command_print(CMD\)_CTX,/\1,/'
's/\(command_print(struct command_\)context \*context,/\1invocation *cmd,/'
's/\(command_print_sameline(cmd\)->ctx,/\1,/'
's/\(command_print_sameline(CMD\)_CTX,/\1,/'
's/\(command_print_sameline(struct command_\)context \*context,/\1invocation *cmd,/'
This change is inspired by http://openocd.zylin.com/1815 from Paul
Fertser but is now done through scripting.
Change-Id: I3386d8f96cdc477e7a2308dd18269de3bed04385
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Signed-off-by: Paul Fertser <fercerpav@gmail.com>
Reviewed-on: http://openocd.zylin.com/5081
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2019-04-03 03:37:24 -05:00
|
|
|
command_print(cmd, "cache type: 0x%1.1x, %s", armv4_5_cache->ctype,
|
2006-06-02 05:36:31 -05:00
|
|
|
(armv4_5_cache->separate) ? "separate caches" : "unified cache");
|
|
|
|
|
helper/command: change prototype of command_print/command_print_sameline
To prepare for handling TCL return values consistently, all calls
to command_print/command_print_sameline should switch to CMD as
first parameter.
Change prototype of command_print() and command_print_sameline()
to pass CMD instead of CMD_CTX.
Since the first parameter is currently not used, the change can be
done though scripts without manual coding.
This patch is created using the command:
sed -i PATTERN $(find src/ doc/ -type f)
with all the following patters:
's/\(command_print(cmd\)->ctx,/\1,/'
's/\(command_print(CMD\)_CTX,/\1,/'
's/\(command_print(struct command_\)context \*context,/\1invocation *cmd,/'
's/\(command_print_sameline(cmd\)->ctx,/\1,/'
's/\(command_print_sameline(CMD\)_CTX,/\1,/'
's/\(command_print_sameline(struct command_\)context \*context,/\1invocation *cmd,/'
This change is inspired by http://openocd.zylin.com/1815 from Paul
Fertser but is now done through scripting.
Change-Id: I3386d8f96cdc477e7a2308dd18269de3bed04385
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Signed-off-by: Paul Fertser <fercerpav@gmail.com>
Reviewed-on: http://openocd.zylin.com/5081
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2019-04-03 03:37:24 -05:00
|
|
|
command_print(cmd, "D-Cache: linelen %i, associativity %i, nsets %i, cachesize 0x%x",
|
2006-06-02 05:36:31 -05:00
|
|
|
armv4_5_cache->d_u_size.linelen,
|
|
|
|
armv4_5_cache->d_u_size.associativity,
|
|
|
|
armv4_5_cache->d_u_size.nsets,
|
|
|
|
armv4_5_cache->d_u_size.cachesize);
|
|
|
|
|
helper/command: change prototype of command_print/command_print_sameline
To prepare for handling TCL return values consistently, all calls
to command_print/command_print_sameline should switch to CMD as
first parameter.
Change prototype of command_print() and command_print_sameline()
to pass CMD instead of CMD_CTX.
Since the first parameter is currently not used, the change can be
done though scripts without manual coding.
This patch is created using the command:
sed -i PATTERN $(find src/ doc/ -type f)
with all the following patters:
's/\(command_print(cmd\)->ctx,/\1,/'
's/\(command_print(CMD\)_CTX,/\1,/'
's/\(command_print(struct command_\)context \*context,/\1invocation *cmd,/'
's/\(command_print_sameline(cmd\)->ctx,/\1,/'
's/\(command_print_sameline(CMD\)_CTX,/\1,/'
's/\(command_print_sameline(struct command_\)context \*context,/\1invocation *cmd,/'
This change is inspired by http://openocd.zylin.com/1815 from Paul
Fertser but is now done through scripting.
Change-Id: I3386d8f96cdc477e7a2308dd18269de3bed04385
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Signed-off-by: Paul Fertser <fercerpav@gmail.com>
Reviewed-on: http://openocd.zylin.com/5081
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2019-04-03 03:37:24 -05:00
|
|
|
command_print(cmd, "I-Cache: linelen %i, associativity %i, nsets %i, cachesize 0x%x",
|
2006-06-02 05:36:31 -05:00
|
|
|
armv4_5_cache->i_size.linelen,
|
|
|
|
armv4_5_cache->i_size.associativity,
|
|
|
|
armv4_5_cache->i_size.nsets,
|
|
|
|
armv4_5_cache->i_size.cachesize);
|
2009-05-10 14:02:07 -05:00
|
|
|
|
2006-06-02 05:36:31 -05:00
|
|
|
return ERROR_OK;
|
|
|
|
}
|