20 #include "pedigree/native/ipc/Ipc.h" 22 #include "pedigree/native/native-syscall.h" 23 #include "pedigree/native/nativeSyscallNumbers.h" 27 PedigreeIpc::StandardIpcMessage::StandardIpcMessage() : m_vAddr(0)
31 PedigreeIpc::StandardIpcMessage::~StandardIpcMessage()
33 syscall1(IPC_DESTROY_MESSAGE, reinterpret_cast<uintptr_t>(
this));
36 PedigreeIpc::SharedIpcMessage::SharedIpcMessage(
size_t nBytes,
void *handle)
41 PedigreeIpc::SharedIpcMessage::~SharedIpcMessage()
43 syscall1(IPC_DESTROY_MESSAGE, reinterpret_cast<uintptr_t>(
this));
46 PedigreeIpc::StandardIpcMessage::StandardIpcMessage(
void *pKernelMessage)
48 m_vAddr =
reinterpret_cast<void *
>(syscall2(
49 IPC_RECV_PHASE2, reinterpret_cast<uintptr_t>(
this),
50 reinterpret_cast<uintptr_t>(pKernelMessage)));
53 bool PedigreeIpc::StandardIpcMessage::initialise()
55 m_vAddr =
reinterpret_cast<void *
>(syscall1(
56 IPC_CREATE_STANDARD_MESSAGE, reinterpret_cast<uintptr_t>(
this)));
61 bool PedigreeIpc::SharedIpcMessage::initialise()
63 m_vAddr =
reinterpret_cast<void *
>(syscall3(
64 IPC_CREATE_SHARED_MESSAGE, reinterpret_cast<uintptr_t>(
this), m_nBytes,
65 reinterpret_cast<uintptr_t>(m_pHandle)));
66 m_pHandle =
reinterpret_cast<void *
>(
67 syscall1(IPC_GET_SHARED_REGION, reinterpret_cast<uintptr_t>(
this)));
69 return (m_vAddr != 0) && (m_pHandle != 0);
72 bool PedigreeIpc::send(
73 IpcEndpoint *pEndpoint,
IpcMessage *pMessage,
bool bAsync)
75 return static_cast<bool>(syscall3(
76 IPC_SEND_IPC, reinterpret_cast<uintptr_t>(pEndpoint),
77 reinterpret_cast<uintptr_t>(pMessage), static_cast<uintptr_t>(bAsync)));
80 bool PedigreeIpc::recv(
81 IpcEndpoint *pEndpoint,
IpcMessage **pMessage,
bool bAsync)
83 void *kernelPointer =
reinterpret_cast<void *
>(syscall2(
84 IPC_RECV_PHASE1, reinterpret_cast<uintptr_t>(pEndpoint),
85 static_cast<uintptr_t>(bAsync)));
94 void PedigreeIpc::createEndpoint(
const char *name)
96 syscall1(IPC_CREATE_ENDPOINT, reinterpret_cast<uintptr_t>(name));
99 void PedigreeIpc::removeEndpoint(
const char *name)
101 syscall1(IPC_REMOVE_ENDPOINT, reinterpret_cast<uintptr_t>(name));
104 IpcEndpoint *PedigreeIpc::getEndpoint(
const char *name)
106 return reinterpret_cast<IpcEndpoint *
>(
107 syscall1(IPC_GET_ENDPOINT, reinterpret_cast<uintptr_t>(name)));
A standard IPC message that is less than 4 KB in size.