#!/usr/bin/env python3 # SPDX-License-Identifier: MIT """Codeless AuxKC format, admission, and real loader placement checks.""" import contextlib import copy import hashlib import io from pathlib import Path import plistlib import struct import sys from types import SimpleNamespace import unittest ROOT = Path(__file__).resolve().parents[1] sys.path.insert(0, str(ROOT / 'probes')) import bootfb from appledt import DeviceTree import xnuboot as xb class BootFramebufferTests(unittest.TestCase): @classmethod def setUpClass(cls): xb.configure_guest('j700ap-26A428-bootfb') cls.image = xb.kc_load.Image(xb.DEFAULT_KERNELCACHE.read_bytes()) cls.info = plistlib.loads((ROOT / 'drivers/boot-framebuffer/' 'SnapintoshBootFramebuffer.kext/Contents/Info.plist').read_bytes()) def setUp(self): xb.configure_guest('j700ap-26A428-bootfb') xb.place(0x8c0000000, guest_span=8192 << 20) def tearDown(self): xb.configure_guest('j700ap-26A428-sep-preload') def test_native_collection_geometry_and_identity(self): data = bootfb.build_auxkc(self.image, self.info) magic, cpu, subtype, kind, count, command_bytes, flags, reserved = struct.unpack_from('<8I', data) self.assertEqual((magic, cpu, subtype, kind), (0xfeedfacf, 0x100000c, 2, 12)) self.assertEqual(len(data), 32768) pos = 32 ranges = [] metadata = None collection_id = None for _ in range(count): cmd, size = struct.unpack_from('