nsprepkg.c 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771
  1. /******************************************************************************
  2. *
  3. * Module Name: nsprepkg - Validation of package objects for predefined names
  4. *
  5. *****************************************************************************/
  6. /*
  7. * Copyright (C) 2000 - 2016, 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 "acnamesp.h"
  45. #include "acpredef.h"
  46. #define _COMPONENT ACPI_NAMESPACE
  47. ACPI_MODULE_NAME("nsprepkg")
  48. /* Local prototypes */
  49. static acpi_status
  50. acpi_ns_check_package_list(struct acpi_evaluate_info *info,
  51. const union acpi_predefined_info *package,
  52. union acpi_operand_object **elements, u32 count);
  53. static acpi_status
  54. acpi_ns_check_package_elements(struct acpi_evaluate_info *info,
  55. union acpi_operand_object **elements,
  56. u8 type1,
  57. u32 count1,
  58. u8 type2, u32 count2, u32 start_index);
  59. static acpi_status
  60. acpi_ns_custom_package(struct acpi_evaluate_info *info,
  61. union acpi_operand_object **elements, u32 count);
  62. /*******************************************************************************
  63. *
  64. * FUNCTION: acpi_ns_check_package
  65. *
  66. * PARAMETERS: info - Method execution information block
  67. * return_object_ptr - Pointer to the object returned from the
  68. * evaluation of a method or object
  69. *
  70. * RETURN: Status
  71. *
  72. * DESCRIPTION: Check a returned package object for the correct count and
  73. * correct type of all sub-objects.
  74. *
  75. ******************************************************************************/
  76. acpi_status
  77. acpi_ns_check_package(struct acpi_evaluate_info *info,
  78. union acpi_operand_object **return_object_ptr)
  79. {
  80. union acpi_operand_object *return_object = *return_object_ptr;
  81. const union acpi_predefined_info *package;
  82. union acpi_operand_object **elements;
  83. acpi_status status = AE_OK;
  84. u32 expected_count;
  85. u32 count;
  86. u32 i;
  87. ACPI_FUNCTION_NAME(ns_check_package);
  88. /* The package info for this name is in the next table entry */
  89. package = info->predefined + 1;
  90. ACPI_DEBUG_PRINT((ACPI_DB_NAMES,
  91. "%s Validating return Package of Type %X, Count %X\n",
  92. info->full_pathname, package->ret_info.type,
  93. return_object->package.count));
  94. /*
  95. * For variable-length Packages, we can safely remove all embedded
  96. * and trailing NULL package elements
  97. */
  98. acpi_ns_remove_null_elements(info, package->ret_info.type,
  99. return_object);
  100. /* Extract package count and elements array */
  101. elements = return_object->package.elements;
  102. count = return_object->package.count;
  103. /*
  104. * Most packages must have at least one element. The only exception
  105. * is the variable-length package (ACPI_PTYPE1_VAR).
  106. */
  107. if (!count) {
  108. if (package->ret_info.type == ACPI_PTYPE1_VAR) {
  109. return (AE_OK);
  110. }
  111. ACPI_WARN_PREDEFINED((AE_INFO, info->full_pathname,
  112. info->node_flags,
  113. "Return Package has no elements (empty)"));
  114. return (AE_AML_OPERAND_VALUE);
  115. }
  116. /*
  117. * Decode the type of the expected package contents
  118. *
  119. * PTYPE1 packages contain no subpackages
  120. * PTYPE2 packages contain subpackages
  121. */
  122. switch (package->ret_info.type) {
  123. case ACPI_PTYPE_CUSTOM:
  124. status = acpi_ns_custom_package(info, elements, count);
  125. break;
  126. case ACPI_PTYPE1_FIXED:
  127. /*
  128. * The package count is fixed and there are no subpackages
  129. *
  130. * If package is too small, exit.
  131. * If package is larger than expected, issue warning but continue
  132. */
  133. expected_count =
  134. package->ret_info.count1 + package->ret_info.count2;
  135. if (count < expected_count) {
  136. goto package_too_small;
  137. } else if (count > expected_count) {
  138. ACPI_DEBUG_PRINT((ACPI_DB_REPAIR,
  139. "%s: Return Package is larger than needed - "
  140. "found %u, expected %u\n",
  141. info->full_pathname, count,
  142. expected_count));
  143. }
  144. /* Validate all elements of the returned package */
  145. status = acpi_ns_check_package_elements(info, elements,
  146. package->ret_info.
  147. object_type1,
  148. package->ret_info.
  149. count1,
  150. package->ret_info.
  151. object_type2,
  152. package->ret_info.
  153. count2, 0);
  154. break;
  155. case ACPI_PTYPE1_VAR:
  156. /*
  157. * The package count is variable, there are no subpackages, and all
  158. * elements must be of the same type
  159. */
  160. for (i = 0; i < count; i++) {
  161. status = acpi_ns_check_object_type(info, elements,
  162. package->ret_info.
  163. object_type1, i);
  164. if (ACPI_FAILURE(status)) {
  165. return (status);
  166. }
  167. elements++;
  168. }
  169. break;
  170. case ACPI_PTYPE1_OPTION:
  171. /*
  172. * The package count is variable, there are no subpackages. There are
  173. * a fixed number of required elements, and a variable number of
  174. * optional elements.
  175. *
  176. * Check if package is at least as large as the minimum required
  177. */
  178. expected_count = package->ret_info3.count;
  179. if (count < expected_count) {
  180. goto package_too_small;
  181. }
  182. /* Variable number of sub-objects */
  183. for (i = 0; i < count; i++) {
  184. if (i < package->ret_info3.count) {
  185. /* These are the required package elements (0, 1, or 2) */
  186. status =
  187. acpi_ns_check_object_type(info, elements,
  188. package->
  189. ret_info3.
  190. object_type[i],
  191. i);
  192. if (ACPI_FAILURE(status)) {
  193. return (status);
  194. }
  195. } else {
  196. /* These are the optional package elements */
  197. status =
  198. acpi_ns_check_object_type(info, elements,
  199. package->
  200. ret_info3.
  201. tail_object_type,
  202. i);
  203. if (ACPI_FAILURE(status)) {
  204. return (status);
  205. }
  206. }
  207. elements++;
  208. }
  209. break;
  210. case ACPI_PTYPE2_REV_FIXED:
  211. /* First element is the (Integer) revision */
  212. status =
  213. acpi_ns_check_object_type(info, elements,
  214. ACPI_RTYPE_INTEGER, 0);
  215. if (ACPI_FAILURE(status)) {
  216. return (status);
  217. }
  218. elements++;
  219. count--;
  220. /* Examine the subpackages */
  221. status =
  222. acpi_ns_check_package_list(info, package, elements, count);
  223. break;
  224. case ACPI_PTYPE2_PKG_COUNT:
  225. /* First element is the (Integer) count of subpackages to follow */
  226. status =
  227. acpi_ns_check_object_type(info, elements,
  228. ACPI_RTYPE_INTEGER, 0);
  229. if (ACPI_FAILURE(status)) {
  230. return (status);
  231. }
  232. /*
  233. * Count cannot be larger than the parent package length, but allow it
  234. * to be smaller. The >= accounts for the Integer above.
  235. */
  236. expected_count = (u32)(*elements)->integer.value;
  237. if (expected_count >= count) {
  238. goto package_too_small;
  239. }
  240. count = expected_count;
  241. elements++;
  242. /* Examine the subpackages */
  243. status =
  244. acpi_ns_check_package_list(info, package, elements, count);
  245. break;
  246. case ACPI_PTYPE2:
  247. case ACPI_PTYPE2_FIXED:
  248. case ACPI_PTYPE2_MIN:
  249. case ACPI_PTYPE2_COUNT:
  250. case ACPI_PTYPE2_FIX_VAR:
  251. /*
  252. * These types all return a single Package that consists of a
  253. * variable number of subpackages.
  254. *
  255. * First, ensure that the first element is a subpackage. If not,
  256. * the BIOS may have incorrectly returned the object as a single
  257. * package instead of a Package of Packages (a common error if
  258. * there is only one entry). We may be able to repair this by
  259. * wrapping the returned Package with a new outer Package.
  260. */
  261. if (*elements
  262. && ((*elements)->common.type != ACPI_TYPE_PACKAGE)) {
  263. /* Create the new outer package and populate it */
  264. status =
  265. acpi_ns_wrap_with_package(info, return_object,
  266. return_object_ptr);
  267. if (ACPI_FAILURE(status)) {
  268. return (status);
  269. }
  270. /* Update locals to point to the new package (of 1 element) */
  271. return_object = *return_object_ptr;
  272. elements = return_object->package.elements;
  273. count = 1;
  274. }
  275. /* Examine the subpackages */
  276. status =
  277. acpi_ns_check_package_list(info, package, elements, count);
  278. break;
  279. case ACPI_PTYPE2_VAR_VAR:
  280. /*
  281. * Returns a variable list of packages, each with a variable list
  282. * of objects.
  283. */
  284. break;
  285. case ACPI_PTYPE2_UUID_PAIR:
  286. /* The package must contain pairs of (UUID + type) */
  287. if (count & 1) {
  288. expected_count = count + 1;
  289. goto package_too_small;
  290. }
  291. while (count > 0) {
  292. status = acpi_ns_check_object_type(info, elements,
  293. package->ret_info.
  294. object_type1, 0);
  295. if (ACPI_FAILURE(status)) {
  296. return (status);
  297. }
  298. /* Validate length of the UUID buffer */
  299. if ((*elements)->buffer.length != 16) {
  300. ACPI_WARN_PREDEFINED((AE_INFO,
  301. info->full_pathname,
  302. info->node_flags,
  303. "Invalid length for UUID Buffer"));
  304. return (AE_AML_OPERAND_VALUE);
  305. }
  306. status = acpi_ns_check_object_type(info, elements + 1,
  307. package->ret_info.
  308. object_type2, 0);
  309. if (ACPI_FAILURE(status)) {
  310. return (status);
  311. }
  312. elements += 2;
  313. count -= 2;
  314. }
  315. break;
  316. default:
  317. /* Should not get here if predefined info table is correct */
  318. ACPI_WARN_PREDEFINED((AE_INFO, info->full_pathname,
  319. info->node_flags,
  320. "Invalid internal return type in table entry: %X",
  321. package->ret_info.type));
  322. return (AE_AML_INTERNAL);
  323. }
  324. return (status);
  325. package_too_small:
  326. /* Error exit for the case with an incorrect package count */
  327. ACPI_WARN_PREDEFINED((AE_INFO, info->full_pathname, info->node_flags,
  328. "Return Package is too small - found %u elements, expected %u",
  329. count, expected_count));
  330. return (AE_AML_OPERAND_VALUE);
  331. }
  332. /*******************************************************************************
  333. *
  334. * FUNCTION: acpi_ns_check_package_list
  335. *
  336. * PARAMETERS: info - Method execution information block
  337. * package - Pointer to package-specific info for method
  338. * elements - Element list of parent package. All elements
  339. * of this list should be of type Package.
  340. * count - Count of subpackages
  341. *
  342. * RETURN: Status
  343. *
  344. * DESCRIPTION: Examine a list of subpackages
  345. *
  346. ******************************************************************************/
  347. static acpi_status
  348. acpi_ns_check_package_list(struct acpi_evaluate_info *info,
  349. const union acpi_predefined_info *package,
  350. union acpi_operand_object **elements, u32 count)
  351. {
  352. union acpi_operand_object *sub_package;
  353. union acpi_operand_object **sub_elements;
  354. acpi_status status;
  355. u32 expected_count;
  356. u32 i;
  357. u32 j;
  358. /*
  359. * Validate each subpackage in the parent Package
  360. *
  361. * NOTE: assumes list of subpackages contains no NULL elements.
  362. * Any NULL elements should have been removed by earlier call
  363. * to acpi_ns_remove_null_elements.
  364. */
  365. for (i = 0; i < count; i++) {
  366. sub_package = *elements;
  367. sub_elements = sub_package->package.elements;
  368. info->parent_package = sub_package;
  369. /* Each sub-object must be of type Package */
  370. status = acpi_ns_check_object_type(info, &sub_package,
  371. ACPI_RTYPE_PACKAGE, i);
  372. if (ACPI_FAILURE(status)) {
  373. return (status);
  374. }
  375. /* Examine the different types of expected subpackages */
  376. info->parent_package = sub_package;
  377. switch (package->ret_info.type) {
  378. case ACPI_PTYPE2:
  379. case ACPI_PTYPE2_PKG_COUNT:
  380. case ACPI_PTYPE2_REV_FIXED:
  381. /* Each subpackage has a fixed number of elements */
  382. expected_count =
  383. package->ret_info.count1 + package->ret_info.count2;
  384. if (sub_package->package.count < expected_count) {
  385. goto package_too_small;
  386. }
  387. status =
  388. acpi_ns_check_package_elements(info, sub_elements,
  389. package->ret_info.
  390. object_type1,
  391. package->ret_info.
  392. count1,
  393. package->ret_info.
  394. object_type2,
  395. package->ret_info.
  396. count2, 0);
  397. if (ACPI_FAILURE(status)) {
  398. return (status);
  399. }
  400. break;
  401. case ACPI_PTYPE2_FIX_VAR:
  402. /*
  403. * Each subpackage has a fixed number of elements and an
  404. * optional element
  405. */
  406. expected_count =
  407. package->ret_info.count1 + package->ret_info.count2;
  408. if (sub_package->package.count < expected_count) {
  409. goto package_too_small;
  410. }
  411. status =
  412. acpi_ns_check_package_elements(info, sub_elements,
  413. package->ret_info.
  414. object_type1,
  415. package->ret_info.
  416. count1,
  417. package->ret_info.
  418. object_type2,
  419. sub_package->package.
  420. count -
  421. package->ret_info.
  422. count1, 0);
  423. if (ACPI_FAILURE(status)) {
  424. return (status);
  425. }
  426. break;
  427. case ACPI_PTYPE2_VAR_VAR:
  428. /*
  429. * Each subpackage has a fixed or variable number of elements
  430. */
  431. break;
  432. case ACPI_PTYPE2_FIXED:
  433. /* Each subpackage has a fixed length */
  434. expected_count = package->ret_info2.count;
  435. if (sub_package->package.count < expected_count) {
  436. goto package_too_small;
  437. }
  438. /* Check the type of each subpackage element */
  439. for (j = 0; j < expected_count; j++) {
  440. status =
  441. acpi_ns_check_object_type(info,
  442. &sub_elements[j],
  443. package->
  444. ret_info2.
  445. object_type[j],
  446. j);
  447. if (ACPI_FAILURE(status)) {
  448. return (status);
  449. }
  450. }
  451. break;
  452. case ACPI_PTYPE2_MIN:
  453. /* Each subpackage has a variable but minimum length */
  454. expected_count = package->ret_info.count1;
  455. if (sub_package->package.count < expected_count) {
  456. goto package_too_small;
  457. }
  458. /* Check the type of each subpackage element */
  459. status =
  460. acpi_ns_check_package_elements(info, sub_elements,
  461. package->ret_info.
  462. object_type1,
  463. sub_package->package.
  464. count, 0, 0, 0);
  465. if (ACPI_FAILURE(status)) {
  466. return (status);
  467. }
  468. break;
  469. case ACPI_PTYPE2_COUNT:
  470. /*
  471. * First element is the (Integer) count of elements, including
  472. * the count field (the ACPI name is num_elements)
  473. */
  474. status = acpi_ns_check_object_type(info, sub_elements,
  475. ACPI_RTYPE_INTEGER,
  476. 0);
  477. if (ACPI_FAILURE(status)) {
  478. return (status);
  479. }
  480. /*
  481. * Make sure package is large enough for the Count and is
  482. * is as large as the minimum size
  483. */
  484. expected_count = (u32)(*sub_elements)->integer.value;
  485. if (sub_package->package.count < expected_count) {
  486. goto package_too_small;
  487. }
  488. if (sub_package->package.count <
  489. package->ret_info.count1) {
  490. expected_count = package->ret_info.count1;
  491. goto package_too_small;
  492. }
  493. if (expected_count == 0) {
  494. /*
  495. * Either the num_entries element was originally zero or it was
  496. * a NULL element and repaired to an Integer of value zero.
  497. * In either case, repair it by setting num_entries to be the
  498. * actual size of the subpackage.
  499. */
  500. expected_count = sub_package->package.count;
  501. (*sub_elements)->integer.value = expected_count;
  502. }
  503. /* Check the type of each subpackage element */
  504. status =
  505. acpi_ns_check_package_elements(info,
  506. (sub_elements + 1),
  507. package->ret_info.
  508. object_type1,
  509. (expected_count - 1),
  510. 0, 0, 1);
  511. if (ACPI_FAILURE(status)) {
  512. return (status);
  513. }
  514. break;
  515. default: /* Should not get here, type was validated by caller */
  516. return (AE_AML_INTERNAL);
  517. }
  518. elements++;
  519. }
  520. return (AE_OK);
  521. package_too_small:
  522. /* The subpackage count was smaller than required */
  523. ACPI_WARN_PREDEFINED((AE_INFO, info->full_pathname, info->node_flags,
  524. "Return SubPackage[%u] is too small - found %u elements, expected %u",
  525. i, sub_package->package.count, expected_count));
  526. return (AE_AML_OPERAND_VALUE);
  527. }
  528. /*******************************************************************************
  529. *
  530. * FUNCTION: acpi_ns_custom_package
  531. *
  532. * PARAMETERS: info - Method execution information block
  533. * elements - Pointer to the package elements array
  534. * count - Element count for the package
  535. *
  536. * RETURN: Status
  537. *
  538. * DESCRIPTION: Check a returned package object for the correct count and
  539. * correct type of all sub-objects.
  540. *
  541. * NOTE: Currently used for the _BIX method only. When needed for two or more
  542. * methods, probably a detect/dispatch mechanism will be required.
  543. *
  544. ******************************************************************************/
  545. static acpi_status
  546. acpi_ns_custom_package(struct acpi_evaluate_info *info,
  547. union acpi_operand_object **elements, u32 count)
  548. {
  549. u32 expected_count;
  550. u32 version;
  551. acpi_status status = AE_OK;
  552. ACPI_FUNCTION_NAME(ns_custom_package);
  553. /* Get version number, must be Integer */
  554. if ((*elements)->common.type != ACPI_TYPE_INTEGER) {
  555. ACPI_WARN_PREDEFINED((AE_INFO, info->full_pathname,
  556. info->node_flags,
  557. "Return Package has invalid object type for version number"));
  558. return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
  559. }
  560. version = (u32)(*elements)->integer.value;
  561. expected_count = 21; /* Version 1 */
  562. if (version == 0) {
  563. expected_count = 20; /* Version 0 */
  564. }
  565. if (count < expected_count) {
  566. ACPI_WARN_PREDEFINED((AE_INFO, info->full_pathname,
  567. info->node_flags,
  568. "Return Package is too small - found %u elements, expected %u",
  569. count, expected_count));
  570. return_ACPI_STATUS(AE_AML_OPERAND_VALUE);
  571. } else if (count > expected_count) {
  572. ACPI_DEBUG_PRINT((ACPI_DB_REPAIR,
  573. "%s: Return Package is larger than needed - "
  574. "found %u, expected %u\n",
  575. info->full_pathname, count, expected_count));
  576. }
  577. /* Validate all elements of the returned package */
  578. status = acpi_ns_check_package_elements(info, elements,
  579. ACPI_RTYPE_INTEGER, 16,
  580. ACPI_RTYPE_STRING, 4, 0);
  581. if (ACPI_FAILURE(status)) {
  582. return_ACPI_STATUS(status);
  583. }
  584. /* Version 1 has a single trailing integer */
  585. if (version > 0) {
  586. status = acpi_ns_check_package_elements(info, elements + 20,
  587. ACPI_RTYPE_INTEGER, 1,
  588. 0, 0, 20);
  589. }
  590. return_ACPI_STATUS(status);
  591. }
  592. /*******************************************************************************
  593. *
  594. * FUNCTION: acpi_ns_check_package_elements
  595. *
  596. * PARAMETERS: info - Method execution information block
  597. * elements - Pointer to the package elements array
  598. * type1 - Object type for first group
  599. * count1 - Count for first group
  600. * type2 - Object type for second group
  601. * count2 - Count for second group
  602. * start_index - Start of the first group of elements
  603. *
  604. * RETURN: Status
  605. *
  606. * DESCRIPTION: Check that all elements of a package are of the correct object
  607. * type. Supports up to two groups of different object types.
  608. *
  609. ******************************************************************************/
  610. static acpi_status
  611. acpi_ns_check_package_elements(struct acpi_evaluate_info *info,
  612. union acpi_operand_object **elements,
  613. u8 type1,
  614. u32 count1,
  615. u8 type2, u32 count2, u32 start_index)
  616. {
  617. union acpi_operand_object **this_element = elements;
  618. acpi_status status;
  619. u32 i;
  620. /*
  621. * Up to two groups of package elements are supported by the data
  622. * structure. All elements in each group must be of the same type.
  623. * The second group can have a count of zero.
  624. */
  625. for (i = 0; i < count1; i++) {
  626. status = acpi_ns_check_object_type(info, this_element,
  627. type1, i + start_index);
  628. if (ACPI_FAILURE(status)) {
  629. return (status);
  630. }
  631. this_element++;
  632. }
  633. for (i = 0; i < count2; i++) {
  634. status = acpi_ns_check_object_type(info, this_element,
  635. type2,
  636. (i + count1 + start_index));
  637. if (ACPI_FAILURE(status)) {
  638. return (status);
  639. }
  640. this_element++;
  641. }
  642. return (AE_OK);
  643. }