Нужно разобраться где происходит взаимодействие с ec embedded controller, и какие взаимодействия происходят между ними, что они посылают друг другу или чем обмениваются какими данными в каких случаях
Файл — это Intel serial flash (4 МБ), судя по сигнатуре дескриптора 0x0FF0A55A на смещении 0x10. Сначала разберу флеш-лейаут и вырежу регионы, чтобы понять, где лежит код EC и где BIOS.
Дескриптор распарсился. Лейаут:
- Region 0 (Descriptor):
0x000000–0x000FFF - Region 2:
0x001000–0x17FFFF(~1.5 МБ) — кандидат на EC-прошивку/блок до BIOS - Region 1 (BIOS):
0x180000–0x3FFFFF(2.5 МБ)
Вырежу регионы и посмотрю, что внутри.
Это HP Pavilion dm4 (Insyde H2O, CNU1375FCG). Регион 2 начинается с $FPT (flash partition table) — похоже на выделенную область EC/данных. Разберу таблицу разделов и посмотрю содержимое.
Error calling tool 'run_sandbox': Failed to create sandbox: Function 'create' exceeded timeout of 30.0 seconds.
Регион 2 — это, судя по строкам Intel ME («ME Wake in S3…», записи NV*, EFFS), регион Intel ME, а не EC. Значит, EC-код находится в BIOS-регионе (Insyde H2O). Разберу BIOS-регион: найду firmware volumes и модули.*
Error calling tool 'run_sandbox': Failed to create sandbox: Function 'create' exceeded timeout of 30.0 seconds.
Error calling tool 'run_sandbox': Failed to create sandbox: Function 'create' exceeded timeout of 30.0 seconds.
Error calling tool 'run_sandbox': Failed to create sandbox: Function 'create' exceeded timeout of 30.0 seconds.
FVMAIN (DXE) сжат. Теперь посмотрю на «зазор» между DXE-FV и PEI-FV (bios-rel 0x1B1000–0x221000) — там часто лежит EC-прошивка, и доработаю парсер секций (LZMA-распаковка).
В FVMAIN лежит LZMA-сжатый DXE-том (стандартный EFI COMPRESSION-секция: props 5D 00 00 80 00). Распакую его и получу список всех DXE-модулей.
Error calling tool 'run_sandbox': Failed to create sandbox: Function 'create' exceeded timeout of 30.0 seconds.
Error calling tool 'run_sandbox': Failed to create sandbox: Function 'create' exceeded timeout of 30.0 seconds.
Error calling tool 'run_sandbox': Failed to create sandbox: Function 'create' exceeded timeout of 30.0 seconds.
Теперь вытащу «свободные» (FREEFORM) файлы — среди них обычно лежит сама прошивка EC — и просканирую все модули на предмет EC-строк и портов.
Есть попадания по портам 0x62/0x66. Теперь сопоставлю их с конкретными FFS-модулями и найду EC-драйверы по строкам.
Кандидаты найдены. Посмотрю содержимое FREEFORM-файлов с обращениями к портам 0x62/0x66 и ACPI-таблиц с EC0.
Error calling tool 'run_sandbox': Failed to create sandbox: Function 'create' exceeded timeout of 30.0 seconds.
Error calling tool 'run_sandbox': Failed to create sandbox: Function 'create' exceeded timeout of 30.0 seconds.
Вариант с option ROM'ами отпадает (там VGA BIOS/UNDI/Computrace). Теперь найду «настоящие» EC-драйверы: поищу per-file EC-строки и идентифицирую модули по их строкам.
DSDT найден (EC0-методы ECRG, ECMX, FANS и т.д.). Теперь идентифицирую DXE-драйверы с портами 0x62/0x66 и проверю PEIFV/bootblock/HP-bootblock области.
Error calling tool 'run_sandbox': Failed to create sandbox: Function 'create' exceeded timeout of 30.0 seconds.
Error calling tool 'run_sandbox': Failed to create sandbox: Function 'create' exceeded timeout of 30.0 seconds.
Error calling tool 'run_sandbox': Failed to create sandbox: Function 'create' exceeded timeout of 30.0 seconds.
Error calling tool 'run_sandbox': Failed to create sandbox: Function 'create' exceeded timeout of 30.0 seconds.
Error calling tool 'run_sandbox': Failed to create sandbox: Function 'create' exceeded timeout of 30.0 seconds.
Error calling tool 'run_sandbox': Failed to create sandbox: Function 'create' exceeded timeout of 30.0 seconds.
Индекс оборвался на 0x362000 — допрохожу остаток FV (там как раз может быть EC-драйвер).
Все DXE-модули перечислены. EC-функционал у HP реализован в модулях H19 (HP ODM) и через ACPI. Теперь просканирую PEIFV, bootblock и HP-bootblock область на обращения к портам EC.
Модули внутри FVMAIN сжаты по-отдельности (GUID_DEFINED). Проверю, какой алгоритм сжатия используется, и распакую их.
Все модули — Tiano-сжатые (FC1BCDB0-…). Нужен декомпрессор EFI/Tiano. Возьму эталонный декодер из EDK2 и портирую его.
Алгоритм есть. Осталось взять константы из заголовка internals:
Все константы получены (NC=510, NPT=31, BITBUFSIZ=32, Tiano: mPBit=5). Пишу Python-порт декомпрессора Tiano и распаковываю все модули.
Error calling tool 'run_sandbox': Failed to create sandbox: Function 'create' exceeded timeout of 30.0 seconds.
Error calling tool 'run_sandbox': Failed to create sandbox: Function 'create' exceeded timeout of 30.0 seconds.
Error calling tool 'run_sandbox': Failed to create sandbox: Function 'create' exceeded timeout of 30.0 seconds.
Error calling tool 'run_sandbox': Failed to create sandbox: Function 'create' exceeded timeout of 30.0 seconds.
Error calling tool 'run_sandbox': Failed to create sandbox: Function 'create' exceeded timeout of 30.0 seconds.
OOM — проверю заголовки потоков (OrigSize) и добавлю ограничение.
Error calling tool 'run_sandbox': Failed to create sandbox: Function 'create' exceeded timeout of 30.0 seconds.
Похоже, данные в этих секциях лежат несжатыми (заголовки секций видны в открытом виде). Проверю гипотезу: 4 байта перед секциями — контрольная сумма, а секции — raw.
Разгадка: в «Tiano»-секциях Insyde данные лежат несжатыми — перед ними CRC32 (d[0x18:0x1C] = LE CRC32 от d[0x1C:]), совпадает! Значит можно парсить все секции напрямую. Извлекаю все модули и ищу EC-код.
Все секции подтвердились. Теперь сканирую реальные PE-модули на обращения к портам 0x62/0x66/0x64/0x60 и EC-строки.
Есть структурные попадания. Дизассемблирую H19ODMServiceDriver (обращение к порту 0x62) и SetupUtility (порт 0x66).
Error calling tool 'run_sandbox': Failed to create sandbox: Function 'create' exceeded timeout of 30.0 seconds.
Error calling tool 'run_sandbox': Failed to create sandbox: Function 'create' exceeded timeout of 30.0 seconds.
Error calling tool 'run_sandbox': Failed to create sandbox: Function 'create' exceeded timeout of 30.0 seconds.
Error calling tool 'run_sandbox': Failed to create sandbox: Function 'create' exceeded timeout of 30.0 seconds.
Error calling tool 'run_sandbox': Failed to create sandbox: Function 'create' exceeded timeout of 30.0 seconds.
Это x64-код. Переключаю дизассемблер в 64-bit и смотрю EC-функции.
Ручной разбор долгий — подключу Ghidra-декомпиляцию для ключевых модулей. Параллельно вытащу и просканирую PEIFV и bootblock.
Error calling tool 'run_sandbox': Failed to create sandbox: Function 'create' exceeded timeout of 30.0 seconds.
Error calling tool 'run_sandbox': Failed to create sandbox: Function 'create' exceeded timeout of 30.0 seconds.
Error calling tool 'run_sandbox': Failed to create sandbox: Function 'create' exceeded timeout of 30.0 seconds.
Error calling tool 'run_sandbox': Failed to create sandbox: Function 'create' exceeded timeout of 30.0 seconds.
Найдена строка «ITE851LSx» — это ITE IT851L EC, и здесь же лежит его прошивка! Локализую точнее.
EC-прошивка найдена: ITE IT851L, 8051-код в блоках ~0x391000–0x3A1000 (в дампе видны опкоды 90 xx xx (mov DPTR), e0/f0 (movx) — обращение к внутренним регистрам хост-интерфейса). Теперь распарсю DSDT/SSDT с EC0.
Error calling tool 'run_sandbox': Failed to create sandbox: Function 'create' exceeded timeout of 30.0 seconds.
Таблицы ACPI извлечены (DSDT 60 КБ). Теперь декомпилирую H19-модули (HP ODM EC-сервисы) через Ghidra.
Error calling tool 'run_sandbox': Failed to create sandbox: Function 'create' exceeded timeout of 30.0 seconds.
Дизассемблирую ключевые места: SetupUtility (порт 0x66/0x62) и H19DxeServiceBody (0x62/0x64).
Error calling tool 'run_sandbox': Failed to create sandbox: Function 'create' exceeded timeout of 30.0 seconds.
Прямых mov edx,0x66 нет — значит EC-доступ идёт через CpuIo-обёртки (константа порта передаётся аргументом). Ищу паттерны аргументов: push 0x66 / mov e?x, 0x66.
Теперь всё встало на места: общий EcLib (in/out 0x66/0x62) статически вшит в модули SmmPlatform, H19*, Bds, OemServices, и в PEIM'ы PEIFV. Дизассемблирую саму EC-библиотеку.*
EC-библиотека декодирована: 0x80 = чтение EC-RAM (индекс→значение), 0x81 = запись EC-RAM (индекс+значение), через ожидание IBF/OBF. Смотрю соседние функции.
Декомпилирую параллельно DSDT (EC0) и запущу Ghidra на ключевых модулях. Сначала — AML-сканер для EC0.
Error calling tool 'run_sandbox': Failed to create sandbox: Function 'create' exceeded timeout of 30.0 seconds.
Опкод OpRegion — это 86, а не 5B 85. Правлю сканер.
Error calling tool 'run_sandbox': Failed to create sandbox: Function 'create' exceeded timeout of 30.0 seconds.
EC-устройство — \_SB.PCI0.LPCB.H_EC (+ BAT0, AC__, LID0, FAN0, WMID, ACEL). Разбираю его AML: OpRegion, поля, методы.__
Разбираю Field-список EC-опрегиона корректно (имя региона + FieldFlags=0x11).
Error calling tool 'run_sandbox': Failed to create sandbox: Function 'create' exceeded timeout of 30.0 seconds.
[stopped: the account is out of credit]
