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.
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
acpi/acpi.haccommon.hacresrc.h
Detected Declarations
function acpi_ut_walk_aml_resourcesfunction acpi_ut_validate_resourcefunction namefunction acpi_ut_get_resource_typefunction namefunction acpi_ut_get_resource_lengthfunction namefunction acpi_ut_get_resource_header_lengthfunction acpi_ut_get_descriptor_lengthfunction acpi_ut_get_resource_end_tag
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
- Immediate include surface: `acpi/acpi.h`, `accommon.h`, `acresrc.h`.
- Detected declarations: `function acpi_ut_walk_aml_resources`, `function acpi_ut_validate_resource`, `function name`, `function acpi_ut_get_resource_type`, `function name`, `function acpi_ut_get_resource_length`, `function name`, `function acpi_ut_get_resource_header_length`, `function acpi_ut_get_descriptor_length`, `function acpi_ut_get_resource_end_tag`.
- Atlas domain: Driver Families / drivers/acpi.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.