1 /* *********************************************************************
2 * Broadcom Common Firmware Environment (CFE)
4 * SOC Display functions File: ui_soccmds.c
6 * UI functions for examining SOC registers
8 * Author: Mitch Lichtenberg (mpl@broadcom.com)
10 *********************************************************************
12 * Copyright 2000,2001,2002,2003
13 * Broadcom Corporation. All rights reserved.
15 * This software is furnished under license and may be used and
16 * copied only in accordance with the following terms and
17 * conditions. Subject to these conditions, you may download,
18 * copy, install, use, modify and distribute modified or unmodified
19 * copies of this software in source and/or binary form. No title
20 * or ownership is transferred hereby.
22 * 1) Any source code used, modified or distributed must reproduce
23 * and retain this copyright notice and list of conditions
24 * as they appear in the source file.
26 * 2) No right is granted to use any trade name, trademark, or
27 * logo of Broadcom Corporation. The "Broadcom Corporation"
28 * name may not be used to endorse or promote products derived
29 * from this software without the prior written permission of
30 * Broadcom Corporation.
32 * 3) THIS SOFTWARE IS PROVIDED "AS-IS" AND ANY EXPRESS OR
33 * IMPLIED WARRANTIES, INCLUDING BUT NOT LIMITED TO, ANY IMPLIED
34 * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
35 * PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT
36 * SHALL BROADCOM BE LIABLE FOR ANY DAMAGES WHATSOEVER, AND IN
37 * PARTICULAR, BROADCOM SHALL NOT BE LIABLE FOR DIRECT, INDIRECT,
38 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
39 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
40 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
41 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
42 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
43 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE), EVEN IF ADVISED OF
44 * THE POSSIBILITY OF SUCH DAMAGE.
45 ********************************************************************* */
50 #include "lib_types.h"
51 #include "lib_string.h"
52 #include "lib_queue.h"
53 #include "lib_malloc.h"
54 #include "lib_printf.h"
56 #include "cfe_error.h"
57 #include "cfe_console.h"
59 #include "ui_command.h"
64 #include "sb1250_regs.h"
65 #include "sb1250_socregs.inc"
67 #include "exchandler.h"
70 static int ui_cmd_soc(ui_cmdline_t
*cmd
,int argc
,char *argv
[]);
71 static int ui_cmd_socagents(ui_cmdline_t
*cmd
,int argc
,char *argv
[]);
73 int ui_init_soccmds(void);
79 * show soc agentname instance subinstance
81 * show soc mac Show all MACs
82 * show soc mac 0 Show just MAC0
83 * show soc macdma 0 tx0 Show just TX channel 0 of MAC DMA 0
86 static void ui_showreg(const socreg_t
*reg
,int verbose
)
94 ptr
+= sprintf(ptr
,"%s",socagents
[reg
->reg_agent
]);
95 if (reg
->reg_inst
[0] != '*') {
96 ptr
+= sprintf(ptr
," %s",reg
->reg_inst
);
98 if (reg
->reg_subinst
[0] != '*') {
99 ptr
+= sprintf(ptr
," %s",reg
->reg_subinst
);
101 ptr
+= sprintf(ptr
," %s",reg
->reg_descr
);
103 res
= mem_peek(&value
,PHYS_TO_K1(reg
->reg_addr
),MEM_QUADWORD
);
105 // value = *((volatile uint64_t *) PHYS_TO_K1(reg->reg_addr));
107 if (res
== 0) sprintf(number
,"%016llX",value
);
108 else sprintf(number
,"N/A N/A N/A N/A ");
110 xprintf("%30s 0x%08X %4s_%4s_%4s_%4s\n",
111 buffer
,reg
->reg_addr
,
112 &number
[0],&number
[4],&number
[8],&number
[12]);
115 if (verbose
&& (reg
->reg_printfunc
)) {
117 (*(reg
->reg_printfunc
))(reg
,value
);
124 static int ui_cmd_soc(ui_cmdline_t
*cmd
,int argc
,char *argv
[])
128 char *subinst
= NULL
;
134 agent
= cmd_getarg(cmd
,0);
135 inst
= cmd_getarg(cmd
,1);
136 subinst
= cmd_getarg(cmd
,2);
138 if (!cmd_sw_isset(cmd
,"-all")) {
139 if (!agent
) return ui_showusage(cmd
);
142 if (cmd_sw_isset(cmd
,"-v")) verbose
= 1;
145 xprintf("Register Name Address Value\n");
146 xprintf("------------------------------ ---------- -------------------\n");
148 while (reg
->reg_descr
) {
149 if (!agent
|| (strcmpi(agent
,socagents
[reg
->reg_agent
]) == 0)) {
150 /* Handle the case of subinstances of something we have only one of */
151 if (reg
->reg_inst
[0] != '*') {
152 if ((!inst
|| (strcmpi(inst
,reg
->reg_inst
) == 0)) &&
153 (!subinst
|| (strcmpi(subinst
,reg
->reg_subinst
) == 0))) {
154 ui_showreg(reg
,verbose
);
158 if (!inst
|| (strcmpi(inst
,reg
->reg_subinst
) == 0)) {
159 ui_showreg(reg
,verbose
);
169 static int ui_cmd_socagents(ui_cmdline_t
*cmd
,int argc
,char *argv
[])
175 xprintf("Available SOC agents: ");
179 if (*aptr
) xprintf(", ");
187 int ui_init_soccmds(void)
189 cmd_addcmd("show soc",
192 "Display SOC register contents",
193 "show soc agentname [instance [section]]\n\n"
194 "Display register values for SOC registers.\n",
195 "-v;Verbose information: Display register fields where available|"
196 "-all;Display all registers in all agents");
198 cmd_addcmd("show agents",
201 "Display list of SOC agents",
203 "Display the names of the available SOC agents that can be examined\n"
204 "using the 'show soc' command",