2023-06-12 19:20:51 -07:00
|
|
|
#pragma once
|
|
|
|
|
2023-06-21 16:34:30 -07:00
|
|
|
#include <glacier/container/intrusive_list.h>
|
2023-06-21 15:07:40 -07:00
|
|
|
#include <glacier/memory/ref_ptr.h>
|
|
|
|
|
2023-06-16 15:58:50 -07:00
|
|
|
#include "capability/capability.h"
|
2023-06-20 15:29:32 -07:00
|
|
|
#include "lib/message_queue.h"
|
2023-06-21 23:42:21 -07:00
|
|
|
#include "object/ipc_object.h"
|
2023-06-12 19:20:51 -07:00
|
|
|
#include "object/kernel_object.h"
|
2023-06-12 20:56:25 -07:00
|
|
|
#include "object/thread.h"
|
2023-06-12 19:20:51 -07:00
|
|
|
|
2023-06-16 14:53:57 -07:00
|
|
|
class Port;
|
|
|
|
|
|
|
|
template <>
|
|
|
|
struct KernelObjectTag<Port> {
|
|
|
|
static const uint64_t type = KernelObject::PORT;
|
|
|
|
};
|
|
|
|
|
2023-06-21 23:42:21 -07:00
|
|
|
class Port : public IpcObject {
|
2023-06-12 19:20:51 -07:00
|
|
|
public:
|
2023-06-16 14:53:57 -07:00
|
|
|
uint64_t TypeTag() override { return KernelObject::PORT; }
|
2023-08-01 18:22:41 -07:00
|
|
|
static uint64_t DefaultPermissions() {
|
2023-08-01 18:37:17 -07:00
|
|
|
return kZionPerm_Write | kZionPerm_Read | kZionPerm_Duplicate |
|
|
|
|
kZionPerm_Transmit;
|
2023-08-01 18:22:41 -07:00
|
|
|
}
|
2023-06-16 14:53:57 -07:00
|
|
|
|
2023-06-21 23:42:21 -07:00
|
|
|
Port() = default;
|
2023-06-12 19:20:51 -07:00
|
|
|
|
2023-06-21 15:07:40 -07:00
|
|
|
void WriteKernel(uint64_t init, glcr::RefPtr<Capability> cap);
|
2023-06-17 00:07:58 -07:00
|
|
|
|
2023-06-21 23:42:21 -07:00
|
|
|
virtual MessageQueue& GetSendMessageQueue() override {
|
|
|
|
return message_queue_;
|
|
|
|
}
|
|
|
|
virtual MessageQueue& GetRecvMessageQueue() override {
|
|
|
|
return message_queue_;
|
|
|
|
}
|
2023-06-16 23:15:28 -07:00
|
|
|
|
2023-06-12 19:20:51 -07:00
|
|
|
private:
|
2023-06-20 15:29:32 -07:00
|
|
|
UnboundedMessageQueue message_queue_;
|
2023-06-12 19:20:51 -07:00
|
|
|
};
|