Deleted Added
full compact
adisasm.c (138287) adisasm.c (151937)
1/******************************************************************************
2 *
3 * Module Name: adisasm - Application-level disassembler routines
1/******************************************************************************
2 *
3 * Module Name: adisasm - Application-level disassembler routines
4 * $Revision: 69 $
4 * $Revision: 1.77 $
5 *
6 *****************************************************************************/
7
8/******************************************************************************
9 *
10 * 1. Copyright Notice
11 *
5 *
6 *****************************************************************************/
7
8/******************************************************************************
9 *
10 * 1. Copyright Notice
11 *
12 * Some or all of this work - Copyright (c) 1999 - 2004, Intel Corp.
12 * Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp.
13 * All rights reserved.
14 *
15 * 2. License
16 *
17 * 2.1. This is your license from Intel Corp. under its intellectual property
18 * rights. You may have additional license terms from the party that provided
19 * you this software, covering your right to use that party's intellectual
20 * property rights.

--- 89 unchanged lines hidden (view full) ---

110 * software, or service, directly or indirectly, to any country for which the
111 * United States government or any agency thereof requires an export license,
112 * other governmental approval, or letter of assurance, without first obtaining
113 * such license, approval or letter.
114 *
115 *****************************************************************************/
116
117
13 * All rights reserved.
14 *
15 * 2. License
16 *
17 * 2.1. This is your license from Intel Corp. under its intellectual property
18 * rights. You may have additional license terms from the party that provided
19 * you this software, covering your right to use that party's intellectual
20 * property rights.

--- 89 unchanged lines hidden (view full) ---

110 * software, or service, directly or indirectly, to any country for which the
111 * United States government or any agency thereof requires an export license,
112 * other governmental approval, or letter of assurance, without first obtaining
113 * such license, approval or letter.
114 *
115 *****************************************************************************/
116
117
118#include "acpi.h"
119#include "acparser.h"
120#include "amlcode.h"
121#include "acdebug.h"
122#include "acdisasm.h"
123#include "acdispat.h"
124#include "acnamesp.h"
125#include "acapps.h"
118#include <contrib/dev/acpica/acpi.h>
119#include <contrib/dev/acpica/acparser.h>
120#include <contrib/dev/acpica/amlcode.h>
121#include <contrib/dev/acpica/acdebug.h>
122#include <contrib/dev/acpica/acdisasm.h>
123#include <contrib/dev/acpica/acdispat.h>
124#include <contrib/dev/acpica/acnamesp.h>
125#include <contrib/dev/acpica/acapps.h>
126
127#include <stdio.h>
128#include <string.h>
129#include <time.h>
130
131
132#define _COMPONENT ACPI_TOOLS
133 ACPI_MODULE_NAME ("adisasm")
134
135
136ACPI_PARSE_OBJECT *AcpiGbl_ParsedNamespaceRoot;
137
138
126
127#include <stdio.h>
128#include <string.h>
129#include <time.h>
130
131
132#define _COMPONENT ACPI_TOOLS
133 ACPI_MODULE_NAME ("adisasm")
134
135
136ACPI_PARSE_OBJECT *AcpiGbl_ParsedNamespaceRoot;
137
138
139#ifndef _ACPI_ASL_COMPILER
139#ifndef ACPI_ASL_COMPILER
140BOOLEAN
141AcpiDsIsResultUsed (
142 ACPI_PARSE_OBJECT *Op,
143 ACPI_WALK_STATE *WalkState)
144{
145 return TRUE;
146}
147#endif
148
149ACPI_STATUS
150AcpiDsRestartControlMethod (
151 ACPI_WALK_STATE *WalkState,
152 ACPI_OPERAND_OBJECT *ReturnDesc)
153{
154 return (AE_OK);
155}
156
140BOOLEAN
141AcpiDsIsResultUsed (
142 ACPI_PARSE_OBJECT *Op,
143 ACPI_WALK_STATE *WalkState)
144{
145 return TRUE;
146}
147#endif
148
149ACPI_STATUS
150AcpiDsRestartControlMethod (
151 ACPI_WALK_STATE *WalkState,
152 ACPI_OPERAND_OBJECT *ReturnDesc)
153{
154 return (AE_OK);
155}
156
157ACPI_STATUS
157void
158AcpiDsTerminateControlMethod (
159 ACPI_WALK_STATE *WalkState)
160{
158AcpiDsTerminateControlMethod (
159 ACPI_WALK_STATE *WalkState)
160{
161 return (AE_OK);
161 return;
162}
163
164ACPI_STATUS
165AcpiDsCallControlMethod (
166 ACPI_THREAD_STATE *Thread,
167 ACPI_WALK_STATE *WalkState,
168 ACPI_PARSE_OBJECT *Op)
169{

--- 13 unchanged lines hidden (view full) ---

183#define FILE_SUFFIX_DISASSEMBLY "dsl"
184#define ACPI_TABLE_FILE_SUFFIX ".dat"
185char FilenameBuf[20];
186
187/******************************************************************************
188 *
189 * FUNCTION: AfGenerateFilename
190 *
162}
163
164ACPI_STATUS
165AcpiDsCallControlMethod (
166 ACPI_THREAD_STATE *Thread,
167 ACPI_WALK_STATE *WalkState,
168 ACPI_PARSE_OBJECT *Op)
169{

--- 13 unchanged lines hidden (view full) ---

183#define FILE_SUFFIX_DISASSEMBLY "dsl"
184#define ACPI_TABLE_FILE_SUFFIX ".dat"
185char FilenameBuf[20];
186
187/******************************************************************************
188 *
189 * FUNCTION: AfGenerateFilename
190 *
191 * PARAMETERS:
191 * PARAMETERS: Prefix - prefix string
192 * TableId - The table ID
192 *
193 *
193 * RETURN:
194 * RETURN: Pointer to the completed string
194 *
195 * DESCRIPTION: Build an output filename from an ACPI table ID string
196 *
197 ******************************************************************************/
198
199char *
200AdGenerateFilename (
201 char *Prefix,

--- 21 unchanged lines hidden (view full) ---

223 return FilenameBuf;
224}
225
226
227/******************************************************************************
228 *
229 * FUNCTION: AfWriteBuffer
230 *
195 *
196 * DESCRIPTION: Build an output filename from an ACPI table ID string
197 *
198 ******************************************************************************/
199
200char *
201AdGenerateFilename (
202 char *Prefix,

--- 21 unchanged lines hidden (view full) ---

224 return FilenameBuf;
225}
226
227
228/******************************************************************************
229 *
230 * FUNCTION: AfWriteBuffer
231 *
231 * PARAMETERS:
232 * PARAMETERS: Filename - name of file
233 * Buffer - data to write
234 * Length - length of data
232 *
235 *
233 * RETURN:
236 * RETURN: Actual number of bytes written
234 *
235 * DESCRIPTION: Open a file and write out a single buffer
236 *
237 ******************************************************************************/
238
239ACPI_NATIVE_INT
240AdWriteBuffer (
241 char *Filename,

--- 16 unchanged lines hidden (view full) ---

258 return Actual;
259}
260
261
262/******************************************************************************
263 *
264 * FUNCTION: AfWriteTable
265 *
237 *
238 * DESCRIPTION: Open a file and write out a single buffer
239 *
240 ******************************************************************************/
241
242ACPI_NATIVE_INT
243AdWriteBuffer (
244 char *Filename,

--- 16 unchanged lines hidden (view full) ---

261 return Actual;
262}
263
264
265/******************************************************************************
266 *
267 * FUNCTION: AfWriteTable
268 *
266 * PARAMETERS:
269 * PARAMETERS: Table - pointer to the ACPI table
270 * Length - length of the table
271 * TableName - the table signature
272 * OemTableID - from the table header
267 *
273 *
268 * RETURN:
274 * RETURN: None
269 *
270 * DESCRIPTION: Dump the loaded tables to a file (or files)
271 *
272 ******************************************************************************/
273
274void
275AdWriteTable (
276 ACPI_TABLE_HEADER *Table,

--- 96 unchanged lines hidden (view full) ---

373
374
375/*******************************************************************************
376 *
377 * FUNCTION: FlSplitInputPathname
378 *
379 * PARAMETERS: InputFilename - The user-specified ASL source file to be
380 * compiled
275 *
276 * DESCRIPTION: Dump the loaded tables to a file (or files)
277 *
278 ******************************************************************************/
279
280void
281AdWriteTable (
282 ACPI_TABLE_HEADER *Table,

--- 96 unchanged lines hidden (view full) ---

379
380
381/*******************************************************************************
382 *
383 * FUNCTION: FlSplitInputPathname
384 *
385 * PARAMETERS: InputFilename - The user-specified ASL source file to be
386 * compiled
387 * OutDirectoryPath - Where the directory path prefix is
388 * returned
389 * OutFilename - Where the filename part is returned
381 *
382 * RETURN: Status
383 *
384 * DESCRIPTION: Split the input path into a directory and filename part
385 * 1) Directory part used to open include files
386 * 2) Filename part used to generate output filenames
387 *
388 ******************************************************************************/

--- 57 unchanged lines hidden (view full) ---

446 return (AE_OK);
447}
448
449
450/******************************************************************************
451 *
452 * FUNCTION: AdAmlDisassemble
453 *
390 *
391 * RETURN: Status
392 *
393 * DESCRIPTION: Split the input path into a directory and filename part
394 * 1) Directory part used to open include files
395 * 2) Filename part used to generate output filenames
396 *
397 ******************************************************************************/

--- 57 unchanged lines hidden (view full) ---

455 return (AE_OK);
456}
457
458
459/******************************************************************************
460 *
461 * FUNCTION: AdAmlDisassemble
462 *
454 * PARAMETERS: OutToFile - TRUE if output should go to a file
455 * Filename - AML input filename
463 * PARAMETERS: Filename - AML input filename
464 * OutToFile - TRUE if output should go to a file
465 * Prefix - Path prefix for output
466 * OutFilename - where the filename is returned
467 * GetAllTables - TRUE if all tables are desired
456 *
457 * RETURN: Status
458 *
459 * DESCRIPTION: Disassemble an entire ACPI table
460 *
461 *****************************************************************************/
462
463ACPI_STATUS

--- 139 unchanged lines hidden (view full) ---

603
604 time (&Timer);
605
606 AcpiOsPrintf ("/*\n * Intel ACPI Component Architecture\n");
607 AcpiOsPrintf (" * AML Disassembler version %8.8X\n", ACPI_CA_VERSION);
608 AcpiOsPrintf (" *\n * Disassembly of %s, %s */\n", Filename, ctime (&Timer));
609
610 AcpiOsPrintf (
468 *
469 * RETURN: Status
470 *
471 * DESCRIPTION: Disassemble an entire ACPI table
472 *
473 *****************************************************************************/
474
475ACPI_STATUS

--- 139 unchanged lines hidden (view full) ---

615
616 time (&Timer);
617
618 AcpiOsPrintf ("/*\n * Intel ACPI Component Architecture\n");
619 AcpiOsPrintf (" * AML Disassembler version %8.8X\n", ACPI_CA_VERSION);
620 AcpiOsPrintf (" *\n * Disassembly of %s, %s */\n", Filename, ctime (&Timer));
621
622 AcpiOsPrintf (
611 "DefinitionBlock (\"%4.4s.aml\", \"%4.4s\", %hd, \"%.6s\", \"%.8s\", %u)\n",
623 "DefinitionBlock (\"%4.4s.aml\", \"%4.4s\", %hd, \"%.6s\", \"%.8s\", 0x%8.8X)\n",
612 Table->Signature, Table->Signature, Table->Revision,
613 Table->OemId, Table->OemTableId, Table->OemRevision);
614}
615
616
617/******************************************************************************
618 *
619 * FUNCTION: AdDisplayTables
620 *
621 * PARAMETERS: Filename - Input file for the table
624 Table->Signature, Table->Signature, Table->Revision,
625 Table->OemId, Table->OemTableId, Table->OemRevision);
626}
627
628
629/******************************************************************************
630 *
631 * FUNCTION: AdDisplayTables
632 *
633 * PARAMETERS: Filename - Input file for the table
634 * Table - Pointer to the raw table
622 *
623 * RETURN: Status
624 *
625 * DESCRIPTION: Display (disassemble) loaded tables and dump raw tables
626 *
627 *****************************************************************************/
628
629ACPI_STATUS

--- 83 unchanged lines hidden (view full) ---

713 if (ACPI_FAILURE (Status))
714 {
715 return_ACPI_STATUS (Status);
716 }
717
718 /* Parse the method */
719
720 WalkState->ParseFlags &= ~ACPI_PARSE_DELETE_TREE;
635 *
636 * RETURN: Status
637 *
638 * DESCRIPTION: Display (disassemble) loaded tables and dump raw tables
639 *
640 *****************************************************************************/
641
642ACPI_STATUS

--- 83 unchanged lines hidden (view full) ---

726 if (ACPI_FAILURE (Status))
727 {
728 return_ACPI_STATUS (Status);
729 }
730
731 /* Parse the method */
732
733 WalkState->ParseFlags &= ~ACPI_PARSE_DELETE_TREE;
734 WalkState->ParseFlags |= ACPI_PARSE_DISASSEMBLE;
721 Status = AcpiPsParseAml (WalkState);
722
723 /*
724 * We need to update all of the Aml offsets, since the parser thought
725 * that the method began at offset zero. In reality, it began somewhere
726 * within the ACPI table, at the BaseAmlOffset. Walk the entire tree that
727 * was just created and update the AmlOffset in each Op
728 */

--- 16 unchanged lines hidden (view full) ---

745 {
746 case AML_BUFFER_OP:
747 case AML_PACKAGE_OP:
748 case AML_VAR_PACKAGE_OP:
749
750 switch (Op->Common.AmlOpcode)
751 {
752 case AML_PACKAGE_OP:
735 Status = AcpiPsParseAml (WalkState);
736
737 /*
738 * We need to update all of the Aml offsets, since the parser thought
739 * that the method began at offset zero. In reality, it began somewhere
740 * within the ACPI table, at the BaseAmlOffset. Walk the entire tree that
741 * was just created and update the AmlOffset in each Op
742 */

--- 16 unchanged lines hidden (view full) ---

759 {
760 case AML_BUFFER_OP:
761 case AML_PACKAGE_OP:
762 case AML_VAR_PACKAGE_OP:
763
764 switch (Op->Common.AmlOpcode)
765 {
766 case AML_PACKAGE_OP:
753 case AML_VAR_PACKAGE_OP:
754 ExtraOp = Op->Common.Value.Arg;
755 ExtraOp = ExtraOp->Common.Next;
756 Op->Common.Value.Arg = ExtraOp->Common.Value.Arg;
757 break;
758
767 ExtraOp = Op->Common.Value.Arg;
768 ExtraOp = ExtraOp->Common.Next;
769 Op->Common.Value.Arg = ExtraOp->Common.Value.Arg;
770 break;
771
772 case AML_VAR_PACKAGE_OP:
759 case AML_BUFFER_OP:
760 default:
761 ExtraOp = Op->Common.Value.Arg;
762 Op->Common.Value.Arg = ExtraOp->Common.Value.Arg;
763 break;
764 }
765
766 /* Must point all parents to the main tree */

--- 90 unchanged lines hidden (view full) ---

857 return Status;
858}
859
860
861/******************************************************************************
862 *
863 * FUNCTION: AdGetLocalTables
864 *
773 case AML_BUFFER_OP:
774 default:
775 ExtraOp = Op->Common.Value.Arg;
776 Op->Common.Value.Arg = ExtraOp->Common.Value.Arg;
777 break;
778 }
779
780 /* Must point all parents to the main tree */

--- 90 unchanged lines hidden (view full) ---

871 return Status;
872}
873
874
875/******************************************************************************
876 *
877 * FUNCTION: AdGetLocalTables
878 *
865 * PARAMETERS:
879 * PARAMETERS: Filename - Not used
880 * GetAllTables - TRUE if all tables are desired
866 *
881 *
867 * RETURN: None
882 * RETURN: Status
868 *
869 * DESCRIPTION: Get the ACPI tables from either memory or a file
870 *
871 *****************************************************************************/
872
873ACPI_STATUS
874AdGetLocalTables (
875 char *Filename,

--- 101 unchanged lines hidden (view full) ---

977
978 return AE_OK;
979}
980
981/******************************************************************************
982 *
983 * FUNCTION: AdParseTable
984 *
883 *
884 * DESCRIPTION: Get the ACPI tables from either memory or a file
885 *
886 *****************************************************************************/
887
888ACPI_STATUS
889AdGetLocalTables (
890 char *Filename,

--- 101 unchanged lines hidden (view full) ---

992
993 return AE_OK;
994}
995
996/******************************************************************************
997 *
998 * FUNCTION: AdParseTable
999 *
985 * PARAMETERS: None
1000 * PARAMETERS: Table - Pointer to the raw table
986 *
987 * RETURN: Status
988 *
989 * DESCRIPTION: Parse the DSDT.
990 *
991 *****************************************************************************/
992
993ACPI_STATUS

--- 39 unchanged lines hidden (view full) ---

1033 Status = AcpiDsInitAmlWalk (WalkState, AcpiGbl_ParsedNamespaceRoot,
1034 NULL, AmlStart, AmlLength, NULL, 1);
1035 if (ACPI_FAILURE (Status))
1036 {
1037 return (Status);
1038 }
1039
1040 WalkState->ParseFlags &= ~ACPI_PARSE_DELETE_TREE;
1001 *
1002 * RETURN: Status
1003 *
1004 * DESCRIPTION: Parse the DSDT.
1005 *
1006 *****************************************************************************/
1007
1008ACPI_STATUS

--- 39 unchanged lines hidden (view full) ---

1048 Status = AcpiDsInitAmlWalk (WalkState, AcpiGbl_ParsedNamespaceRoot,
1049 NULL, AmlStart, AmlLength, NULL, 1);
1050 if (ACPI_FAILURE (Status))
1051 {
1052 return (Status);
1053 }
1054
1055 WalkState->ParseFlags &= ~ACPI_PARSE_DELETE_TREE;
1056 WalkState->ParseFlags |= ACPI_PARSE_DISASSEMBLE;
1041
1042 Status = AcpiPsParseAml (WalkState);
1043 if (ACPI_FAILURE (Status))
1044 {
1045 return Status;
1046 }
1047
1048 /* Pass 2 */
1049
1050 TableDesc.AmlStart = AmlStart;
1051 TableDesc.AmlLength = AmlLength;
1052 fprintf (stderr, "Pass 2 parse of [%4.4s]\n", (char *) Table->Signature);
1057
1058 Status = AcpiPsParseAml (WalkState);
1059 if (ACPI_FAILURE (Status))
1060 {
1061 return Status;
1062 }
1063
1064 /* Pass 2 */
1065
1066 TableDesc.AmlStart = AmlStart;
1067 TableDesc.AmlLength = AmlLength;
1068 fprintf (stderr, "Pass 2 parse of [%4.4s]\n", (char *) Table->Signature);
1069 WalkState->ParseFlags |= ACPI_PARSE_DISASSEMBLE;
1053
1054 Status = AcpiNsOneCompleteParse (2, &TableDesc);
1055 if (ACPI_FAILURE (Status))
1056 {
1057 return (Status);
1058 }
1059
1060 /* Pass 3: Parse control methods and link their parse trees into the main parse tree */
1061
1062 Status = AdParseDeferredOps (AcpiGbl_ParsedNamespaceRoot);
1063
1064 fprintf (stderr, "Parsing completed\n");
1065 return AE_OK;
1066}
1067
1068
1070
1071 Status = AcpiNsOneCompleteParse (2, &TableDesc);
1072 if (ACPI_FAILURE (Status))
1073 {
1074 return (Status);
1075 }
1076
1077 /* Pass 3: Parse control methods and link their parse trees into the main parse tree */
1078
1079 Status = AdParseDeferredOps (AcpiGbl_ParsedNamespaceRoot);
1080
1081 fprintf (stderr, "Parsing completed\n");
1082 return AE_OK;
1083}
1084
1085