forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-01-04 1543e317f1da31b75942316931e8f491a8920811
kernel/drivers/acpi/acpica/exconvrt.c
....@@ -3,7 +3,7 @@
33 *
44 * Module Name: exconvrt - Object conversion routines
55 *
6
- * Copyright (C) 2000 - 2018, Intel Corp.
6
+ * Copyright (C) 2000 - 2020, Intel Corp.
77 *
88 *****************************************************************************/
99
....@@ -323,7 +323,7 @@
323323
324324 /* hex_length: 2 ascii hex chars per data byte */
325325
326
- hex_length = ACPI_MUL_2(data_width);
326
+ hex_length = (data_width * 2);
327327 for (i = 0, j = (hex_length - 1); i < hex_length; i++, j--) {
328328
329329 /* Get one hex digit, most significant digits first */
....@@ -364,7 +364,8 @@
364364 *
365365 * RETURN: Status
366366 *
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.
368369 *
369370 ******************************************************************************/
370371
....@@ -393,9 +394,11 @@
393394
394395 switch (type) {
395396 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
+ */
399402 string_length = ACPI_MAX_DECIMAL_DIGITS;
400403 base = 10;
401404 break;
....@@ -440,8 +443,10 @@
440443 switch (type) {
441444 case ACPI_EXPLICIT_CONVERT_DECIMAL: /* Used by to_decimal_string */
442445 /*
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."
445450 */
446451 base = 10;
447452
....@@ -462,20 +467,29 @@
462467
463468 case ACPI_IMPLICIT_CONVERT_HEX:
464469 /*
470
+ * Implicit buffer-to-string conversion
471
+ *
465472 * 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
467474 * two-character hexadecimal numbers, each separated by a space."
475
+ *
476
+ * Each hex number is prefixed with 0x (11/2018)
468477 */
469478 separator = ' ';
470
- string_length = (obj_desc->buffer.length * 3);
479
+ string_length = (obj_desc->buffer.length * 5);
471480 break;
472481
473
- case ACPI_EXPLICIT_CONVERT_HEX: /* Used by to_hex_string */
482
+ case ACPI_EXPLICIT_CONVERT_HEX:
474483 /*
484
+ * Explicit conversion from the to_hex_string ASL operator.
485
+ *
475486 * From ACPI: "If Data is a buffer, it is converted to a string of
476487 * hexadecimal values separated by commas."
488
+ *
489
+ * Each hex number is prefixed with 0x (11/2018)
477490 */
478
- string_length = (obj_desc->buffer.length * 3);
491
+ separator = ',';
492
+ string_length = (obj_desc->buffer.length * 5);
479493 break;
480494
481495 default:
....@@ -504,10 +518,21 @@
504518 * (separated by commas or spaces)
505519 */
506520 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
+
507529 new_buf += acpi_ex_convert_to_ascii((u64) obj_desc->
508530 buffer.pointer[i],
509531 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;
511536 }
512537
513538 /*