aboutsummaryrefslogtreecommitdiff
path: root/kernel
diff options
context:
space:
mode:
authorMarvin Borner2021-01-09 23:31:28 +0100
committerMarvin Borner2021-01-09 23:33:34 +0100
commitff9c7766edded74f4d522484c828b1bdc7dfa96d (patch)
treefc076342222b6eb0c200a9bbb028c7765ed758b2 /kernel
parent836294b9232c7d63d26db4f87c32cf1420cd856d (diff)
Let's make a procfs for IPC instead
Diffstat (limited to 'kernel')
-rw-r--r--kernel/Makefile3
-rw-r--r--kernel/drivers/keyboard.c3
-rw-r--r--kernel/drivers/mouse.c3
-rw-r--r--kernel/features/event.c61
-rw-r--r--kernel/features/proc.c29
-rw-r--r--kernel/features/syscall.c18
-rw-r--r--kernel/inc/event.h19
-rw-r--r--kernel/inc/proc.h10
8 files changed, 3 insertions, 143 deletions
diff --git a/kernel/Makefile b/kernel/Makefile
index 64b5993..492d975 100644
--- a/kernel/Makefile
+++ b/kernel/Makefile
@@ -14,8 +14,7 @@ COBJS = main.o \
features/proc.o \
features/proc_asm.o \
features/syscall.o \
- features/net.o \
- features/event.o
+ features/net.o
CC = ccache ../cross/opt/bin/i686-elf-gcc
LD = ccache ../cross/opt/bin/i686-elf-ld
OC = ccache ../cross/opt/bin/i686-elf-objcopy
diff --git a/kernel/drivers/keyboard.c b/kernel/drivers/keyboard.c
index ac97d36..7f3247f 100644
--- a/kernel/drivers/keyboard.c
+++ b/kernel/drivers/keyboard.c
@@ -2,7 +2,6 @@
#include <cpu.h>
#include <def.h>
-#include <event.h>
#include <interrupts.h>
#include <mem.h>
#include <print.h>
@@ -34,7 +33,7 @@ void keyboard_handler()
event->magic = KEYBOARD_MAGIC;
event->press = (scancode & 0x80) == 0;
event->scancode = event->press ? scancode : scancode & ~0x80;
- event_trigger(EVENT_KEYBOARD, event);
+ //event_trigger(EVENT_KEYBOARD, event);
state = 0;
merged = 0;
diff --git a/kernel/drivers/mouse.c b/kernel/drivers/mouse.c
index d58fbfc..f70fb6a 100644
--- a/kernel/drivers/mouse.c
+++ b/kernel/drivers/mouse.c
@@ -2,7 +2,6 @@
#include <boot.h>
#include <cpu.h>
-#include <event.h>
#include <interrupts.h>
#include <mem.h>
#include <print.h>
@@ -39,7 +38,7 @@ void mouse_handler()
event->but1 = mouse_byte[0] & 1;
event->but2 = (mouse_byte[0] >> 1) & 1;
event->but3 = (mouse_byte[0] >> 2) & 1;
- event_trigger(EVENT_MOUSE, event);
+ //event_trigger(EVENT_MOUSE, event);
mouse_cycle = 0;
break;
diff --git a/kernel/features/event.c b/kernel/features/event.c
deleted file mode 100644
index c9bd3a4..0000000
--- a/kernel/features/event.c
+++ /dev/null
@@ -1,61 +0,0 @@
-// MIT License, Copyright (c) 2020 Marvin Borner
-
-#include <assert.h>
-#include <def.h>
-#include <event.h>
-#include <list.h>
-#include <mem.h>
-#include <proc.h>
-#include <sys.h>
-
-static struct list *event_table[] = { [EVENT_KEYBOARD] = NULL, [EVENT_MOUSE] = NULL };
-
-u32 event_register(u32 id, struct proc *proc)
-{
- assert(id < sizeof(event_table) / sizeof(*event_table));
-
- if (event_table[id] == NULL)
- event_table[id] = (struct list *)list_new();
-
- struct event_descriptor *desc = malloc(sizeof(*desc));
- desc->id = id;
- desc->proc = proc;
-
- list_add(event_table[id], (void *)desc);
- return 0;
-}
-
-void event_unregister(u32 id, struct proc *proc)
-{
- assert(id < sizeof(event_table) / sizeof(*event_table));
-
- struct event_descriptor desc;
- desc.id = id;
- desc.proc = proc;
-
- struct node *iterator = event_table[id]->head;
- while (iterator != NULL) {
- struct event_descriptor *desc_comp = iterator->data;
- if (desc_comp->id == desc.id && desc_comp->proc == desc.proc)
- list_remove(event_table[id], iterator);
- iterator = iterator->next;
- }
-}
-
-u32 event_trigger(u32 id, void *data)
-{
- assert(id < sizeof(event_table) / sizeof(*event_table));
-
- if (!event_table[id] || !event_table[id]->head) {
- printf("Event %d not mapped!\n", id);
- return 1;
- }
-
- struct node *iterator = event_table[id]->head;
- while (iterator != NULL) {
- proc_send(kernel_proc, ((struct event_descriptor *)iterator->data)->proc, id, data);
- iterator = iterator->next;
- }
-
- return 0;
-}
diff --git a/kernel/features/proc.c b/kernel/features/proc.c
index 08f3b8e..93e97f1 100644
--- a/kernel/features/proc.c
+++ b/kernel/features/proc.c
@@ -82,34 +82,6 @@ struct proc *proc_current(void)
return current && current->data ? current->data : NULL;
}
-void proc_send(struct proc *src, struct proc *dest, u32 type, void *data)
-{
- // TODO: Use unique key instead of pid for IPC
- if (!src || !dest)
- return;
- struct proc_message *msg = malloc(sizeof(*msg));
- msg->src = src;
- msg->dest = dest;
- msg->msg = malloc(sizeof(*msg->msg));
- msg->msg->src = (int)src->pid;
- msg->msg->type = (int)type;
- msg->msg->data = data;
- list_add(dest->messages, msg);
- priority_proc = dest;
-}
-
-u32 proc_receive(struct proc *proc, struct message *buf)
-{
- if (proc->messages && proc->messages->head) {
- struct proc_message *msg = proc->messages->head->data;
- list_remove(proc->messages, proc->messages->head);
- memcpy(buf, msg->msg, sizeof(*buf));
- return 1;
- } else {
- return 0;
- }
-}
-
struct proc *proc_from_pid(u32 pid)
{
struct node *iterator = proc_list->head;
@@ -157,7 +129,6 @@ struct proc *proc_make(void)
{
struct proc *proc = malloc(sizeof(*proc));
proc->pid = current_pid++;
- proc->messages = list_new();
proc->state = PROC_RUNNING;
if (current)
diff --git a/kernel/features/syscall.c b/kernel/features/syscall.c
index a6bfb2a..bb174a1 100644
--- a/kernel/features/syscall.c
+++ b/kernel/features/syscall.c
@@ -1,7 +1,6 @@
// MIT License, Copyright (c) 2020 Marvin Borner
#include <cpu.h>
-#include <event.h>
#include <fs.h>
#include <interrupts.h>
#include <load.h>
@@ -74,23 +73,6 @@ void syscall_handler(struct regs *r)
r->eax = timer_get();
break;
}
- case SYS_REGISTER: {
- event_register(r->ebx, proc_current());
- break;
- }
- case SYS_UNREGISTER: {
- event_unregister(r->ebx, proc_current());
- break;
- }
- case SYS_SEND: {
- proc_send(proc_current(), proc_from_pid(r->ebx), r->ecx, (void *)r->edx);
- proc_yield(r);
- break;
- }
- case SYS_RECEIVE: {
- r->eax = proc_receive(proc_current(), (void *)r->ebx);
- break;
- }
case SYS_GETPID: {
r->eax = proc_current()->pid;
break;
diff --git a/kernel/inc/event.h b/kernel/inc/event.h
deleted file mode 100644
index 59a0df1..0000000
--- a/kernel/inc/event.h
+++ /dev/null
@@ -1,19 +0,0 @@
-// MIT License, Copyright (c) 2020 Marvin Borner
-
-#ifndef EVENT_H
-#define EVENT_H
-
-#include <def.h>
-#include <proc.h>
-#include <sys.h>
-
-struct event_descriptor {
- u32 id;
- struct proc *proc;
-};
-
-u32 event_register(u32 id, struct proc *proc);
-void event_unregister(u32 id, struct proc *proc);
-u32 event_trigger(u32 id, void *data);
-
-#endif
diff --git a/kernel/inc/proc.h b/kernel/inc/proc.h
index 93d8d48..c8fb3e2 100644
--- a/kernel/inc/proc.h
+++ b/kernel/inc/proc.h
@@ -4,7 +4,6 @@
#define PROC_H
#include <def.h>
-#include <event.h>
#include <interrupts.h>
#include <list.h>
#include <sys.h>
@@ -25,13 +24,6 @@ struct proc {
struct regs regs;
struct regs regs_backup;
enum proc_state state;
- struct list *messages;
-};
-
-struct proc_message {
- struct proc *src;
- struct proc *dest;
- struct message *msg;
};
struct proc *kernel_proc;
@@ -40,8 +32,6 @@ void scheduler(struct regs *regs);
void proc_init(void);
void proc_print(void);
struct proc *proc_current(void);
-void proc_send(struct proc *src, struct proc *dest, u32 type, void *data);
-u32 proc_receive(struct proc *proc, struct message *buf);
struct proc *proc_from_pid(u32 pid);
void proc_exit(struct proc *proc, int status);
void proc_yield(struct regs *r);