Rev 1498 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1498 | Rev 2216 | ||
---|---|---|---|
Line 7... | Line 7... | ||
7 | /****************************************************************************** |
7 | /****************************************************************************** |
8 | * |
8 | * |
9 | * 1. Copyright Notice |
9 | * 1. Copyright Notice |
10 | * |
10 | * |
11 | * Some or all of this work - Copyright (c) 1999 - 2010, Intel Corp. |
11 | * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. |
12 | * All rights reserved. |
12 | * All rights reserved. |
13 | * |
13 | * |
14 | * 2. License |
14 | * 2. License |
15 | * |
15 | * |
16 | * 2.1. This is your license from Intel Corp. under its intellectual property |
16 | * 2.1. This is your license from Intel Corp. under its intellectual property |
Line 120... | Line 120... | ||
120 | 120 | ||
Line 121... | Line 121... | ||
121 | 121 | ||
Line 122... | Line 122... | ||
122 | /* Note: This is a 32-bit program only */ |
122 | /* Note: This is a 32-bit program only */ |
123 | 123 | ||
124 | #define VERSION 0x20100107 |
124 | #define VERSION 0x20110330 |
125 | #define FIND_HEADER 0 |
125 | #define FIND_HEADER 0 |
126 | #define EXTRACT_DATA 1 |
- | |
- | 126 | #define EXTRACT_DATA 1 |
|
Line 127... | Line 127... | ||
127 | #define BUFFER_SIZE 256 |
127 | #define BUFFER_SIZE 256 |
Line 128... | Line 128... | ||
128 | 128 | #define MIN_HEADER_LENGTH 6 /* strlen ("DSDT @") */ |
|
129 | 129 | ||
130 | /* Local prototypes */ |
130 | /* Local prototypes */ |
131 | 131 | ||
Line 132... | Line 132... | ||
132 | void |
132 | static void |
133 | CheckAscii ( |
133 | CheckAscii ( |
134 | char *Name, |
134 | char *Name, |
Line 135... | Line 135... | ||
135 | int Count); |
135 | int Count); |
136 | 136 | ||
137 | void |
137 | static void |
138 | NormalizeSignature ( |
138 | NormalizeSignature ( |
Line 139... | Line 139... | ||
139 | char *Signature); |
139 | char *Signature); |
140 | 140 | ||
141 | unsigned int |
141 | static unsigned int |
142 | GetNextInstance ( |
142 | GetNextInstance ( |
143 | char *InputPathname, |
143 | char *InputPathname, |
Line 144... | Line 144... | ||
144 | char *Signature); |
144 | char *Signature); |
145 | 145 | ||
146 | int |
146 | static int |
147 | ExtractTables ( |
147 | ExtractTables ( |
Line 148... | Line 148... | ||
148 | char *InputPathname, |
148 | char *InputPathname, |
149 | char *Signature, |
149 | char *Signature, |
150 | unsigned int MinimumInstances); |
150 | unsigned int MinimumInstances); |
151 | 151 | ||
Line 152... | Line 152... | ||
152 | size_t |
152 | static size_t |
153 | GetTableHeader ( |
153 | GetTableHeader ( |
154 | FILE *InputFile, |
154 | FILE *InputFile, |
Line 155... | Line 155... | ||
155 | unsigned char *OutputData); |
155 | unsigned char *OutputData); |
156 | 156 | ||
157 | unsigned int |
157 | static unsigned int |
158 | CountTableInstances ( |
158 | CountTableInstances ( |
Line 159... | Line 159... | ||
159 | char *InputPathname, |
159 | char *InputPathname, |
160 | char *Signature); |
160 | char *Signature); |
161 | 161 | ||
Line 162... | Line 162... | ||
162 | int |
162 | static int |
Line 194... | Line 194... | ||
194 | unsigned int NextInstance; |
194 | unsigned int NextInstance; |
195 | struct TableInfo *Next; |
195 | struct TableInfo *Next; |
196 | }; |
196 | }; |
197 | 197 | ||
Line 198... | Line 198... | ||
198 | struct TableInfo *ListHead = NULL; |
198 | static struct TableInfo *ListHead = NULL; |
199 | char Filename[16]; |
199 | static char Filename[16]; |
200 | unsigned char Data[16]; |
200 | static unsigned char Data[16]; |
Line 201... | Line 201... | ||
201 | 201 | ||
202 | 202 | ||
203 | /****************************************************************************** |
203 | /****************************************************************************** |
204 | * |
204 | * |
205 | * FUNCTION: DisplayUsage |
205 | * FUNCTION: DisplayUsage |
206 | * |
206 | * |
207 | * DESCRIPTION: Usage message |
207 | * DESCRIPTION: Usage message |
Line 208... | Line 208... | ||
208 | * |
208 | * |
209 | ******************************************************************************/ |
209 | ******************************************************************************/ |
210 | 210 | ||
211 | void |
211 | static void |
Line 212... | Line 212... | ||
212 | DisplayUsage ( |
212 | DisplayUsage ( |
Line 238... | Line 238... | ||
238 | * Ascii characters. Sets non-printable and null chars to |
238 | * Ascii characters. Sets non-printable and null chars to |
239 | * |
239 | * |
240 | ******************************************************************************/ |
240 | ******************************************************************************/ |
241 | 241 | ||
Line 242... | Line 242... | ||
242 | void |
242 | static void |
243 | CheckAscii ( |
243 | CheckAscii ( |
244 | char *Name, |
244 | char *Name, |
245 | int Count) |
245 | int Count) |
246 | { |
246 | { |
247 | int i; |
247 | int i; |
Line 268... | Line 268... | ||
268 | * DESCRIPTION: Change "RSD PTR" to "RSDP" |
268 | * DESCRIPTION: Change "RSD PTR" to "RSDP" |
269 | * |
269 | * |
270 | ******************************************************************************/ |
270 | ******************************************************************************/ |
271 | 271 | ||
Line 272... | Line 272... | ||
272 | void |
272 | static void |
273 | NormalizeSignature ( |
273 | NormalizeSignature ( |
274 | char *Signature) |
274 | char *Signature) |
275 | { |
275 | { |
Line 276... | Line 276... | ||
276 | 276 | ||
Line 293... | Line 293... | ||
293 | * DESCRIPTION: Convert one line of ascii text binary (up to 16 bytes) |
293 | * DESCRIPTION: Convert one line of ascii text binary (up to 16 bytes) |
294 | * |
294 | * |
295 | ******************************************************************************/ |
295 | ******************************************************************************/ |
296 | 296 | ||
Line 297... | Line 297... | ||
297 | size_t |
297 | static size_t |
298 | ConvertLine ( |
298 | ConvertLine ( |
299 | char *InputLine, |
299 | char *InputLine, |
300 | unsigned char *OutputData) |
300 | unsigned char *OutputData) |
301 | { |
301 | { |
302 | char *End; |
302 | char *End; |
Line 351... | Line 351... | ||
351 | * DESCRIPTION: Extract and convert an ACPI table header |
351 | * DESCRIPTION: Extract and convert an ACPI table header |
352 | * |
352 | * |
353 | ******************************************************************************/ |
353 | ******************************************************************************/ |
354 | 354 | ||
Line 355... | Line 355... | ||
355 | size_t |
355 | static size_t |
356 | GetTableHeader ( |
356 | GetTableHeader ( |
357 | FILE *InputFile, |
357 | FILE *InputFile, |
358 | unsigned char *OutputData) |
358 | unsigned char *OutputData) |
359 | { |
359 | { |
360 | size_t BytesConverted; |
360 | size_t BytesConverted; |
Line 399... | Line 399... | ||
399 | * the input acpidump file. |
399 | * the input acpidump file. |
400 | * |
400 | * |
401 | ******************************************************************************/ |
401 | ******************************************************************************/ |
402 | 402 | ||
Line 403... | Line 403... | ||
403 | unsigned int |
403 | static unsigned int |
404 | CountTableInstances ( |
404 | CountTableInstances ( |
405 | char *InputPathname, |
405 | char *InputPathname, |
406 | char *Signature) |
406 | char *Signature) |
407 | { |
407 | { |
408 | char Buffer[BUFFER_SIZE]; |
408 | char Buffer[BUFFER_SIZE]; |
Line 457... | Line 457... | ||
457 | * instances. |
457 | * instances. |
458 | * |
458 | * |
459 | ******************************************************************************/ |
459 | ******************************************************************************/ |
460 | 460 | ||
Line 461... | Line 461... | ||
461 | unsigned int |
461 | static unsigned int |
462 | GetNextInstance ( |
462 | GetNextInstance ( |
463 | char *InputPathname, |
463 | char *InputPathname, |
464 | char *Signature) |
464 | char *Signature) |
465 | { |
465 | { |
466 | struct TableInfo *Info; |
466 | struct TableInfo *Info; |
Line 518... | Line 518... | ||
518 | * DESCRIPTION: Convert text ACPI tables to binary |
518 | * DESCRIPTION: Convert text ACPI tables to binary |
519 | * |
519 | * |
520 | ******************************************************************************/ |
520 | ******************************************************************************/ |
521 | 521 | ||
Line 522... | Line 522... | ||
522 | int |
522 | static int |
523 | ExtractTables ( |
523 | ExtractTables ( |
524 | char *InputPathname, |
524 | char *InputPathname, |
525 | char *Signature, |
525 | char *Signature, |
526 | unsigned int MinimumInstances) |
526 | unsigned int MinimumInstances) |
527 | { |
527 | { |
Line 575... | Line 575... | ||
575 | switch (State) |
575 | switch (State) |
576 | { |
576 | { |
577 | case FIND_HEADER: |
577 | case FIND_HEADER: |
578 | 578 | ||
Line -... | Line 579... | ||
- | 579 | /* Ignore lines that are too short to be header lines */ |
|
- | 580 | ||
- | 581 | if (strlen (Buffer) < MIN_HEADER_LENGTH) |
|
- | 582 | { |
|
- | 583 | continue; |
|
- | 584 | } |
|
- | 585 | ||
579 | /* Ignore empty lines and lines that start with a space */ |
586 | /* Ignore empty lines and lines that start with a space */ |
Line 580... | Line 587... | ||
580 | 587 | ||
581 | if ((Buffer[0] == ' ') || |
588 | if ((Buffer[0] == ' ') || |
582 | (Buffer[0] == '\n')) |
589 | (Buffer[0] == '\n')) |
583 | { |
590 | { |
584 | continue; |
591 | continue; |
Line -... | Line 592... | ||
- | 592 | } |
|
- | 593 | ||
- | 594 | /* |
|
- | 595 | * Ignore lines that are not of the form |
|
- | 596 | * |
|
- | 597 | * DSDT @ 0x737e4000 |
|
- | 598 | * XSDT @ 0x737f2fff |
|
- | 599 | * RSD PTR @ 0xf6cd0 |
|
- | 600 | * SSDT @ (nil) |
|
- | 601 | */ |
|
- | 602 | if (!strstr (Buffer, " @ ")) |
|
- | 603 | { |
|
- | 604 | continue; |
|
585 | } |
605 | } |
586 | 606 | ||
Line 587... | Line 607... | ||
587 | NormalizeSignature (Buffer); |
607 | NormalizeSignature (Buffer); |
588 | strncpy (ThisSignature, Buffer, 4); |
608 | strncpy (ThisSignature, Buffer, 4); |
Line 637... | Line 657... | ||
637 | fclose (OutputFile); |
657 | fclose (OutputFile); |
638 | OutputFile = NULL; |
658 | OutputFile = NULL; |
639 | State = FIND_HEADER; |
659 | State = FIND_HEADER; |
640 | 660 | ||
Line 641... | Line 661... | ||
641 | printf ("Acpi table [%4.4s] - % 7d bytes written to %s\n", |
661 | printf ("Acpi table [%4.4s] - %u bytes written to %s\n", |
642 | ThisSignature, TotalBytesWritten, Filename); |
662 | ThisSignature, (unsigned int) TotalBytesWritten, Filename); |
643 | continue; |
663 | continue; |
644 | } |
664 | } |
Line 645... | Line 665... | ||
645 | 665 | ||
Line 682... | Line 702... | ||
682 | if (State == EXTRACT_DATA) |
702 | if (State == EXTRACT_DATA) |
683 | { |
703 | { |
684 | /* Received an EOF while extracting data */ |
704 | /* Received an EOF while extracting data */ |
685 | 705 | ||
Line 686... | Line 706... | ||
686 | printf ("Acpi table [%4.4s] - % 7d bytes written to %s\n", |
706 | printf ("Acpi table [%4.4s] - %u bytes written to %s\n", |
687 | ThisSignature, TotalBytesWritten, Filename); |
707 | ThisSignature, (unsigned int) TotalBytesWritten, Filename); |
688 | } |
708 | } |
689 | } |
709 | } |
Line 690... | Line 710... | ||
690 | 710 | ||
691 | fclose (InputFile); |
711 | fclose (InputFile); |
Line 705... | Line 725... | ||
705 | * perform an actual extraction of the tables. |
725 | * perform an actual extraction of the tables. |
706 | * |
726 | * |
707 | ******************************************************************************/ |
727 | ******************************************************************************/ |
708 | 728 | ||
Line 709... | Line 729... | ||
709 | int |
729 | static int |
710 | ListTables ( |
730 | ListTables ( |
711 | char *InputPathname) |
731 | char *InputPathname) |
712 | { |
732 | { |
713 | FILE *InputFile; |
733 | FILE *InputFile; |
714 | char Buffer[BUFFER_SIZE]; |
734 | char Buffer[BUFFER_SIZE]; |