Skip to content

Commit 6a72bf2

Browse files
committed
kboot: Reserve ISP firmware
Signed-off-by: Eileen Yoon <eyn@gmx.com>
1 parent 912691e commit 6a72bf2

File tree

1 file changed

+66
-0
lines changed

1 file changed

+66
-0
lines changed

src/kboot.c

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1791,6 +1791,68 @@ static int dt_set_sio_fwdata(void)
17911791
return 0;
17921792
}
17931793

1794+
struct isp_segment_ranges {
1795+
u64 phys;
1796+
u64 iova;
1797+
u64 remap;
1798+
u32 size;
1799+
u32 unk;
1800+
} PACKED;
1801+
1802+
static int dt_set_isp_fwdata(void)
1803+
{
1804+
const char *path = "isp";
1805+
const char *adt_path = "/arm-io/isp";
1806+
1807+
int adt_node = adt_path_offset(adt, adt_path);
1808+
if (adt_node < 0) {
1809+
printf("ADT: '%s' node not found\n", adt_path);
1810+
return 0;
1811+
}
1812+
1813+
u32 segments_len;
1814+
struct isp_segment_ranges *segments;
1815+
segments =
1816+
(struct isp_segment_ranges *)adt_getprop(adt, adt_node, "segment-ranges", &segments_len);
1817+
if (!segments || !segments_len)
1818+
bail("ADT: invalid ISP segment-ranges\n");
1819+
1820+
int count = segments_len / sizeof(*segments);
1821+
for (int i = 0; i < count; i++)
1822+
segments[i].remap = segments[i].iova; // match sio segment-ranges
1823+
1824+
u64 ctrr_size;
1825+
switch (os_firmware.version) {
1826+
case V12_1: // haven't checked, probably right
1827+
case V12_2: // "
1828+
case V12_3:
1829+
case V12_3_1:
1830+
case V12_4:
1831+
case V12_5:
1832+
ctrr_size = 0x1800000;
1833+
break;
1834+
case V13_5:
1835+
ctrr_size = 0x1000000;
1836+
break;
1837+
default:
1838+
bail("FDT: couldn't get ISP CTRR size (%d)\n", os_firmware.version);
1839+
}
1840+
1841+
u64 heap_base = segments[count - 1].iova + segments[count - 1].size;
1842+
u64 heap_size = ctrr_size - heap_base;
1843+
1844+
int fdt_node = fdt_path_offset(dt, path);
1845+
if (fdt_node < 0)
1846+
bail("FDT: '%s' node not found\n", path);
1847+
1848+
if (fdt_appendprop_u64(dt, fdt_node, "apple,isp-heap-base", heap_base))
1849+
bail("FDT: couldn't set apple,isp-heap-base\n");
1850+
if (fdt_appendprop_u64(dt, fdt_node, "apple,isp-heap-size", heap_size))
1851+
bail("FDT: couldn't set apple,isp-heap-size\n");
1852+
1853+
return 0;
1854+
}
1855+
17941856
static int dt_disable_missing_devs(const char *adt_prefix, const char *dt_prefix, int max_devs)
17951857
{
17961858
int ret = -1;
@@ -2101,6 +2163,10 @@ int kboot_prepare_dt(void *fdt)
21012163
return -1;
21022164
if (dt_set_sio_fwdata())
21032165
return -1;
2166+
if (dt_set_isp_fwdata())
2167+
return -1;
2168+
if (dt_reserve_asc_firmware("/arm-io/isp", "isp"))
2169+
return -1;
21042170
#ifndef RELEASE
21052171
if (dt_transfer_virtios())
21062172
return 1;

0 commit comments

Comments
 (0)