patch-2.4.6 linux/drivers/acpi/debugger/dbhistry.c

Next file: linux/drivers/acpi/debugger/dbinput.c
Previous file: linux/drivers/acpi/debugger/dbfileio.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.4.5/linux/drivers/acpi/debugger/dbhistry.c linux/drivers/acpi/debugger/dbhistry.c
@@ -0,0 +1,199 @@
+/******************************************************************************
+ *
+ * Module Name: dbhistry - debugger HISTORY command
+ *              $Revision: 18 $
+ *
+ *****************************************************************************/
+
+/*
+ *  Copyright (C) 2000, 2001 R. Byron Moore
+ *
+ *  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 "acpi.h"
+#include "acparser.h"
+#include "acdispat.h"
+#include "amlcode.h"
+#include "acnamesp.h"
+#include "acparser.h"
+#include "acevents.h"
+#include "acinterp.h"
+#include "acdebug.h"
+#include "actables.h"
+
+#ifdef ENABLE_DEBUGGER
+
+#define _COMPONENT          ACPI_DEBUGGER
+	 MODULE_NAME         ("dbhistry")
+
+
+#define HI_NO_HISTORY       0
+#define HI_RECORD_HISTORY   1
+#define HISTORY_SIZE        20
+
+
+typedef struct history_info
+{
+	NATIVE_CHAR             command[80];
+	u32                     cmd_num;
+
+} HISTORY_INFO;
+
+
+HISTORY_INFO                history_buffer[HISTORY_SIZE];
+u16                         lo_history = 0;
+u16                         num_history = 0;
+u16                         next_history_index = 0;
+u32                         next_cmd_num = 1;
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    Acpi_db_add_to_history
+ *
+ * PARAMETERS:  Command_line    - Command to add
+ *
+ * RETURN:      None
+ *
+ * DESCRIPTION: Add a command line to the history buffer.
+ *
+ ******************************************************************************/
+
+void
+acpi_db_add_to_history (
+	NATIVE_CHAR             *command_line)
+{
+
+
+	/* Put command into the next available slot */
+
+	STRCPY (history_buffer[next_history_index].command, command_line);
+	history_buffer[next_history_index].cmd_num = next_cmd_num;
+
+	/* Adjust indexes */
+
+	if ((num_history == HISTORY_SIZE) &&
+		(next_history_index == lo_history)) {
+		lo_history++;
+		if (lo_history >= HISTORY_SIZE) {
+			lo_history = 0;
+		}
+	}
+
+	next_history_index++;
+	if (next_history_index >= HISTORY_SIZE) {
+		next_history_index = 0;
+	}
+
+
+	next_cmd_num++;
+	if (num_history < HISTORY_SIZE) {
+		num_history++;
+	}
+
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    Acpi_db_display_history
+ *
+ * PARAMETERS:  None
+ *
+ * RETURN:      None
+ *
+ * DESCRIPTION: Display the contents of the history buffer
+ *
+ ******************************************************************************/
+
+void
+acpi_db_display_history (void)
+{
+	NATIVE_UINT             i;
+	u16                     history_index;
+
+
+	history_index = lo_history;
+
+	/* Dump entire history buffer */
+
+	for (i = 0; i < num_history; i++) {
+		acpi_os_printf ("%ld %s\n", history_buffer[history_index].cmd_num, history_buffer[history_index].command);
+
+		history_index++;
+		if (history_index >= HISTORY_SIZE) {
+			history_index = 0;
+		}
+	}
+}
+
+
+/*******************************************************************************
+ *
+ * FUNCTION:    Acpi_db_get_from_history
+ *
+ * PARAMETERS:  Command_num_arg         - String containing the number of the
+ *                                        command to be retrieved
+ *
+ * RETURN:      None
+ *
+ * DESCRIPTION: Get a command from the history buffer
+ *
+ ******************************************************************************/
+
+NATIVE_CHAR *
+acpi_db_get_from_history (
+	NATIVE_CHAR             *command_num_arg)
+{
+	NATIVE_UINT             i;
+	u16                     history_index;
+	u32                     cmd_num;
+
+
+	if (command_num_arg == NULL) {
+		cmd_num = next_cmd_num - 1;
+	}
+
+	else {
+		cmd_num = STRTOUL (command_num_arg, NULL, 0);
+	}
+
+
+	/* Search history buffer */
+
+	history_index = lo_history;
+	for (i = 0; i < num_history; i++) {
+		if (history_buffer[history_index].cmd_num == cmd_num) {
+			/* Found the commnad, return it */
+
+			return (history_buffer[history_index].command);
+		}
+
+
+		history_index++;
+		if (history_index >= HISTORY_SIZE) {
+			history_index = 0;
+		}
+	}
+
+	acpi_os_printf ("Invalid history number: %d\n", history_index);
+	return (NULL);
+}
+
+
+#endif /* ENABLE_DEBUGGER */
+

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)