drivers/acpi/acpi_memhotplug.c
Source file repositories/reference/linux-study-clean/drivers/acpi/acpi_memhotplug.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/acpi/acpi_memhotplug.c- Extension
.c- Size
- 9467 bytes
- Lines
- 368
- 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.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/acpi.hlinux/memory.hlinux/memory_hotplug.hinternal.h
Detected Declarations
struct acpi_memory_infostruct acpi_memory_devicefunction acpi_memory_get_resourcefunction list_for_each_entryfunction acpi_memory_free_device_resourcesfunction acpi_memory_get_device_resourcesfunction acpi_memory_check_devicefunction acpi_bind_memblkfunction acpi_bind_memory_blocksfunction acpi_unbind_memblkfunction acpi_unbind_memory_blocksfunction acpi_memory_enable_devicefunction list_for_each_entryfunction acpi_memory_remove_memoryfunction list_for_each_entry_safefunction acpi_memory_device_freefunction acpi_memory_device_addfunction acpi_memory_device_removefunction acpi_memory_hotplug_initfunction disable_acpi_memory_hotplugfunction acpi_memory_hotplug_init
Annotated Snippet
struct acpi_memory_info {
struct list_head list;
u64 start_addr; /* Memory Range start physical addr */
u64 length; /* Memory Range length */
unsigned short caching; /* memory cache attribute */
unsigned short write_protect; /* memory read/write attribute */
unsigned int enabled:1;
};
struct acpi_memory_device {
struct acpi_device *device;
struct list_head res_list;
int mgid;
};
static acpi_status
acpi_memory_get_resource(struct acpi_resource *resource, void *context)
{
struct acpi_memory_device *mem_device = context;
struct acpi_resource_address64 address64;
struct acpi_memory_info *info, *new;
acpi_status status;
status = acpi_resource_to_address64(resource, &address64);
if (ACPI_FAILURE(status) ||
(address64.resource_type != ACPI_MEMORY_RANGE))
return AE_OK;
list_for_each_entry(info, &mem_device->res_list, list) {
/* Can we combine the resource range information? */
if ((info->caching == address64.info.mem.caching) &&
(info->write_protect == address64.info.mem.write_protect) &&
(info->start_addr + info->length == address64.address.minimum)) {
info->length += address64.address.address_length;
return AE_OK;
}
}
new = kzalloc_obj(struct acpi_memory_info);
if (!new)
return AE_ERROR;
INIT_LIST_HEAD(&new->list);
new->caching = address64.info.mem.caching;
new->write_protect = address64.info.mem.write_protect;
new->start_addr = address64.address.minimum;
new->length = address64.address.address_length;
list_add_tail(&new->list, &mem_device->res_list);
return AE_OK;
}
static void
acpi_memory_free_device_resources(struct acpi_memory_device *mem_device)
{
struct acpi_memory_info *info, *n;
list_for_each_entry_safe(info, n, &mem_device->res_list, list)
kfree(info);
INIT_LIST_HEAD(&mem_device->res_list);
}
static int
acpi_memory_get_device_resources(struct acpi_memory_device *mem_device)
{
acpi_status status;
if (!list_empty(&mem_device->res_list))
return 0;
status = acpi_walk_resources(mem_device->device->handle, METHOD_NAME__CRS,
acpi_memory_get_resource, mem_device);
if (ACPI_FAILURE(status)) {
acpi_memory_free_device_resources(mem_device);
return -EINVAL;
}
return 0;
}
static int acpi_memory_check_device(struct acpi_memory_device *mem_device)
{
unsigned long long current_status;
/* Get device present/absent information from the _STA */
if (ACPI_FAILURE(acpi_evaluate_integer(mem_device->device->handle,
METHOD_NAME__STA, NULL,
¤t_status)))
return -ENODEV;
/*
Annotation
- Immediate include surface: `linux/acpi.h`, `linux/memory.h`, `linux/memory_hotplug.h`, `internal.h`.
- Detected declarations: `struct acpi_memory_info`, `struct acpi_memory_device`, `function acpi_memory_get_resource`, `function list_for_each_entry`, `function acpi_memory_free_device_resources`, `function acpi_memory_get_device_resources`, `function acpi_memory_check_device`, `function acpi_bind_memblk`, `function acpi_bind_memory_blocks`, `function acpi_unbind_memblk`.
- 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.