diff --git a/src/dapf.c b/src/dapf.c index b2e3d99db..c25d868ee 100644 --- a/src/dapf.c +++ b/src/dapf.c @@ -110,6 +110,7 @@ struct dapf_t8110_config { u8 r0_lo; u8 unk4; } PACKED; +static_assert(sizeof(struct dapf_t8110_config) == 52, "Invalid T8110 DAPF entry size"); struct dapf_t8110b_config { u64 start; @@ -223,24 +224,26 @@ static void dapf_t8132_put(u64 base, const struct dapf_slice *slice) write32(base + 0x20, slice->r20); } -static const struct dapf_t8110_config *dapf_t8132_config(const char *path, int node, u32 instance, +static const struct dapf_t8110_config *dapf_t8110_slices(const char *path, int node, u32 instance, u32 *count) { char prop[32]; - u32 length; + u32 length = 0; snprintf(prop, sizeof(prop), "dapf-instance-%u", instance); const struct dapf_t8110_config *config = adt_getprop(adt, node, prop, &length); if (!config || !length || length % sizeof(*config) || length / sizeof(*config) > T8132_DAPF_SLICES) { - printf("dapf: Invalid T8132 %s for %s\n", prop, path); + printf("dapf: Invalid %s for %s (len %u)\n", prop, path, length); return NULL; } *count = length / sizeof(*config); for (u32 i = 0; i < *count; i++) { - if (config[i].end < config[i].start) { - printf("dapf: Invalid T8132 %s slice %u for %s\n", prop, i, path); + struct dapf_t8110_config entry; + memcpy(&entry, &config[i], sizeof(entry)); + if (entry.end < entry.start) { + printf("dapf: Invalid %s slice %u for %s\n", prop, i, path); return NULL; } } @@ -257,7 +260,7 @@ static int dapf_program_t8132(const char *path, u64 base, int node, u32 instance { struct dapf_slice want[T8132_DAPF_SLICES], had[T8132_DAPF_SLICES]; u32 count; - const struct dapf_t8110_config *config = dapf_t8132_config(path, node, instance, &count); + const struct dapf_t8110_config *config = dapf_t8110_slices(path, node, instance, &count); if (!config) return -1; @@ -410,7 +413,7 @@ int dapf_t8132_windows(const char *path, int index, struct dapf_window *out, int dapf_select_t8132(path, index, node, dart_path, &instance) != 1) return -1; - const struct dapf_t8110_config *config = dapf_t8132_config(path, node, instance, &count); + const struct dapf_t8110_config *config = dapf_t8110_slices(path, node, instance, &count); if (!config) return -1; @@ -492,7 +495,7 @@ int dapf_t8132_ranges(const char *path, u32 r0, u32 r4, u32 r20, u64 *ranges, in if (index < 0 || dapf_select_t8132(path, index, node, dart_path, &instance) != 1) return -1; - const struct dapf_t8110_config *config = dapf_t8132_config(path, node, instance, &count); + const struct dapf_t8110_config *config = dapf_t8110_slices(path, node, instance, &count); if (!config || !count || count > (u32)max) return -1; @@ -509,6 +512,32 @@ int dapf_t8132_ranges(const char *path, u32 r0, u32 r4, u32 r20, u64 *ranges, in return count; } +/* + * Return the raw inclusive [start, end] slices of a T8110 DART's dapf-instance + * property (up to max entries), or -1 on missing or malformed ADT metadata. + */ +int dapf_t8110_ranges(const char *path, u32 instance, struct dapf_window *out, int max) +{ + int node = adt_path_offset(adt, path); + u32 count = 0; + + if (node < 0 || max <= 0) { + printf("dapf: Missing ADT node %s for dapf-instance-%u\n", path, instance); + return -1; + } + + const struct dapf_t8110_config *config = dapf_t8110_slices(path, node, instance, &count); + if (!config || (int)count > max) + return -1; + + for (u32 i = 0; i < count; i++) { + struct dapf_t8110_config entry; + memcpy(&entry, &config[i], sizeof(entry)); + out[i] = (struct dapf_window){.start = entry.start, .end = entry.end}; + } + return (int)count; +} + static bool dapf_is_j614s(void) { return chip_id == T6040 && board_id == 4 && adt_is_compatible(adt, 0, "J614sAP"); diff --git a/src/dapf.h b/src/dapf.h index 70ce9eb3c..5e206f27d 100644 --- a/src/dapf.h +++ b/src/dapf.h @@ -17,8 +17,11 @@ struct dapf_window { u64 end; }; +#define DAPF_T8110_MAX_SLICES 16 + int dapf_init_t8132_halted(const char *path, int index); int dapf_t8132_windows(const char *path, int index, struct dapf_window *out, int max); int dapf_t8132_ranges(const char *path, u32 r0, u32 r4, u32 r20, u64 *ranges, int max); +int dapf_t8110_ranges(const char *path, u32 instance, struct dapf_window *out, int max); #endif diff --git a/src/isp.c b/src/isp.c index 5c44f6a11..0a90b7780 100644 --- a/src/isp.c +++ b/src/isp.c @@ -10,6 +10,38 @@ #include "utils.h" #include "xnuboot.h" +#include "libfdt/libfdt.h" + +/* + * Loader ISP power-up and heap carveout apply only when the kernel tree enables an + * `isp` node that has neither firmware segment placeholders nor a kernel-managed ISP + * compatible (apple,t8132-isp, apple,t6041-isp on T6040/T6041, apple,t6050-isp). + */ +bool isp_fdt_needs_init(const void *fdt) +{ + static const char *const kernel_owned[] = { + "apple,t8132-isp", + "apple,t6041-isp", + "apple,t6050-isp", + }; + if (!fdt || fdt_check_header(fdt) != 0) + return false; + int isp = fdt_path_offset(fdt, "isp"); + if (isp < 0) + return false; + const char *status = fdt_getprop(fdt, isp, "status", NULL); + if (status && strcmp(status, "okay") && strcmp(status, "ok")) + return false; + int resv = fdt_path_offset(fdt, "/reserved-memory"); + if (resv >= 0 && fdt_subnode_offset(fdt, resv, "isp-firmware-text") >= 0 && + fdt_subnode_offset(fdt, resv, "isp-firmware-data") >= 0) + return false; + for (size_t i = 0; i < ARRAY_SIZE(kernel_owned); i++) + if (!fdt_node_check_compatible(fdt, isp, kernel_owned[i])) + return false; + return true; +} + #define ISP_ASC_VERSION 0x1800000 #define ISP_VER_T8103 0xb0090 @@ -56,6 +88,11 @@ static const struct { static bool isp_initialized = false; static u64 heap_phys, heap_iova, heap_size; +void isp_reset(void) +{ + isp_initialized = false; +} + int isp_get_heap(u64 *phys, u64 *iova, u64 *size) { if (!isp_initialized) @@ -95,9 +132,7 @@ static int isp_firmware_end(const struct adt_segment_ranges *segments, u32 lengt int isp_init(void) { - /* The T6050 kernel owns power-up. Its handoff only reserves memory. */ - if (chip_id == T6050) - return 0; + isp_initialized = false; int err = -1; /* T8142 takes the T8140 (ISP17a) path throughout. */ diff --git a/src/isp.h b/src/isp.h index 630e599a0..ba09ea80c 100644 --- a/src/isp.h +++ b/src/isp.h @@ -5,6 +5,8 @@ #include "types.h" +void isp_reset(void); +bool isp_fdt_needs_init(const void *fdt); int isp_init(void); int isp_get_heap(u64 *phys, u64 *iova, u64 *size); u64 isp_iova_base(void); diff --git a/src/kboot.c b/src/kboot.c index 87b767d2c..696272704 100644 --- a/src/kboot.c +++ b/src/kboot.c @@ -9208,39 +9208,109 @@ struct isp_segment_ranges { } PACKED; /* - * T6041 (M4 Pro/Max) ISP: iBoot loads the firmware and Linux starts it as iBoot left it - * (aurora-silicon/linux#384). Its TEXT and DATA live wherever this boot's iBoot put them, so fill - * the kernel DT's placeholders /reserved-memory/isp-firmware-text and isp-firmware-data from the - * ADT segment-ranges: reg (no-map) at the physical address and iommu-addresses at the address the - * firmware runs them at. Without a placeholder, or with the ISP disabled, nothing is done. + * The firmware's main-memory IOVA window in /reserved-memory/isp-heap is at most 64 MiB + * (32 MiB on T6040/T6041, 20 MiB on T8132); the kernel allocates shared DMA buffers right above + * isp-heap, so __TEXT and __DATA must fit inside isp-heap's window rather than the old 64 MiB cap. */ -static int dt_set_isp_t6041(int fdt_node) +#define ISP_FW_WINDOW_MAX (64 * SZ_1M) + +static bool dt_isp_has_placeholders(void) { + int resv = fdt_path_offset(dt, "/reserved-memory"); + return resv >= 0 && fdt_subnode_offset(dt, resv, "isp-firmware-text") >= 0 && + fdt_subnode_offset(dt, resv, "isp-firmware-data") >= 0; +} + +/* + * Placeholder-driven ISP handoff (T6040/T6041 and any tree with /reserved-memory/isp-firmware-text + * and isp-firmware-data): iBoot loads the firmware and Linux starts it as iBoot left it. Fill the + * kernel DT's placeholders from this boot's ADT segment-ranges within dart-isp vm-base + isp-heap, + * and when the first ISP DART carries apple,dapf-ranges, replace it from ADT dapf-instance-0 via + * dapf_t8110_ranges() (failing closed if dapf-instance-0 is missing or malformed). + */ +static int dt_fill_isp_placeholders(int fdt_node, bool require_enabled) +{ + static const char expected_names[] = "text\0data\0heap"; static const struct { const char *segment; const char *node; } wanted[] = {{"__TEXT", "isp-firmware-text"}, {"__DATA", "isp-firmware-data"}}; - const char *status = fdt_getprop(dt, fdt_node, "status", NULL); - if (status && strcmp(status, "okay") && strcmp(status, "ok")) - return 0; + if (require_enabled) { + const char *status = fdt_getprop(dt, fdt_node, "status", NULL); + if (status && strcmp(status, "okay") && strcmp(status, "ok")) + return 0; + } - int adt_node = adt_path_offset(adt, "/arm-io/isp0"); - if (adt_node < 0) - bail("ADT: /arm-io/isp0 not found\n"); + const char *adt_isp_path = "/arm-io/isp0"; + const char *adt_dart_path = "/arm-io/dart-isp0"; + int adt_node = adt_path_offset(adt, adt_isp_path); + int dart_adt = adt_path_offset(adt, adt_dart_path); + if (adt_node < 0 || dart_adt < 0) { + adt_isp_path = "/arm-io/isp"; + adt_dart_path = "/arm-io/dart-isp"; + adt_node = adt_path_offset(adt, adt_isp_path); + dart_adt = adt_path_offset(adt, adt_dart_path); + } + if (adt_node < 0 || dart_adt < 0) + bail("ADT: ISP or ISP DART node not found\n"); - u32 names_len, ranges_len; + u64 vm_base = 0; + if (ADT_GETPROP(adt, dart_adt, "vm-base", &vm_base) != sizeof(vm_base) || !vm_base || + (vm_base & (SZ_16K - 1))) + bail("ADT: %s vm-base missing or unaligned\n", adt_dart_path); + + u32 names_len = 0, ranges_len = 0; const char *names = adt_getprop(adt, adt_node, "segment-names", &names_len); const struct adt_segment_ranges *seg = adt_getprop(adt, adt_node, "segment-ranges", &ranges_len); - if (!names || !seg) - bail("ADT: isp0 segment-names/segment-ranges missing\n"); + if (!names || !seg || !ranges_len || (ranges_len % sizeof(*seg))) + bail("ADT: %s segment-names/segment-ranges missing\n", adt_isp_path); + + u64 ram = 0, ram_size = 0; + int chosen = adt_path_offset(adt, "/chosen"); + if (chosen < 0 || ADT_GETPROP(adt, chosen, "dram-base", &ram) != sizeof(ram) || + ADT_GETPROP(adt, chosen, "dram-size", &ram_size) != sizeof(ram_size) || !ram_size || + ram > UINT64_MAX - ram_size) + bail("ADT: DRAM bounds missing for ISP segment validation\n"); uint32_t isp_phandle = fdt_get_phandle(dt, fdt_node); int resv = fdt_path_offset(dt, "/reserved-memory"); if (!isp_phandle || resv < 0) bail("FDT: ISP phandle or /reserved-memory missing\n"); + int bytes = 0; + const char *mr_names = fdt_getprop(dt, fdt_node, "memory-region-names", &bytes); + const fdt32_t *mr_refs = fdt_getprop(dt, fdt_node, "memory-region", &bytes); + if (!mr_names || bytes != 3 * (int)sizeof(*mr_refs)) + bail("FDT: ISP memory-region layout is not text, data and heap\n"); + int names_bytes = 0; + mr_names = fdt_getprop(dt, fdt_node, "memory-region-names", &names_bytes); + if (!mr_names || names_bytes != sizeof(expected_names) || + memcmp(mr_names, expected_names, sizeof(expected_names))) + bail("FDT: ISP memory-region-names are not text, data and heap\n"); + + int heap = fdt_subnode_offset(dt, resv, "isp-heap"); + for (size_t w = 0; w < ARRAY_SIZE(wanted); w++) { + int sub = fdt_subnode_offset(dt, resv, wanted[w].node); + if (sub < 0 || fdt_node_offset_by_phandle(dt, fdt32_ld(mr_refs + w)) != sub) + bail("FDT: ISP region %zu does not match /reserved-memory/%s\n", w, wanted[w].node); + } + if (heap < 0 || fdt_node_offset_by_phandle(dt, fdt32_ld(mr_refs + 2)) != heap) + bail("FDT: ISP heap region does not match /reserved-memory/isp-heap\n"); + + const fdt32_t *map = fdt_getprop(dt, heap, "iommu-addresses", &bytes); + if (!map || bytes != 5 * (int)sizeof(*map) || fdt32_ld(map) != isp_phandle) + bail("FDT: /reserved-memory/isp-heap has no valid iommu-addresses window\n"); + u64 heap_base = ((u64)fdt32_ld(map + 1) << 32) | fdt32_ld(map + 2); + u64 window_size = ((u64)fdt32_ld(map + 3) << 32) | fdt32_ld(map + 4); + if (heap_base != vm_base || !window_size || (window_size & (SZ_16K - 1)) || + window_size > ISP_FW_WINDOW_MAX || vm_base > UINT64_MAX - window_size) + bail("FDT: isp-heap window 0x%lx+0x%lx does not match %s vm-base 0x%lx\n", heap_base, + window_size, adt_dart_path, vm_base); + + struct adt_segment_ranges found[ARRAY_SIZE(wanted)] = {0}; + unsigned int seen = 0; unsigned int count = ranges_len / sizeof(*seg); const char *name = names; for (unsigned int i = 0; i < count && name < names + names_len; i++) { @@ -9250,35 +9320,80 @@ static int dt_set_isp_t6041(int fdt_node) for (size_t w = 0; w < ARRAY_SIZE(wanted); w++) { if (len != strlen(wanted[w].segment) || memcmp(name, wanted[w].segment, len)) continue; - - if (!seg[i].size || seg[i].size > 64 * SZ_1M || (seg[i].phys & (SZ_16K - 1)) || - (seg[i].size & (SZ_16K - 1))) - bail("ADT: ISP segment %s has a bad range\n", wanted[w].segment); - - int node = fdt_subnode_offset(dt, resv, wanted[w].node); - if (node < 0) { - printf("FDT: no /reserved-memory/%s placeholder, ISP left as is\n", wanted[w].node); - return 0; - } - - fdt64_t reg[2] = {cpu_to_fdt64(seg[i].phys), cpu_to_fdt64(seg[i].size)}; - fdt32_t iommu[5] = {cpu_to_fdt32(isp_phandle), cpu_to_fdt32(seg[i].remap >> 32), - cpu_to_fdt32(seg[i].remap), cpu_to_fdt32((u64)seg[i].size >> 32), - cpu_to_fdt32(seg[i].size)}; - if (fdt_setprop(dt, node, "reg", reg, sizeof(reg)) || - fdt_setprop_empty(dt, node, "no-map") || - fdt_setprop(dt, node, "iommu-addresses", iommu, sizeof(iommu))) - bail("FDT: could not fill /reserved-memory/%s\n", wanted[w].node); - /* the offsets moved: look the parent up again for the next segment */ - resv = fdt_path_offset(dt, "/reserved-memory"); - printf("FDT: ISP %s at 0x%lx (+0x%x), runs at 0x%lx\n", wanted[w].segment, seg[i].phys, - seg[i].size, seg[i].remap); + if (seen & (1U << w)) + bail("ADT: duplicate ISP segment %s\n", wanted[w].segment); + u64 aligned_size = ALIGN_UP((u64)seg[i].size, SZ_16K); + if (!seg[i].size || aligned_size > window_size || (seg[i].phys & (SZ_16K - 1)) || + (seg[i].remap & (SZ_16K - 1)) || seg[i].remap < vm_base || + seg[i].remap - vm_base > window_size - aligned_size) + bail("ADT: ISP segment %s outside firmware window 0x%lx+0x%lx\n", wanted[w].segment, + vm_base, window_size); + if (seg[i].phys < ram || seg[i].phys - ram >= ram_size || + aligned_size > ram_size - (seg[i].phys - ram)) + bail("ADT: ISP segment %s outside DRAM\n", wanted[w].segment); + + found[w] = seg[i]; + found[w].size = aligned_size; + seen |= 1U << w; } if (!end) break; name = end + 1; } + if (seen != ((1U << ARRAY_SIZE(wanted)) - 1)) + bail("ADT: ISP __TEXT/__DATA segments incomplete\n"); + if ((found[0].phys < found[1].phys + found[1].size && + found[1].phys < found[0].phys + found[0].size) || + (found[0].remap < found[1].remap + found[1].size && + found[1].remap < found[0].remap + found[0].size)) + bail("ADT: ISP segments overlap\n"); + + int iommus_len = 0; + const fdt32_t *iommus = fdt_getprop(dt, fdt_node, "iommus", &iommus_len); + uint32_t dart_ph = (iommus && iommus_len >= (int)sizeof(*iommus)) ? fdt32_ld(iommus) : 0; + int dart_fdt = dart_ph ? fdt_node_offset_by_phandle(dt, dart_ph) : -1; + bool sync_dapf = dart_fdt >= 0 && fdt_getprop(dt, dart_fdt, "apple,dapf-ranges", NULL) != NULL; + struct dapf_window dapf[DAPF_T8110_MAX_SLICES]; + int dapf_count = 0; + if (sync_dapf) { + dapf_count = dapf_t8110_ranges(adt_dart_path, 0, dapf, ARRAY_SIZE(dapf)); + if (dapf_count < 0) + bail("ADT: invalid %s dapf-instance-0; refusing stale apple,dapf-ranges\n", + adt_dart_path); + } + + for (size_t w = 0; w < ARRAY_SIZE(wanted); w++) { + int node = fdt_subnode_offset(dt, resv, wanted[w].node); + if (node < 0) + bail("FDT: missing /reserved-memory/%s\n", wanted[w].node); + + fdt64_t reg[2] = {cpu_to_fdt64(found[w].phys), cpu_to_fdt64(found[w].size)}; + fdt32_t iommu[5] = {cpu_to_fdt32(isp_phandle), cpu_to_fdt32(found[w].remap >> 32), + cpu_to_fdt32(found[w].remap), cpu_to_fdt32((u64)found[w].size >> 32), + cpu_to_fdt32(found[w].size)}; + if (fdt_setprop(dt, node, "reg", reg, sizeof(reg)) || + fdt_setprop_empty(dt, node, "no-map") || + fdt_setprop(dt, node, "iommu-addresses", iommu, sizeof(iommu))) + bail("FDT: could not fill /reserved-memory/%s\n", wanted[w].node); + /* the offsets moved: look the parent up again for the next segment */ + resv = fdt_path_offset(dt, "/reserved-memory"); + printf("FDT: ISP %s at 0x%lx (+0x%x), runs at 0x%lx\n", wanted[w].segment, found[w].phys, + found[w].size, found[w].remap); + } + + if (sync_dapf) { + fdt64_t ranges[2 * DAPF_T8110_MAX_SLICES]; + for (int i = 0; i < dapf_count; i++) { + ranges[2 * i] = cpu_to_fdt64(dapf[i].start); + ranges[2 * i + 1] = cpu_to_fdt64(dapf[i].end); + } + dart_fdt = fdt_node_offset_by_phandle(dt, dart_ph); + if (dart_fdt < 0 || fdt_setprop(dt, dart_fdt, "apple,dapf-ranges", ranges, + 2 * (size_t)dapf_count * sizeof(fdt64_t))) + bail("FDT: could not set %s apple,dapf-ranges\n", adt_dart_path); + } + return 0; } @@ -9312,9 +9427,9 @@ static int dt_set_isp_fwdata(void) if (firmware_set_fdt(dt, fdt_node, "apple,firmware-compat", compat) < 0) bail("FDT: Could not set apple,firmware-compat for %s\n", fdt_path); - /* T6041: iBoot's firmware, not m1n1's heap setup */ - if (chip_id == T6041) - return dt_set_isp_t6041(fdt_node); + /* Trees with firmware placeholders take iBoot's segments instead of a loader heap. */ + if (dt_isp_has_placeholders()) + return dt_fill_isp_placeholders(fdt_node, true); if (isp_get_heap(&phys, &iova, &size)) { const char *status = fdt_getprop(dt, fdt_node, "status", NULL); @@ -9534,9 +9649,20 @@ static int dt_set_isp(void) !fdt_node_check_compatible(dt, 0, "apple,j614s")) return 0; - /* A T8140/T8142 ISP that isp_init() did not bring up has no firmware to reserve. */ - if ((chip_id == T8140 || chip_id == T8142) && - isp_get_heap(&heap_phys, &heap_iova, &heap_size)) { + /* Trees with firmware placeholders fill them in dt_set_isp_fwdata() without asc-firmware. */ + if (dt_isp_has_placeholders()) { + if (!dt_set_isp_fwdata()) + return 0; + int resv = fdt_path_offset(dt, "/reserved-memory"); + static const char *const placeholders[] = {"isp-firmware-text", "isp-firmware-data"}; + for (unsigned int i = 0; resv >= 0 && i < ARRAY_SIZE(placeholders); i++) { + int p = fdt_subnode_offset(dt, resv, placeholders[i]); + if (p >= 0 && fdt_setprop_string(dt, p, "status", "disabled") < 0) + return -1; + resv = fdt_path_offset(dt, "/reserved-memory"); + } + } else if ((chip_id == T8140 || chip_id == T8142) && + isp_get_heap(&heap_phys, &heap_iova, &heap_size)) { if (!dt_set_isp_fwdata()) return 0; } else if (!dt_reserve_asc_firmware("/arm-io/isp", "/arm-io/isp0", "isp", false, @@ -11386,8 +11512,9 @@ int kboot_prepare_dt(void *fdt) /* Before the tree and anything kboot reserves are allocated */ kboot_decide_hibernate_layout(); - /* Need to init ISP early to carve out heap */ - if (chip_id != T8152) + /* Need to init ISP early to carve out heap when the kernel tree asks for one */ + isp_reset(); + if (chip_id != T8152 && isp_fdt_needs_init(fdt)) isp_init(); dt_bufsize = fdt_totalsize(fdt); @@ -11777,82 +11904,24 @@ static int dt_disable_j713_pcie(void) /* J614s ISP handoff. Run only after the DAPF result is known. */ static int dt_finish_j614s_isp(bool ready) { - static const char expected_names[] = "text\0data\0heap"; - static const char segment_names[] = "__TEXT;__DATA"; - static const char *const paths[] = {"/reserved-memory/isp-firmware-text", - "/reserved-memory/isp-firmware-data", - "/reserved-memory/isp-heap"}; - const struct adt_segment_ranges *segments; - const fdt32_t *refs, *map; - u64 phys[2], iova[2], size[2], dram_base, dram_size; - u32 isp_phandle, handles[3], darts[3], len; - int bytes, chosen, adt_isp, isp; + const fdt32_t *refs; + u32 darts[3]; + int bytes, isp; if (!ready || firmware_os_components() != V26_6_2) return -1; - chosen = adt_path_offset(adt, "/chosen"); - adt_isp = adt_path_offset(adt, "/arm-io/isp0"); isp = fdt_node_offset_by_compatible(dt, -1, "apple,t6041-isp"); - if (chosen < 0 || adt_isp < 0 || isp < 0 || - ADT_GETPROP(adt, chosen, "dram-base", &dram_base) != sizeof(dram_base) || - ADT_GETPROP(adt, chosen, "dram-size", &dram_size) != sizeof(dram_size) || !dram_size || - dram_base > UINT64_MAX - dram_size) - return -1; - const char *names = adt_getprop(adt, adt_isp, "segment-names", &len); - if (!names || len != sizeof(segment_names) || memcmp(names, segment_names, len)) - return -1; - segments = adt_getprop(adt, adt_isp, "segment-ranges", &len); - if (!segments || len != 2 * sizeof(*segments)) - return -1; - for (int i = 0; i < 2; i++) { - phys[i] = segments[i].phys; - iova[i] = segments[i].remap; - size[i] = ALIGN_UP((u64)segments[i].size, SZ_16K); - if (!size[i] || size[i] > 32 * SZ_1M || (phys[i] & (SZ_16K - 1)) || - (iova[i] & (SZ_16K - 1)) || phys[i] < dram_base || size[i] > dram_size || - phys[i] - dram_base > dram_size - size[i] || iova[i] > UINT64_MAX - size[i]) - return -1; - } - if (iova[0] != 0x10000000000ULL || iova[1] != iova[0] + size[0] || - size[0] + size[1] > 32 * SZ_1M || - (phys[0] < phys[1] + size[1] && phys[1] < phys[0] + size[0])) - return -1; - - names = fdt_getprop(dt, isp, "memory-region-names", &bytes); - if (!names || bytes != sizeof(expected_names) || memcmp(names, expected_names, bytes)) - return -1; - refs = fdt_getprop(dt, isp, "memory-region", &bytes); - if (!refs || bytes != sizeof(handles)) - return -1; - for (int i = 0; i < 3; i++) { - handles[i] = fdt32_ld(refs + i); - int node = fdt_path_offset(dt, paths[i]); - if (node < 0 || fdt_node_offset_by_phandle(dt, handles[i]) != node) - return -1; - } - isp_phandle = fdt_get_phandle(dt, isp); - int heap = fdt_path_offset(dt, paths[2]); - map = fdt_getprop(dt, heap, "iommu-addresses", &bytes); - if (!isp_phandle || !map || bytes != 5 * sizeof(*map) || fdt32_ld(map) != isp_phandle || - fdt32_ld(map + 1) != 0x100 || fdt32_ld(map + 2) || fdt32_ld(map + 3) || - fdt32_ld(map + 4) != 32 * SZ_1M) + if (isp < 0) return -1; refs = fdt_getprop(dt, isp, "iommus", &bytes); - if (!refs || bytes != 6 * sizeof(*refs)) + if (!refs || bytes != 6 * (int)sizeof(*refs)) return -1; for (int i = 0; i < 3; i++) darts[i] = fdt32_ld(refs + i * 2); - for (int i = 0; i < 2; i++) { - const char *name = i ? "isp-firmware-data" : "isp-firmware-text"; - int node = dt_get_or_add_reserved_mem(name, "apple,asc-mem", true, phys[i], size[i]); - if (node < 0) - return -1; - int ret = fdt_delprop(dt, node, "iommu-addresses"); - if ((ret && ret != -FDT_ERR_NOTFOUND) || - dt_device_set_reserved_mem(node, name, isp_phandle, iova[i], size[i])) - return -1; - } + if (dt_fill_isp_placeholders(isp, false)) + return -1; + isp = fdt_node_offset_by_compatible(dt, -1, "apple,t6041-isp"); if (isp < 0 || firmware_set_fdt(dt, isp, "apple,firmware-version", &os_firmware) < 0) return -1; diff --git a/tests/python/test_isp_heap.py b/tests/python/test_isp_heap.py index c8f931278..4e93dd039 100644 --- a/tests/python/test_isp_heap.py +++ b/tests/python/test_isp_heap.py @@ -47,8 +47,10 @@ #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) #define GENMASK(h, l) (((~0ULL) << (l)) & (~0ULL >> (63 - (h)))) #define ALIGN_UP(x, a) (((x) + (a) - 1) & ~((a) - 1)) -/* Stub: the T6041 ISP handoff isn't exercised here. */ -__attribute__((unused)) static int dt_set_isp_t6041(int node) { (void)node; return 0; } +/* Stub: placeholder-based ISP handoff isn't exercised here. */ +__attribute__((unused)) static bool dt_isp_has_placeholders(void) { return false; } +__attribute__((unused)) static int dt_fill_isp_placeholders(int node, bool req) +{ (void)node; (void)req; return 0; } struct adt_segment_ranges { u64 phys, iova, remap; @@ -344,9 +346,8 @@ def test_isp_fdt_fails_closed_and_exports_heap(tmp_path): #include typedef uint64_t u64; typedef uint32_t u32; -#define T6041 0x6041 -static u32 chip_id; -static int dt_set_isp_t6041(int node) { (void)node; return 0; } +static bool dt_isp_has_placeholders(void) { return false; } +static int dt_fill_isp_placeholders(int node, bool req) { (void)node; (void)req; return 0; } #define V13_6_1 1 #define V13_5 2 #define bail(...) do { fprintf(stderr, __VA_ARGS__); return -1; } while (0) diff --git a/tests/python/test_isp_optional.py b/tests/python/test_isp_optional.py index ab21b7648..4abcd624a 100644 --- a/tests/python/test_isp_optional.py +++ b/tests/python/test_isp_optional.py @@ -18,6 +18,8 @@ def function(name): start = source.index("static int " + name + "(") return source[start:source.index("\n}", start) + 2] + "\n" + start = source.index("static bool dt_isp_has_placeholders(void)") + has_placeholders = source[start:source.index("\n}", start) + 2] + "\n" start = source.index("/*\n * The camera is optional.") set_isp = source[start:source.index("\n}", start) + 2] + "\n" header = (ROOT / "src/adt.h").read_text() @@ -41,6 +43,7 @@ def function(name): #define T8142 0x8142 #define T8132 0x8132 #define SZ_16K 16384 +#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) #define ALIGN_UP(x, a) (((x) + (a) - 1) & ~((a) - 1)) #define bail(...) do { printf(__VA_ARGS__); return -1; } while (0) /* Only the dram_only segment filter reads properties this way; ISP reservations do not. */ @@ -97,7 +100,8 @@ def function(name): /* This fixture exercises the legacy optional-camera path, never the T6050 transaction. */ static int dt_t6050_isp_transaction(void) { abort(); } ''' + function("dt_device_set_reserved_mem") + - function("dt_reserve_asc_segments_at") + function("dt_reserve_asc_segments") + function("dt_reserve_asc_firmware") + set_isp + r''' + function("dt_reserve_asc_segments_at") + function("dt_reserve_asc_segments") + + function("dt_reserve_asc_firmware") + has_placeholders + set_isp + r''' static void world(int which) { fault = which; @@ -160,6 +164,24 @@ def function(name): /* If its firmware data then fails, it is disabled too. */ world(2); chip_id = T8140; isp_up = false; fwdata_fault = 1; assert(dt_set_isp() == 0 && !strcmp(isp_status(), "disabled")); + /* Any chip (T6040, T6041, etc.) with placeholders fills them directly without asc-firmware. */ + for (int k = 0; k < 2; k++) { + world(2); chip_id = k ? 0x6041 : T6040; + int resv = fdt_path_offset(dt, "/reserved-memory"); + assert(fdt_add_subnode(dt, resv, "isp-firmware-text") >= 0); + resv = fdt_path_offset(dt, "/reserved-memory"); + assert(fdt_add_subnode(dt, resv, "isp-firmware-data") >= 0); + assert(dt_set_isp() == 0 && fwdata_calls == 1 && !reservations && !strcmp(isp_status(), "okay")); + world(2); chip_id = k ? 0x6041 : T6040; fwdata_fault = 1; + resv = fdt_path_offset(dt, "/reserved-memory"); + assert(fdt_add_subnode(dt, resv, "isp-firmware-text") >= 0); + resv = fdt_path_offset(dt, "/reserved-memory"); + assert(fdt_add_subnode(dt, resv, "isp-firmware-data") >= 0); + assert(dt_set_isp() == 0 && !reservations && !strcmp(isp_status(), "disabled")); + resv = fdt_path_offset(dt, "/reserved-memory"); + int t = fdt_subnode_offset(dt, resv, "isp-firmware-text"); + assert(!strcmp(fdt_getprop(dt, t, "status", NULL), "disabled")); + } puts("PASS isp optional"); return 0; } diff --git a/tests/python/test_isp_reservation_full.py b/tests/python/test_isp_reservation_full.py index 2ac8e67c2..66bea4e1a 100644 --- a/tests/python/test_isp_reservation_full.py +++ b/tests/python/test_isp_reservation_full.py @@ -36,8 +36,10 @@ def definition(signature): static u32 chip_id; static unsigned int mappings, links; #define ALIGN_UP(x, a) (((x) + (a) - 1) & ~((a) - 1)) -/* Stub: the T6041 ISP handoff isn't exercised here. */ -__attribute__((unused)) static int dt_set_isp_t6041(int node) { (void)node; return 0; } +/* Stub: placeholder-based ISP handoff isn't exercised here. */ +__attribute__((unused)) static bool dt_isp_has_placeholders(void) { return false; } +__attribute__((unused)) static int dt_fill_isp_placeholders(int node, bool req) +{ (void)node; (void)req; return 0; } #define V13_5 0 #define V13_6_1 1 #define bail(...) do { return -1; } while (0) diff --git a/tests/python/test_j713_aop_dapf.py b/tests/python/test_j713_aop_dapf.py index a018f043f..b126ee61e 100644 --- a/tests/python/test_j713_aop_dapf.py +++ b/tests/python/test_j713_aop_dapf.py @@ -238,7 +238,7 @@ def run(text): ("end mask", "(read64(slice + 0x10) & ~3UL) != (want[i].end & ~3UL)", "read64(slice + 0x10) != want[i].end"), ("slice limit", "length / sizeof(*config) > T8132_DAPF_SLICES", "false"), - ("slice order", "config[i].end < config[i].start", "false"), + ("slice order", "entry.end < entry.start", "false"), ("merge", "if (pos > 0 && window.start <= out[pos - 1].end) {", "if (false) {"), ("grown merge", "while (pos + 1 < used && out[pos + 1].start <= out[pos].end) {", "while (false) {"), diff --git a/tests/python/test_j713_isp_dapf.py b/tests/python/test_j713_isp_dapf.py index 686f3a2a3..983b86cb6 100644 --- a/tests/python/test_j713_isp_dapf.py +++ b/tests/python/test_j713_isp_dapf.py @@ -101,7 +101,7 @@ def run(text): ("words", "config[i].r4 != r4 ||", "false ||"), ("room", "count > (u32)max", "false"), ("order", "ranges[2 * i] = config[i].start;", "ranges[2 * i] = config[count - 1 - i].start;"), - ("slice order", "config[i].end < config[i].start", "false"), + ("slice order", "entry.end < entry.start", "false"), ("smmu", "case DAPF_INSTANCE_SMMU:", ""), ("one bank", "if (found >= 0) {", "if (false) {"), ] diff --git a/tests/python/test_t6041_isp_handoff.py b/tests/python/test_t6041_isp_handoff.py new file mode 100644 index 000000000..7e4077434 --- /dev/null +++ b/tests/python/test_t6041_isp_handoff.py @@ -0,0 +1,275 @@ +# SPDX-License-Identifier: MIT +"""Exercise property-driven ISP power-up skip, placeholder segment fill, and DAPF sync.""" + +import shutil +import subprocess +from pathlib import Path + +import pytest +from test_siliconforest_handoff import run_c + +ROOT = Path(__file__).resolve().parents[2] + +TREE = r'''/dts-v1/; +/ { + compatible = "apple,j616c", "apple,t6041"; + #address-cells = <2>; #size-cells = <2>; + aliases { isp = &isp; }; + reserved-memory { + #address-cells = <2>; #size-cells = <2>; ranges; + isp_fw_text: isp-firmware-text@10000c44000 { + reg = <0x100 0x00c44000 0x0 0xca8000>; + iommu-addresses = <&isp 0x100 0x0 0x0 0xca8000>; + no-map; + }; + isp_fw_data: isp-firmware-data@10001e7c000 { + reg = <0x100 0x01e7c000 0x0 0x1344000>; + iommu-addresses = <&isp 0x100 0xca8000 0x0 0x1344000>; + no-map; + }; + isp_heap: isp-heap { iommu-addresses = <&isp 0x100 0x0 0x0 0x2000000>; }; + }; + soc { + #address-cells = <2>; #size-cells = <2>; ranges; + isp: isp@580000000 { + compatible = "apple,t6041-isp", "apple,isp"; + iommus = <&isp_dart0 0>, <&isp_dart1 0>, <&isp_dart2 0>; + memory-region = <&isp_fw_text>, <&isp_fw_data>, <&isp_heap>; + memory-region-names = "text", "data", "heap"; + status = "okay"; + }; + isp_dart0: iommu@5828c0000 { + #iommu-cells = <1>; + apple,dapf-ranges = /bits/ 64 <0x502284000 0x50228402b>; + status = "okay"; + }; + isp_dart1: iommu@5828e0000 { #iommu-cells = <1>; status = "okay"; }; + isp_dart2: iommu@582900000 { #iommu-cells = <1>; status = "okay"; }; + }; +}; +''' + + +def test_isp_placeholder_handoff_dapf_sync_and_fdt_power_gate(tmp_path): + if not shutil.which("dtc"): + pytest.skip("needs dtc") + kboot = (ROOT / "src/kboot.c").read_text() + isp_src = (ROOT / "src/isp.c").read_text() + dapf_src = (ROOT / "src/dapf.c").read_text() + dapf_hdr = (ROOT / "src/dapf.h").read_text() + + def kboot_fn(sig): + start = kboot.index(sig) + return kboot[start:kboot.index("\n}", start) + 2] + "\n" + + needs_init = isp_src[isp_src.index("bool isp_fdt_needs_init("):isp_src.index("#define ISP_ASC_VERSION")] + t8110_cfg = dapf_src[dapf_src.index("struct dapf_t8110_config {"):dapf_src.index("struct dapf_t8110b_config {")] + dapf_slices = dapf_src[dapf_src.index("static const struct dapf_t8110_config *dapf_t8110_slices("): + dapf_src.index("/*\n * Program a genuine T8132")] + dapf_ranges = dapf_src[dapf_src.index("int dapf_t8110_ranges("): + dapf_src.index("static bool dapf_is_j614s(")] + window_def = dapf_hdr[dapf_hdr.index("struct dapf_window {"):dapf_hdr.index("#endif")] + + header = (ROOT / "src/adt.h").read_text() + start = header.index("struct adt_segment_ranges {") + layout = header[start:header.index("} PACKED;", start) + len("} PACKED;")] + dtb = tmp_path / "j616c.dtb" + subprocess.run(["dtc", "-q", "-I", "dts", "-O", "dtb", "-o", str(dtb), "-"], + input=TREE, text=True, check=True) + run_c(tmp_path, "isp-placeholder-handoff", '#define DTB_PATH "%s"\n' % dtb + r''' +#include +#include +#include +#include +#include +#include +#include "libfdt.h" +typedef unsigned long u64; +typedef uint32_t u32; +typedef uint8_t u8; +#define PACKED __attribute__((packed)) +#define static_assert _Static_assert +#define T6030 0x6030 +#define T6040 0x6040 +#define T6041 0x6041 +#define T6050 0x6050 +#define T8132 0x8132 +#define T8140 0x8140 +#define T8142 0x8142 +#define V13_5 0 +#define V13_6_1 1 +#define V26_6_2 2 +#define SZ_16K 0x4000 +#define SZ_1M 0x100000 +#define ISP_FW_WINDOW_MAX (64 * SZ_1M) +#define T8132_DAPF_SLICES 16 +#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) +#define ALIGN_UP(x, a) (((x) + (a) - 1) & ~((a) - 1)) +static char log_buf[8192]; +#define printf(...) snprintf(log_buf + strlen(log_buf), sizeof(log_buf) - strlen(log_buf), __VA_ARGS__) +#define bail(...) do { printf(__VA_ARGS__); return -1; } while (0) +struct fw_version_info { int version; }; +static struct fw_version_info os_firmware = {V26_6_2}, fw_versions[3]; +static int firmware_os_components(void) { return os_firmware.version; } +static void *dt, *adt; +static u32 chip_id = T6041, board_id = 6; +static unsigned char blob[32768]; +''' + window_def + layout + t8110_cfg + r''' +static struct adt_segment_ranges segments[2]; +static const char *seg_names; +static u64 dram_base, dram_size, dart_vm_base; +static struct dapf_t8110_config dapf_records[17]; +static u32 dapf_len; +static bool adt_is_compatible(const void *tree, int node, const char *compat) +{ (void)tree; (void)node; (void)compat; return false; } +static int firmware_set_fdt(void *tree, int node, const char *name, + const struct fw_version_info *version) +{ (void)version; return fdt_setprop_u32(tree, node, name, 27); } +static u64 isp_iova_base(void) { return 0x10000000000ULL; } +static int isp_get_heap(u64 *p, u64 *i, u64 *s) { (void)p; (void)i; (void)s; return -1; } +static int dt_t6050_isp_transaction(void) { abort(); } +static int dt_reserve_asc_firmware(const char *a, const char *b, const char *c, bool d, u64 e) +{ (void)a; (void)b; (void)c; (void)d; (void)e; abort(); } +static int dt_get_or_add_reserved_mem(const char *a, const char *b, bool c, u64 d, size_t e) +{ (void)a; (void)b; (void)c; (void)d; (void)e; abort(); } +static int dt_device_set_reserved_mem(int a, const char *b, u32 c, u64 d, size_t e) +{ (void)a; (void)b; (void)c; (void)d; (void)e; abort(); } +static int adt_path_offset(const void *tree, const char *path) +{ + (void)tree; + if (!strcmp(path, "/chosen")) return 2; + if (!strcmp(path, "/arm-io/isp0")) return 3; + if (!strcmp(path, "/arm-io/dart-isp0")) return 4; + return -1; +} +static const void *adt_getprop(const void *tree, int node, const char *name, u32 *len) +{ + (void)tree; + if (node == 2 && !strcmp(name, "dram-base")) { *len = 8; return &dram_base; } + if (node == 2 && !strcmp(name, "dram-size")) { *len = 8; return &dram_size; } + if (node == 3 && !strcmp(name, "segment-names")) { *len = strlen(seg_names) + 1; return seg_names; } + if (node == 3 && !strcmp(name, "segment-ranges")) { *len = sizeof(segments); return segments; } + if (node == 4 && !strcmp(name, "vm-base")) { *len = 8; return &dart_vm_base; } + if (node == 4 && !strcmp(name, "dapf-instance-0")) { *len = dapf_len; return dapf_records; } + return NULL; +} +static int get_value(int node, const char *name, void *out, size_t cap) +{ + u32 len = 0; + const void *p = adt_getprop(adt, node, name, &len); + if (!p || len > cap) return -1; + memcpy(out, p, len); + return len; +} +#define ADT_GETPROP(a, n, k, v) get_value(n, k, v, sizeof(*(v))) +''' + needs_init + dapf_slices + dapf_ranges + kboot_fn("static bool dt_isp_has_placeholders(") + + kboot_fn("static int dt_fill_isp_placeholders(") + kboot_fn("static int dt_set_isp_fwdata(") + + kboot_fn("static int dt_set_isp(") + kboot_fn("static int dt_finish_j614s_isp(") + r''' +static void setup(unsigned int amccs) +{ + FILE *f = fopen(DTB_PATH, "rb"); + unsigned char raw[8192]; + size_t n = fread(raw, 1, sizeof(raw), f); + fclose(f); + assert(n > 0); + memset(blob, 0, sizeof(blob)); + assert(!fdt_open_into(raw, blob, sizeof(blob))); + dt = blob; + log_buf[0] = 0; + chip_id = T6041; + dram_base = 0x10000000000ULL; + dram_size = 0x1000000000ULL; + dart_vm_base = 0x10000000000ULL; + seg_names = "__TEXT;__DATA"; + segments[0] = (struct adt_segment_ranges){ + .phys = 0x10000dd4000ULL, .iova = 0, .remap = 0x10000000000ULL, .size = 0xbf0000, .unk = 1 + }; + segments[1] = (struct adt_segment_ranges){ + .phys = 0x10002020000ULL, .iova = 0xbf0000, .remap = 0x10000bf0000ULL, .size = 0x13fc000 + }; + u32 count = 7 + amccs; + memset(dapf_records, 0, sizeof(dapf_records)); + for (unsigned int i = 0; i < count; i++) { + u64 s = i < 7 ? (0x502284000ULL + i * 0x4000) : (0x220004000ULL + (i - 7) * 0x2000000ULL); + u64 e = i < 7 ? (s + 0x2b) : (s + 0x1d22fcULL); + dapf_records[i].start = s; + dapf_records[i].end = e; + } + dapf_len = count * sizeof(struct dapf_t8110_config); +} +int main(void) +{ + /* 1. FDT property-driven isp_init() gate: skips kernel-managed/placeholder trees on T6040/T6041/T6050. */ + setup(8); + assert(!isp_fdt_needs_init(dt)); + int resv = fdt_path_offset(dt, "/reserved-memory"); + assert(!fdt_del_node(dt, fdt_subnode_offset(dt, resv, "isp-firmware-text"))); + resv = fdt_path_offset(dt, "/reserved-memory"); + assert(!fdt_del_node(dt, fdt_subnode_offset(dt, resv, "isp-firmware-data"))); + /* Even without placeholders, apple,t6041-isp / apple,t6050-isp / apple,t8132-isp skip isp_init(). */ + assert(!isp_fdt_needs_init(dt)); + assert(!fdt_setprop_string(dt, fdt_path_offset(dt, "isp"), "compatible", "apple,t6050-isp")); + assert(!isp_fdt_needs_init(dt)); + /* A legacy/H17 enabled ISP without placeholders DOES run isp_init(), unless disabled. */ + assert(!fdt_setprop_string(dt, fdt_path_offset(dt, "isp"), "compatible", "apple,t8140-isp")); + assert(isp_fdt_needs_init(dt)); + assert(!fdt_setprop_string(dt, fdt_path_offset(dt, "isp"), "status", "disabled")); + assert(!isp_fdt_needs_init(dt)); + + /* 2. Full 8-AMCC T6041: 3 memory-regions (no asc-firmware duplicates), 15 DAPF pairs. */ + setup(8); + assert(dt_set_isp() == 0); + int isp = fdt_path_offset(dt, "isp"), len = 0; + assert(fdt_getprop(dt, isp, "memory-region", &len) && len == 3 * 4); + int dart = fdt_path_offset(dt, "/soc/iommu@5828c0000"); + const fdt64_t *ranges = fdt_getprop(dt, dart, "apple,dapf-ranges", &len); + assert(ranges && len == 15 * 16); + assert(fdt64_ld(&ranges[28]) == 0x22e004000ULL && fdt64_ld(&ranges[29]) == 0x22e1d62fcULL); + + resv = fdt_path_offset(dt, "/reserved-memory"); + int tnode = fdt_subnode_offset(dt, resv, "isp-firmware-text"); + const fdt64_t *reg = fdt_getprop(dt, tnode, "reg", &len); + assert(reg && len == 16 && fdt64_ld(reg) == 0x10000dd4000ULL && fdt64_ld(reg + 1) == 0xbf0000); + + /* 3. T6040 (e.g. J616s) takes the exact same placeholder path without chip_id == T6041 gating. */ + setup(6); + chip_id = T6040; + assert(dt_set_isp() == 0); + dart = fdt_path_offset(dt, "/soc/iommu@5828c0000"); + assert(fdt_getprop(dt, dart, "apple,dapf-ranges", &len) && len == 13 * 16); + assert(!strcmp(fdt_getprop(dt, fdt_path_offset(dt, "isp"), "status", NULL), "okay")); + + /* 4. J614s disabled-at-boot flow shares dt_fill_isp_placeholders() and enables ISP + 3 DARTs. */ + setup(6); + chip_id = T6040; + assert(!fdt_setprop_string(dt, fdt_path_offset(dt, "isp"), "status", "disabled")); + assert(!fdt_setprop_string(dt, fdt_path_offset(dt, "/soc/iommu@5828c0000"), "status", "disabled")); + assert(dt_finish_j614s_isp(true) == 0); + assert(!strcmp(fdt_getprop(dt, fdt_path_offset(dt, "isp"), "status", NULL), "okay")); + assert(!strcmp(fdt_getprop(dt, fdt_path_offset(dt, "/soc/iommu@5828c0000"), "status", NULL), "okay")); + + /* 5. Malformed dapf-instance-0 logs an error and fails closed (disables ISP + placeholders). */ + setup(8); + dapf_len = sizeof(struct dapf_t8110_config) - 2; + assert(dt_set_isp() == 0); + assert(strstr(log_buf, "dapf: Invalid dapf-instance-0") != NULL); + assert(strstr(log_buf, "refusing stale apple,dapf-ranges") != NULL); + assert(!strcmp(fdt_getprop(dt, fdt_path_offset(dt, "isp"), "status", NULL), "disabled")); + resv = fdt_path_offset(dt, "/reserved-memory"); + assert(!strcmp(fdt_getprop(dt, fdt_subnode_offset(dt, resv, "isp-firmware-text"), "status", NULL), "disabled")); + + /* 6. Overlapping or out-of-window segments disable ISP and both placeholders. */ + setup(8); + segments[1].phys = segments[0].phys + 0x4000; + assert(dt_set_isp() == 0); + assert(!strcmp(fdt_getprop(dt, fdt_path_offset(dt, "isp"), "status", NULL), "disabled")); + + setup(8); + segments[1].remap = dart_vm_base + 0x1ff0000ULL; + assert(dt_set_isp() == 0); + assert(!strcmp(fdt_getprop(dt, fdt_path_offset(dt, "isp"), "status", NULL), "disabled")); + + puts("PASS ISP placeholder handoff"); + return 0; +} +''')