mirror of
https://github.com/Fennix-Project/Kernel.git
synced 2025-07-09 06:19:19 +00:00
IPC stub
This commit is contained in:
75
include/ipc.hpp
Normal file
75
include/ipc.hpp
Normal file
@ -0,0 +1,75 @@
|
||||
#ifndef __FENNIX_KERNEL_IPC_H__
|
||||
#define __FENNIX_KERNEL_IPC_H__
|
||||
|
||||
#include <types.h>
|
||||
|
||||
#include <lock.hpp>
|
||||
|
||||
namespace InterProcessCommunication
|
||||
{
|
||||
typedef unsigned int IPCPort;
|
||||
|
||||
enum IPCOperationType
|
||||
{
|
||||
IPCOperationNone,
|
||||
IPCOperationWrite,
|
||||
IPCOperationRead
|
||||
};
|
||||
|
||||
enum IPCErrorCode
|
||||
{
|
||||
IPCUnknown,
|
||||
IPCSuccess,
|
||||
IPCNotListening,
|
||||
IPCTimeout,
|
||||
IPCInvalidPort,
|
||||
IPCPortInUse,
|
||||
IPCPortNotRegistered
|
||||
};
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int ID;
|
||||
int Length;
|
||||
void *Buffer;
|
||||
bool Listening;
|
||||
IPCOperationType Type;
|
||||
IPCErrorCode Error;
|
||||
LockClass Lock;
|
||||
} IPCHandle;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int ID;
|
||||
int Length;
|
||||
IPCOperationType Type;
|
||||
IPCErrorCode Error;
|
||||
void *Buffer;
|
||||
|
||||
// Reserved
|
||||
IPCHandle *HandleBuffer;
|
||||
} __attribute__((packed)) IPCSyscallHandle;
|
||||
|
||||
struct IPCError
|
||||
{
|
||||
uint64_t ErrorCode;
|
||||
};
|
||||
|
||||
class IPC
|
||||
{
|
||||
private:
|
||||
|
||||
public:
|
||||
IPC();
|
||||
~IPC();
|
||||
|
||||
IPCHandle *RegisterHandle(IPCPort Port);
|
||||
IPCHandle *Wait(IPCPort port);
|
||||
IPCError Read(int pid, IPCPort port, void *buf, int size);
|
||||
IPCError Write(int pid, IPCPort port, void *buf, int size);
|
||||
};
|
||||
}
|
||||
|
||||
extern InterProcessCommunication::IPC *ipc;
|
||||
|
||||
#endif // !__FENNIX_KERNEL_IPC_H__
|
Reference in New Issue
Block a user