rscalc.c 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718
  1. /*******************************************************************************
  2. *
  3. * Module Name: rscalc - Calculate stream and list lengths
  4. *
  5. ******************************************************************************/
  6. /*
  7. * Copyright (C) 2000 - 2015, Intel Corp.
  8. * All rights reserved.
  9. *
  10. * Redistribution and use in source and binary forms, with or without
  11. * modification, are permitted provided that the following conditions
  12. * are met:
  13. * 1. Redistributions of source code must retain the above copyright
  14. * notice, this list of conditions, and the following disclaimer,
  15. * without modification.
  16. * 2. Redistributions in binary form must reproduce at minimum a disclaimer
  17. * substantially similar to the "NO WARRANTY" disclaimer below
  18. * ("Disclaimer") and any redistribution must be conditioned upon
  19. * including a substantially similar Disclaimer requirement for further
  20. * binary redistribution.
  21. * 3. Neither the names of the above-listed copyright holders nor the names
  22. * of any contributors may be used to endorse or promote products derived
  23. * from this software without specific prior written permission.
  24. *
  25. * Alternatively, this software may be distributed under the terms of the
  26. * GNU General Public License ("GPL") version 2 as published by the Free
  27. * Software Foundation.
  28. *
  29. * NO WARRANTY
  30. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  31. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  32. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
  33. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  34. * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  35. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  36. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  37. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
  38. * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
  39. * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  40. * POSSIBILITY OF SUCH DAMAGES.
  41. */
  42. #include <acpi/acpi.h>
  43. #include "accommon.h"
  44. #include "acresrc.h"
  45. #include "acnamesp.h"
  46. #define _COMPONENT ACPI_RESOURCES
  47. ACPI_MODULE_NAME("rscalc")
  48. /* Local prototypes */
  49. static u8 acpi_rs_count_set_bits(u16 bit_field);
  50. static acpi_rs_length
  51. acpi_rs_struct_option_length(struct acpi_resource_source *resource_source);
  52. static u32
  53. acpi_rs_stream_option_length(u32 resource_length, u32 minimum_total_length);
  54. /*******************************************************************************
  55. *
  56. * FUNCTION: acpi_rs_count_set_bits
  57. *
  58. * PARAMETERS: bit_field - Field in which to count bits
  59. *
  60. * RETURN: Number of bits set within the field
  61. *
  62. * DESCRIPTION: Count the number of bits set in a resource field. Used for
  63. * (Short descriptor) interrupt and DMA lists.
  64. *
  65. ******************************************************************************/
  66. static u8 acpi_rs_count_set_bits(u16 bit_field)
  67. {
  68. u8 bits_set;
  69. ACPI_FUNCTION_ENTRY();
  70. for (bits_set = 0; bit_field; bits_set++) {
  71. /* Zero the least significant bit that is set */
  72. bit_field &= (u16) (bit_field - 1);
  73. }
  74. return (bits_set);
  75. }
  76. /*******************************************************************************
  77. *
  78. * FUNCTION: acpi_rs_struct_option_length
  79. *
  80. * PARAMETERS: resource_source - Pointer to optional descriptor field
  81. *
  82. * RETURN: Status
  83. *
  84. * DESCRIPTION: Common code to handle optional resource_source_index and
  85. * resource_source fields in some Large descriptors. Used during
  86. * list-to-stream conversion
  87. *
  88. ******************************************************************************/
  89. static acpi_rs_length
  90. acpi_rs_struct_option_length(struct acpi_resource_source *resource_source)
  91. {
  92. ACPI_FUNCTION_ENTRY();
  93. /*
  94. * If the resource_source string is valid, return the size of the string
  95. * (string_length includes the NULL terminator) plus the size of the
  96. * resource_source_index (1).
  97. */
  98. if (resource_source->string_ptr) {
  99. return ((acpi_rs_length) (resource_source->string_length + 1));
  100. }
  101. return (0);
  102. }
  103. /*******************************************************************************
  104. *
  105. * FUNCTION: acpi_rs_stream_option_length
  106. *
  107. * PARAMETERS: resource_length - Length from the resource header
  108. * minimum_total_length - Minimum length of this resource, before
  109. * any optional fields. Includes header size
  110. *
  111. * RETURN: Length of optional string (0 if no string present)
  112. *
  113. * DESCRIPTION: Common code to handle optional resource_source_index and
  114. * resource_source fields in some Large descriptors. Used during
  115. * stream-to-list conversion
  116. *
  117. ******************************************************************************/
  118. static u32
  119. acpi_rs_stream_option_length(u32 resource_length,
  120. u32 minimum_aml_resource_length)
  121. {
  122. u32 string_length = 0;
  123. ACPI_FUNCTION_ENTRY();
  124. /*
  125. * The resource_source_index and resource_source are optional elements of some
  126. * Large-type resource descriptors.
  127. */
  128. /*
  129. * If the length of the actual resource descriptor is greater than the ACPI
  130. * spec-defined minimum length, it means that a resource_source_index exists
  131. * and is followed by a (required) null terminated string. The string length
  132. * (including the null terminator) is the resource length minus the minimum
  133. * length, minus one byte for the resource_source_index itself.
  134. */
  135. if (resource_length > minimum_aml_resource_length) {
  136. /* Compute the length of the optional string */
  137. string_length =
  138. resource_length - minimum_aml_resource_length - 1;
  139. }
  140. /*
  141. * Round the length up to a multiple of the native word in order to
  142. * guarantee that the entire resource descriptor is native word aligned
  143. */
  144. return ((u32) ACPI_ROUND_UP_TO_NATIVE_WORD(string_length));
  145. }
  146. /*******************************************************************************
  147. *
  148. * FUNCTION: acpi_rs_get_aml_length
  149. *
  150. * PARAMETERS: resource - Pointer to the resource linked list
  151. * resource_list_size - Size of the resource linked list
  152. * size_needed - Where the required size is returned
  153. *
  154. * RETURN: Status
  155. *
  156. * DESCRIPTION: Takes a linked list of internal resource descriptors and
  157. * calculates the size buffer needed to hold the corresponding
  158. * external resource byte stream.
  159. *
  160. ******************************************************************************/
  161. acpi_status
  162. acpi_rs_get_aml_length(struct acpi_resource *resource,
  163. acpi_size resource_list_size, acpi_size * size_needed)
  164. {
  165. acpi_size aml_size_needed = 0;
  166. struct acpi_resource *resource_end;
  167. acpi_rs_length total_size;
  168. ACPI_FUNCTION_TRACE(rs_get_aml_length);
  169. /* Traverse entire list of internal resource descriptors */
  170. resource_end =
  171. ACPI_ADD_PTR(struct acpi_resource, resource, resource_list_size);
  172. while (resource < resource_end) {
  173. /* Validate the descriptor type */
  174. if (resource->type > ACPI_RESOURCE_TYPE_MAX) {
  175. return_ACPI_STATUS(AE_AML_INVALID_RESOURCE_TYPE);
  176. }
  177. /* Sanity check the length. It must not be zero, or we loop forever */
  178. if (!resource->length) {
  179. return_ACPI_STATUS(AE_AML_BAD_RESOURCE_LENGTH);
  180. }
  181. /* Get the base size of the (external stream) resource descriptor */
  182. total_size = acpi_gbl_aml_resource_sizes[resource->type];
  183. /*
  184. * Augment the base size for descriptors with optional and/or
  185. * variable-length fields
  186. */
  187. switch (resource->type) {
  188. case ACPI_RESOURCE_TYPE_IRQ:
  189. /* Length can be 3 or 2 */
  190. if (resource->data.irq.descriptor_length == 2) {
  191. total_size--;
  192. }
  193. break;
  194. case ACPI_RESOURCE_TYPE_START_DEPENDENT:
  195. /* Length can be 1 or 0 */
  196. if (resource->data.irq.descriptor_length == 0) {
  197. total_size--;
  198. }
  199. break;
  200. case ACPI_RESOURCE_TYPE_VENDOR:
  201. /*
  202. * Vendor Defined Resource:
  203. * For a Vendor Specific resource, if the Length is between 1 and 7
  204. * it will be created as a Small Resource data type, otherwise it
  205. * is a Large Resource data type.
  206. */
  207. if (resource->data.vendor.byte_length > 7) {
  208. /* Base size of a Large resource descriptor */
  209. total_size =
  210. sizeof(struct aml_resource_large_header);
  211. }
  212. /* Add the size of the vendor-specific data */
  213. total_size = (acpi_rs_length)
  214. (total_size + resource->data.vendor.byte_length);
  215. break;
  216. case ACPI_RESOURCE_TYPE_END_TAG:
  217. /*
  218. * End Tag:
  219. * We are done -- return the accumulated total size.
  220. */
  221. *size_needed = aml_size_needed + total_size;
  222. /* Normal exit */
  223. return_ACPI_STATUS(AE_OK);
  224. case ACPI_RESOURCE_TYPE_ADDRESS16:
  225. /*
  226. * 16-Bit Address Resource:
  227. * Add the size of the optional resource_source info
  228. */
  229. total_size = (acpi_rs_length)
  230. (total_size +
  231. acpi_rs_struct_option_length(&resource->data.
  232. address16.
  233. resource_source));
  234. break;
  235. case ACPI_RESOURCE_TYPE_ADDRESS32:
  236. /*
  237. * 32-Bit Address Resource:
  238. * Add the size of the optional resource_source info
  239. */
  240. total_size = (acpi_rs_length)
  241. (total_size +
  242. acpi_rs_struct_option_length(&resource->data.
  243. address32.
  244. resource_source));
  245. break;
  246. case ACPI_RESOURCE_TYPE_ADDRESS64:
  247. /*
  248. * 64-Bit Address Resource:
  249. * Add the size of the optional resource_source info
  250. */
  251. total_size = (acpi_rs_length)
  252. (total_size +
  253. acpi_rs_struct_option_length(&resource->data.
  254. address64.
  255. resource_source));
  256. break;
  257. case ACPI_RESOURCE_TYPE_EXTENDED_IRQ:
  258. /*
  259. * Extended IRQ Resource:
  260. * Add the size of each additional optional interrupt beyond the
  261. * required 1 (4 bytes for each u32 interrupt number)
  262. */
  263. total_size = (acpi_rs_length)
  264. (total_size +
  265. ((resource->data.extended_irq.interrupt_count -
  266. 1) * 4) +
  267. /* Add the size of the optional resource_source info */
  268. acpi_rs_struct_option_length(&resource->data.
  269. extended_irq.
  270. resource_source));
  271. break;
  272. case ACPI_RESOURCE_TYPE_GPIO:
  273. total_size =
  274. (acpi_rs_length) (total_size +
  275. (resource->data.gpio.
  276. pin_table_length * 2) +
  277. resource->data.gpio.
  278. resource_source.string_length +
  279. resource->data.gpio.
  280. vendor_length);
  281. break;
  282. case ACPI_RESOURCE_TYPE_SERIAL_BUS:
  283. total_size =
  284. acpi_gbl_aml_resource_serial_bus_sizes[resource->
  285. data.
  286. common_serial_bus.
  287. type];
  288. total_size = (acpi_rs_length) (total_size +
  289. resource->data.
  290. i2c_serial_bus.
  291. resource_source.
  292. string_length +
  293. resource->data.
  294. i2c_serial_bus.
  295. vendor_length);
  296. break;
  297. default:
  298. break;
  299. }
  300. /* Update the total */
  301. aml_size_needed += total_size;
  302. /* Point to the next object */
  303. resource =
  304. ACPI_ADD_PTR(struct acpi_resource, resource,
  305. resource->length);
  306. }
  307. /* Did not find an end_tag resource descriptor */
  308. return_ACPI_STATUS(AE_AML_NO_RESOURCE_END_TAG);
  309. }
  310. /*******************************************************************************
  311. *
  312. * FUNCTION: acpi_rs_get_list_length
  313. *
  314. * PARAMETERS: aml_buffer - Pointer to the resource byte stream
  315. * aml_buffer_length - Size of aml_buffer
  316. * size_needed - Where the size needed is returned
  317. *
  318. * RETURN: Status
  319. *
  320. * DESCRIPTION: Takes an external resource byte stream and calculates the size
  321. * buffer needed to hold the corresponding internal resource
  322. * descriptor linked list.
  323. *
  324. ******************************************************************************/
  325. acpi_status
  326. acpi_rs_get_list_length(u8 * aml_buffer,
  327. u32 aml_buffer_length, acpi_size * size_needed)
  328. {
  329. acpi_status status;
  330. u8 *end_aml;
  331. u8 *buffer;
  332. u32 buffer_size;
  333. u16 temp16;
  334. u16 resource_length;
  335. u32 extra_struct_bytes;
  336. u8 resource_index;
  337. u8 minimum_aml_resource_length;
  338. union aml_resource *aml_resource;
  339. ACPI_FUNCTION_TRACE(rs_get_list_length);
  340. *size_needed = ACPI_RS_SIZE_MIN; /* Minimum size is one end_tag */
  341. end_aml = aml_buffer + aml_buffer_length;
  342. /* Walk the list of AML resource descriptors */
  343. while (aml_buffer < end_aml) {
  344. /* Validate the Resource Type and Resource Length */
  345. status =
  346. acpi_ut_validate_resource(NULL, aml_buffer,
  347. &resource_index);
  348. if (ACPI_FAILURE(status)) {
  349. /*
  350. * Exit on failure. Cannot continue because the descriptor length
  351. * may be bogus also.
  352. */
  353. return_ACPI_STATUS(status);
  354. }
  355. aml_resource = (void *)aml_buffer;
  356. /* Get the resource length and base (minimum) AML size */
  357. resource_length = acpi_ut_get_resource_length(aml_buffer);
  358. minimum_aml_resource_length =
  359. acpi_gbl_resource_aml_sizes[resource_index];
  360. /*
  361. * Augment the size for descriptors with optional
  362. * and/or variable length fields
  363. */
  364. extra_struct_bytes = 0;
  365. buffer =
  366. aml_buffer + acpi_ut_get_resource_header_length(aml_buffer);
  367. switch (acpi_ut_get_resource_type(aml_buffer)) {
  368. case ACPI_RESOURCE_NAME_IRQ:
  369. /*
  370. * IRQ Resource:
  371. * Get the number of bits set in the 16-bit IRQ mask
  372. */
  373. ACPI_MOVE_16_TO_16(&temp16, buffer);
  374. extra_struct_bytes = acpi_rs_count_set_bits(temp16);
  375. break;
  376. case ACPI_RESOURCE_NAME_DMA:
  377. /*
  378. * DMA Resource:
  379. * Get the number of bits set in the 8-bit DMA mask
  380. */
  381. extra_struct_bytes = acpi_rs_count_set_bits(*buffer);
  382. break;
  383. case ACPI_RESOURCE_NAME_VENDOR_SMALL:
  384. case ACPI_RESOURCE_NAME_VENDOR_LARGE:
  385. /*
  386. * Vendor Resource:
  387. * Get the number of vendor data bytes
  388. */
  389. extra_struct_bytes = resource_length;
  390. /*
  391. * There is already one byte included in the minimum
  392. * descriptor size. If there are extra struct bytes,
  393. * subtract one from the count.
  394. */
  395. if (extra_struct_bytes) {
  396. extra_struct_bytes--;
  397. }
  398. break;
  399. case ACPI_RESOURCE_NAME_END_TAG:
  400. /*
  401. * End Tag: This is the normal exit
  402. */
  403. return_ACPI_STATUS(AE_OK);
  404. case ACPI_RESOURCE_NAME_ADDRESS32:
  405. case ACPI_RESOURCE_NAME_ADDRESS16:
  406. case ACPI_RESOURCE_NAME_ADDRESS64:
  407. /*
  408. * Address Resource:
  409. * Add the size of the optional resource_source
  410. */
  411. extra_struct_bytes =
  412. acpi_rs_stream_option_length(resource_length,
  413. minimum_aml_resource_length);
  414. break;
  415. case ACPI_RESOURCE_NAME_EXTENDED_IRQ:
  416. /*
  417. * Extended IRQ Resource:
  418. * Using the interrupt_table_length, add 4 bytes for each additional
  419. * interrupt. Note: at least one interrupt is required and is
  420. * included in the minimum descriptor size (reason for the -1)
  421. */
  422. extra_struct_bytes = (buffer[1] - 1) * sizeof(u32);
  423. /* Add the size of the optional resource_source */
  424. extra_struct_bytes +=
  425. acpi_rs_stream_option_length(resource_length -
  426. extra_struct_bytes,
  427. minimum_aml_resource_length);
  428. break;
  429. case ACPI_RESOURCE_NAME_GPIO:
  430. /* Vendor data is optional */
  431. if (aml_resource->gpio.vendor_length) {
  432. extra_struct_bytes +=
  433. aml_resource->gpio.vendor_offset -
  434. aml_resource->gpio.pin_table_offset +
  435. aml_resource->gpio.vendor_length;
  436. } else {
  437. extra_struct_bytes +=
  438. aml_resource->large_header.resource_length +
  439. sizeof(struct aml_resource_large_header) -
  440. aml_resource->gpio.pin_table_offset;
  441. }
  442. break;
  443. case ACPI_RESOURCE_NAME_SERIAL_BUS:
  444. minimum_aml_resource_length =
  445. acpi_gbl_resource_aml_serial_bus_sizes
  446. [aml_resource->common_serial_bus.type];
  447. extra_struct_bytes +=
  448. aml_resource->common_serial_bus.resource_length -
  449. minimum_aml_resource_length;
  450. break;
  451. default:
  452. break;
  453. }
  454. /*
  455. * Update the required buffer size for the internal descriptor structs
  456. *
  457. * Important: Round the size up for the appropriate alignment. This
  458. * is a requirement on IA64.
  459. */
  460. if (acpi_ut_get_resource_type(aml_buffer) ==
  461. ACPI_RESOURCE_NAME_SERIAL_BUS) {
  462. buffer_size =
  463. acpi_gbl_resource_struct_serial_bus_sizes
  464. [aml_resource->common_serial_bus.type] +
  465. extra_struct_bytes;
  466. } else {
  467. buffer_size =
  468. acpi_gbl_resource_struct_sizes[resource_index] +
  469. extra_struct_bytes;
  470. }
  471. buffer_size = (u32)ACPI_ROUND_UP_TO_NATIVE_WORD(buffer_size);
  472. *size_needed += buffer_size;
  473. ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES,
  474. "Type %.2X, AmlLength %.2X InternalLength %.2X\n",
  475. acpi_ut_get_resource_type(aml_buffer),
  476. acpi_ut_get_descriptor_length(aml_buffer),
  477. buffer_size));
  478. /*
  479. * Point to the next resource within the AML stream using the length
  480. * contained in the resource descriptor header
  481. */
  482. aml_buffer += acpi_ut_get_descriptor_length(aml_buffer);
  483. }
  484. /* Did not find an end_tag resource descriptor */
  485. return_ACPI_STATUS(AE_AML_NO_RESOURCE_END_TAG);
  486. }
  487. /*******************************************************************************
  488. *
  489. * FUNCTION: acpi_rs_get_pci_routing_table_length
  490. *
  491. * PARAMETERS: package_object - Pointer to the package object
  492. * buffer_size_needed - u32 pointer of the size buffer
  493. * needed to properly return the
  494. * parsed data
  495. *
  496. * RETURN: Status
  497. *
  498. * DESCRIPTION: Given a package representing a PCI routing table, this
  499. * calculates the size of the corresponding linked list of
  500. * descriptions.
  501. *
  502. ******************************************************************************/
  503. acpi_status
  504. acpi_rs_get_pci_routing_table_length(union acpi_operand_object *package_object,
  505. acpi_size * buffer_size_needed)
  506. {
  507. u32 number_of_elements;
  508. acpi_size temp_size_needed = 0;
  509. union acpi_operand_object **top_object_list;
  510. u32 index;
  511. union acpi_operand_object *package_element;
  512. union acpi_operand_object **sub_object_list;
  513. u8 name_found;
  514. u32 table_index;
  515. ACPI_FUNCTION_TRACE(rs_get_pci_routing_table_length);
  516. number_of_elements = package_object->package.count;
  517. /*
  518. * Calculate the size of the return buffer.
  519. * The base size is the number of elements * the sizes of the
  520. * structures. Additional space for the strings is added below.
  521. * The minus one is to subtract the size of the u8 Source[1]
  522. * member because it is added below.
  523. *
  524. * But each PRT_ENTRY structure has a pointer to a string and
  525. * the size of that string must be found.
  526. */
  527. top_object_list = package_object->package.elements;
  528. for (index = 0; index < number_of_elements; index++) {
  529. /* Dereference the subpackage */
  530. package_element = *top_object_list;
  531. /* We must have a valid Package object */
  532. if (!package_element ||
  533. (package_element->common.type != ACPI_TYPE_PACKAGE)) {
  534. return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
  535. }
  536. /*
  537. * The sub_object_list will now point to an array of the
  538. * four IRQ elements: Address, Pin, Source and source_index
  539. */
  540. sub_object_list = package_element->package.elements;
  541. /* Scan the irq_table_elements for the Source Name String */
  542. name_found = FALSE;
  543. for (table_index = 0;
  544. table_index < package_element->package.count
  545. && !name_found; table_index++) {
  546. if (*sub_object_list && /* Null object allowed */
  547. ((ACPI_TYPE_STRING ==
  548. (*sub_object_list)->common.type) ||
  549. ((ACPI_TYPE_LOCAL_REFERENCE ==
  550. (*sub_object_list)->common.type) &&
  551. ((*sub_object_list)->reference.class ==
  552. ACPI_REFCLASS_NAME)))) {
  553. name_found = TRUE;
  554. } else {
  555. /* Look at the next element */
  556. sub_object_list++;
  557. }
  558. }
  559. temp_size_needed += (sizeof(struct acpi_pci_routing_table) - 4);
  560. /* Was a String type found? */
  561. if (name_found) {
  562. if ((*sub_object_list)->common.type == ACPI_TYPE_STRING) {
  563. /*
  564. * The length String.Length field does not include the
  565. * terminating NULL, add 1
  566. */
  567. temp_size_needed += ((acpi_size)
  568. (*sub_object_list)->string.
  569. length + 1);
  570. } else {
  571. temp_size_needed += acpi_ns_get_pathname_length((*sub_object_list)->reference.node);
  572. }
  573. } else {
  574. /*
  575. * If no name was found, then this is a NULL, which is
  576. * translated as a u32 zero.
  577. */
  578. temp_size_needed += sizeof(u32);
  579. }
  580. /* Round up the size since each element must be aligned */
  581. temp_size_needed = ACPI_ROUND_UP_TO_64BIT(temp_size_needed);
  582. /* Point to the next union acpi_operand_object */
  583. top_object_list++;
  584. }
  585. /*
  586. * Add an extra element to the end of the list, essentially a
  587. * NULL terminator
  588. */
  589. *buffer_size_needed =
  590. temp_size_needed + sizeof(struct acpi_pci_routing_table);
  591. return_ACPI_STATUS(AE_OK);
  592. }