aboutsummaryrefslogtreecommitdiffstats
path: root/recipes/u-boot/u-boot-2009.11/at91/0009-cmd_debug.c-Add-a-generic-function-for-debug-vars.patch
diff options
context:
space:
mode:
Diffstat (limited to 'recipes/u-boot/u-boot-2009.11/at91/0009-cmd_debug.c-Add-a-generic-function-for-debug-vars.patch')
-rw-r--r--recipes/u-boot/u-boot-2009.11/at91/0009-cmd_debug.c-Add-a-generic-function-for-debug-vars.patch168
1 files changed, 168 insertions, 0 deletions
diff --git a/recipes/u-boot/u-boot-2009.11/at91/0009-cmd_debug.c-Add-a-generic-function-for-debug-vars.patch b/recipes/u-boot/u-boot-2009.11/at91/0009-cmd_debug.c-Add-a-generic-function-for-debug-vars.patch
new file mode 100644
index 0000000000..34828ebaaf
--- /dev/null
+++ b/recipes/u-boot/u-boot-2009.11/at91/0009-cmd_debug.c-Add-a-generic-function-for-debug-vars.patch
@@ -0,0 +1,168 @@
+From f96a5c1051eac6c5782d775a97f9651c5e10b7af Mon Sep 17 00:00:00 2001
+From: Ulf Samuelsson <ulf.samuelsson@atmel.com>
+Date: Sun, 14 Mar 2010 00:03:14 +0100
+Subject: [PATCH] cmd_debug.c: Add a generic function for debug vars
+
+This introduces a way for a module to register a debug variable.
+The debug command can then be used to turn on/off the debug
+variable or set it to a level
+* 0 (off)
+* 1 (on)
+* 2 (verbose)
+
+The value of all debug variables can be listed by just typing "debug"
+
+module will use the debug level for its debug variable
+to determine debug verbosity.
+
+Signed-off-by: Ulf Samuelsson <ulf.samuelsson@atmel.com>
+---
+ common/cmd_debug.c | 136 ++++++++++++++++++++++++++++++++++++++++++++++++++++
+ 1 files changed, 136 insertions(+), 0 deletions(-)
+ create mode 100644 common/cmd_debug.c
+
+diff --git a/common/cmd_debug.c b/common/cmd_debug.c
+new file mode 100644
+index 0000000..99f05a2
+--- /dev/null
++++ b/common/cmd_debug.c
+@@ -0,0 +1,136 @@
++/*
++ * (C) Copyright 2010
++ * Ulf Samuelsson <ulf.samuelsson@atmel.com>
++ *
++ * 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 as
++ * published by the Free Software Foundation; either version 2 of
++ * the License, or (at your option) any later version.
++ *
++ * 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.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
++ * MA 02111-1307 USA
++ */
++
++#include <common.h>
++#include <command.h>
++#include <debug.h>
++
++#undef DEBUG
++#if defined(DEBUG)
++#define pr_debug(fmt, args...) printf(fmt, ##args)
++#else
++#define pr_debug(...) do { } while(0)
++#endif
++
++static struct debug_flag debug = {
++ .debug = 0,
++ .name = "all",
++ .next = NULL,
++};
++struct debug_flag *dbg_vars = &debug;
++
++static char *debug_variable (const char *s)
++{
++ struct debug_flag *vars;
++ vars = dbg_vars;
++ while(vars != NULL) {
++ if (strcmp (s, vars->name) == 0) {
++ return &vars->debug;
++ }
++ vars = vars->next;
++ }
++ return NULL;
++}
++
++static int debug_level (const char *s)
++{
++ if (strcmp (s, "0") == 0) {
++ return 0;
++ } else if (strcmp (s, "off") == 0) {
++ return 0;
++ } else if (strcmp (s, "1") == 0) {
++ return 1;
++ } else if (strcmp (s, "on") == 0) {
++ return 1;
++ } else if (strcmp (s, "2") == 0) {
++ return 2;
++ } else {
++ return -1;
++ }
++}
++
++int do_debug (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
++{
++ int value;
++ char *p;
++ struct debug_flag *dbg;
++ pr_debug("Arg count = %d\n",argc);
++ for (value = 0; value < argc; value++) {
++ pr_debug("argv[%d] = \"%s\"\n",value,argv[value]);
++ }
++ value = 1; /* Standard value, if we do not have a second parameter */
++ switch (argc) {
++ case 3: /* on / off */
++ value = debug_level(argv[2]);
++ if(value < 0) {
++ printf("Illegal debug variable: %s\n",p);
++ return -1;
++ }
++
++ case 2:
++ p = debug_variable (argv[1]);
++ if(p == NULL) {
++ printf("Illegal debug variable: %s\n",p);
++ return -1;
++ }
++ if(p == &debug.debug) { /* Set all debug variables */
++ dbg = dbg_vars;
++ while(dbg != NULL) {
++ dbg->debug = value;
++ dbg = dbg->next;
++ }
++ }
++ *p = value;
++ break;
++ default:
++ printf ("Usage:\n%s\n", cmdtp->usage);
++ printf ("Valid are: \n");
++ dbg = dbg_vars;
++ while(dbg != NULL) {
++ printf("\t%s\t = %d\n",dbg->name, dbg->debug);
++ dbg = dbg->next;
++ }
++ return 1;
++ }
++ return 0;
++}
++
++void register_debug_variable(struct debug_flag *dbg)
++{
++ struct debug_flag *vars;
++ vars = dbg_vars;
++ pr_debug("Registering \"%s_debug\" = %d\n",dbg->name,dbg->debug);
++ while(vars->next != NULL) {
++ vars = vars->next;
++ }
++ vars->next = dbg;
++ dbg->next = NULL;
++}
++
++
++U_BOOT_CMD(
++ debug, 3, 1, do_debug,
++ "debug\t- enable or disable debug\n",
++ "<var> [on|off|0|1|2]\n"
++ " - enable or disable debug"
++);
+--
+1.6.0.2
+