scripts/dtc/libfdt/fdt_ro.c
Source file repositories/reference/linux-study-clean/scripts/dtc/libfdt/fdt_ro.c
File Facts
- System
- Linux kernel
- Corpus path
scripts/dtc/libfdt/fdt_ro.c- Extension
.c- Size
- 19311 bytes
- Lines
- 889
- Domain
- Support Tooling And Documentation
- Bucket
- scripts
- Inferred role
- Support Tooling And Documentation: implementation source
- Status
- source implementation candidate
Why This File Exists
Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
libfdt_env.hfdt.hlibfdt.hlibfdt_internal.h
Detected Declarations
function Copyrightfunction fdt_string_eq_function fdt_find_max_phandlefunction fdt_generate_phandlefunction fdt_get_mem_rsvfunction fdt_num_mem_rsvfunction nextprop_function fdt_subnode_offset_namelenfunction fdt_subnode_offsetfunction fdt_path_offset_namelenfunction fdt_path_offsetfunction fdt_first_property_offsetfunction fdt_next_property_offsetfunction fdt_get_phandlefunction fdt_get_pathfunction fdt_supernode_atdepth_offsetfunction fdt_node_depthfunction fdt_parent_offsetfunction fdt_node_offset_by_prop_valuefunction fdt_node_offset_by_phandlefunction fdt_stringlist_containsfunction fdt_stringlist_countfunction fdt_stringlist_searchfunction fdt_node_check_compatiblefunction fdt_node_offset_by_compatible
Annotated Snippet
if (can_assume(LATEST) || fdt_version(fdt) >= 17) {
if ((unsigned)stroffset >= fdt_size_dt_strings(fdt))
goto fail;
if ((fdt_size_dt_strings(fdt) - stroffset) < len)
len = fdt_size_dt_strings(fdt) - stroffset;
}
} else if (fdt_magic(fdt) == FDT_SW_MAGIC) {
unsigned int sw_stroffset = -stroffset;
if ((stroffset >= 0) ||
(sw_stroffset > fdt_size_dt_strings(fdt)))
goto fail;
if (sw_stroffset < len)
len = sw_stroffset;
} else {
err = -FDT_ERR_INTERNAL;
goto fail;
}
s = (const char *)fdt + absoffset;
n = memchr(s, '\0', len);
if (!n) {
/* missing terminating NULL */
err = -FDT_ERR_TRUNCATED;
goto fail;
}
if (lenp)
*lenp = n - s;
return s;
fail:
if (lenp)
*lenp = err;
return NULL;
}
const char *fdt_string(const void *fdt, int stroffset)
{
return fdt_get_string(fdt, stroffset, NULL);
}
static int fdt_string_eq_(const void *fdt, int stroffset,
const char *s, int len)
{
int slen;
const char *p = fdt_get_string(fdt, stroffset, &slen);
return p && (slen == len) && (memcmp(p, s, len) == 0);
}
int fdt_find_max_phandle(const void *fdt, uint32_t *phandle)
{
uint32_t max = 0;
int offset = -1;
while (true) {
uint32_t value;
offset = fdt_next_node(fdt, offset, NULL);
if (offset < 0) {
if (offset == -FDT_ERR_NOTFOUND)
break;
return offset;
}
value = fdt_get_phandle(fdt, offset);
if (value > max)
max = value;
}
if (phandle)
*phandle = max;
return 0;
}
int fdt_generate_phandle(const void *fdt, uint32_t *phandle)
{
uint32_t max;
int err;
err = fdt_find_max_phandle(fdt, &max);
if (err < 0)
return err;
if (max == FDT_MAX_PHANDLE)
return -FDT_ERR_NOPHANDLES;
Annotation
- Immediate include surface: `libfdt_env.h`, `fdt.h`, `libfdt.h`, `libfdt_internal.h`.
- Detected declarations: `function Copyright`, `function fdt_string_eq_`, `function fdt_find_max_phandle`, `function fdt_generate_phandle`, `function fdt_get_mem_rsv`, `function fdt_num_mem_rsv`, `function nextprop_`, `function fdt_subnode_offset_namelen`, `function fdt_subnode_offset`, `function fdt_path_offset_namelen`.
- Atlas domain: Support Tooling And Documentation / scripts.
- 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.