import assert from'node:assert/strict'; import{inspectFrameServiceInputs}from'./smp-frame-service-inputs-proof.mjs'; import{publicationSymbols}from'./acquire-release-capture.mjs'; export const publicationModelLayout=[560,0,8,16,40,48,24,0,8,16,64,0,8,16,24,56,72,0,64,32,0,8,16,24,512],publicationSlotLayout=[72,0,64,80,0,72]; export const publicationAtomicSites={publicationCycle:[[500,0xc89ffd1f],[660,0xc89fff48],[668,0xc8dffe68],[752,0xc8dffe7b],[904,0xc8dffe10],[920,0xc8dffe10],[1132,0xc89ffd1c],[1668,0xc89fff5b],[1676,0xc8dffe68]],publicationDrive:[[580,0xc8dffd28],[596,0xc89ffd38],[600,0xc89ffd17],[840,0xc89fff17],[940,0xc89ffec8],[1164,0xc89ffd68],[1388,0xc89ffef6]],publicationReusable:[[56,0xc8dffd08],[108,0xc8dffd6b]],publicationAcquire:[[76,0xc8dffd29],[132,0xc8dffd14]],publicationBusy:[[152,0xc89ffd14]],publicationClose:[[12,0xc89ffd28]]}; // The payload, sequence and acknowledgement offsets are bound to the compiled // repr(C) layouts. These are the actual load loop and completion instructions. export const publicationInstructionSites={publicationReusable:[[52,0x9100a148],[88,0xf9400548],[96,0x9100414a],[104,0x8b09014b],[112,0xeb08017f],[116,0x540000a1],[120,0x91002129],[124,0xf100613f],[128,0x54ffff41]],publicationAcquire:[[72,0x9100a109],[128,0x91002108],[136,0xf9401c28],[140,0xeb08029f],[156,0xb100051f],[164,0x91000508],[168,0xeb14011f]],publicationObserved:[[64,0xf940000a],[80,0x9100c14a],[136,0xd53be02b],[148,0xf86e7831],[156,0xeb12023f],[160,0x54000781],[172,0x910005ce],[176,0xf10101df],[200,0x54fffe21]],publicationCycle:[[1104,0xd1000720],[1108,0xf1000c1f],[1112,0x54001e62],[1116,0x8b000fa8],[1128,0x91004108]],publicationReusableCall:[[0,0x9101a3e0]],publicationBusyCall:[[0,0x9101a3e0]],publicationClose:[[0,0x52800028],[4,0xb00023c9],[8,0x9106a129],[16,0xd65f03c0]]}; export const publicationCallSites=[['publicationCycle',296,'publicationAcquire'],['publicationCycle',1048,'publicationObserved'],['publicationCycle',1176,'publicationAcquire'],['publicationCycle',1324,'publicationAcquire'],['publicationCycle',1436,'publicationObserved'],['publicationBusy',88,'publicationReusable'],...[724,892,1328,1552].map(at=>['publicationDrive',at,'publicationReusableCall']),...[880,1124,1428].map(at=>['publicationDrive',at,'publicationBusyCall']),...[1088,1576].map(at=>['publicationDrive',at,'publicationClose']),['publicationReusableCall',4,'publicationReusable','b'],['publicationBusyCall',4,'publicationBusy','b']]; export function inspectPublicationInputs(compiled,symbols){ const inherited=inspectFrameServiceInputs(compiled,symbols); for(const[n,size]of Object.entries(publicationSymbols)){assert.equal(symbols[n]?.size,size,n);assert.equal(compiled[n]?.length,size,n);} for(const[n,expected]of[['OS_K2080_MODEL_LAYOUT',publicationModelLayout],['OS_K2080_SLOT_LAYOUT',publicationSlotLayout]])assert.deepEqual(Array.from({length:compiled[n].length/8},(_,i)=>Number(compiled[n].readBigUInt64LE(i*8))),expected,n); for(const[name,size]of[['publicationCycle',2096],['publicationDrive',1772],['publicationReusable',148],['publicationAcquire',204],['publicationBusy',292],['publicationObserved',412],['publicationReusableCall',8],['publicationBusyCall',8],['publicationClose',20]]){assert.equal(symbols[name]?.size,size,name);assert.equal(compiled[name]?.length,size,name);} for(const sites of[publicationAtomicSites,publicationInstructionSites])for(const[name,words]of Object.entries(sites))for(const[at,op]of words)assert.equal(compiled[name].readUInt32LE(at),op,name+' instruction '+at); for(const[name,at,destination,kind]of publicationCallSites){const op=compiled[name].readUInt32LE(at);assert.equal((op&0xfc000000)>>>0,kind==='b'?0x14000000:0x94000000,name+' branch opcode '+at);assert.equal(symbols[name].address+at+((op<<6)>>4),symbols[destination].address,name+' branch destination '+at);} assert.equal(symbols.publicationClose.address+4+((((0xb00023c9>>>5)&0x7ffff)<<2)|((0xb00023c9>>>29)&3))*4096-(symbols.publicationClose.address+4)%4096+0x1a8,symbols.OS_K2080_CHANNEL.address+40,'close release addresses channel.closed'); return{...inherited,publicationModelLayout,publicationSlotLayout,publicationCompiledAtomicSites:22,publicationCompiledPayloadReadWords:64,publicationCompiledCallSites:17}; }