drivers/acpi/apei/apei-base.c
Source file repositories/reference/linux-study-clean/drivers/acpi/apei/apei-base.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/acpi/apei/apei-base.c- Extension
.c- Size
- 19550 bytes
- Lines
- 801
- Domain
- Driver Families
- Bucket
- drivers/acpi
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- 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/kernel.hlinux/module.hlinux/init.hlinux/acpi.hlinux/slab.hlinux/io.hlinux/kref.hlinux/interrupt.hlinux/debugfs.hacpi/apei.hlinux/unaligned.hapei-internal.h
Detected Declarations
struct apei_resfunction Copyrightfunction __apei_exec_read_registerfunction apei_exec_read_registerfunction apei_exec_read_register_valuefunction __apei_exec_write_registerfunction apei_exec_write_registerfunction apei_exec_write_register_valuefunction apei_exec_noopfunction __apei_exec_runfunction apei_exec_for_each_entryfunction pre_map_gar_callbackfunction apei_exec_pre_map_garsfunction post_unmap_gar_callbackfunction apei_exec_post_unmap_garsfunction apei_res_addfunction apei_res_subfunction list_for_each_entryfunction apei_res_cleanfunction list_for_each_entry_safefunction apei_resources_finifunction apei_resources_mergefunction list_for_each_entryfunction apei_resources_addfunction GARsfunction apei_get_res_callbackfunction apei_get_nvs_resourcesfunction apei_get_arch_resourcesfunction apei_resources_requestfunction list_for_each_entryfunction apei_resources_releasefunction apei_check_garfunction apei_map_generic_addressfunction apei_readfunction apei_writefunction collect_res_callbackfunction apei_exec_collect_resourcesfunction arch_apei_enable_cmcfffunction arch_apei_report_mem_errorfunction apei_osc_setupexport apei_exec_ctx_initexport apei_exec_read_registerexport apei_exec_read_register_valueexport apei_exec_write_registerexport apei_exec_write_register_valueexport apei_exec_noopexport __apei_exec_runexport apei_exec_pre_map_gars
Annotated Snippet
struct apei_res {
struct list_head list;
unsigned long start;
unsigned long end;
};
/* Collect all resources requested, to avoid conflict */
static struct apei_resources apei_resources_all = {
.iomem = LIST_HEAD_INIT(apei_resources_all.iomem),
.ioport = LIST_HEAD_INIT(apei_resources_all.ioport),
};
static int apei_res_add(struct list_head *res_list,
unsigned long start, unsigned long size)
{
struct apei_res *res, *resn, *res_ins = NULL;
unsigned long end = start + size;
if (end <= start)
return 0;
repeat:
list_for_each_entry_safe(res, resn, res_list, list) {
if (res->start > end || res->end < start)
continue;
else if (end <= res->end && start >= res->start) {
kfree(res_ins);
return 0;
}
list_del(&res->list);
res->start = start = min(res->start, start);
res->end = end = max(res->end, end);
kfree(res_ins);
res_ins = res;
goto repeat;
}
if (res_ins)
list_add(&res_ins->list, res_list);
else {
res_ins = kmalloc_obj(*res_ins);
if (!res_ins)
return -ENOMEM;
res_ins->start = start;
res_ins->end = end;
list_add(&res_ins->list, res_list);
}
return 0;
}
static int apei_res_sub(struct list_head *res_list1,
struct list_head *res_list2)
{
struct apei_res *res1, *resn1, *res2, *res;
res1 = list_entry(res_list1->next, struct apei_res, list);
resn1 = list_entry(res1->list.next, struct apei_res, list);
while (&res1->list != res_list1) {
list_for_each_entry(res2, res_list2, list) {
if (res1->start >= res2->end ||
res1->end <= res2->start)
continue;
else if (res1->end <= res2->end &&
res1->start >= res2->start) {
list_del(&res1->list);
kfree(res1);
break;
} else if (res1->end > res2->end &&
res1->start < res2->start) {
res = kmalloc_obj(*res);
if (!res)
return -ENOMEM;
res->start = res2->end;
res->end = res1->end;
res1->end = res2->start;
list_add(&res->list, &res1->list);
resn1 = res;
} else {
if (res1->start < res2->start)
res1->end = res2->start;
else
res1->start = res2->end;
}
}
res1 = resn1;
resn1 = list_entry(resn1->list.next, struct apei_res, list);
}
return 0;
}
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/module.h`, `linux/init.h`, `linux/acpi.h`, `linux/slab.h`, `linux/io.h`, `linux/kref.h`, `linux/interrupt.h`.
- Detected declarations: `struct apei_res`, `function Copyright`, `function __apei_exec_read_register`, `function apei_exec_read_register`, `function apei_exec_read_register_value`, `function __apei_exec_write_register`, `function apei_exec_write_register`, `function apei_exec_write_register_value`, `function apei_exec_noop`, `function __apei_exec_run`.
- Atlas domain: Driver Families / drivers/acpi.
- Implementation status: integration 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.