dbhistry.c revision 99679
1709Swollman/****************************************************************************** 217210Spst * 3709Swollman * Module Name: dbhistry - debugger HISTORY command 437Srgrimes * $Revision: 24 $ 537Srgrimes * 637Srgrimes *****************************************************************************/ 737Srgrimes 837Srgrimes/****************************************************************************** 937Srgrimes * 108460Sjkh * 1. Copyright Notice 118460Sjkh * 128460Sjkh * Some or all of this work - Copyright (c) 1999 - 2002, Intel Corp. 138460Sjkh * All rights reserved. 1437Srgrimes * 1537Srgrimes * 2. License 1637Srgrimes * 1737Srgrimes * 2.1. This is your license from Intel Corp. under its intellectual property 1837Srgrimes * rights. You may have additional license terms from the party that provided 1937Srgrimes * you this software, covering your right to use that party's intellectual 2037Srgrimes * property rights. 2137Srgrimes * 2237Srgrimes * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a 2337Srgrimes * copy of the source code appearing in this file ("Covered Code") an 2437Srgrimes * irrevocable, perpetual, worldwide license under Intel's copyrights in the 2515568Sasami * base code distributed originally by Intel ("Original Intel Code") to copy, 2615568Sasami * make derivatives, distribute, use and display any portion of the Covered 2715568Sasami * Code in any form, with the right to sublicense such rights; and 2815568Sasami * 2915568Sasami * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent 3015568Sasami * license (with the right to sublicense), under only those claims of Intel 313843Sdg * patents that are infringed by the Original Intel Code, to make, use, sell, 323843Sdg * offer to sell, and import the Covered Code and derivative works thereof 332164Sdg * solely to the minimum extent necessary to exercise the above copyright 3437Srgrimes * license, and in no event shall the patent license extend to any additions 3537Srgrimes * to or modifications of the Original Intel Code. No other license or right 3637Srgrimes * is granted directly or by implication, estoppel or otherwise; 3737Srgrimes * 3837Srgrimes * The above copyright and patent license is granted only if the following 3937Srgrimes * conditions are met: 4037Srgrimes * 4137Srgrimes * 3. Conditions 4237Srgrimes * 4337Srgrimes * 3.1. Redistribution of Source with Rights to Further Distribute Source. 4437Srgrimes * Redistribution of source code of any substantial portion of the Covered 4537Srgrimes * Code or modification with rights to further distribute source must include 4637Srgrimes * the above Copyright Notice, the above License, this list of Conditions, 4737Srgrimes * and the following Disclaimer and Export Compliance provision. In addition, 4837Srgrimes * Licensee must cause all Covered Code to which Licensee contributes to 4937Srgrimes * contain a file documenting the changes Licensee made to create that Covered 5037Srgrimes * Code and the date of any change. Licensee must include in that file the 5137Srgrimes * documentation of any changes made by any predecessor Licensee. Licensee 5237Srgrimes * must include a prominent statement that the modification is derived, 5337Srgrimes * directly or indirectly, from Original Intel Code. 5437Srgrimes * 5537Srgrimes * 3.2. Redistribution of Source with no Rights to Further Distribute Source. 5637Srgrimes * Redistribution of source code of any substantial portion of the Covered 5737Srgrimes * Code or modification without rights to further distribute source must 5837Srgrimes * include the following Disclaimer and Export Compliance provision in the 5937Srgrimes * documentation and/or other materials provided with distribution. In 6037Srgrimes * addition, Licensee may not authorize further sublicense of source of any 6137Srgrimes * portion of the Covered Code, and must include terms to the effect that the 6237Srgrimes * license from Licensee to its licensee is limited to the intellectual 6337Srgrimes * property embodied in the software Licensee provides to its licensee, and 6437Srgrimes * not to intellectual property embodied in modifications its licensee may 652164Sdg * make. 662164Sdg * 6737Srgrimes * 3.3. Redistribution of Executable. Redistribution in executable form of any 6837Srgrimes * substantial portion of the Covered Code or modification must reproduce the 6937Srgrimes * above Copyright Notice, and the following Disclaimer and Export Compliance 7037Srgrimes * provision in the documentation and/or other materials provided with the 713036Sdg * distribution. 723036Sdg * 733036Sdg * 3.4. Intel retains all right, title, and interest in and to the Original 748530Sdg * Intel Code. 758530Sdg * 768530Sdg * 3.5. Neither the name Intel nor any other trademark owned or controlled by 778530Sdg * Intel shall be used in advertising or otherwise to promote the sale, use or 781692Sphk * other dealings in products derived from or relating to the Covered Code 7937Srgrimes * without prior written authorization from Intel. 808530Sdg * 8137Srgrimes * 4. Disclaimer and Export Compliance 828530Sdg * 838530Sdg * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED 848530Sdg * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE 858530Sdg * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, 8637Srgrimes * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY 874091Sache * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY 88872Sache * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A 897219Sjkh * PARTICULAR PURPOSE. 907219Sjkh * 917219Sjkh * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES 927219Sjkh * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR 937219Sjkh * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, 941675Sache * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY 957219Sjkh * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL 967293Sjkh * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS 971675Sache * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY 981675Sache * LIMITED REMEDY. 9914596Snate * 10014624Snate * 4.3. Licensee shall not export, either directly or indirectly, any of this 10114624Snate * software or system incorporating such software without first obtaining any 10214596Snate * required license or other approval from the U. S. Department of Commerce or 10314596Snate * any other agency or department of the United States Government. In the 1047487Srgrimes * event Licensee exports any such software from the United States or 1057460Sjkh * re-exports any such software from a foreign destination, Licensee shall 1067750Srgrimes * ensure that the distribution and export/re-export of the software is in 1077460Sjkh * compliance with all laws, regulations, orders, or other restrictions of the 1087460Sjkh * U.S. Export Administration Regulations. Licensee agrees that neither it nor 1098540Srgrimes * any of its subsidiaries will export/re-export any technical data, process, 1107487Srgrimes * software, or service, directly or indirectly, to any country for which the 1117487Srgrimes * United States government or any agency thereof requires an export license, 1127487Srgrimes * other governmental approval, or letter of assurance, without first obtaining 1137487Srgrimes * such license, approval or letter. 1147487Srgrimes * 1157487Srgrimes *****************************************************************************/ 1167487Srgrimes 1177761Sache 1187487Srgrimes#include "acpi.h" 11915684Sjkh#include "acdebug.h" 1207487Srgrimes 12116588Sjoerg#ifdef ENABLE_DEBUGGER 12216588Sjoerg 12316588Sjoerg#define _COMPONENT ACPI_DEBUGGER 12416588Sjoerg ACPI_MODULE_NAME ("dbhistry") 12516588Sjoerg 12616588Sjoerg 12716588Sjoerg#define HI_NO_HISTORY 0 12816588Sjoerg#define HI_RECORD_HISTORY 1 12916588Sjoerg#define HISTORY_SIZE 20 1307487Srgrimes 1317487Srgrimes 1327487Srgrimestypedef struct HistoryInfo 1337487Srgrimes{ 1347487Srgrimes NATIVE_CHAR Command[80]; 1357487Srgrimes UINT32 CmdNum; 1367487Srgrimes 13716588Sjoerg} HISTORY_INFO; 13816588Sjoerg 13916588Sjoerg 14016588Sjoergstatic HISTORY_INFO AcpiGbl_HistoryBuffer[HISTORY_SIZE]; 14116588Sjoergstatic UINT16 AcpiGbl_LoHistory = 0; 14216588Sjoergstatic UINT16 AcpiGbl_NumHistory = 0; 14316588Sjoergstatic UINT16 AcpiGbl_NextHistoryIndex = 0; 14416588Sjoergstatic UINT32 AcpiGbl_NextCmdNum = 1; 1459305Sbde 1469305Sbde 1479305Sbde/******************************************************************************* 1489305Sbde * 1499305Sbde * FUNCTION: AcpiDbAddToHistory 1507487Srgrimes * 1517487Srgrimes * PARAMETERS: CommandLine - Command to add 1527487Srgrimes * 1537487Srgrimes * RETURN: None 1547487Srgrimes * 1557487Srgrimes * DESCRIPTION: Add a command line to the history buffer. 1567487Srgrimes * 1577487Srgrimes ******************************************************************************/ 1587487Srgrimes 1597487Srgrimesvoid 1607487SrgrimesAcpiDbAddToHistory ( 1617487Srgrimes NATIVE_CHAR *CommandLine) 1627487Srgrimes{ 1637487Srgrimes 1647487Srgrimes /* Put command into the next available slot */ 1657487Srgrimes 1667487Srgrimes ACPI_STRCPY (AcpiGbl_HistoryBuffer[AcpiGbl_NextHistoryIndex].Command, CommandLine); 1677487Srgrimes 1687487Srgrimes AcpiGbl_HistoryBuffer[AcpiGbl_NextHistoryIndex].CmdNum = AcpiGbl_NextCmdNum; 1697487Srgrimes 1707487Srgrimes /* Adjust indexes */ 1717259Sjkh 1727487Srgrimes if ((AcpiGbl_NumHistory == HISTORY_SIZE) && 1737487Srgrimes (AcpiGbl_NextHistoryIndex == AcpiGbl_LoHistory)) 1747708Srgrimes { 1757487Srgrimes AcpiGbl_LoHistory++; 1767487Srgrimes if (AcpiGbl_LoHistory >= HISTORY_SIZE) 1777487Srgrimes { 1787487Srgrimes AcpiGbl_LoHistory = 0; 1797487Srgrimes } 1807708Srgrimes } 181857Sdg 18237Srgrimes AcpiGbl_NextHistoryIndex++; 1837487Srgrimes if (AcpiGbl_NextHistoryIndex >= HISTORY_SIZE) 1847487Srgrimes { 1857487Srgrimes AcpiGbl_NextHistoryIndex = 0; 1867487Srgrimes } 1877487Srgrimes 1887487Srgrimes AcpiGbl_NextCmdNum++; 1897487Srgrimes if (AcpiGbl_NumHistory < HISTORY_SIZE) 190958Sache { 1917487Srgrimes AcpiGbl_NumHistory++; 1927487Srgrimes } 1937487Srgrimes} 1947487Srgrimes 1957487Srgrimes 1967487Srgrimes/******************************************************************************* 1977487Srgrimes * 1981186Srgrimes * FUNCTION: AcpiDbDisplayHistory 1991186Srgrimes * 2007487Srgrimes * PARAMETERS: None 2017487Srgrimes * 2027487Srgrimes * RETURN: None 2037487Srgrimes * 2047487Srgrimes * DESCRIPTION: Display the contents of the history buffer 2057219Sjkh * 2067487Srgrimes ******************************************************************************/ 2077487Srgrimes 2087487Srgrimesvoid 2097487SrgrimesAcpiDbDisplayHistory (void) 2107238Sache{ 2117487Srgrimes NATIVE_UINT i; 2127487Srgrimes UINT16 HistoryIndex; 2137487Srgrimes 2147708Srgrimes 2157238Sache HistoryIndex = AcpiGbl_LoHistory; 2167487Srgrimes 21714202Sadam /* Dump entire history buffer */ 2187487Srgrimes 2197487Srgrimes for (i = 0; i < AcpiGbl_NumHistory; i++) 2207238Sache { 2217487Srgrimes AcpiOsPrintf ("%ld %s\n", AcpiGbl_HistoryBuffer[HistoryIndex].CmdNum, 2227487Srgrimes AcpiGbl_HistoryBuffer[HistoryIndex].Command); 2237708Srgrimes 2249593Swollman HistoryIndex++; 2259593Swollman if (HistoryIndex >= HISTORY_SIZE) 2269593Swollman { 2277219Sjkh HistoryIndex = 0; 2287219Sjkh } 2297487Srgrimes } 2307487Srgrimes} 2317487Srgrimes 2327487Srgrimes 2337238Sache/******************************************************************************* 2347238Sache * 2357487Srgrimes * FUNCTION: AcpiDbGetFromHistory 23610716Sjkh * 23713071Sjkh * PARAMETERS: CommandNumArg - String containing the number of the 23810716Sjkh * command to be retrieved 23910716Sjkh * 24010716Sjkh * RETURN: None 24110716Sjkh * 2427487Srgrimes * DESCRIPTION: Get a command from the history buffer 2437477Sache * 2447477Sache ******************************************************************************/ 2457487Srgrimes 2467487SrgrimesNATIVE_CHAR * 2477487SrgrimesAcpiDbGetFromHistory ( 2487238Sache NATIVE_CHAR *CommandNumArg) 2497487Srgrimes{ 25013455Sgraichen NATIVE_UINT i; 25113996Sjkh UINT16 HistoryIndex; 2527238Sache UINT32 CmdNum; 2537238Sache 2547487Srgrimes 2557487Srgrimes if (CommandNumArg == NULL) 2567487Srgrimes { 2577487Srgrimes CmdNum = AcpiGbl_NextCmdNum - 1; 25812053Spst } 2597238Sache 2607238Sache else 26113701Sgpalmer { 26213701Sgpalmer CmdNum = ACPI_STRTOUL (CommandNumArg, NULL, 0); 26313701Sgpalmer } 26413701Sgpalmer 26513701Sgpalmer /* Search history buffer */ 2667487Srgrimes 2677487Srgrimes HistoryIndex = AcpiGbl_LoHistory; 2687487Srgrimes for (i = 0; i < AcpiGbl_NumHistory; i++) 2697487Srgrimes { 2707487Srgrimes if (AcpiGbl_HistoryBuffer[HistoryIndex].CmdNum == CmdNum) 2717487Srgrimes { 2727487Srgrimes /* Found the commnad, return it */ 2737487Srgrimes 2747487Srgrimes return (AcpiGbl_HistoryBuffer[HistoryIndex].Command); 2757487Srgrimes } 2767487Srgrimes 2777487Srgrimes 2787238Sache HistoryIndex++; 2797238Sache if (HistoryIndex >= HISTORY_SIZE) 2807487Srgrimes { 28111992Sache HistoryIndex = 0; 28211992Sache } 28311992Sache } 28411992Sache 28511992Sache AcpiOsPrintf ("Invalid history number: %d\n", HistoryIndex); 2867238Sache return (NULL); 2877238Sache} 2887487Srgrimes 2897487Srgrimes 2907487Srgrimes#endif /* ENABLE_DEBUGGER */ 2917487Srgrimes 2927487Srgrimes