No networking for now
This commit is contained in:
@ -1,124 +0,0 @@
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include "syscall.h"
|
||||
#include "spinlock/spinlock.h"
|
||||
#include "ipc/netsock/netsock.h"
|
||||
#include "util/util.h"
|
||||
#include "errors.h"
|
||||
|
||||
int32_t SYSCALL2(sys_ipc_netsockmake, net1, proto1) {
|
||||
uint16_t net = net1;
|
||||
uint16_t proto = proto1;
|
||||
|
||||
IpcNetSock *netsock = ipc_netsockmake(net, proto, _caller_pid);
|
||||
|
||||
if (netsock == NULL) {
|
||||
return E_NOMEMORY;
|
||||
}
|
||||
|
||||
spinlock_acquire(&IPC_NETSOCKS.spinlock);
|
||||
size_t idx = 0;
|
||||
IpcNetSock *ns = NULL, *nstmp = NULL;
|
||||
LL_FOREACH_SAFE_IDX(IPC_NETSOCKS.netsocks, ns, nstmp, idx) {
|
||||
if (ns == netsock) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
spinlock_release(&IPC_NETSOCKS.spinlock);
|
||||
|
||||
return idx;
|
||||
}
|
||||
|
||||
int32_t SYSCALL2(sys_ipc_netsocklisten, socknum1, maxlisteners1) {
|
||||
size_t socknum = socknum1;
|
||||
size_t maxlisteners = maxlisteners1;
|
||||
|
||||
spinlock_acquire(&IPC_NETSOCKS.spinlock);
|
||||
size_t idx = 0;
|
||||
IpcNetSock *ns = NULL, *nstmp = NULL;
|
||||
LL_FOREACH_SAFE_IDX(IPC_NETSOCKS.netsocks, ns, nstmp, idx) {
|
||||
if (idx == socknum) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
spinlock_release(&IPC_NETSOCKS.spinlock);
|
||||
|
||||
if (ns == NULL) {
|
||||
return E_NOENTRY;
|
||||
}
|
||||
|
||||
return ipc_netsocklisten(ns, maxlisteners);
|
||||
}
|
||||
|
||||
int32_t SYSCALL1(sys_ipc_netsockpollev, socknum1) {
|
||||
size_t socknum = socknum1;
|
||||
|
||||
spinlock_acquire(&IPC_NETSOCKS.spinlock);
|
||||
size_t idx = 0;
|
||||
IpcNetSock *ns, *nstmp;
|
||||
LL_FOREACH_SAFE_IDX(IPC_NETSOCKS.netsocks, ns, nstmp, idx) {
|
||||
if (idx == socknum) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
spinlock_release(&IPC_NETSOCKS.spinlock);
|
||||
|
||||
if (ns == NULL) {
|
||||
return E_NOENTRY;
|
||||
}
|
||||
|
||||
spinlock_acquire(&ns->spinlock);
|
||||
|
||||
IpcNetSockEventBuffer ev;
|
||||
bool empty = false;
|
||||
rbuft_pop(&ns->eventbuffer, &ev, &empty);
|
||||
|
||||
spinlock_release(&ns->spinlock);
|
||||
|
||||
if (empty) {
|
||||
return E_NOTYET;
|
||||
}
|
||||
|
||||
return (int32_t)ev;
|
||||
}
|
||||
|
||||
int32_t SYSCALL1(sys_ipc_netsockdelete, socknum1) {
|
||||
size_t socknum = socknum1;
|
||||
|
||||
spinlock_acquire(&IPC_NETSOCKS.spinlock);
|
||||
size_t idx = 0;
|
||||
IpcNetSock *ns, *nstmp;
|
||||
LL_FOREACH_SAFE_IDX(IPC_NETSOCKS.netsocks, ns, nstmp, idx) {
|
||||
if (idx == socknum) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
spinlock_release(&IPC_NETSOCKS.spinlock);
|
||||
|
||||
if (ns == NULL) {
|
||||
return E_NOENTRY;
|
||||
}
|
||||
|
||||
return ipc_netsockdelete(ns);
|
||||
}
|
||||
|
||||
int32_t SYSCALL2(sys_ipc_netsockbindport, socknum1, port1) {
|
||||
size_t socknum = socknum1;
|
||||
uint16_t port = port1;
|
||||
|
||||
spinlock_acquire(&IPC_NETSOCKS.spinlock);
|
||||
size_t idx = 0;
|
||||
IpcNetSock *ns, *nstmp;
|
||||
LL_FOREACH_SAFE_IDX(IPC_NETSOCKS.netsocks, ns, nstmp, idx) {
|
||||
if (idx == socknum) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
spinlock_release(&IPC_NETSOCKS.spinlock);
|
||||
|
||||
if (ns == NULL) {
|
||||
return E_NOENTRY;
|
||||
}
|
||||
|
||||
return ipc_netsockbindport(ns, port);
|
||||
}
|
||||
@ -1,14 +0,0 @@
|
||||
#ifndef SYSCALL_IPCNETSOCK_H_
|
||||
#define SYSCALL_IPCNETSOCK_H_
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include "syscall.h"
|
||||
|
||||
int32_t SYSCALL2(sys_ipc_netsockmake, net1, proto1);
|
||||
int32_t SYSCALL2(sys_ipc_netsocklisten, socknum1, maxlisteners1);
|
||||
int32_t SYSCALL1(sys_ipc_netsockpollev, socknum1);
|
||||
int32_t SYSCALL1(sys_ipc_netsockdelete, socknum1);
|
||||
int32_t SYSCALL2(sys_ipc_netsockbindport, socknum1, port1);
|
||||
|
||||
#endif // SYSCALL_IPC_NETSOCK_H_
|
||||
@ -12,7 +12,6 @@
|
||||
#include "fs.h"
|
||||
#include "dev.h"
|
||||
#include "time.h"
|
||||
#include "ipcnetsock.h"
|
||||
|
||||
int32_t SYSCALL1(sys_debugprint, string) {
|
||||
char *p = (char *)string;
|
||||
@ -65,10 +64,4 @@ SyscallFn SYSCALL_TABLE[SYSCALLS_MAX] = {
|
||||
[SYS_DEV_CMD] = &sys_dev_cmd,
|
||||
|
||||
[SYS_TIME] = &sys_time,
|
||||
|
||||
[SYS_IPC_NETSOCKMAKE] = &sys_ipc_netsockmake,
|
||||
[SYS_IPC_NETSOCKLISTEN] = &sys_ipc_netsocklisten,
|
||||
[SYS_IPC_NETSOCKPOLLEV] = &sys_ipc_netsockpollev,
|
||||
[SYS_IPC_NETSOCKDELETE] = &sys_ipc_netsockdelete,
|
||||
[SYS_IPC_NETSOCKBINDPORT] = &sys_ipc_netsockbindport,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user