scripts/dtc/yamltree.c
Source file repositories/reference/linux-study-clean/scripts/dtc/yamltree.c
File Facts
- System
- Linux kernel
- Corpus path
scripts/dtc/yamltree.c- Extension
.c- Size
- 6461 bytes
- Lines
- 236
- 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
stdlib.hyaml.hdtc.hsrcpos.h
Detected Declarations
function yaml_propval_intfunction for_each_marker_of_typefunction yaml_propval_stringfunction yaml_propvalfunction for_each_markerfunction yaml_treefunction dt_to_yaml
Annotated Snippet
switch(width) {
case 1:
sprintf(buf, "0x%"PRIx8, *(uint8_t*)(data + off));
break;
case 2:
sprintf(buf, "0x%"PRIx16, dtb_ld16(data + off));
break;
case 4:
sprintf(buf, "0x%"PRIx32, dtb_ld32(data + off));
m = markers;
is_phandle = false;
for_each_marker_of_type(m, REF_PHANDLE) {
if (m->offset == (seq_offset + off)) {
is_phandle = true;
break;
}
}
break;
case 8:
sprintf(buf, "0x%"PRIx64, dtb_ld64(data + off));
break;
}
if (is_phandle)
yaml_scalar_event_initialize(&event, NULL,
(yaml_char_t*)"!phandle", (yaml_char_t *)buf,
strlen(buf), 0, 0, YAML_PLAIN_SCALAR_STYLE);
else
yaml_scalar_event_initialize(&event, NULL,
(yaml_char_t*)YAML_INT_TAG, (yaml_char_t *)buf,
strlen(buf), 1, 1, YAML_PLAIN_SCALAR_STYLE);
yaml_emitter_emit_or_die(emitter, &event);
}
yaml_sequence_end_event_initialize(&event);
yaml_emitter_emit_or_die(emitter, &event);
}
static void yaml_propval_string(yaml_emitter_t *emitter, char *str, int len)
{
yaml_event_t event;
int i;
assert(str[len-1] == '\0');
/* Make sure the entire string is in the lower 7-bit ascii range */
for (i = 0; i < len; i++)
assert(isascii(str[i]));
yaml_scalar_event_initialize(&event, NULL,
(yaml_char_t *)YAML_STR_TAG, (yaml_char_t*)str,
len-1, 0, 1, YAML_DOUBLE_QUOTED_SCALAR_STYLE);
yaml_emitter_emit_or_die(emitter, &event);
}
static void yaml_propval(yaml_emitter_t *emitter, struct property *prop)
{
yaml_event_t event;
unsigned int len = prop->val.len;
struct marker *m = prop->val.markers;
struct marker *markers = prop->val.markers;
/* Emit the property name */
yaml_scalar_event_initialize(&event, NULL,
(yaml_char_t *)YAML_STR_TAG, (yaml_char_t*)prop->name,
strlen(prop->name), 1, 1, YAML_PLAIN_SCALAR_STYLE);
yaml_emitter_emit_or_die(emitter, &event);
/* Boolean properties are easiest to deal with. Length is zero, so just emit 'true' */
if (len == 0) {
yaml_scalar_event_initialize(&event, NULL,
(yaml_char_t *)YAML_BOOL_TAG,
(yaml_char_t*)"true",
strlen("true"), 1, 0, YAML_PLAIN_SCALAR_STYLE);
yaml_emitter_emit_or_die(emitter, &event);
return;
}
if (!m)
die("No markers present in property '%s' value\n", prop->name);
yaml_sequence_start_event_initialize(&event, NULL,
(yaml_char_t *)YAML_SEQ_TAG, 1, YAML_FLOW_SEQUENCE_STYLE);
yaml_emitter_emit_or_die(emitter, &event);
for_each_marker(m) {
int chunk_len;
char *data = &prop->val.val[m->offset];
if (m->type < TYPE_UINT8)
Annotation
- Immediate include surface: `stdlib.h`, `yaml.h`, `dtc.h`, `srcpos.h`.
- Detected declarations: `function yaml_propval_int`, `function for_each_marker_of_type`, `function yaml_propval_string`, `function yaml_propval`, `function for_each_marker`, `function yaml_tree`, `function dt_to_yaml`.
- 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.