summaryrefslogtreecommitdiffstats
path: root/src/ukify/ukify.py
diff options
context:
space:
mode:
authoranonymix007 <48598263+anonymix007@users.noreply.github.com>2024-11-15 13:48:24 +0100
committerLuca Boccassi <luca.boccassi@gmail.com>2024-11-15 20:15:30 +0100
commit61d6075775188f16ff4cc27ba035988ce310c90b (patch)
tree92e5cd7fa0ddd17a8d8a54f927c368df78e893e4 /src/ukify/ukify.py
parentbootctl: Only create loader/keys/auto if required (diff)
downloadsystemd-61d6075775188f16ff4cc27ba035988ce310c90b.tar.xz
systemd-61d6075775188f16ff4cc27ba035988ce310c90b.zip
ukify: Use new .hwids PE section format
Diffstat (limited to 'src/ukify/ukify.py')
-rwxr-xr-xsrc/ukify/ukify.py22
1 files changed, 17 insertions, 5 deletions
diff --git a/src/ukify/ukify.py b/src/ukify/ukify.py
index 5ea52898ee..8d601e791e 100755
--- a/src/ukify/ukify.py
+++ b/src/ukify/ukify.py
@@ -1002,15 +1002,20 @@ def merge_sbat(input_pe: list[Path], input_text: list[str]) -> str:
)
-# Keep in sync with EFI_GUID (src/boot/efi/efi.h)
+# Keep in sync with EFI_GUID (src/boot/efi.h)
# uint32_t Data1, uint16_t Data2, uint16_t Data3, uint8_t Data4[8]
EFI_GUID = tuple[int, int, int, tuple[int, int, int, int, int, int, int, int]]
EFI_GUID_STRUCT_SIZE = 4 + 2 + 2 + 1 * 8
-# Keep in sync with Device (src/boot/efi/chid.h)
-# uint32_t struct_size, uint32_t name_offset, uint32_t compatible_offset, EFI_GUID chid
-DEVICE_STRUCT_SIZE = 4 + 4 + 4 + EFI_GUID_STRUCT_SIZE
+# Keep in sync with Device (DEVICE_TYPE_DEVICETREE) from src/boot/chid.h
+# uint32_t descriptor, EFI_GUID chid, uint32_t name_offset, uint32_t compatible_offset
+DEVICE_STRUCT_SIZE = 4 + EFI_GUID_STRUCT_SIZE + 4 + 4
NULL_DEVICE = b'\0' * DEVICE_STRUCT_SIZE
+DEVICE_TYPE_DEVICETREE = 1
+
+
+def device_make_descriptor(device_type: int, size: int) -> int:
+ return (size) | (device_type << 28)
def pack_device(offsets: dict[str, int], name: str, compatible: str, chids: list[EFI_GUID]) -> bytes:
@@ -1018,7 +1023,14 @@ def pack_device(offsets: dict[str, int], name: str, compatible: str, chids: list
for data1, data2, data3, data4 in chids:
data += struct.pack(
- '<IIIIHH8B', DEVICE_STRUCT_SIZE, offsets[name], offsets[compatible], data1, data2, data3, *data4
+ '<IIHH8BII',
+ device_make_descriptor(DEVICE_TYPE_DEVICETREE, DEVICE_STRUCT_SIZE),
+ data1,
+ data2,
+ data3,
+ *data4,
+ offsets[name],
+ offsets[compatible],
)
assert len(data) == DEVICE_STRUCT_SIZE * len(chids)