| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
#define _DECLARE_GLOBALS |
| 45 |
#include "acpidump.h" |
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
|
| 63 |
|
| 64 |
|
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
|
| 71 |
|
| 72 |
static void |
| 73 |
ApDisplayUsage ( |
| 74 |
void); |
| 75 |
|
| 76 |
static int |
| 77 |
ApDoOptions ( |
| 78 |
int argc, |
| 79 |
char **argv); |
| 80 |
|
| 81 |
static int |
| 82 |
ApInsertAction ( |
| 83 |
char *Argument, |
| 84 |
UINT32 ToBeDone); |
| 85 |
|
| 86 |
|
| 87 |
|
| 88 |
|
| 89 |
AP_DUMP_ACTION ActionTable [AP_MAX_ACTIONS]; |
| 90 |
UINT32 CurrentAction = 0; |
| 91 |
|
| 92 |
|
| 93 |
#define AP_UTILITY_NAME "ACPI Binary Table Dump Utility" |
| 94 |
#define AP_SUPPORTED_OPTIONS "?a:bc:f:hn:o:r:sv^xz" |
| 95 |
|
| 96 |
|
| 97 |
|
| 98 |
|
| 99 |
|
| 100 |
|
| 101 |
|
| 102 |
|
| 103 |
|
| 104 |
|
| 105 |
static void |
| 106 |
ApDisplayUsage ( |
| 107 |
void) |
| 108 |
{ |
| 109 |
|
| 110 |
ACPI_USAGE_HEADER ("acpidump [options]"); |
| 111 |
|
| 112 |
ACPI_OPTION ("-b", "Dump tables to binary files"); |
| 113 |
ACPI_OPTION ("-h -?", "This help message"); |
| 114 |
ACPI_OPTION ("-o <File>", "Redirect output to file"); |
| 115 |
ACPI_OPTION ("-r <Address>", "Dump tables from specified RSDP"); |
| 116 |
ACPI_OPTION ("-s", "Print table summaries only"); |
| 117 |
ACPI_OPTION ("-v", "Display version information"); |
| 118 |
ACPI_OPTION ("-vd", "Display build date and time"); |
| 119 |
ACPI_OPTION ("-z", "Verbose mode"); |
| 120 |
|
| 121 |
ACPI_USAGE_TEXT ("\nTable Options:\n"); |
| 122 |
|
| 123 |
ACPI_OPTION ("-a <Address>", "Get table via a physical address"); |
| 124 |
ACPI_OPTION ("-c <on|off>", "Turning on/off customized table dumping"); |
| 125 |
ACPI_OPTION ("-f <BinaryFile>", "Get table via a binary file"); |
| 126 |
ACPI_OPTION ("-n <Signature>", "Get table via a name/signature"); |
| 127 |
ACPI_OPTION ("-x", "Use RSDT instead of XSDT"); |
| 128 |
|
| 129 |
ACPI_USAGE_TEXT ( |
| 130 |
"\n" |
| 131 |
"Invocation without parameters dumps all available tables\n" |
| 132 |
"Multiple mixed instances of -a, -f, and -n are supported\n\n"); |
| 133 |
} |
| 134 |
|
| 135 |
|
| 136 |
|
| 137 |
|
| 138 |
|
| 139 |
|
| 140 |
|
| 141 |
|
| 142 |
|
| 143 |
|
| 144 |
|
| 145 |
|
| 146 |
|
| 147 |
|
| 148 |
|
| 149 |
static int |
| 150 |
ApInsertAction ( |
| 151 |
char *Argument, |
| 152 |
UINT32 ToBeDone) |
| 153 |
{ |
| 154 |
|
| 155 |
|
| 156 |
|
| 157 |
ActionTable [CurrentAction].Argument = Argument; |
| 158 |
ActionTable [CurrentAction].ToBeDone = ToBeDone; |
| 159 |
|
| 160 |
CurrentAction++; |
| 161 |
if (CurrentAction > AP_MAX_ACTIONS) |
| 162 |
{ |
| 163 |
fprintf (stderr, "Too many table options (max %d)\n", AP_MAX_ACTIONS); |
| 164 |
return (-1); |
| 165 |
} |
| 166 |
|
| 167 |
return (0); |
| 168 |
} |
| 169 |
|
| 170 |
|
| 171 |
|
| 172 |
|
| 173 |
|
| 174 |
|
| 175 |
|
| 176 |
|
| 177 |
|
| 178 |
|
| 179 |
|
| 180 |
|
| 181 |
|
| 182 |
|
| 183 |
|
| 184 |
static int |
| 185 |
ApDoOptions ( |
| 186 |
int argc, |
| 187 |
char **argv) |
| 188 |
{ |
| 189 |
int j; |
| 190 |
ACPI_STATUS Status; |
| 191 |
|
| 192 |
|
| 193 |
|
| 194 |
|
| 195 |
while ((j = AcpiGetopt (argc, argv, AP_SUPPORTED_OPTIONS)) != ACPI_OPT_END) switch (j) |
| 196 |
{ |
| 197 |
|
| 198 |
|
| 199 |
|
| 200 |
case 'b': |
| 201 |
|
| 202 |
Gbl_BinaryMode = TRUE; |
| 203 |
continue; |
| 204 |
|
| 205 |
case 'c': |
| 206 |
|
| 207 |
if (!strcmp (AcpiGbl_Optarg, "on")) |
| 208 |
{ |
| 209 |
Gbl_DumpCustomizedTables = TRUE; |
| 210 |
} |
| 211 |
else if (!strcmp (AcpiGbl_Optarg, "off")) |
| 212 |
{ |
| 213 |
Gbl_DumpCustomizedTables = FALSE; |
| 214 |
} |
| 215 |
else |
| 216 |
{ |
| 217 |
fprintf (stderr, "%s: Cannot handle this switch, please use on|off\n", |
| 218 |
AcpiGbl_Optarg); |
| 219 |
return (-1); |
| 220 |
} |
| 221 |
continue; |
| 222 |
|
| 223 |
case 'h': |
| 224 |
case '?': |
| 225 |
|
| 226 |
ApDisplayUsage (); |
| 227 |
return (1); |
| 228 |
|
| 229 |
case 'o': |
| 230 |
|
| 231 |
if (ApOpenOutputFile (AcpiGbl_Optarg)) |
| 232 |
{ |
| 233 |
return (-1); |
| 234 |
} |
| 235 |
continue; |
| 236 |
|
| 237 |
case 'r': |
| 238 |
|
| 239 |
Status = AcpiUtStrtoul64 (AcpiGbl_Optarg, &Gbl_RsdpBase); |
| 240 |
if (ACPI_FAILURE (Status)) |
| 241 |
{ |
| 242 |
fprintf (stderr, "%s: Could not convert to a physical address\n", |
| 243 |
AcpiGbl_Optarg); |
| 244 |
return (-1); |
| 245 |
} |
| 246 |
continue; |
| 247 |
|
| 248 |
case 's': |
| 249 |
|
| 250 |
Gbl_SummaryMode = TRUE; |
| 251 |
continue; |
| 252 |
|
| 253 |
case 'x': |
| 254 |
|
| 255 |
if (!AcpiGbl_DoNotUseXsdt) |
| 256 |
{ |
| 257 |
AcpiGbl_DoNotUseXsdt = TRUE; |
| 258 |
} |
| 259 |
else |
| 260 |
{ |
| 261 |
Gbl_DoNotDumpXsdt = TRUE; |
| 262 |
} |
| 263 |
continue; |
| 264 |
|
| 265 |
case 'v': |
| 266 |
|
| 267 |
switch (AcpiGbl_Optarg[0]) |
| 268 |
{ |
| 269 |
case '^': |
| 270 |
|
| 271 |
fprintf (stderr, ACPI_COMMON_SIGNON (AP_UTILITY_NAME)); |
| 272 |
return (1); |
| 273 |
|
| 274 |
case 'd': |
| 275 |
|
| 276 |
fprintf (stderr, ACPI_COMMON_SIGNON (AP_UTILITY_NAME)); |
| 277 |
printf (ACPI_COMMON_BUILD_TIME); |
| 278 |
return (1); |
| 279 |
|
| 280 |
default: |
| 281 |
|
| 282 |
printf ("Unknown option: -v%s\n", AcpiGbl_Optarg); |
| 283 |
return (-1); |
| 284 |
} |
| 285 |
break; |
| 286 |
|
| 287 |
case 'z': |
| 288 |
|
| 289 |
Gbl_VerboseMode = TRUE; |
| 290 |
fprintf (stderr, ACPI_COMMON_SIGNON (AP_UTILITY_NAME)); |
| 291 |
continue; |
| 292 |
|
| 293 |
|
| 294 |
|
| 295 |
|
| 296 |
case 'a': |
| 297 |
|
| 298 |
if (ApInsertAction (AcpiGbl_Optarg, AP_DUMP_TABLE_BY_ADDRESS)) |
| 299 |
{ |
| 300 |
return (-1); |
| 301 |
} |
| 302 |
break; |
| 303 |
|
| 304 |
case 'f': |
| 305 |
|
| 306 |
if (ApInsertAction (AcpiGbl_Optarg, AP_DUMP_TABLE_BY_FILE)) |
| 307 |
{ |
| 308 |
return (-1); |
| 309 |
} |
| 310 |
break; |
| 311 |
|
| 312 |
case 'n': |
| 313 |
|
| 314 |
if (ApInsertAction (AcpiGbl_Optarg, AP_DUMP_TABLE_BY_NAME)) |
| 315 |
{ |
| 316 |
return (-1); |
| 317 |
} |
| 318 |
break; |
| 319 |
|
| 320 |
default: |
| 321 |
|
| 322 |
ApDisplayUsage (); |
| 323 |
return (-1); |
| 324 |
} |
| 325 |
|
| 326 |
|
| 327 |
|
| 328 |
if (CurrentAction == 0) |
| 329 |
{ |
| 330 |
if (ApInsertAction (NULL, AP_DUMP_ALL_TABLES)) |
| 331 |
{ |
| 332 |
return (-1); |
| 333 |
} |
| 334 |
} |
| 335 |
|
| 336 |
return (0); |
| 337 |
} |
| 338 |
|
| 339 |
|
| 340 |
|
| 341 |
|
| 342 |
|
| 343 |
|
| 344 |
|
| 345 |
|
| 346 |
|
| 347 |
|
| 348 |
|
| 349 |
|
| 350 |
|
| 351 |
|
| 352 |
#if !defined(_GNU_EFI) && !defined(_EDK2_EFI) |
| 353 |
int ACPI_SYSTEM_XFACE |
| 354 |
main ( |
| 355 |
int argc, |
| 356 |
char *argv[]) |
| 357 |
#else |
| 358 |
int ACPI_SYSTEM_XFACE |
| 359 |
acpi_main ( |
| 360 |
int argc, |
| 361 |
char *argv[]) |
| 362 |
#endif |
| 363 |
{ |
| 364 |
int Status = 0; |
| 365 |
AP_DUMP_ACTION *Action; |
| 366 |
UINT32 FileSize; |
| 367 |
UINT32 i; |
| 368 |
|
| 369 |
|
| 370 |
ACPI_DEBUG_INITIALIZE (); |
| 371 |
AcpiOsInitialize (); |
| 372 |
Gbl_OutputFile = ACPI_FILE_OUT; |
| 373 |
AcpiGbl_IntegerByteWidth = 8; |
| 374 |
|
| 375 |
|
| 376 |
|
| 377 |
Status = ApDoOptions (argc, argv); |
| 378 |
if (Status > 0) |
| 379 |
{ |
| 380 |
return (0); |
| 381 |
} |
| 382 |
if (Status < 0) |
| 383 |
{ |
| 384 |
return (Status); |
| 385 |
} |
| 386 |
|
| 387 |
|
| 388 |
|
| 389 |
for (i = 0; i < CurrentAction; i++) |
| 390 |
{ |
| 391 |
Action = &ActionTable[i]; |
| 392 |
switch (Action->ToBeDone) |
| 393 |
{ |
| 394 |
case AP_DUMP_ALL_TABLES: |
| 395 |
|
| 396 |
Status = ApDumpAllTables (); |
| 397 |
break; |
| 398 |
|
| 399 |
case AP_DUMP_TABLE_BY_ADDRESS: |
| 400 |
|
| 401 |
Status = ApDumpTableByAddress (Action->Argument); |
| 402 |
break; |
| 403 |
|
| 404 |
case AP_DUMP_TABLE_BY_NAME: |
| 405 |
|
| 406 |
Status = ApDumpTableByName (Action->Argument); |
| 407 |
break; |
| 408 |
|
| 409 |
case AP_DUMP_TABLE_BY_FILE: |
| 410 |
|
| 411 |
Status = ApDumpTableFromFile (Action->Argument); |
| 412 |
break; |
| 413 |
|
| 414 |
default: |
| 415 |
|
| 416 |
fprintf (stderr, "Internal error, invalid action: 0x%X\n", |
| 417 |
Action->ToBeDone); |
| 418 |
return (-1); |
| 419 |
} |
| 420 |
|
| 421 |
if (Status) |
| 422 |
{ |
| 423 |
return (Status); |
| 424 |
} |
| 425 |
} |
| 426 |
|
| 427 |
if (Gbl_OutputFilename) |
| 428 |
{ |
| 429 |
if (Gbl_VerboseMode) |
| 430 |
{ |
| 431 |
|
| 432 |
|
| 433 |
FileSize = CmGetFileSize (Gbl_OutputFile); |
| 434 |
fprintf (stderr, "Output file %s contains 0x%X (%u) bytes\n\n", |
| 435 |
Gbl_OutputFilename, FileSize, FileSize); |
| 436 |
} |
| 437 |
|
| 438 |
fclose (Gbl_OutputFile); |
| 439 |
} |
| 440 |
|
| 441 |
return (Status); |
| 442 |
} |