scripts/dtc/treesource.c
Source file repositories/reference/linux-study-clean/scripts/dtc/treesource.c
File Facts
- System
- Linux kernel
- Corpus path
scripts/dtc/treesource.c- Extension
.c- Size
- 9308 bytes
- Lines
- 438
- 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
dtc.hsrcpos.h
Detected Declarations
function write_prefixfunction isstringfunction write_propval_stringfunction write_propval_intfunction property_add_markerfunction add_string_markersfunction add_phandle_markerfunction guess_value_typefunction guess_type_markersfunction write_propvalfunction for_each_markerfunction write_tree_source_nodefunction for_each_propertyfunction dt_to_source
Annotated Snippet
switch (c) {
case '\a':
fprintf(f, "\\a");
break;
case '\b':
fprintf(f, "\\b");
break;
case '\t':
fprintf(f, "\\t");
break;
case '\n':
fprintf(f, "\\n");
break;
case '\v':
fprintf(f, "\\v");
break;
case '\f':
fprintf(f, "\\f");
break;
case '\r':
fprintf(f, "\\r");
break;
case '\\':
fprintf(f, "\\\\");
break;
case '\"':
fprintf(f, "\\\"");
break;
case '\0':
fprintf(f, "\\0");
break;
default:
if (isprint((unsigned char)c))
fprintf(f, "%c", c);
else
fprintf(f, "\\x%02"PRIx8, c);
}
}
fprintf(f, "\"");
}
static void write_propval_int(FILE *f, const char *p, size_t len, size_t width)
{
const char *end = p + len;
assert(len % width == 0);
for (; p < end; p += width) {
switch (width) {
case 1:
fprintf(f, "%02"PRIx8, *(const uint8_t*)p);
break;
case 2:
fprintf(f, "0x%02"PRIx16, dtb_ld16(p));
break;
case 4:
fprintf(f, "0x%02"PRIx32, dtb_ld32(p));
break;
case 8:
fprintf(f, "0x%02"PRIx64, dtb_ld64(p));
break;
}
if (p + width < end)
fputc(' ', f);
}
}
static const char *delim_start[] = {
[TYPE_UINT8] = "[",
[TYPE_UINT16] = "/bits/ 16 <",
[TYPE_UINT32] = "<",
[TYPE_UINT64] = "/bits/ 64 <",
[TYPE_STRING] = "",
};
static const char *delim_end[] = {
[TYPE_UINT8] = "]",
[TYPE_UINT16] = ">",
[TYPE_UINT32] = ">",
[TYPE_UINT64] = ">",
[TYPE_STRING] = "",
};
/*
* The invariants in the marker list are:
* - offsets are non-strictly monotonically increasing
* - for a single offset there is at most one type marker
* - for a single offset that has both a type marker and non-type markers, the
* type marker appears before the others.
*/
static struct marker **add_marker(struct marker **mi,
enum markertype type, unsigned int offset, char *ref)
Annotation
- Immediate include surface: `dtc.h`, `srcpos.h`.
- Detected declarations: `function write_prefix`, `function isstring`, `function write_propval_string`, `function write_propval_int`, `function property_add_marker`, `function add_string_markers`, `function add_phandle_marker`, `function guess_value_type`, `function guess_type_markers`, `function write_propval`.
- 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.