| .. | .. |
|---|
| 3 | 3 | * |
|---|
| 4 | 4 | * Module Name: exconvrt - Object conversion routines |
|---|
| 5 | 5 | * |
|---|
| 6 | | - * Copyright (C) 2000 - 2018, Intel Corp. |
|---|
| 6 | + * Copyright (C) 2000 - 2020, Intel Corp. |
|---|
| 7 | 7 | * |
|---|
| 8 | 8 | *****************************************************************************/ |
|---|
| 9 | 9 | |
|---|
| .. | .. |
|---|
| 323 | 323 | |
|---|
| 324 | 324 | /* hex_length: 2 ascii hex chars per data byte */ |
|---|
| 325 | 325 | |
|---|
| 326 | | - hex_length = ACPI_MUL_2(data_width); |
|---|
| 326 | + hex_length = (data_width * 2); |
|---|
| 327 | 327 | for (i = 0, j = (hex_length - 1); i < hex_length; i++, j--) { |
|---|
| 328 | 328 | |
|---|
| 329 | 329 | /* Get one hex digit, most significant digits first */ |
|---|
| .. | .. |
|---|
| 364 | 364 | * |
|---|
| 365 | 365 | * RETURN: Status |
|---|
| 366 | 366 | * |
|---|
| 367 | | - * DESCRIPTION: Convert an ACPI Object to a string |
|---|
| 367 | + * DESCRIPTION: Convert an ACPI Object to a string. Supports both implicit |
|---|
| 368 | + * and explicit conversions and related rules. |
|---|
| 368 | 369 | * |
|---|
| 369 | 370 | ******************************************************************************/ |
|---|
| 370 | 371 | |
|---|
| .. | .. |
|---|
| 393 | 394 | |
|---|
| 394 | 395 | switch (type) { |
|---|
| 395 | 396 | case ACPI_EXPLICIT_CONVERT_DECIMAL: |
|---|
| 396 | | - |
|---|
| 397 | | - /* Make room for maximum decimal number */ |
|---|
| 398 | | - |
|---|
| 397 | + /* |
|---|
| 398 | + * From to_decimal_string, integer source. |
|---|
| 399 | + * |
|---|
| 400 | + * Make room for the maximum decimal number size |
|---|
| 401 | + */ |
|---|
| 399 | 402 | string_length = ACPI_MAX_DECIMAL_DIGITS; |
|---|
| 400 | 403 | base = 10; |
|---|
| 401 | 404 | break; |
|---|
| .. | .. |
|---|
| 440 | 443 | switch (type) { |
|---|
| 441 | 444 | case ACPI_EXPLICIT_CONVERT_DECIMAL: /* Used by to_decimal_string */ |
|---|
| 442 | 445 | /* |
|---|
| 443 | | - * From ACPI: "If Data is a buffer, it is converted to a string of |
|---|
| 444 | | - * decimal values separated by commas." |
|---|
| 446 | + * Explicit conversion from the to_decimal_string ASL operator. |
|---|
| 447 | + * |
|---|
| 448 | + * From ACPI: "If the input is a buffer, it is converted to a |
|---|
| 449 | + * a string of decimal values separated by commas." |
|---|
| 445 | 450 | */ |
|---|
| 446 | 451 | base = 10; |
|---|
| 447 | 452 | |
|---|
| .. | .. |
|---|
| 462 | 467 | |
|---|
| 463 | 468 | case ACPI_IMPLICIT_CONVERT_HEX: |
|---|
| 464 | 469 | /* |
|---|
| 470 | + * Implicit buffer-to-string conversion |
|---|
| 471 | + * |
|---|
| 465 | 472 | * From the ACPI spec: |
|---|
| 466 | | - *"The entire contents of the buffer are converted to a string of |
|---|
| 473 | + * "The entire contents of the buffer are converted to a string of |
|---|
| 467 | 474 | * two-character hexadecimal numbers, each separated by a space." |
|---|
| 475 | + * |
|---|
| 476 | + * Each hex number is prefixed with 0x (11/2018) |
|---|
| 468 | 477 | */ |
|---|
| 469 | 478 | separator = ' '; |
|---|
| 470 | | - string_length = (obj_desc->buffer.length * 3); |
|---|
| 479 | + string_length = (obj_desc->buffer.length * 5); |
|---|
| 471 | 480 | break; |
|---|
| 472 | 481 | |
|---|
| 473 | | - case ACPI_EXPLICIT_CONVERT_HEX: /* Used by to_hex_string */ |
|---|
| 482 | + case ACPI_EXPLICIT_CONVERT_HEX: |
|---|
| 474 | 483 | /* |
|---|
| 484 | + * Explicit conversion from the to_hex_string ASL operator. |
|---|
| 485 | + * |
|---|
| 475 | 486 | * From ACPI: "If Data is a buffer, it is converted to a string of |
|---|
| 476 | 487 | * hexadecimal values separated by commas." |
|---|
| 488 | + * |
|---|
| 489 | + * Each hex number is prefixed with 0x (11/2018) |
|---|
| 477 | 490 | */ |
|---|
| 478 | | - string_length = (obj_desc->buffer.length * 3); |
|---|
| 491 | + separator = ','; |
|---|
| 492 | + string_length = (obj_desc->buffer.length * 5); |
|---|
| 479 | 493 | break; |
|---|
| 480 | 494 | |
|---|
| 481 | 495 | default: |
|---|
| .. | .. |
|---|
| 504 | 518 | * (separated by commas or spaces) |
|---|
| 505 | 519 | */ |
|---|
| 506 | 520 | for (i = 0; i < obj_desc->buffer.length; i++) { |
|---|
| 521 | + if (base == 16) { |
|---|
| 522 | + |
|---|
| 523 | + /* Emit 0x prefix for explicit/implicit hex conversion */ |
|---|
| 524 | + |
|---|
| 525 | + *new_buf++ = '0'; |
|---|
| 526 | + *new_buf++ = 'x'; |
|---|
| 527 | + } |
|---|
| 528 | + |
|---|
| 507 | 529 | new_buf += acpi_ex_convert_to_ascii((u64) obj_desc-> |
|---|
| 508 | 530 | buffer.pointer[i], |
|---|
| 509 | 531 | base, new_buf, 1); |
|---|
| 510 | | - *new_buf++ = separator; /* each separated by a comma or space */ |
|---|
| 532 | + |
|---|
| 533 | + /* Each digit is separated by either a comma or space */ |
|---|
| 534 | + |
|---|
| 535 | + *new_buf++ = separator; |
|---|
| 511 | 536 | } |
|---|
| 512 | 537 | |
|---|
| 513 | 538 | /* |
|---|