mirror of
https://github.com/gnif/LookingGlass.git
synced 2026-08-22 07:01:30 +00:00
[common/idd] recovery: reserve IVSHMEM control region
Define a fixed, protocol-independent recovery ABI in the final 64 KiB of IVSHMEM. Provide crash-safe multi-client requests and coherent producer status. Exclude the region from LGMP allocation and frame capacity so future protocol mismatches retain a stable control path.
This commit is contained in:
@@ -24,6 +24,8 @@
|
||||
#include <SetupAPI.h>
|
||||
#include <vector>
|
||||
|
||||
#include "common/KVMFRRecovery.h"
|
||||
|
||||
class CIVSHMEM
|
||||
{
|
||||
private:
|
||||
@@ -46,6 +48,21 @@ public:
|
||||
bool Open();
|
||||
void Close();
|
||||
|
||||
size_t GetSize() const { return m_size; }
|
||||
void * GetMem () const { return m_mem; }
|
||||
size_t GetFullSize () const { return m_size; }
|
||||
size_t GetUsableSize () const
|
||||
{
|
||||
if (m_size < KVMFR_R_REGION_SIZE)
|
||||
return 0;
|
||||
|
||||
return m_size - KVMFR_R_REGION_SIZE;
|
||||
}
|
||||
|
||||
void * GetMem () const { return m_mem; }
|
||||
void * GetRecoveryMem () const
|
||||
{
|
||||
if (!m_mem || m_size < KVMFR_R_REGION_SIZE)
|
||||
return nullptr;
|
||||
|
||||
return static_cast<uint8_t *>(m_mem) + GetUsableSize();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -119,7 +119,7 @@ bool CLGMPFrameTransport::Initialize()
|
||||
void CLGMPFrameTransport::SealMemoryLayout()
|
||||
{
|
||||
m_frameMemoryOffset =
|
||||
m_ivshmem.GetSize() - m_host.Available();
|
||||
m_ivshmem.GetUsableSize() - m_host.Available();
|
||||
}
|
||||
|
||||
bool CLGMPFrameTransport::Setup(size_t alignSize)
|
||||
@@ -246,7 +246,7 @@ void CLGMPFrameTransport::DeInit()
|
||||
FrameMemoryLimits CLGMPFrameTransport::GetMemoryLimits() const
|
||||
{
|
||||
FrameMemoryLimits limits;
|
||||
limits.capacity = m_ivshmem.GetSize();
|
||||
limits.capacity = m_ivshmem.GetUsableSize();
|
||||
limits.frameMemoryOffset = m_frameMemoryOffset;
|
||||
limits.alignment = m_alignSize;
|
||||
limits.maxFrameSize = m_maxFrameSize;
|
||||
|
||||
@@ -119,7 +119,8 @@ bool CLGMPHost::Initialize(CIVSHMEM& ivshmem)
|
||||
LGMP_STATUS status;
|
||||
std::string udata = ss.str();
|
||||
|
||||
if ((status = lgmpHostInit(ivshmem.GetMem(), (uint32_t)ivshmem.GetSize(),
|
||||
if ((status = lgmpHostInit(ivshmem.GetMem(),
|
||||
(uint32_t)ivshmem.GetUsableSize(),
|
||||
&m_host, (uint32_t)udata.size(), (uint8_t*)&udata[0])) != LGMP_OK)
|
||||
{
|
||||
DEBUG_ERROR("lgmpHostInit Failed: %s", lgmpStatusString(status));
|
||||
|
||||
@@ -181,5 +181,5 @@ FrameMemoryLimits CLGMPTransport::GetMemoryLimits() const
|
||||
|
||||
DirectFrameBufferMemory CLGMPTransport::GetDirectMemory() const
|
||||
{
|
||||
return {m_ivshmem.GetMem(), m_ivshmem.GetSize()};
|
||||
return {m_ivshmem.GetMem(), m_ivshmem.GetFullSize()};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user