import assert from 'node:assert/strict'; import {prepare,compiled,symbols,bindings,bootId} from './native_irq_fixture.mjs'; import {NATIVE_STAGES} from '../../scripts/os-acceptance/features/k2155-native-capture.mjs'; import {checkNativeIrqs} from '../../scripts/os-acceptance/features/k2155-native-irq-check.mjs'; import {IRQ_FORGERIES,irqForgery} from '../../scripts/os-acceptance/features/k2155-irq-dma-check.mjs'; const W=b=>Array.from({length:b.length/8},(_,i)=>b.readBigUInt64LE(i*8)),l=W(compiled.OS_K2155_IRQ_LAYOUT).map(Number); function fixture(first,tco){ const original=prepare(first,tco),stages=[...NATIVE_STAGES];stages.splice(4,4,first,first+1,first===100?110:100,first===100?111:101); const snapshots=stages.map((stage,index)=>{ const source=index<2?0:index<4?1:index<8?index-2:6,s=Object.fromEntries(Object.entries(original[source]).map(([k,b])=>[k,Buffer.from(b)])); s.OS_K2155_EVIDENCE=Buffer.alloc(512);s.OS_K2155_EVIDENCE.writeBigUInt64LE(0x4b32313535494e54n);s.OS_K2155_EVIDENCE.writeBigUInt64LE(BigInt(stage),8); s.OS_K2155_CPU_STATE=Buffer.alloc(64); if(index>=4&&index<8){const entry=W(s.OS_K2155_IRQ_EVENTS).slice((index>=6?1:0)*16);s.OS_K2155_CPU_STATE.writeBigUInt64LE(BigInt(symbols.__os_k2155_irq_vectors.address),8);s.OS_K2155_CPU_STATE.writeBigUInt64LE(entry[3]-512n,24);} if(index>=8&&index<16){s.OS_K2155_IRQ_STATE.writeBigUInt64LE(0n,128);s['irq-owner'][l[17]]=0;s['irq-owner'][l[18]]=0;for(let d=0;d<2;d++)s['gic-'+d+'-enable'].writeUInt32LE(0xc000,0);} if(stage===70)delete s['irq-owner'];return s; });return {snapshots,compiled,symbols,bindings,bootId}; } export {fixture,bindings};