drivers/of/kexec.c
Source file repositories/reference/linux-study-clean/drivers/of/kexec.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/of/kexec.c- Extension
.c- Size
- 12803 bytes
- Lines
- 527
- Domain
- Driver Families
- Bucket
- drivers/of
- 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/ima.hlinux/kernel.hlinux/kexec.hlinux/memblock.hlinux/libfdt.hlinux/of.hlinux/of_fdt.hlinux/random.hlinux/slab.hlinux/types.h
Detected Declarations
function Copyrightfunction get_addr_size_cellsfunction do_get_kexec_bufferfunction ima_get_kexec_bufferfunction ima_free_kexec_bufferfunction remove_ima_bufferfunction setup_ima_bufferfunction setup_ima_bufferfunction kho_add_chosen
Annotated Snippet
if (ret) {
pr_err("Malformed device tree.\n");
return -EINVAL;
}
if (rsv_start == start && rsv_size == size) {
ret = fdt_del_mem_rsv(fdt, i);
if (ret) {
pr_err("Error deleting device tree reservation.\n");
return -EINVAL;
}
return 0;
}
}
return -ENOENT;
}
/**
* get_addr_size_cells - Get address and size of root node
*
* @addr_cells: Return address of the root node
* @size_cells: Return size of the root node
*
* Return: 0 on success, or negative errno on error.
*/
static int get_addr_size_cells(int *addr_cells, int *size_cells)
{
struct device_node *root;
root = of_find_node_by_path("/");
if (!root)
return -EINVAL;
*addr_cells = of_n_addr_cells(root);
*size_cells = of_n_size_cells(root);
of_node_put(root);
return 0;
}
/**
* do_get_kexec_buffer - Get address and size of device tree property
*
* @prop: Device tree property
* @len: Size of @prop
* @addr: Return address of the node
* @size: Return size of the node
*
* Return: 0 on success, or negative errno on error.
*/
static int do_get_kexec_buffer(const void *prop, int len, unsigned long *addr,
size_t *size)
{
int ret, addr_cells, size_cells;
ret = get_addr_size_cells(&addr_cells, &size_cells);
if (ret)
return ret;
if (len < 4 * (addr_cells + size_cells))
return -ENOENT;
*addr = of_read_number(prop, addr_cells);
*size = of_read_number(prop + 4 * addr_cells, size_cells);
return 0;
}
#ifdef CONFIG_HAVE_IMA_KEXEC
/**
* ima_get_kexec_buffer - get IMA buffer from the previous kernel
* @addr: On successful return, set to point to the buffer contents.
* @size: On successful return, set to the buffer size.
*
* Return: 0 on success, negative errno on error.
*/
int __init ima_get_kexec_buffer(void **addr, size_t *size)
{
int ret, len;
unsigned long tmp_addr;
size_t tmp_size;
const void *prop;
prop = of_get_property(of_chosen, "linux,ima-kexec-buffer", &len);
if (!prop)
return -ENOENT;
Annotation
- Immediate include surface: `linux/ima.h`, `linux/kernel.h`, `linux/kexec.h`, `linux/memblock.h`, `linux/libfdt.h`, `linux/of.h`, `linux/of_fdt.h`, `linux/random.h`.
- Detected declarations: `function Copyright`, `function get_addr_size_cells`, `function do_get_kexec_buffer`, `function ima_get_kexec_buffer`, `function ima_free_kexec_buffer`, `function remove_ima_buffer`, `function setup_ima_buffer`, `function setup_ima_buffer`, `function kho_add_chosen`.
- Atlas domain: Driver Families / drivers/of.
- 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.