-
Notifications
You must be signed in to change notification settings - Fork 33
/
Copy pathasahi
59 lines (46 loc) · 1.71 KB
/
asahi
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/usr/bin/ash
# SPDX-License-Identifier: MIT
run_earlyhook() {
if [ -e /vendorfw ]; then
msg ":: Asahi: Vendor firmware was loaded by the bootloader"
return 0
fi
if [ ! -e /proc/device-tree/chosen/asahi,efi-system-partition ]; then
msg ":: Asahi: Missing asahi,efi-system-partition variable, firmware will not be loaded!"
return 1
fi
msg ":: Asahi: Triggering early load of NVMe modules..."
modprobe apple-mailbox
modprobe nvme-apple
modprobe xhci-plat-hcd
for i in $(seq 0 50); do
[ -e /sys/bus/platform/drivers/nvme-apple/*.nvme/nvme/nvme*/nvme*n1/ ] && break
sleep 0.1
done
if [ ! -e /sys/bus/platform/drivers/nvme-apple/*.nvme/nvme/nvme*/nvme*n1/ ]; then
err "Timed out waiting for NVMe device"
return 1
fi
# If the above exists, hopefully the /dev device exists and this will work
msg ":: Asahi: Unpacking vendor firmware into initramfs..."
VENDORFW="/run/.system-efi/vendorfw/"
(
. /usr/share/asahi-scripts/functions.sh
mount_sys_esp /run/.system-efi
)
if [ ! -e "$VENDORFW/firmware.cpio" ]; then
msg ":: Asahi: Vendor firmware not available in ESP!"
umount /run/.system-efi
return 1
fi
( cd /; cpio -i < "$VENDORFW/firmware.cpio" )
umount /run/.system-efi
msg ":: Asahi: Vendor firmware unpacked successfully"
}
run_latehook() {
[ -e /vendorfw ] || return
msg ":: Asahi: Copying vendor firmware to tmpfs under root filesystem..."
mkdir -p /new_root/lib/firmware/vendor
mount -t tmpfs -o mode=0755 vendorfw /new_root/lib/firmware/vendor
cp -r /vendorfw/* /vendorfw/.vendorfw.manifest /new_root/lib/firmware/vendor
}