2011-12-22 15:19:25 +00:00
|
|
|
/*
|
|
|
|
* \brief Noux session interface
|
|
|
|
* \author Norman Feske
|
|
|
|
* \date 2011-02-15
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
2013-01-10 20:44:47 +00:00
|
|
|
* Copyright (C) 2011-2013 Genode Labs GmbH
|
2011-12-22 15:19:25 +00:00
|
|
|
*
|
|
|
|
* This file is part of the Genode OS framework, which is distributed
|
|
|
|
* under the terms of the GNU General Public License version 2.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _INCLUDE__NOUX_SESSION__NOUX_SESSION_H_
|
|
|
|
#define _INCLUDE__NOUX_SESSION__NOUX_SESSION_H_
|
|
|
|
|
|
|
|
#include <base/stdint.h>
|
|
|
|
#include <session/session.h>
|
|
|
|
#include <dataspace/capability.h>
|
2014-01-28 13:07:36 +00:00
|
|
|
#include <rm_session/capability.h>
|
2011-12-22 15:19:25 +00:00
|
|
|
|
|
|
|
#define NOUX_DECL_SYSCALL_NAME(name) \
|
|
|
|
case SYSCALL_##name: return #name;
|
|
|
|
|
|
|
|
namespace Noux {
|
|
|
|
|
2012-04-23 18:42:55 +00:00
|
|
|
using namespace Genode;
|
|
|
|
|
2011-12-22 15:19:25 +00:00
|
|
|
struct Session : Genode::Session
|
|
|
|
{
|
|
|
|
static const char *service_name() { return "Noux"; }
|
|
|
|
|
|
|
|
virtual ~Session() { }
|
|
|
|
|
2012-04-23 18:42:55 +00:00
|
|
|
virtual Dataspace_capability sysio_dataspace() = 0;
|
2011-12-22 15:19:25 +00:00
|
|
|
|
2014-01-28 13:07:36 +00:00
|
|
|
/**
|
|
|
|
* Return leaf RM session that covers a given address
|
|
|
|
*
|
|
|
|
* \param addr address that is covered by the requested RM session
|
|
|
|
*/
|
|
|
|
virtual Rm_session_capability lookup_rm_session(addr_t const addr) = 0;
|
|
|
|
|
2011-12-22 15:19:25 +00:00
|
|
|
enum Syscall {
|
|
|
|
SYSCALL_WRITE,
|
|
|
|
SYSCALL_READ,
|
|
|
|
SYSCALL_STAT,
|
|
|
|
SYSCALL_LSTAT,
|
|
|
|
SYSCALL_FSTAT,
|
2012-08-02 13:17:24 +00:00
|
|
|
SYSCALL_FTRUNCATE,
|
2011-12-22 15:19:25 +00:00
|
|
|
SYSCALL_FCNTL,
|
|
|
|
SYSCALL_OPEN,
|
|
|
|
SYSCALL_CLOSE,
|
|
|
|
SYSCALL_IOCTL,
|
2012-04-25 21:52:49 +00:00
|
|
|
SYSCALL_LSEEK,
|
2011-12-22 15:19:25 +00:00
|
|
|
SYSCALL_DIRENT,
|
|
|
|
SYSCALL_EXECVE,
|
|
|
|
SYSCALL_SELECT,
|
2012-02-15 18:51:13 +00:00
|
|
|
SYSCALL_FORK,
|
|
|
|
SYSCALL_GETPID,
|
2012-02-24 14:19:38 +00:00
|
|
|
SYSCALL_WAIT4,
|
2012-03-19 21:52:26 +00:00
|
|
|
SYSCALL_PIPE,
|
|
|
|
SYSCALL_DUP2,
|
2012-04-25 21:52:49 +00:00
|
|
|
SYSCALL_UNLINK,
|
2012-10-08 12:44:31 +00:00
|
|
|
SYSCALL_READLINK,
|
2012-04-25 21:52:49 +00:00
|
|
|
SYSCALL_RENAME,
|
|
|
|
SYSCALL_MKDIR,
|
2012-10-08 12:44:31 +00:00
|
|
|
SYSCALL_SYMLINK,
|
2012-05-24 15:06:54 +00:00
|
|
|
SYSCALL_SOCKET,
|
|
|
|
SYSCALL_GETSOCKOPT,
|
|
|
|
SYSCALL_SETSOCKOPT,
|
|
|
|
SYSCALL_ACCEPT,
|
|
|
|
SYSCALL_BIND,
|
|
|
|
SYSCALL_LISTEN,
|
|
|
|
SYSCALL_SEND,
|
|
|
|
SYSCALL_SENDTO,
|
|
|
|
SYSCALL_RECV,
|
2012-06-08 12:24:38 +00:00
|
|
|
SYSCALL_RECVFROM,
|
2012-05-24 15:06:54 +00:00
|
|
|
SYSCALL_GETPEERNAME,
|
|
|
|
SYSCALL_SHUTDOWN,
|
|
|
|
SYSCALL_CONNECT,
|
2012-08-20 16:24:11 +00:00
|
|
|
SYSCALL_USERINFO,
|
2012-09-12 14:12:55 +00:00
|
|
|
SYSCALL_GETTIMEOFDAY,
|
|
|
|
SYSCALL_CLOCK_GETTIME,
|
|
|
|
SYSCALL_UTIMES,
|
2013-12-18 11:04:04 +00:00
|
|
|
SYSCALL_SYNC,
|
2014-01-23 16:21:35 +00:00
|
|
|
SYSCALL_KILL,
|
2011-12-22 15:19:25 +00:00
|
|
|
SYSCALL_INVALID = -1
|
|
|
|
};
|
|
|
|
|
|
|
|
static char const *syscall_name(Syscall sc)
|
|
|
|
{
|
|
|
|
switch (sc) {
|
|
|
|
NOUX_DECL_SYSCALL_NAME(WRITE)
|
|
|
|
NOUX_DECL_SYSCALL_NAME(READ)
|
|
|
|
NOUX_DECL_SYSCALL_NAME(STAT)
|
|
|
|
NOUX_DECL_SYSCALL_NAME(LSTAT)
|
|
|
|
NOUX_DECL_SYSCALL_NAME(FSTAT)
|
2012-08-02 13:17:24 +00:00
|
|
|
NOUX_DECL_SYSCALL_NAME(FTRUNCATE)
|
2011-12-22 15:19:25 +00:00
|
|
|
NOUX_DECL_SYSCALL_NAME(FCNTL)
|
|
|
|
NOUX_DECL_SYSCALL_NAME(OPEN)
|
|
|
|
NOUX_DECL_SYSCALL_NAME(CLOSE)
|
|
|
|
NOUX_DECL_SYSCALL_NAME(IOCTL)
|
2012-04-25 21:52:49 +00:00
|
|
|
NOUX_DECL_SYSCALL_NAME(LSEEK)
|
2011-12-22 15:19:25 +00:00
|
|
|
NOUX_DECL_SYSCALL_NAME(DIRENT)
|
|
|
|
NOUX_DECL_SYSCALL_NAME(EXECVE)
|
|
|
|
NOUX_DECL_SYSCALL_NAME(SELECT)
|
2012-02-15 18:51:13 +00:00
|
|
|
NOUX_DECL_SYSCALL_NAME(FORK)
|
|
|
|
NOUX_DECL_SYSCALL_NAME(GETPID)
|
2012-02-24 14:19:38 +00:00
|
|
|
NOUX_DECL_SYSCALL_NAME(WAIT4)
|
2012-03-19 21:52:26 +00:00
|
|
|
NOUX_DECL_SYSCALL_NAME(PIPE)
|
|
|
|
NOUX_DECL_SYSCALL_NAME(DUP2)
|
2012-04-25 21:52:49 +00:00
|
|
|
NOUX_DECL_SYSCALL_NAME(UNLINK)
|
2012-10-08 12:44:31 +00:00
|
|
|
NOUX_DECL_SYSCALL_NAME(READLINK)
|
2012-04-25 21:52:49 +00:00
|
|
|
NOUX_DECL_SYSCALL_NAME(RENAME)
|
|
|
|
NOUX_DECL_SYSCALL_NAME(MKDIR)
|
2012-10-08 12:44:31 +00:00
|
|
|
NOUX_DECL_SYSCALL_NAME(SYMLINK)
|
2012-05-24 15:06:54 +00:00
|
|
|
NOUX_DECL_SYSCALL_NAME(SOCKET)
|
|
|
|
NOUX_DECL_SYSCALL_NAME(GETSOCKOPT)
|
|
|
|
NOUX_DECL_SYSCALL_NAME(SETSOCKOPT)
|
|
|
|
NOUX_DECL_SYSCALL_NAME(ACCEPT)
|
|
|
|
NOUX_DECL_SYSCALL_NAME(BIND)
|
|
|
|
NOUX_DECL_SYSCALL_NAME(LISTEN)
|
|
|
|
NOUX_DECL_SYSCALL_NAME(SEND)
|
|
|
|
NOUX_DECL_SYSCALL_NAME(SENDTO)
|
|
|
|
NOUX_DECL_SYSCALL_NAME(RECV)
|
2012-06-08 12:24:38 +00:00
|
|
|
NOUX_DECL_SYSCALL_NAME(RECVFROM)
|
2012-05-24 15:06:54 +00:00
|
|
|
NOUX_DECL_SYSCALL_NAME(GETPEERNAME)
|
|
|
|
NOUX_DECL_SYSCALL_NAME(SHUTDOWN)
|
|
|
|
NOUX_DECL_SYSCALL_NAME(CONNECT)
|
2012-08-20 16:24:11 +00:00
|
|
|
NOUX_DECL_SYSCALL_NAME(USERINFO)
|
2012-09-12 14:12:55 +00:00
|
|
|
NOUX_DECL_SYSCALL_NAME(GETTIMEOFDAY)
|
|
|
|
NOUX_DECL_SYSCALL_NAME(CLOCK_GETTIME)
|
|
|
|
NOUX_DECL_SYSCALL_NAME(UTIMES)
|
2013-12-18 11:04:04 +00:00
|
|
|
NOUX_DECL_SYSCALL_NAME(SYNC)
|
2014-01-23 16:21:35 +00:00
|
|
|
NOUX_DECL_SYSCALL_NAME(KILL)
|
2011-12-22 15:19:25 +00:00
|
|
|
case SYSCALL_INVALID: return 0;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Perform syscall
|
|
|
|
*
|
|
|
|
* The syscall arguments and results are communicated via the shared
|
|
|
|
* sysio dataspace.
|
|
|
|
*
|
|
|
|
* \return true on success
|
|
|
|
*/
|
|
|
|
virtual bool syscall(Syscall syscall) = 0;
|
|
|
|
|
2013-09-06 19:10:23 +00:00
|
|
|
/*
|
|
|
|
* Return the next open file descriptor, starting from (and including)
|
|
|
|
* 'start_fd'.
|
|
|
|
*
|
|
|
|
* \return the next open file descriptor or -1
|
|
|
|
*/
|
|
|
|
virtual int next_open_fd(int start_fd) = 0;
|
2011-12-22 15:19:25 +00:00
|
|
|
|
|
|
|
/*********************
|
|
|
|
** RPC declaration **
|
|
|
|
*********************/
|
|
|
|
|
2012-04-23 18:42:55 +00:00
|
|
|
GENODE_RPC(Rpc_sysio_dataspace, Dataspace_capability, sysio_dataspace);
|
2014-01-28 13:07:36 +00:00
|
|
|
GENODE_RPC(Rpc_lookup_rm_session, Rm_session_capability,
|
|
|
|
lookup_rm_session, addr_t);
|
2011-12-22 15:19:25 +00:00
|
|
|
GENODE_RPC(Rpc_syscall, bool, syscall, Syscall);
|
2013-09-06 19:10:23 +00:00
|
|
|
GENODE_RPC(Rpc_next_open_fd, int, next_open_fd, int);
|
2011-12-22 15:19:25 +00:00
|
|
|
|
2014-01-28 13:07:36 +00:00
|
|
|
GENODE_RPC_INTERFACE(Rpc_sysio_dataspace, Rpc_lookup_rm_session,
|
|
|
|
Rpc_syscall, Rpc_next_open_fd);
|
2011-12-22 15:19:25 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
#undef NOUX_DECL_SYSCALL_NAME
|
|
|
|
|
|
|
|
#endif /* _INCLUDE__NOUX_SESSION__NOUX_SESSION_H_ */
|
|
|
|
|