drivers/acpi/acpica/exoparg3.c
Source file repositories/reference/linux-study-clean/drivers/acpi/acpica/exoparg3.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/acpi/acpica/exoparg3.c- Extension
.c- Size
- 6772 bytes
- Lines
- 250
- 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.hacinterp.hacpi/acoutput.hacparser.hamlcode.h
Detected Declarations
function Copyrightfunction acpi_ex_opcode_3A_1T_1R
Annotated Snippet
if (!return_desc) {
status = AE_NO_MEMORY;
goto cleanup;
}
/* Get the Integer values from the objects */
index = operand[1]->integer.value;
length = (acpi_size)operand[2]->integer.value;
/*
* If the index is beyond the length of the String/Buffer, or if the
* requested length is zero, return a zero-length String/Buffer
*/
if (index >= operand[0]->string.length) {
length = 0;
}
/* Truncate request if larger than the actual String/Buffer */
else if ((index + length) > operand[0]->string.length || (index + length) < index) { /* Check for overflow */
length =
(acpi_size)operand[0]->string.length -
(acpi_size)index;
}
/* Strings always have a sub-pointer, not so for buffers */
switch ((operand[0])->common.type) {
case ACPI_TYPE_STRING:
/* Always allocate a new buffer for the String */
buffer = ACPI_ALLOCATE_ZEROED((acpi_size)length + 1);
if (!buffer) {
status = AE_NO_MEMORY;
goto cleanup;
}
break;
case ACPI_TYPE_BUFFER:
/* If the requested length is zero, don't allocate a buffer */
if (length > 0) {
/* Allocate a new buffer for the Buffer */
buffer = ACPI_ALLOCATE_ZEROED(length);
if (!buffer) {
status = AE_NO_MEMORY;
goto cleanup;
}
}
break;
default: /* Should not happen */
status = AE_AML_OPERAND_TYPE;
goto cleanup;
}
if (buffer) {
/* We have a buffer, copy the portion requested */
memcpy(buffer,
operand[0]->string.pointer + index, length);
}
/* Set the length of the new String/Buffer */
return_desc->string.pointer = buffer;
return_desc->string.length = (u32) length;
/* Mark buffer initialized */
return_desc->buffer.flags |= AOPOBJ_DATA_VALID;
break;
default:
ACPI_ERROR((AE_INFO, "Unknown AML opcode 0x%X",
walk_state->opcode));
status = AE_AML_BAD_OPCODE;
goto cleanup;
}
/* Store the result in the target */
Annotation
- Immediate include surface: `acpi/acpi.h`, `accommon.h`, `acinterp.h`, `acpi/acoutput.h`, `acparser.h`, `amlcode.h`.
- Detected declarations: `function Copyright`, `function acpi_ex_opcode_3A_1T_1R`.
- 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.