arch/riscv/kernel/pi/fdt_early.c
Source file repositories/reference/linux-study-clean/arch/riscv/kernel/pi/fdt_early.c
File Facts
- System
- Linux kernel
- Corpus path
arch/riscv/kernel/pi/fdt_early.c- Extension
.c- Size
- 5055 bytes
- Lines
- 226
- Domain
- Architecture Layer
- Bucket
- arch/riscv
- Inferred role
- Architecture Layer: implementation source
- Status
- source implementation candidate
Why This File Exists
CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.
- CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.
Dependency Surface
linux/types.hlinux/init.hlinux/libfdt.hlinux/ctype.hasm/csr.hpi.h
Detected Declarations
function get_kaslr_seedfunction fdt_device_is_availablefunction fdt_node_name_eqfunction isa_string_containsfunction early_cpu_isa_ext_availablefunction fdt_early_match_extension_isafunction fdt_for_each_subnodefunction set_satp_mode_from_fdtfunction fdt_for_each_subnode
Annotated Snippet
if (strncasecmp(isa_str, ext_name, len) == 0) {
ext_end = isa_str[len];
/* Check if matches the whole extension. */
if (ext_end == '\0' || ext_end == '_')
return true;
}
/* Multi-letter extensions must be split from other multi-letter
* extensions with an "_", the end of a multi-letter extension will
* either be the null character or the "_" at the start of the next
* multi-letter extension.
*/
isa_str = strchr(isa_str, '_');
if (isa_str)
isa_str++;
}
return false;
}
/**
* early_cpu_isa_ext_available - check if cpu node has an extension
*
* @fdt: pointer to the device tree blob
* @node: offset of the cpu node
* @ext_name: the extension to search for
*
* Returns true if the cpu node has the extension,
* false otherwise
*/
static bool early_cpu_isa_ext_available(const void *fdt, int node, const char *ext_name)
{
const void *prop;
int len;
prop = fdt_getprop(fdt, node, "riscv,isa-extensions", &len);
if (prop && fdt_stringlist_contains(prop, len, ext_name))
return true;
prop = fdt_getprop(fdt, node, "riscv,isa", &len);
if (prop && isa_string_contains(prop, ext_name))
return true;
return false;
}
/**
* fdt_early_match_extension_isa - check if all cpu nodes have an extension
*
* @fdt: pointer to the device tree blob
* @ext_name: the extension to search for
*
* Returns true if the all available the cpu nodes have the extension,
* false otherwise
*/
bool fdt_early_match_extension_isa(const void *fdt, const char *ext_name)
{
int node, parent;
bool ret = false;
parent = fdt_path_offset(fdt, "/cpus");
if (parent < 0)
return false;
fdt_for_each_subnode(node, fdt, parent) {
if (!fdt_node_name_eq(fdt, node, "cpu"))
continue;
if (!fdt_device_is_available(fdt, node))
continue;
if (!early_cpu_isa_ext_available(fdt, node, ext_name))
return false;
ret = true;
}
return ret;
}
/**
* set_satp_mode_from_fdt - determine SATP mode based on the MMU type in fdt
*
* @dtb_pa: physical address of the device tree blob
*
* Returns the SATP mode corresponding to the MMU type of the first enabled CPU,
* 0 otherwise
*/
u64 set_satp_mode_from_fdt(uintptr_t dtb_pa)
{
const void *fdt = (const void *)dtb_pa;
Annotation
- Immediate include surface: `linux/types.h`, `linux/init.h`, `linux/libfdt.h`, `linux/ctype.h`, `asm/csr.h`, `pi.h`.
- Detected declarations: `function get_kaslr_seed`, `function fdt_device_is_available`, `function fdt_node_name_eq`, `function isa_string_contains`, `function early_cpu_isa_ext_available`, `function fdt_early_match_extension_isa`, `function fdt_for_each_subnode`, `function set_satp_mode_from_fdt`, `function fdt_for_each_subnode`.
- Atlas domain: Architecture Layer / arch/riscv.
- 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.