userspace socket support

This commit is contained in:
U-MobileHooK\Benedikt 2011-07-11 13:30:05 +02:00
parent a7c1517e9b
commit b6ea3d50f4
158 changed files with 291 additions and 1 deletions

View file

@ -51,6 +51,18 @@ extern "C" {
#define __NR_execve 14
#define __NR_times 15
/* networking
*/
#define __NR_socket 16
#define __NR_bind 17
#define __NR_listen 18
#define __NR_accept 19
#define __NR_connect 20
#define __NR_send 21
#define __NR_recv 22
#define __NR_closesocket 23
#ifdef __cplusplus
}
#endif

View file

@ -25,6 +25,8 @@
#include <metalsvm/spinlock.h>
#include <metalsvm/time.h>
#include <lwip/socket.h>
static int sys_write(int fildes, const char *buf, size_t len)
{
int i;
@ -127,6 +129,61 @@ int syscall_handler(uint32_t sys_nr, ...)
ret = sys_times(buffer, clock);
break;
}
case __NR_socket: {
int domain= va_arg(v1,int);
int type = va_arg(v1,int);
int protocol = va_arg(v1,int);
ret = socket(domin,type,protocol);
break;
}
case __NR_bind: {
int s = va_arg(v1,int);
const struct sockaddr *name = va_arg(v1,(const struct sockaddr *));
socklen_t namelen = va_arg(v1,socklen_t);
ret = bind(s,name,namelen);
break;
}
case __NR_listen: {
int s = va_arg(v1,int);
int backlog = va_arg(v1,int);
ret = listen(s,backlog);
break;
}
case __NR_accept: {
int s = va_arg(v1,int);
struct sockaddr *addr = va_arg(v1,(struct sockaddr *));
socklen_t *addrlen = va_arg(v1,socklen_t*);
ret = accept(s,addr,addrlen);
break;
}
case __NR_connect: {
int s = va_arg(v1,int);
const struct sockaddr *name =va_arg(v1,(const struct sockaddr *));
socklen_t namelen = va_arg(v1,socklen_t);
ret = connect(s,name,namelen);
break;
}
case __NR_send: {
int s = va_arg(v1,int);
const void *data = va_arg(v1,void*);
size_t size = va_arg(v1,size_t);
int flags = va_arg(v1,int);
ret = send(s,data,size,flags);
break;
}
case __NR_recv: {
int s = va_arg(v1,int);
const void *data = va_arg(v1,void*);
size_t size = va_arg(v1,size_t);
int flags = va_arg(v1,int);
ret = recv(s,data,size,flags);
break;
}
case __NR_closesocket: {
int s = va_arg(v1,int);
ret = closesocket(s);
break;
}
default:
kputs("invalid system call\n");
ret = -ENOSYS;

0
newlib/src/compile Executable file → Normal file
View file

0
newlib/src/config.guess vendored Executable file → Normal file
View file

0
newlib/src/config.rpath Executable file → Normal file
View file

0
newlib/src/config.status Executable file → Normal file
View file

0
newlib/src/config.sub vendored Executable file → Normal file
View file

0
newlib/src/config/acinclude.m4 Executable file → Normal file
View file

0
newlib/src/configure vendored Executable file → Normal file
View file

0
newlib/src/depcomp Executable file → Normal file
View file

0
newlib/src/etc/config.status Executable file → Normal file
View file

0
newlib/src/etc/configure vendored Executable file → Normal file
View file

0
newlib/src/install-sh Executable file → Normal file
View file

0
newlib/src/libgloss/bfin/configure vendored Executable file → Normal file
View file

0
newlib/src/libgloss/configure vendored Executable file → Normal file
View file

0
newlib/src/libgloss/cris/configure vendored Executable file → Normal file
View file

0
newlib/src/libgloss/crx/configure vendored Executable file → Normal file
View file

0
newlib/src/libgloss/d30v/configure vendored Executable file → Normal file
View file

0
newlib/src/libgloss/doc/configure vendored Executable file → Normal file
View file

0
newlib/src/libgloss/fr30/configure vendored Executable file → Normal file
View file

0
newlib/src/libgloss/frv/configure vendored Executable file → Normal file
View file

0
newlib/src/libgloss/hp74x/configure vendored Executable file → Normal file
View file

0
newlib/src/libgloss/i386/configure vendored Executable file → Normal file
View file

0
newlib/src/libgloss/i960/configure vendored Executable file → Normal file
View file

0
newlib/src/libgloss/iq2000/configure vendored Executable file → Normal file
View file

0
newlib/src/libgloss/libnosys/configure vendored Executable file → Normal file
View file

0
newlib/src/libgloss/lm32/configure vendored Executable file → Normal file
View file

0
newlib/src/libgloss/m32c/configure vendored Executable file → Normal file
View file

0
newlib/src/libgloss/m32r/configure vendored Executable file → Normal file
View file

0
newlib/src/libgloss/m68hc11/configure vendored Executable file → Normal file
View file

0
newlib/src/libgloss/m68k/configure vendored Executable file → Normal file
View file

0
newlib/src/libgloss/mcore/configure vendored Executable file → Normal file
View file

0
newlib/src/libgloss/mep/configure vendored Executable file → Normal file
View file

View file

@ -63,7 +63,8 @@ CRT0 = crt0.o
METALSVM_BSP = libgloss.a
METALSVM_OBJS = chown.o errno.o fork.o gettod.o kill.o open.o sbrk.o times.o write.o \
close.o execve.o fstat.o init.o link.o read.o stat.o unlink.o \
environ.o _exit.o getpid.o isatty.o lseek.o readlink.o symlink.o wait.o
environ.o _exit.o getpid.o isatty.o lseek.o readlink.o symlink.o wait.o \
socket.o bind.o listen.o accept.o connect.o send.o recv.o closesocket.o
#### Host specific Makefile fragment comes in here.

View file

@ -0,0 +1,26 @@
#include "config.h"
#include <_ansi.h>
#include <_syslist.h>
#include <errno.h>
#undef errno
extern int errno;
#include "warning.h"
#include "syscall.h"
#include <lwip/socket.h>
int
_DEFUN (accept, (s, addr, addrlen),
int s, struct sockaddr *addr, socklen_t *addrlen)
{
int ret;
ret = SYSCALL3(__NR_accept, s, addr, addrlen);
if (ret < 0) {
errno = -ret;
ret = -1;
}
return ret;
}

View file

@ -0,0 +1,26 @@
#include "config.h"
#include <_ansi.h>
#include <_syslist.h>
#include <errno.h>
#undef errno
extern int errno;
#include "warning.h"
#include "syscall.h"
#include <lwip/socket.h>
int
_DEFUN (bind, (s, name, namelen),
int s, const struct sockaddr *name, socklen_t namelen)
{
int ret;
ret = SYSCALL3(__NR_bind, s, name, namelen);
if (ret < 0) {
errno = -ret;
ret = -1;
}
return ret;
}

View file

@ -0,0 +1,26 @@
#include "config.h"
#include <_ansi.h>
#include <_syslist.h>
#include <errno.h>
#undef errno
extern int errno;
#include "warning.h"
#include "syscall.h"
#include <lwip/socket.h>
int
_DEFUN (closesocket, (s),
int s)
{
int ret;
ret = SYSCALL1(__NR_closesocket, s);
if (ret < 0) {
errno = -ret;
ret = -1;
}
return ret;
}

0
newlib/src/libgloss/metalsvm/configure vendored Executable file → Normal file
View file

View file

@ -0,0 +1,26 @@
#include "config.h"
#include <_ansi.h>
#include <_syslist.h>
#include <errno.h>
#undef errno
extern int errno;
#include "warning.h"
#include "syscall.h"
#include <lwip/socket.h>
int
_DEFUN (connect, (s, name, namelen),
int s, const struct sockaddr *name, socklen_t namelen)
{
int ret;
ret = SYSCALL3(__NR_connect, s, name, namelen);
if (ret < 0) {
errno = -ret;
ret = -1;
}
return ret;
}

View file

@ -0,0 +1,26 @@
#include "config.h"
#include <_ansi.h>
#include <_syslist.h>
#include <errno.h>
#undef errno
extern int errno;
#include "warning.h"
#include "syscall.h"
#include <lwip/socket.h>
int
_DEFUN (listen, (s, backlog),
int s, int backlog)
{
int ret;
ret = SYSCALL2(__NR_listen, s, backlog);
if (ret < 0) {
errno = -ret;
ret = -1;
}
return ret;
}

View file

@ -0,0 +1,26 @@
#include "config.h"
#include <_ansi.h>
#include <_syslist.h>
#include <errno.h>
#undef errno
extern int errno;
#include "warning.h"
#include "syscall.h"
#include <lwip/socket.h>
int
_DEFUN (recv, (s, data, size,flags),
int s, const void *data, size_t size, int flags)
{
int ret;
ret = SYSCALL4(__NR_recv, s, data, size, flags);
if (ret < 0) {
errno = -ret;
ret = -1;
}
return ret;
}

View file

@ -0,0 +1,26 @@
#include "config.h"
#include <_ansi.h>
#include <_syslist.h>
#include <errno.h>
#undef errno
extern int errno;
#include "warning.h"
#include "syscall.h"
#include <lwip/socket.h>
int
_DEFUN (send, (s, data, size,flags),
int s, const void *data, size_t size, int flags)
{
int ret;
ret = SYSCALL4(__NR_send, s, data, size, flags);
if (ret < 0) {
errno = -ret;
ret = -1;
}
return ret;
}

View file

@ -0,0 +1,26 @@
#include "config.h"
#include <_ansi.h>
#include <_syslist.h>
#include <errno.h>
#undef errno
extern int errno;
#include "warning.h"
#include "syscall.h"
#include <lwip/socket.h>
int
_DEFUN (socket, (domain, type, protocol),
int domain, int type, int protocol)
{
int ret;
ret = SYSCALL3(__NR_socket, domain, type, protocol);
if (ret < 0) {
errno = -ret;
ret = -1;
}
return ret;
}

View file

@ -40,6 +40,18 @@ extern "C" {
#define __NR_execve 14
#define __NR_times 15
/* networking
*/
#define __NR_socket 16
#define __NR_bind 17
#define __NR_listen 18
#define __NR_accept 19
#define __NR_connect 20
#define __NR_send 21
#define __NR_recv 22
#define __NR_closesocket 23
#define _STR(token) #token
#define _SYSCALLSTR(x) "int $" _STR(x) " "
#define INT_SYSCALL 0x80

0
newlib/src/libgloss/mips/configure vendored Executable file → Normal file
View file

0
newlib/src/libgloss/mn10200/configure vendored Executable file → Normal file
View file

0
newlib/src/libgloss/mn10300/configure vendored Executable file → Normal file
View file

0
newlib/src/libgloss/mt/configure vendored Executable file → Normal file
View file

0
newlib/src/libgloss/pa/configure vendored Executable file → Normal file
View file

0
newlib/src/libgloss/rs6000/configure vendored Executable file → Normal file
View file

0
newlib/src/libgloss/sparc/configure vendored Executable file → Normal file
View file

0
newlib/src/libgloss/sparc/libsys/configure vendored Executable file → Normal file
View file

0
newlib/src/libgloss/tic6x/configure vendored Executable file → Normal file
View file

0
newlib/src/libgloss/wince/configure vendored Executable file → Normal file
View file

0
newlib/src/libgloss/xc16x/configure vendored Executable file → Normal file
View file

0
newlib/src/libgloss/xstormy16/configure vendored Executable file → Normal file
View file

0
newlib/src/missing Executable file → Normal file
View file

0
newlib/src/mkdep Executable file → Normal file
View file

0
newlib/src/mkinstalldirs Executable file → Normal file
View file

0
newlib/src/move-if-change Executable file → Normal file
View file

0
newlib/src/newlib/configure vendored Executable file → Normal file
View file

0
newlib/src/newlib/doc/configure vendored Executable file → Normal file
View file

0
newlib/src/newlib/iconvdata/configure vendored Executable file → Normal file
View file

0
newlib/src/newlib/libc/configure vendored Executable file → Normal file
View file

0
newlib/src/newlib/libc/iconv/ccs/mktbl.pl Executable file → Normal file
View file

0
newlib/src/newlib/libc/iconv/ces/mkdeps.pl Executable file → Normal file
View file

0
newlib/src/newlib/libc/machine/a29k/configure vendored Executable file → Normal file
View file

0
newlib/src/newlib/libc/machine/arm/configure vendored Executable file → Normal file
View file

0
newlib/src/newlib/libc/machine/bfin/configure vendored Executable file → Normal file
View file

0
newlib/src/newlib/libc/machine/configure vendored Executable file → Normal file
View file

0
newlib/src/newlib/libc/machine/cris/configure vendored Executable file → Normal file
View file

0
newlib/src/newlib/libc/machine/crx/configure vendored Executable file → Normal file
View file

0
newlib/src/newlib/libc/machine/d10v/configure vendored Executable file → Normal file
View file

0
newlib/src/newlib/libc/machine/d30v/configure vendored Executable file → Normal file
View file

0
newlib/src/newlib/libc/machine/fr30/configure vendored Executable file → Normal file
View file

0
newlib/src/newlib/libc/machine/frv/configure vendored Executable file → Normal file
View file

0
newlib/src/newlib/libc/machine/h8300/configure vendored Executable file → Normal file
View file

0
newlib/src/newlib/libc/machine/h8500/configure vendored Executable file → Normal file
View file

0
newlib/src/newlib/libc/machine/hppa/configure vendored Executable file → Normal file
View file

0
newlib/src/newlib/libc/machine/i386/configure vendored Executable file → Normal file
View file

0
newlib/src/newlib/libc/machine/i960/configure vendored Executable file → Normal file
View file

0
newlib/src/newlib/libc/machine/iq2000/configure vendored Executable file → Normal file
View file

0
newlib/src/newlib/libc/machine/lm32/configure vendored Executable file → Normal file
View file

0
newlib/src/newlib/libc/machine/m32c/configure vendored Executable file → Normal file
View file

0
newlib/src/newlib/libc/machine/m32r/configure vendored Executable file → Normal file
View file

0
newlib/src/newlib/libc/machine/m68hc11/configure vendored Executable file → Normal file
View file

0
newlib/src/newlib/libc/machine/m68k/configure vendored Executable file → Normal file
View file

0
newlib/src/newlib/libc/machine/m88k/configure vendored Executable file → Normal file
View file

0
newlib/src/newlib/libc/machine/mep/configure vendored Executable file → Normal file
View file

0
newlib/src/newlib/libc/machine/mips/configure vendored Executable file → Normal file
View file

0
newlib/src/newlib/libc/machine/mn10200/configure vendored Executable file → Normal file
View file

0
newlib/src/newlib/libc/machine/mn10300/configure vendored Executable file → Normal file
View file

0
newlib/src/newlib/libc/machine/mt/configure vendored Executable file → Normal file
View file

0
newlib/src/newlib/libc/machine/necv70/configure vendored Executable file → Normal file
View file

0
newlib/src/newlib/libc/machine/powerpc/configure vendored Executable file → Normal file
View file

0
newlib/src/newlib/libc/machine/rx/configure vendored Executable file → Normal file
View file

0
newlib/src/newlib/libc/machine/sh/configure vendored Executable file → Normal file
View file

0
newlib/src/newlib/libc/machine/sparc/configure vendored Executable file → Normal file
View file

0
newlib/src/newlib/libc/machine/tic4x/configure vendored Executable file → Normal file
View file

0
newlib/src/newlib/libc/machine/tic6x/configure vendored Executable file → Normal file
View file

Some files were not shown because too many files have changed in this diff Show more