X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=blobdiff_plain;f=qemu%2Froms%2FSLOF%2Fclients%2Fnet-snk%2Fkernel%2Fsystemcall.c;fp=qemu%2Froms%2FSLOF%2Fclients%2Fnet-snk%2Fkernel%2Fsystemcall.c;h=52c45cad7e3e221a6fa84041dd25e6a6afdca310;hb=e44e3482bdb4d0ebde2d8b41830ac2cdb07948fb;hp=0000000000000000000000000000000000000000;hpb=9ca8dbcc65cfc63d6f5ef3312a33184e1d726e00;p=kvmfornfv.git diff --git a/qemu/roms/SLOF/clients/net-snk/kernel/systemcall.c b/qemu/roms/SLOF/clients/net-snk/kernel/systemcall.c new file mode 100644 index 000000000..52c45cad7 --- /dev/null +++ b/qemu/roms/SLOF/clients/net-snk/kernel/systemcall.c @@ -0,0 +1,176 @@ +/****************************************************************************** + * Copyright (c) 2004, 2008 IBM Corporation + * All rights reserved. + * This program and the accompanying materials + * are made available under the terms of the BSD License + * which accompanies this distribution, and is available at + * http://www.opensource.org/licenses/bsd-license.php + * + * Contributors: + * IBM Corporation - initial implementation + *****************************************************************************/ + +#include +#include +#include +#include +#include +#include +#include + +extern int vsprintf(char *, const char *, va_list); +extern void _exit(int status); + +void exit(int status); + +int open(const char* name, int flags) +{ + int fd; + + /* search free file descriptor */ + for (fd=0; fd= FILEIO_MAX || + fd_array[fd].type == FILEIO_TYPE_EMPTY) + return -1; + if (fd_array[fd].type == FILEIO_TYPE_FILE) + of_close(fd_array[fd].ih); + fd_array[fd].type = FILEIO_TYPE_EMPTY; + return 0; +} + +ssize_t read(int fd, void *buf, size_t len) +{ + if (fd < 0 || fd >= FILEIO_MAX || + fd_array[fd].type == FILEIO_TYPE_EMPTY) + return -1; + + return of_read(fd_array[fd].ih, buf, len); +} + +ssize_t write (int fd, const void *buf, size_t len) +{ + char dest_buf[512]; + char *dest_buf_ptr; + const char *dbuf = buf; + int i; + + if (fd == 1 || fd == 2) { + dest_buf_ptr = &dest_buf[0]; + for (i = 0; i < len && i < 256; i++) + { + *dest_buf_ptr++ = *dbuf++; + if (dbuf[-1] == '\n') + *dest_buf_ptr++ = '\r'; + } + len = dest_buf_ptr - &dest_buf[0]; + buf = &dest_buf[0]; + } + + if(fd < 0 || fd >= FILEIO_MAX || + fd_array[fd].type == FILEIO_TYPE_EMPTY) + return -1; + + return of_write(fd_array[fd].ih, (void *)buf, len); +} + +ssize_t lseek (int fd, long offset, int whence) +{ + return 0; // this syscall is unused !!! +#if 0 + if (whence != 0) + return -1; + + of_seek (fd_array[fd], (unsigned int) (offset>>32), (unsigned int) (offset & 0xffffffffULL)); + + return offset; +#endif +} + +int recv(int fd, void *packet, int packet_len, int flags) +{ + return read(fd, packet, packet_len); +} + +int send(int fd, const void *packet, int packet_len, int flags) +{ + return write(fd, packet, packet_len); +} + +int sendto(int fd, const void *packet, int packet_len, int flags, + const void *sock_addr, int sock_addr_len) +{ + return send(fd, packet, packet_len, flags); +} + +void exit(int status) +{ + _exit(status); +}