summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Kernel/Disk.cpp1
-rw-r--r--Kernel/IPC.cpp104
-rw-r--r--Kernel/IPC.h82
-rw-r--r--Kernel/Makefile1
-rw-r--r--Kernel/Task.cpp37
-rw-r--r--Kernel/Task.h16
-rw-r--r--Kernel/init.cpp7
7 files changed, 6 insertions, 242 deletions
diff --git a/Kernel/Disk.cpp b/Kernel/Disk.cpp
index ed6eb7c1a2..2346865b2e 100644
--- a/Kernel/Disk.cpp
+++ b/Kernel/Disk.cpp
@@ -1,6 +1,5 @@
#include "types.h"
#include "Task.h"
-#include "IPC.h"
#include "VGA.h"
#include "Disk.h"
#include "kmalloc.h"
diff --git a/Kernel/IPC.cpp b/Kernel/IPC.cpp
deleted file mode 100644
index 5e5b0af540..0000000000
--- a/Kernel/IPC.cpp
+++ /dev/null
@@ -1,104 +0,0 @@
-#include "IPC.h"
-#include "Task.h"
-#include "i386.h"
-#include "StdLib.h"
-#include "VGA.h"
-#include "system.h"
-
-namespace IPC {
-
-Message receive(Handle src)
-{
- for (;;) {
- current->ipc.src = src;
- block(Task::BlockedReceive);
- if (src == Handle::Any && current->ipc.notifies) {
- for (BYTE i = 0; i < 32; ++i) {
- if (current->ipc.notifies & (1 << i)) {
- // FIXME: Source PID is `i' here. Do something with it?
- current->ipc.notifies &= ~(1 << i);
- break;
- }
- }
- return Message(MSG_NOTIFY);
- }
-
- if (src == Handle::Any || src == current->ipc.msg.sender()) {
- return move(current->ipc.msg);
- }
-
- // Why are we here?
- ASSERT_NOT_REACHED();
- }
-}
-
-void send(Handle dst, Message&& msg)
-{
- Task* task;
-
- // TODO: Block waiting for `dst' to spawn.
- for (;;) {
- task = Task::fromIPCHandle(dst);
- if (task)
- break;
- yield();
- }
-
- // I'll fill this in myself thankyouverymuch.
- msg.setSender(current->handle());
-
- // Block until `dst' is ready to receive a message.
- current->ipc.dst = dst;
- block(Task::BlockedSend);
-
- ASSERT(msg.isValid());
- task->ipc.msg = move(msg);
-}
-
-void notify(Handle dst)
-{
- Task* task = Task::fromIPCHandle(dst);
-
- if (!task) {
- // Can't really block here since we might be coming from
- // an interrupt handler and that'd be devastating...
- // XXX: Need to figure that one out.
- kprintf("notify(): no such task %u\n", dst.data());
- return;
- }
-
- if (current->pid() >= 32) {
- kprintf( "notify(): PID must be < 32\n" );
- return;
- }
-
- task->ipc.notifies |= 1 << current->pid();
-}
-
-Message::Message(Message&& other)
- : m_data(move(other.m_data))
- , m_type(other.m_type)
- , m_sender(other.m_sender)
- , m_isValid(other.m_isValid)
-{
- other.m_type = 0;
- other.m_sender = Handle();
- other.m_isValid = false;
-}
-
-Message& Message::operator=(Message&& other)
-{
- if (this == &other)
- return *this;
- m_data = move(other.m_data);
- m_type = other.m_type;
- m_sender = other.m_sender;
- m_isValid = other.m_isValid;
- other.m_type = 0;
- other.m_sender = Handle();
- other.m_isValid = false;
- return *this;
-}
-
-
-}
diff --git a/Kernel/IPC.h b/Kernel/IPC.h
deleted file mode 100644
index efb4514696..0000000000
--- a/Kernel/IPC.h
+++ /dev/null
@@ -1,82 +0,0 @@
-#pragma once
-
-#include "types.h"
-#include "DataBuffer.h"
-#include "RefPtr.h"
-#include <AK/StdLib.h>
-
-/* IPC message types. There will be moar. */
-#define MSG_INTERRUPT 0x00000001
-#define MSG_KILL 0x00000002
-#define MSG_NOTIFY 0x00000003
-
-#define DEV_READ 0x00000004
-
-#define FS_OPEN 0x00000100
-#define FS_CLOSE 0x00000101
-#define FS_READ 0x00000102
-
-#define SYS_KILL 0x00000666
-
-namespace IPC {
-
-class Handle {
-public:
- // If Handle::Any is passed as the `src' parameter of receive(),
- // any process can send us a message.
- enum AnyHandle { Any };
- Handle(AnyHandle) : m_data(0xffffffff) { }
-
- enum KernelTask {
- DiskTask = 4002,
- FileSystemTask = 4003,
- MotdTask = 4004,
- UserTask = 4005,
- InitTask = 4006,
- };
- Handle(KernelTask task) : m_data((DWORD)task) { }
-
- Handle() { }
- explicit Handle(DWORD data) : m_data(data) { }
-
- DWORD data() const { return m_data; }
- bool operator==(const Handle& o) const { return m_data == o.m_data; }
- bool operator!=(const Handle& o) const { return m_data != o.m_data; }
-
-private:
- DWORD m_data { 0 };
-};
-
-class Message {
-public:
- Message() { }
- explicit Message(DWORD type) : m_type(type), m_isValid(true) { }
- Message(DWORD type, RefPtr<DataBuffer>&& d) : m_data(move(d)), m_type(type), m_isValid(true) { }
- Message(Message&&);
- Message& operator=(Message&&);
-
- size_t length() const { return m_data ? m_data->length() : 0; }
- const BYTE* data() const { return m_data ? m_data->data() : nullptr; }
- BYTE* data() { return m_data ? m_data->data() : nullptr; }
-
- bool isValid() const { return m_isValid; }
-
- DWORD type() const { return m_type; }
- Handle sender() const { return m_sender; }
-
- void setType(DWORD t) { m_type = t; }
- void setSender(Handle s) { m_sender = s; }
-
-private:
- RefPtr<DataBuffer> m_data;
- DWORD m_type { 0 };
- Handle m_sender;
- bool m_isValid { false };
-};
-
-Message receive(Handle);
-void send(Handle, Message&&);
-void notify(Handle);
-
-}
-
diff --git a/Kernel/Makefile b/Kernel/Makefile
index 2465de2d84..2e02b2aae8 100644
--- a/Kernel/Makefile
+++ b/Kernel/Makefile
@@ -8,7 +8,6 @@ KERNEL_OBJS = \
Task.o \
i8253.o \
Keyboard.o \
- IPC.o \
CMOS.o \
IO.o \
PIC.o \
diff --git a/Kernel/Task.cpp b/Kernel/Task.cpp
index 9949786d20..8191e702c7 100644
--- a/Kernel/Task.cpp
+++ b/Kernel/Task.cpp
@@ -57,7 +57,7 @@ void Task::initialize()
next_pid = 0;
s_tasks = new InlineLinkedList<Task>;
s_deadTasks = new InlineLinkedList<Task>;
- s_kernelTask = new Task(0, "colonel", IPC::Handle::Any, Task::Ring0);
+ s_kernelTask = new Task(0, "colonel", Task::Ring0);
redoKernelTaskTSS();
loadTaskRegister(s_kernelTask->selector());
}
@@ -285,11 +285,10 @@ Task::Task(String&& name, uid_t uid, gid_t gid, pid_t parentPID)
ASSERT(m_pid);
}
-Task::Task(void (*e)(), const char* n, IPC::Handle h, RingLevel ring)
+Task::Task(void (*e)(), const char* n, RingLevel ring)
: m_name(n)
, m_entry(e)
, m_pid(next_pid++)
- , m_handle(h)
, m_state(Runnable)
, m_ring(ring)
{
@@ -518,19 +517,6 @@ bool scheduleNewTask()
// Check and unblock tasks whose wait conditions have been met.
for (auto* task = s_tasks->head(); task; task = task->next()) {
- if (task->state() == Task::BlockedReceive && (task->ipc.msg.isValid() || task->ipc.notifies)) {
- task->unblock();
- continue;
- }
-
- if (task->state() == Task::BlockedSend) {
- Task* peer = Task::fromIPCHandle(task->ipc.dst);
- if (peer && peer->state() == Task::BlockedReceive && peer->acceptsMessageFrom(*task)) {
- task->unblock();
- continue;
- }
- }
-
if (task->state() == Task::BlockedSleep) {
if (task->wakeupTime() <= system.uptime) {
task->unblock();
@@ -647,15 +633,6 @@ Task* Task::fromPID(pid_t pid)
return nullptr;
}
-Task* Task::fromIPCHandle(IPC::Handle handle)
-{
- for (auto* task = s_tasks->head(); task; task = task->next()) {
- if (task->handle() == handle)
- return task;
- }
- return nullptr;
-}
-
FileHandle* Task::fileHandleIfExists(int fd)
{
if (fd < 0)
@@ -780,11 +757,6 @@ int Task::sys$kill(pid_t pid, int sig)
// errno = ESRCH;
return -1;
}
-#if 0
- send(peer->handle(), IPC::Message(SYS_KILL, DataBuffer::copy((BYTE*)&sig, sizeof(sig))));
- IPC::Message response = receive(peer->handle());
- return *(int*)response.data();
-#endif
return -1;
}
@@ -814,11 +786,6 @@ pid_t Task::sys$waitpid(pid_t waitee)
return m_waitee;
}
-bool Task::acceptsMessageFrom(Task& peer)
-{
- return !ipc.msg.isValid() && (ipc.src == IPC::Handle::Any || ipc.src == peer.handle());
-}
-
void Task::unblock()
{
ASSERT(m_state != Task::Runnable && m_state != Task::Running);
diff --git a/Kernel/Task.h b/Kernel/Task.h
index 5b9d02e3d4..76d6269635 100644
--- a/Kernel/Task.h
+++ b/Kernel/Task.h
@@ -1,7 +1,6 @@
#pragma once
#include "types.h"
-#include "IPC.h"
#include "InlineLinkedList.h"
#include <AK/String.h>
#include "TSS.h"
@@ -48,10 +47,9 @@ public:
bool isRing0() const { return m_ring == Ring0; }
static Task* fromPID(pid_t);
- static Task* fromIPCHandle(IPC::Handle);
static Task* kernelTask();
- Task(void (*entry)(), const char* name, IPC::Handle, RingLevel);
+ Task(void (*entry)(), const char* name, RingLevel);
~Task();
const String& name() const { return m_name; }
@@ -60,7 +58,6 @@ public:
WORD selector() const { return m_farPtr.selector; }
TSS32& tss() { return m_tss; }
State state() const { return m_state; }
- IPC::Handle handle() const { return m_handle; }
uid_t uid() const { return m_uid; }
uid_t gid() const { return m_gid; }
@@ -72,8 +69,6 @@ public:
static void doHouseKeeping();
- bool acceptsMessageFrom(Task&);
-
void block(Task::State);
void unblock();
@@ -107,14 +102,6 @@ public:
int sys$get_dir_entries(int fd, void*, size_t);
int sys$getcwd(char*, size_t);
- struct
- {
- IPC::Message msg;
- IPC::Handle dst;
- IPC::Handle src;
- DWORD notifies { 0 };
- } ipc;
-
static void initialize();
void setError(int);
@@ -146,7 +133,6 @@ private:
gid_t m_gid { 0 };
DWORD m_ticks { 0 };
DWORD m_ticksLeft { 0 };
- IPC::Handle m_handle { 0 };
DWORD m_stackTop { 0 };
FarPtr m_farPtr;
State m_state { Invalid };
diff --git a/Kernel/init.cpp b/Kernel/init.cpp
index 99bca8f15b..b9ba06bca4 100644
--- a/Kernel/init.cpp
+++ b/Kernel/init.cpp
@@ -5,7 +5,6 @@
#include "i8253.h"
#include "Keyboard.h"
#include "Task.h"
-#include "IPC.h"
#include "system.h"
#include "Disk.h"
#include "PIC.h"
@@ -115,7 +114,7 @@ static void init_stage2()
#endif
#ifdef TEST_CRASHY_USER_PROCESSES
- new Task(user_main, "user", IPC::Handle::UserTask, Task::Ring3);
+ new Task(user_main, "user", Task::Ring3);
#endif
#ifdef TEST_ELF_LOADER
@@ -197,9 +196,9 @@ void init()
Task::initialize();
- new Task(undertaker_main, "undertaker", IPC::Handle::UserTask, Task::Ring0);
+ new Task(undertaker_main, "undertaker", Task::Ring0);
- auto* init2 = new Task(init_stage2, "init", IPC::Handle::InitTask, Task::Ring0);
+ auto* init2 = new Task(init_stage2, "init", Task::Ring0);
scheduleNewTask();
sti();