Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
350 changes: 8 additions & 342 deletions src/kboot.c

Large diffs are not rendered by default.

12 changes: 0 additions & 12 deletions src/kboot.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,18 +74,6 @@ void kboot_loaded_file_part(u64 *base, u64 *size);
/* The node at an absolute path or alias, matching each node name exactly (see kboot.c) */
int kboot_fdt_path_exact(const void *fdt, const char *path);

/*
* What kboot.c's M4 internal DCP handoff did, for the external display processors' handoff
* (kboot_display_handoff.c), which acts only beside a complete one or on a board with no panel.
*/
enum dcp_internal {
DCP_INTERNAL_NONE, /* refused, or published without its display maps or firmware clocks */
DCP_INTERNAL_COMPLETE, /* published whole: the inherited display maps and, on firmware 27, the
firmware clocks */
DCP_INTERNAL_NO_PANEL, /* not attempted: ADT /arm-io/disp0 is external (no panel) */
};
int dt_set_dcpext_handoff(void *dt, enum dcp_internal internal, bool fw_clocks);

// from rust/usb4.rs
u64 rust_usb4_router_uuid(void);
int rust_platform_uuid(u8 *out);
Expand Down
1,570 changes: 115 additions & 1,455 deletions src/kboot_display_handoff.c

Large diffs are not rendered by default.

25 changes: 7 additions & 18 deletions tests/python/test_m4_dcp_handoff.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,8 @@ def test_m4_dcp_handoff_follows_the_firmware_and_the_panel(tmp_path):
function(kboot, "dt_device_add_mem_region") + function(kboot, "dt_set_dcp_firmware") +
function(kboot, "dt_reserve_asc_segments_at") + function(kboot, "dt_reserve_asc_segments") + function(kboot, "dt_reserve_asc_firmware") +
maps + function(kboot, "j713_display_page") + function(kboot, "dt_set_j713_display_maps") +
function(kboot, "dt_dcp_fw_clocks", "static bool ") + clocks +
function(kboot, "dt_set_m4_dcp_handoff"))
clocks + function(kboot, "dt_set_m4_dcp_handoff"))
production = function(firmware, "firmware_set_fdt", "int ") + production
header = (ROOT / "src/kboot.h").read_text()
start = header.index("enum dcp_internal {")
enum = header[start:header.index("\n};", start) + 3] + "\n"
assert not re.search(r"\bdt_set_j713_dcp_handoff\b", kboot)

source = r'''
Expand Down Expand Up @@ -84,7 +80,7 @@ def test_m4_dcp_handoff_follows_the_firmware_and_the_panel(tmp_path):
[V27_2] = {V27_2, "27.2", {27, 2, 0}, 3, ""},
};
static struct fw_version_info os_firmware;
''' + enum + layout + r'''
''' + layout + r'''
static void *dt, *adt;
static u32 chip_id = T8132;

Expand Down Expand Up @@ -329,14 +325,11 @@ def test_m4_dcp_handoff_follows_the_firmware_and_the_panel(tmp_path):
assert(hz && len == 4 && fdt32_ld(hz) == rate[i]);
}
}
static enum dcp_internal internal;
static void handed_over(const struct board *board, enum fw_version fw, bool piodma)
{
world(board, fw);
assert(!dt_set_m4_dcp_handoff(&internal));
assert(!dt_set_m4_dcp_handoff());
published(piodma);
/* Complete only with the maps (and on firmware 27 the clocks the kernel admits on). */
assert(internal == (piodma ? DCP_INTERNAL_COMPLETE : DCP_INTERNAL_NONE));
char name[64];
snprintf(name, sizeof(name), "%s-%s", board->name, fw_versions[fw].string);
save(name);
Expand All @@ -346,9 +339,8 @@ def test_m4_dcp_handoff_follows_the_firmware_and_the_panel(tmp_path):
{
static unsigned char before[sizeof(blob)];
memcpy(before, blob, sizeof(blob));
assert(dt_set_m4_dcp_handoff(&internal) == -1);
assert(dt_set_m4_dcp_handoff() == -1);
assert(!memcmp(before, blob, sizeof(blob)) && !walks);
assert(internal == (b.external > 0 ? DCP_INTERNAL_NO_PANEL : DCP_INTERNAL_NONE));
}
int main(int argc, char **argv)
{
Expand Down Expand Up @@ -377,7 +369,7 @@ def test_m4_dcp_handoff_follows_the_firmware_and_the_panel(tmp_path):
*/
world(&stub, V27_2);
dart_skew = SZ_16K;
assert(!dt_set_m4_dcp_handoff(&internal) && internal == DCP_INTERNAL_NONE);
assert(!dt_set_m4_dcp_handoff());
assert(walks == 1 && status_is("/soc/display-subsystem", "disabled") &&
status_is("/soc/dcp@30ae00000/piodma", "disabled") &&
status_is("/soc/iommu@30a300000", "disabled"));
Expand All @@ -388,7 +380,7 @@ def test_m4_dcp_handoff_follows_the_firmware_and_the_panel(tmp_path):
/* The same pages on 26.6.2 are refused the same way. */
world(&j713, V26_6_2);
dart_skew = SZ_16K;
assert(!dt_set_m4_dcp_handoff(&internal) && internal == DCP_INTERNAL_NONE);
assert(!dt_set_m4_dcp_handoff());
assert(walks == 1 && status_is("/soc/display-subsystem", "disabled"));

/*
Expand Down Expand Up @@ -438,10 +430,7 @@ def test_m4_dcp_handoff_follows_the_firmware_and_the_panel(tmp_path):
assert(!fdt_delprop(dt, fdt_path_offset(dt, "/aliases"), "dcp"));
static unsigned char before[sizeof(blob)];
memcpy(before, blob, sizeof(blob));
assert(!dt_set_m4_dcp_handoff(&internal) && !memcmp(before, blob, sizeof(blob)));
assert(internal == DCP_INTERNAL_NONE);
/* The Mac mini on 27.2 too: no panel, whatever the firmware (the external processors'). */
world(&j773g, V27_2); refused();
assert(!dt_set_m4_dcp_handoff() && !memcmp(before, blob, sizeof(blob)));
return 0;
}
'''
Expand Down
55 changes: 0 additions & 55 deletions tests/python/test_t6050_handoff_bounds.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,61 +186,6 @@
return n < 1 || n > nnodes ? -1 : nodes[n - 1].nprops;
}

/* The tree walk: a node's children are the nodes whose path is its path plus one component. */
static bool child_of(int parent, int n)
{
const char *p = parent ? nodes[parent - 1].path : "";
size_t len = strlen(p);
const char *c = nodes[n - 1].path;
return !strncmp(c, p, len) && c[len] == '/' && c[len + 1] && !strchr(c + len + 1, '/');
}

static int parent_of(int n)
{
const char *c = nodes[n - 1].path;
const char *slash = strrchr(c, '/');
for (int i = 1; i <= nnodes; i++)
if (strlen(nodes[i - 1].path) == (size_t)(slash - c) &&
!strncmp(nodes[i - 1].path, c, slash - c))
return i;
return 0;
}

static int child_after(int parent, int after)
{
for (int i = after + 1; i <= nnodes; i++)
if (child_of(parent, i))
return i;
return -1;
}

int adt_get_child_count(const void *a, int n)
{
UNUSED(a);
int count = 0;
for (int i = 1; i <= nnodes; i++)
count += child_of(n, i);
return count;
}

int adt_first_child_offset(const void *a, int n)
{
UNUSED(a);
return child_after(n, 0);
}

int adt_next_sibling_offset(const void *a, int n)
{
UNUSED(a);
return n < 1 || n > nnodes ? -1 : child_after(parent_of(n), n);
}

const char *adt_get_name(const void *a, int n)
{
UNUSED(a);
return n < 1 || n > nnodes ? NULL : strrchr(nodes[n - 1].path, '/') + 1;
}

int host_adt_nprops(int n)
{
return 0;
Expand Down
Loading
Loading