Max OS 0.3
Loading...
Searching...
No Matches
ipc.h
Go to the documentation of this file.
1
9#ifndef MAXOS_PROCESSES_IPC_H
10#define MAXOS_PROCESSES_IPC_H
11
12#include <cstdint>
13#include <cstddef>
14
15#include <libcommon/vector.h>
16#include <libcommon/string.h>
17#include <libcommon/buffer.h>
18#include <libcommon/spinlock.h>
19
20#include <memory/physical.h>
21#include <memory/memoryIO.h>
23#include <processes/block.h>
24
25namespace MaxOS::processes {
26
34 typedef struct IPCIOVector {
35
36 const void* address;
37 size_t length;
38
39 } ipc_iovec_t;
40
45 class SharedMemory final : public resources::Resource {
46
47 private:
48 uintptr_t m_physical_address;
49 size_t m_size;
50
51 common::Map<size_t, uintptr_t> m_mappings;
52
53 public:
54 SharedMemory(const string& name, size_t size, resources::resource_type_t type);
55 ~SharedMemory() final;
56
57 void open(size_t flags) final;
58 void close(size_t flags) final;
59
60 int read(void* buffer, size_t size, size_t flags) final;
61
62 [[nodiscard]] uintptr_t physical_address() const;
63 [[nodiscard]] size_t size() const;
64 };
65
71
72 private:
73 common::Vector<common::buffer_t*> m_queue { };
74 BlockingLock m_message_lock;
75
76 public:
77 SharedMessageEndpoint(const string& name, size_t size, resources::resource_type_t type);
79
80 void send(const ipc_iovec_t* vec, size_t count);
81
82 int read(void* buffer, size_t size, size_t flags) final;
83 int write(const void* buffer, size_t size, size_t flags) final;
84 };
85}
86
87
88#endif // MAXOS_PROCESSES_IPC_H
Defines BlockingLock class for thread synchronization.
Enables a resource to be used by only one instance at a time through a combination of spinning and qu...
Definition block.h:28
A block memory that is mapped into multiple processes.
Definition ipc.h:45
size_t size() const
Gets the size of the shared memory block.
Definition ipc.cpp:72
int read(void *buffer, size_t size, size_t flags) final
Get the address that the current process has this shared memory mapped to.
Definition ipc.cpp:47
void close(size_t flags) final
Frees the page containing the shared memory.
Definition ipc.cpp:99
uintptr_t physical_address() const
Gets the physical address of the shared memory block.
Definition ipc.cpp:62
void open(size_t flags) final
Map the shared memory into the address space of the owning process.
Definition ipc.cpp:82
A endpoint that allows processes to queue messages on.
Definition ipc.h:70
int write(const void *buffer, size_t size, size_t flags) final
Handles writing to the message endpoint resource by writing the buffer as a message.
Definition ipc.cpp:194
int read(void *buffer, size_t size, size_t flags) final
Reads the first message from the endpoint or will yield until a message has been written.
Definition ipc.cpp:165
void send(const ipc_iovec_t *vec, size_t count)
Combines a multipart message and sends it to the endpoint.
Definition ipc.cpp:135
~SharedMessageEndpoint() final
Destroys the shared message endpoint and frees all messages.
Definition ipc.cpp:121
Defines classes for memory input and output operations of various bit widths (8, 16,...
Defines a PhysicalMemoryManager class for managing physical memory allocation and deallocation of pag...
Defines classes for managing process resources such as files and devices.
KPI::Resource Resource
Alias to make the libsyscore Resource accessible here.
Definition resource.h:26
KPI::ResourceType resource_type_t
Alias to make the libsyscore ResourceType accessible here.
Definition resource.h:25
Read/Write call entry for a list of I/O requests in a RPC call.
Definition ipc.h:34