drivers/acpi/acpica/utresrc.c

Source file repositories/reference/linux-study-clean/drivers/acpi/acpica/utresrc.c

File Facts

System
Linux kernel
Corpus path
drivers/acpi/acpica/utresrc.c
Extension
.c
Size
17613 bytes
Lines
599
Domain
Driver Families
Bucket
drivers/acpi
Inferred role
Driver Families: implementation source
Status
source implementation candidate

Why This File Exists

Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.

Dependency Surface

Detected Declarations

Annotated Snippet

sizeof(struct aml_resource_end_tag)) {
			return_ACPI_STATUS(AE_AML_BUFFER_LENGTH);
		}

		/*
		 * For large resource descriptors, ensure enough space for
		 * the header plus serial_bus Type field access.
		 */
		if ((ACPI_GET8(aml) & ACPI_RESOURCE_NAME_LARGE) &&
		    ((acpi_size)(end_aml - aml) <
		     ACPI_OFFSET(struct aml_resource_common_serialbus,
				 type) + 1)) {
			return_ACPI_STATUS(AE_AML_BUFFER_LENGTH);
		}

		/* Validate the Resource Type and Resource Length */

		status =
		    acpi_ut_validate_resource(walk_state, aml, &resource_index);
		if (ACPI_FAILURE(status)) {
			/*
			 * Exit on failure. Cannot continue because the descriptor
			 * length may be bogus also.
			 */
			return_ACPI_STATUS(status);
		}

		/* Get the length of this descriptor */

		length = acpi_ut_get_descriptor_length(aml);

		/*
		 * Validate that the descriptor length doesn't exceed the
		 * remaining buffer size to prevent reading beyond the end.
		 */
		if (length > (acpi_size)(end_aml - aml)) {
			return_ACPI_STATUS(AE_AML_BUFFER_LENGTH);
		}

		/* Invoke the user function */

		if (user_function) {
			status =
			    user_function(aml, length, offset, resource_index,
					  context);
			if (ACPI_FAILURE(status)) {
				return_ACPI_STATUS(status);
			}
		}

		/* An end_tag descriptor terminates this resource template */

		if (acpi_ut_get_resource_type(aml) ==
		    ACPI_RESOURCE_NAME_END_TAG) {
			/*
			 * There must be at least one more byte in the buffer for
			 * the 2nd byte of the end_tag
			 */
			if ((aml + 1) >= end_aml) {
				return_ACPI_STATUS(AE_AML_NO_RESOURCE_END_TAG);
			}

			/*
			 * Don't attempt to perform any validation on the 2nd byte.
			 * Although all known ASL compilers insert a zero for the 2nd
			 * byte, it can also be a checksum (as per the ACPI spec),
			 * and this is occasionally seen in the field. July 2017.
			 */

			/* Return the pointer to the end_tag if requested */

			if (!user_function) {
				*context = aml;
			}

			/* Normal exit */

			return_ACPI_STATUS(AE_OK);
		}

		aml += length;
		offset += length;
	}

	/* Did not find an end_tag descriptor */

	if (user_function) {

		/* Insert an end_tag anyway. acpi_rs_get_list_length always leaves room */

Annotation

Implementation Notes