for (;;) {
rc = dtb_embedded_iterator_next(iter, ¤t_dtb, ¤t_dtb_size); if (rc != NO_ERROR) { break;
} int test_node_offset = fdt_node_offset_by_compatible(
current_dtb, -1/* search from the start of the dtb */, compat); if (test_node_offset >= 0) { /* Found the test node */
*dtb = current_dtb;
*dtb_size = current_dtb_size; break;
}
}
dtb_embedded_iterator_free(&iter);
return rc;
}
staticvoid* apply_test_overlay(constvoid* base_dtb,
size_t base_dtb_size, constvoid* test_dtbo,
size_t test_dtbo_size) { /* Overestimate the size needed for the full dtb for now */
size_t full_size = base_dtb_size + test_dtbo_size; void* base = calloc(1, full_size); if (!base) { goto alloc_base;
} /* *libfdtoverwritespartofthedtboheaderifapplyingtheoverlayfails *sowehavetomakeatemporarycopysincetheoriginaldtboisin *read-onlymemory.
*/ void* overlay = calloc(1, test_dtbo_size); if (!overlay) { goto alloc_overlay;
} /* *Usingfdt_open_intocopiesthedtbtothebufferallocatedaboveand *updatesthefdtheaderwiththenewbuffersize
*/ int rc = fdt_open_into(base_dtb, base, full_size); if (rc < 0) {
TRACEF("fdt_open_into failed for base dtb (%d)\n", rc); goto copy_base;
}
rc = fdt_open_into(test_dtbo, overlay, test_dtbo_size); if (rc < 0) {
TRACEF("fdt_open_into failed for test dtb overlay (%d)\n", rc); goto copy_overlay;
}
rc = fdt_overlay_apply(base, overlay); if (rc < 0) {
TRACEF("Failed to apply test overlay to base dtb (%d)\n", rc); goto apply_overlay;
}
free(overlay); return base;
rc = find_dtb_by_compatible("google,test_overlay", &test_dtbo,
&test_dtbo_size); if (rc != NO_ERROR) {
panic("No embedded test dtbo found (%d)\n", rc);
}
constvoid* dtb = apply_test_overlay(base_dtb, base_dtb_size, test_dtbo,
test_dtbo_size); if (!dtb) {
panic("Failed to apply test overlay to base dtb\n");
}
size_t dtb_size = fdt_totalsize(dtb);
rc = dtb_service_add(dtb, dtb_size, DT_PORT, DTB_PORT, &dtb_ktipc_server); if (rc < 0) {
panic("Failed (%d) to add dtb service to server\n", rc);
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.