2012-06-22 09:02:05 +00:00
|
|
|
/*
|
|
|
|
* mmuinfo.c - Show MMU/cache information from cp15 registers
|
|
|
|
*
|
|
|
|
* Copyright (c) Jan Luebbe <j.luebbe@pengutronix.de>, Pengutronix
|
|
|
|
*
|
|
|
|
* 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 version 2
|
|
|
|
* as published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <common.h>
|
|
|
|
#include <command.h>
|
|
|
|
|
|
|
|
static char *inner_attr[] = {
|
|
|
|
"0b000 Non-cacheable",
|
|
|
|
"0b001 Strongly-ordered",
|
|
|
|
"0b010 (reserved)",
|
|
|
|
"0b011 Device",
|
|
|
|
"0b100 (reserved)",
|
|
|
|
"0b101 Write-Back, Write-Allocate",
|
|
|
|
"0b110 Write-Through",
|
|
|
|
"0b111 Write-Back, no Write-Allocate",
|
|
|
|
};
|
|
|
|
|
|
|
|
static char *outer_attr[] = {
|
|
|
|
"0b00 Non-cacheable",
|
|
|
|
"0b01 Write-Back, Write-Allocate",
|
|
|
|
"0b10 Write-Through, no Write-Allocate",
|
|
|
|
"0b11 Write-Back, no Write-Allocate",
|
|
|
|
};
|
|
|
|
|
|
|
|
static void decode_par(unsigned long par)
|
|
|
|
{
|
|
|
|
printf(" Physical Address [31:12]: 0x%08lx\n", par & 0xFFFFF000);
|
|
|
|
printf(" Reserved [11]: 0x%lx\n", (par >> 11) & 0x1);
|
|
|
|
printf(" Not Outer Shareable [10]: 0x%lx\n", (par >> 10) & 0x1);
|
|
|
|
printf(" Non-Secure [9]: 0x%lx\n", (par >> 9) & 0x1);
|
|
|
|
printf(" Impl. def. [8]: 0x%lx\n", (par >> 8) & 0x1);
|
|
|
|
printf(" Shareable [7]: 0x%lx\n", (par >> 7) & 0x1);
|
|
|
|
printf(" Inner mem. attr. [6:4]: 0x%lx (%s)\n", (par >> 4) & 0x7,
|
|
|
|
inner_attr[(par >> 4) & 0x7]);
|
|
|
|
printf(" Outer mem. attr. [3:2]: 0x%lx (%s)\n", (par >> 2) & 0x3,
|
|
|
|
outer_attr[(par >> 2) & 0x3]);
|
|
|
|
printf(" SuperSection [1]: 0x%lx\n", (par >> 1) & 0x1);
|
|
|
|
printf(" Failure [0]: 0x%lx\n", (par >> 0) & 0x1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int do_mmuinfo(int argc, char *argv[])
|
|
|
|
{
|
|
|
|
unsigned long addr = 0, priv_read, priv_write;
|
|
|
|
|
|
|
|
if (argc < 2)
|
|
|
|
return COMMAND_ERROR_USAGE;
|
|
|
|
|
|
|
|
addr = strtoul_suffix(argv[1], NULL, 0);
|
|
|
|
|
|
|
|
__asm__ __volatile__(
|
|
|
|
"mcr p15, 0, %0, c7, c8, 0 @ write VA to PA translation (priv read)\n"
|
|
|
|
:
|
|
|
|
: "r" (addr)
|
|
|
|
: "memory");
|
|
|
|
|
|
|
|
__asm__ __volatile__(
|
|
|
|
"mrc p15, 0, %0, c7, c4, 0 @ read PAR\n"
|
|
|
|
: "=r" (priv_read)
|
|
|
|
:
|
|
|
|
: "memory");
|
|
|
|
|
|
|
|
__asm__ __volatile__(
|
|
|
|
"mcr p15, 0, %0, c7, c8, 1 @ write VA to PA translation (priv write)\n"
|
|
|
|
:
|
|
|
|
: "r" (addr)
|
|
|
|
: "memory");
|
|
|
|
|
|
|
|
__asm__ __volatile__(
|
|
|
|
"mrc p15, 0, %0, c7, c4, 0 @ read PAR\n"
|
|
|
|
: "=r" (priv_write)
|
|
|
|
:
|
|
|
|
: "memory");
|
|
|
|
|
|
|
|
printf("PAR result for 0x%08lx: \n", addr);
|
|
|
|
printf(" privileged read: 0x%08lx\n", priv_read);
|
|
|
|
decode_par(priv_read);
|
|
|
|
printf(" privileged write: 0x%08lx\n", priv_write);
|
|
|
|
decode_par(priv_write);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
BAREBOX_CMD_START(mmuinfo)
|
|
|
|
.cmd = do_mmuinfo,
|
commands: harmonize in-barebox documentation
This patch does probably too much, but it's hard (and very
cumbersome/time consuming) to break it out. What is does is this:
* each command has one short description, e.g. "list MUX configuration"
* made sure the short descriptions start lowercase
* each command has one usage. That string contains just the
options, e.g. "[-npn]". It's not part of the long help text.
* that is, it doesn't say "[OPTIONS]" anymore, every usable option
is listed by character in this (short) option string (the long
description is in the long help text, as before)
* help texts have been reworked, to make them
- sometimes smaller
- sometimes describe the options better
- more often present themselves in a nicer format
* all long help texts are now created with BUSYBOX_CMD_HELP_
macros, no more 'static const __maybe_unused char cmd_foobar_help[]'
* made sure the long help texts starts uppercase
* because cmdtp->name and cmdtp->opts together provide the new usage,
all "Usage: foobar" texts have been removed from the long help texts
* BUSYBOX_CMD_HELP_TEXT() provides the trailing newline by itself, this
is nicer in the source code
* BUSYBOX_CMD_HELP_OPT() provides the trailing newline by itself
* made sure no line gets longer than 77 characters
* delibertely renamed cmdtp->usage, so that we can get compile-time
errors (e.g. in out-of-tree modules that use register_command()
* the 'help' command can now always emit the usage, even without
compiled long help texts
* 'help -v' gives a list of commands with their short description, this
is similar like the old "help" command before my patchset
* 'help -a' gives out help of all commands
Signed-off-by: Holger Schurig <holgerschurig@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2014-05-13 08:28:42 +00:00
|
|
|
BAREBOX_CMD_DESC("show MMU/cache information of an address")
|
|
|
|
BAREBOX_CMD_OPTS("ADDRESS")
|
commands: group 'help' output
The old output of "help" was just producing a long list, that usually
scrolled of the screen (even on a X11 terminal). This list is more
compact, and also sorted by groups.
The old output format (plus grouping) is now available with 'help -v'.
Example:
Information commands:
?, devinfo, help, iomem, meminfo, version
Boot commands:
boot, bootm, go, loadb, loads, loadx, loady, saves, uimage
...
Signed-off-by: Holger Schurig <holgerschurig@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2014-05-13 14:14:05 +00:00
|
|
|
BAREBOX_CMD_GROUP(CMD_GRP_INFO)
|
2012-06-22 09:02:05 +00:00
|
|
|
BAREBOX_CMD_END
|