tegra: fiq_debugger: add scripting in command line
dmitry pervushin [Wed, 3 Jun 2015 08:12:32 +0000 (10:12 +0200)]
New command-line parameter, fiq_debugger.script allows user to execute
some commands on fiq debugger popup.

Example:
  fiq_debugger.script="bt;reset"
This command will print a backtrace and then reset the machine

Bug 200097742
Bug 200081897

Reviewed-on: http://git-master/r/751784
(cherry picked from commit cdf42b8bf502d44691d55b000d9a1cbd5510ed19)
Signed-off-by: dmitry pervushin <dpervushin@nvidia.com>
Change-Id: Ia998081042128305e5f66eb2ad3b47ed73dc7290
Reviewed-on: http://git-master/r/769733
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Mitch Luban <mluban@nvidia.com>

Documentation/kernel-parameters.txt
drivers/staging/android/fiq_debugger/fiq_debugger.c

index 61918e9..4b94953 100644 (file)
@@ -896,6 +896,10 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
                        Format: <interval>,<probability>,<space>,<times>
                        See also Documentation/fault-injection/.
 
+       fiq_debugger.script=
+                       [ARM] Commands, delimited by semicolon, that will be
+                       executed on FIQ debugger popup
+
        floppy=         [HW]
                        See Documentation/blockdev/floppy.txt.
 
index 3b64adc..09bd692 100644 (file)
@@ -123,10 +123,13 @@ static bool initial_console_enable;
 
 static bool fiq_kgdb_enable;
 
+static char *fiq_script;
+
 module_param_named(no_sleep, initial_no_sleep, bool, 0644);
 module_param_named(debug_enable, initial_debug_enable, bool, 0644);
 module_param_named(console_enable, initial_console_enable, bool, 0644);
 module_param_named(kgdb_enable, fiq_kgdb_enable, bool, 0644);
+module_param_named(script, fiq_script, charp, 0644);
 
 #ifdef CONFIG_FIQ_DEBUGGER_WAKEUP_IRQ_ALWAYS_ON
 static inline
@@ -741,6 +744,8 @@ static void fiq_debugger_fiq(struct fiq_glue_handler *h,
                container_of(h, struct fiq_debugger_state, handler);
        unsigned int this_cpu = THREAD_INFO(svc_sp)->cpu;
        bool need_irq;
+       char *fiq_script_ptr;
+       char *command;
 
        /* Spew regs and callstack immediatly after entering FIQ handler */
        if (per_cpu(immediate_dump, this_cpu)) {
@@ -753,6 +758,16 @@ static void fiq_debugger_fiq(struct fiq_glue_handler *h,
                per_cpu(immediate_dump, this_cpu) = false;
        }
 
+       fiq_script_ptr = fiq_script;
+       command = strsep(&fiq_script_ptr, ";");
+       while (command) {
+               fiq_debugger_printf(&state->output,
+                               "# Executing '%s'\n",
+                               command);
+               fiq_debugger_fiq_exec(state, command, regs, svc_sp);
+               command = strsep(&fiq_script_ptr, ";");
+       }
+
        do {
                need_irq = fiq_debugger_handle_uart_interrupt(state, this_cpu,
                                                        regs, svc_sp);