drivers/acpi/acpica/hwregs.c
Source file repositories/reference/linux-study-clean/drivers/acpi/acpica/hwregs.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/acpi/acpica/hwregs.c- Extension
.c- Size
- 22492 bytes
- Lines
- 803
- 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.hacevents.h
Detected Declarations
function acpi_hw_get_access_bit_widthfunction ACPI_IS_POWER_OF_TWOfunction acpi_hw_validate_registerfunction acpi_hw_readfunction acpi_hw_writefunction acpi_hw_clear_acpi_statusfunction acpi_hw_write_pm1_controlfunction acpi_hw_register_readfunction acpi_hw_register_writefunction acpi_hw_read_multiplefunction acpi_hw_write_multiple
Annotated Snippet
ACPI_IS_ALIGNED(reg->bit_width, 8)) {
access_bit_width = reg->bit_width;
} else if (reg->access_width) {
access_bit_width = ACPI_ACCESS_BIT_WIDTH(reg->access_width);
} else {
access_bit_width =
ACPI_ROUND_UP_POWER_OF_TWO_8(reg->bit_offset +
reg->bit_width);
if (access_bit_width <= 8) {
access_bit_width = 8;
} else {
while (!ACPI_IS_ALIGNED(address, access_bit_width >> 3)) {
access_bit_width >>= 1;
}
}
}
/* Maximum IO port access bit width is 32 */
if (reg->space_id == ACPI_ADR_SPACE_SYSTEM_IO) {
max_bit_width = 32;
}
/*
* Return access width according to the requested maximum access bit width,
* as the caller should know the format of the register and may enforce
* a 32-bit accesses.
*/
if (access_bit_width < max_bit_width) {
return (access_bit_width);
}
return (max_bit_width);
}
/******************************************************************************
*
* FUNCTION: acpi_hw_validate_register
*
* PARAMETERS: reg - GAS register structure
* max_bit_width - Max bit_width supported (32 or 64)
* address - Pointer to where the gas->address
* is returned
*
* RETURN: Status
*
* DESCRIPTION: Validate the contents of a GAS register. Checks the GAS
* pointer, Address, space_id, bit_width, and bit_offset.
*
******************************************************************************/
acpi_status
acpi_hw_validate_register(struct acpi_generic_address *reg,
u8 max_bit_width, u64 *address)
{
u8 bit_width;
u8 access_width;
/* Must have a valid pointer to a GAS structure */
if (!reg) {
return (AE_BAD_PARAMETER);
}
/*
* Copy the target address. This handles possible alignment issues.
* Address must not be null. A null address also indicates an optional
* ACPI register that is not supported, so no error message.
*/
ACPI_MOVE_64_TO_64(address, ®->address);
if (!(*address)) {
return (AE_BAD_ADDRESS);
}
/* Validate the space_ID */
if ((reg->space_id != ACPI_ADR_SPACE_SYSTEM_MEMORY) &&
(reg->space_id != ACPI_ADR_SPACE_SYSTEM_IO)) {
ACPI_ERROR((AE_INFO,
"Unsupported address space: 0x%X", reg->space_id));
return (AE_SUPPORT);
}
/* Validate the access_width */
if (reg->access_width > 4) {
ACPI_ERROR((AE_INFO,
"Unsupported register access width: 0x%X",
reg->access_width));
return (AE_SUPPORT);
}
Annotation
- Immediate include surface: `acpi/acpi.h`, `accommon.h`, `acevents.h`.
- Detected declarations: `function acpi_hw_get_access_bit_width`, `function ACPI_IS_POWER_OF_TWO`, `function acpi_hw_validate_register`, `function acpi_hw_read`, `function acpi_hw_write`, `function acpi_hw_clear_acpi_status`, `function acpi_hw_write_pm1_control`, `function acpi_hw_register_read`, `function acpi_hw_register_write`, `function acpi_hw_read_multiple`.
- 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.