Syscalls: Implement sysinfo() syscall.
This commit is contained in:
parent
0f569b4d9d
commit
9b8e61beb3
|
@ -125,6 +125,21 @@ class AlphaLinux : public Linux
|
|||
TGT_RLIMIT_MEMLOCK = 9,
|
||||
TGT_RLIMIT_LOCKS = 10
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
int64_t uptime; /* Seconds since boot */
|
||||
uint64_t loads[3]; /* 1, 5, and 15 minute load averages */
|
||||
uint64_t totalram; /* Total usable main memory size */
|
||||
uint64_t freeram; /* Available memory size */
|
||||
uint64_t sharedram; /* Amount of shared memory */
|
||||
uint64_t bufferram; /* Memory used by buffers */
|
||||
uint64_t totalswap; /* Total swap space size */
|
||||
uint64_t freeswap; /* swap space still available */
|
||||
uint16_t procs; /* Number of current processes */
|
||||
uint64_t totalhigh; /* Total high memory size */
|
||||
uint64_t freehigh; /* Available high memory size */
|
||||
uint64_t mem_unit; /* Memory unit size in bytes */
|
||||
} tgt_sysinfo;
|
||||
};
|
||||
|
||||
#endif // __ALPHA_ALPHA_LINUX_LINUX_HH__
|
||||
|
|
|
@ -440,7 +440,7 @@ SyscallDesc AlphaLinuxProcess::syscallDescs[] = {
|
|||
/* 315 */ SyscallDesc("munlock", unimplementedFunc),
|
||||
/* 316 */ SyscallDesc("mlockall", unimplementedFunc),
|
||||
/* 317 */ SyscallDesc("munlockall", unimplementedFunc),
|
||||
/* 318 */ SyscallDesc("sysinfo", unimplementedFunc),
|
||||
/* 318 */ SyscallDesc("sysinfo", sysinfoFunc<AlphaLinux>),
|
||||
/* 319 */ SyscallDesc("_sysctl", unimplementedFunc),
|
||||
/* 320 */ SyscallDesc("was sys_idle", unimplementedFunc),
|
||||
/* 321 */ SyscallDesc("oldumount", unimplementedFunc),
|
||||
|
|
|
@ -147,6 +147,21 @@ class ArmLinux : public Linux
|
|||
uint64_t st_ino;
|
||||
} tgt_stat64;
|
||||
|
||||
typedef struct {
|
||||
int32_t uptime; /* Seconds since boot */
|
||||
uint32_t loads[3]; /* 1, 5, and 15 minute load averages */
|
||||
uint32_t totalram; /* Total usable main memory size */
|
||||
uint32_t freeram; /* Available memory size */
|
||||
uint32_t sharedram; /* Amount of shared memory */
|
||||
uint32_t bufferram; /* Memory used by buffers */
|
||||
uint32_t totalswap; /* Total swap space size */
|
||||
uint32_t freeswap; /* swap space still available */
|
||||
uint16_t procs; /* Number of current processes */
|
||||
uint32_t totalhigh; /* Total high memory size */
|
||||
uint32_t freehigh; /* Available high memory size */
|
||||
uint32_t mem_unit; /* Memory unit size in bytes */
|
||||
} tgt_sysinfo;
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -179,7 +179,7 @@ SyscallDesc ArmLinuxProcess::syscallDescs[] = {
|
|||
/* 113 */ SyscallDesc("vm86", unimplementedFunc),
|
||||
/* 114 */ SyscallDesc("wait4", unimplementedFunc),
|
||||
/* 115 */ SyscallDesc("swapoff", unimplementedFunc),
|
||||
/* 116 */ SyscallDesc("sysinfo", unimplementedFunc),
|
||||
/* 116 */ SyscallDesc("sysinfo", sysinfoFunc<ArmLinux>),
|
||||
/* 117 */ SyscallDesc("ipc", unimplementedFunc),
|
||||
/* 118 */ SyscallDesc("fsync", unimplementedFunc),
|
||||
/* 119 */ SyscallDesc("sigreturn", unimplementedFunc),
|
||||
|
|
|
@ -126,6 +126,22 @@ class MipsLinux : public Linux
|
|||
/// assign themselves to process IDs reserved for
|
||||
/// the root users.
|
||||
static const int NUM_ROOT_PROCS = 2;
|
||||
|
||||
typedef struct {
|
||||
int32_t uptime; /* Seconds since boot */
|
||||
uint32_t loads[3]; /* 1, 5, and 15 minute load averages */
|
||||
uint32_t totalram; /* Total usable main memory size */
|
||||
uint32_t freeram; /* Available memory size */
|
||||
uint32_t sharedram; /* Amount of shared memory */
|
||||
uint32_t bufferram; /* Memory used by buffers */
|
||||
uint32_t totalswap; /* Total swap space size */
|
||||
uint32_t freeswap; /* swap space still available */
|
||||
uint16_t procs; /* Number of current processes */
|
||||
uint32_t totalhigh; /* Total high memory size */
|
||||
uint32_t freehigh; /* Available high memory size */
|
||||
uint32_t mem_unit; /* Memory unit size in bytes */
|
||||
} tgt_sysinfo;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -238,7 +238,7 @@ SyscallDesc MipsLinuxProcess::syscallDescs[] = {
|
|||
/* 113 */ SyscallDesc("vm86", unimplementedFunc),
|
||||
/* 114 */ SyscallDesc("wait4", unimplementedFunc),
|
||||
/* 115 */ SyscallDesc("swapoff", unimplementedFunc),
|
||||
/* 116 */ SyscallDesc("sysinfo", unimplementedFunc),
|
||||
/* 116 */ SyscallDesc("sysinfo", sysinfoFunc<MipsLinux>),
|
||||
/* 117 */ SyscallDesc("ipc", unimplementedFunc),
|
||||
/* 118 */ SyscallDesc("fsync", unimplementedFunc),
|
||||
/* 119 */ SyscallDesc("sigreturn", unimplementedFunc),
|
||||
|
|
|
@ -77,6 +77,22 @@ class SparcLinux : public Linux
|
|||
static const int NUM_OPEN_FLAGS;
|
||||
|
||||
static const unsigned TGT_MAP_ANONYMOUS = 0x20;
|
||||
|
||||
typedef struct {
|
||||
int64_t uptime; /* Seconds since boot */
|
||||
uint64_t loads[3]; /* 1, 5, and 15 minute load averages */
|
||||
uint64_t totalram; /* Total usable main memory size */
|
||||
uint64_t freeram; /* Available memory size */
|
||||
uint64_t sharedram; /* Amount of shared memory */
|
||||
uint64_t bufferram; /* Memory used by buffers */
|
||||
uint64_t totalswap; /* Total swap space size */
|
||||
uint64_t freeswap; /* swap space still available */
|
||||
uint16_t procs; /* Number of current processes */
|
||||
uint64_t totalhigh; /* Total high memory size */
|
||||
uint64_t freehigh; /* Available high memory size */
|
||||
uint64_t mem_unit; /* Memory unit size in bytes */
|
||||
} tgt_sysinfo;
|
||||
|
||||
};
|
||||
|
||||
class Sparc32Linux : public SparcLinux
|
||||
|
@ -105,6 +121,22 @@ class Sparc32Linux : public SparcLinux
|
|||
uint32_t __unused4;
|
||||
uint32_t __unused5;
|
||||
} tgt_stat64;
|
||||
|
||||
typedef struct {
|
||||
int32_t uptime; /* Seconds since boot */
|
||||
uint32_t loads[3]; /* 1, 5, and 15 minute load averages */
|
||||
uint32_t totalram; /* Total usable main memory size */
|
||||
uint32_t freeram; /* Available memory size */
|
||||
uint32_t sharedram; /* Amount of shared memory */
|
||||
uint32_t bufferram; /* Memory used by buffers */
|
||||
uint32_t totalswap; /* Total swap space size */
|
||||
uint32_t freeswap; /* swap space still available */
|
||||
uint16_t procs; /* Number of current processes */
|
||||
uint32_t totalhigh; /* Total high memory size */
|
||||
uint32_t freehigh; /* Available high memory size */
|
||||
uint32_t mem_unit; /* Memory unit size in bytes */
|
||||
} tgt_sysinfo;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -302,7 +302,7 @@ SyscallDesc SparcLinuxProcess::syscall32Descs[] = {
|
|||
/* 211 */ SyscallDesc("tgkill", unimplementedFunc), //32 bit
|
||||
/* 212 */ SyscallDesc("waitpid", unimplementedFunc), //32 bit
|
||||
/* 213 */ SyscallDesc("swapoff", unimplementedFunc),
|
||||
/* 214 */ SyscallDesc("sysinfo", unimplementedFunc), //32 bit
|
||||
/* 214 */ SyscallDesc("sysinfo", sysinfoFunc<Sparc32Linux>), //32 bit
|
||||
/* 215 */ SyscallDesc("ipc", unimplementedFunc), //32 bit
|
||||
/* 216 */ SyscallDesc("sigreturn", unimplementedFunc), //32 bit
|
||||
/* 217 */ SyscallDesc("clone", cloneFunc),
|
||||
|
@ -608,7 +608,7 @@ SyscallDesc SparcLinuxProcess::syscallDescs[] = {
|
|||
/* 211 */ SyscallDesc("tgkill", unimplementedFunc),
|
||||
/* 212 */ SyscallDesc("waitpid", unimplementedFunc),
|
||||
/* 213 */ SyscallDesc("swapoff", unimplementedFunc),
|
||||
/* 214 */ SyscallDesc("sysinfo", unimplementedFunc),
|
||||
/* 214 */ SyscallDesc("sysinfo", sysinfoFunc<SparcLinux>),
|
||||
/* 215 */ SyscallDesc("ipc", unimplementedFunc),
|
||||
/* 216 */ SyscallDesc("sigreturn", unimplementedFunc),
|
||||
/* 217 */ SyscallDesc("clone", cloneFunc),
|
||||
|
|
|
@ -111,6 +111,22 @@ class X86Linux64 : public Linux
|
|||
uint64_t iov_base; // void *
|
||||
uint64_t iov_len; // size_t
|
||||
} tgt_iovec;
|
||||
|
||||
typedef struct {
|
||||
int64_t uptime; /* Seconds since boot */
|
||||
uint64_t loads[3]; /* 1, 5, and 15 minute load averages */
|
||||
uint64_t totalram; /* Total usable main memory size */
|
||||
uint64_t freeram; /* Available memory size */
|
||||
uint64_t sharedram; /* Amount of shared memory */
|
||||
uint64_t bufferram; /* Memory used by buffers */
|
||||
uint64_t totalswap; /* Total swap space size */
|
||||
uint64_t freeswap; /* swap space still available */
|
||||
uint16_t procs; /* Number of current processes */
|
||||
uint64_t totalhigh; /* Total high memory size */
|
||||
uint64_t freehigh; /* Available high memory size */
|
||||
uint64_t mem_unit; /* Memory unit size in bytes */
|
||||
} tgt_sysinfo;
|
||||
|
||||
};
|
||||
|
||||
class X86Linux32 : public Linux
|
||||
|
@ -160,6 +176,21 @@ class X86Linux32 : public Linux
|
|||
static const int NUM_OPEN_FLAGS;
|
||||
|
||||
static const unsigned TGT_MAP_ANONYMOUS = 0x20;
|
||||
|
||||
typedef struct {
|
||||
int32_t uptime; /* Seconds since boot */
|
||||
uint32_t loads[3]; /* 1, 5, and 15 minute load averages */
|
||||
uint32_t totalram; /* Total usable main memory size */
|
||||
uint32_t freeram; /* Available memory size */
|
||||
uint32_t sharedram; /* Amount of shared memory */
|
||||
uint32_t bufferram; /* Memory used by buffers */
|
||||
uint32_t totalswap; /* Total swap space size */
|
||||
uint32_t freeswap; /* swap space still available */
|
||||
uint16_t procs; /* Number of current processes */
|
||||
uint32_t totalhigh; /* Total high memory size */
|
||||
uint32_t freehigh; /* Available high memory size */
|
||||
uint32_t mem_unit; /* Memory unit size in bytes */
|
||||
} tgt_sysinfo;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -327,7 +327,7 @@ SyscallDesc X86_64LinuxProcess::syscallDescs[] = {
|
|||
/* 96 */ SyscallDesc("gettimeofday", unimplementedFunc),
|
||||
/* 97 */ SyscallDesc("getrlimit", unimplementedFunc),
|
||||
/* 98 */ SyscallDesc("getrusage", unimplementedFunc),
|
||||
/* 99 */ SyscallDesc("sysinfo", unimplementedFunc),
|
||||
/* 99 */ SyscallDesc("sysinfo", sysinfoFunc<X86Linux64>),
|
||||
/* 100 */ SyscallDesc("times", unimplementedFunc),
|
||||
/* 101 */ SyscallDesc("ptrace", unimplementedFunc),
|
||||
/* 102 */ SyscallDesc("getuid", getuidFunc),
|
||||
|
@ -623,7 +623,7 @@ SyscallDesc I386LinuxProcess::syscallDescs[] = {
|
|||
/* 113 */ SyscallDesc("vm86old", unimplementedFunc),
|
||||
/* 114 */ SyscallDesc("wait4", unimplementedFunc),
|
||||
/* 115 */ SyscallDesc("swapoff", unimplementedFunc),
|
||||
/* 116 */ SyscallDesc("sysinfo", unimplementedFunc),
|
||||
/* 116 */ SyscallDesc("sysinfo", sysinfoFunc<X86Linux32>),
|
||||
/* 117 */ SyscallDesc("ipc", unimplementedFunc),
|
||||
/* 118 */ SyscallDesc("fsync", unimplementedFunc),
|
||||
/* 119 */ SyscallDesc("sigreturn", unimplementedFunc),
|
||||
|
|
|
@ -59,6 +59,7 @@
|
|||
#include "cpu/thread_context.hh"
|
||||
#include "mem/translating_port.hh"
|
||||
#include "mem/page_table.hh"
|
||||
#include "sim/system.hh"
|
||||
#include "sim/process.hh"
|
||||
|
||||
///
|
||||
|
@ -558,6 +559,22 @@ openFunc(SyscallDesc *desc, int callnum, LiveProcess *process,
|
|||
|
||||
}
|
||||
|
||||
/// Target sysinfo() handler.
|
||||
template <class OS>
|
||||
SyscallReturn
|
||||
sysinfoFunc(SyscallDesc *desc, int callnum, LiveProcess *process,
|
||||
ThreadContext *tc)
|
||||
{
|
||||
|
||||
TypedBufferArg<typename OS::tgt_sysinfo> sysinfo(process->getSyscallArg(tc, 0));
|
||||
|
||||
sysinfo->uptime=seconds_since_epoch;
|
||||
sysinfo->totalram=process->system->memSize();
|
||||
|
||||
sysinfo.copyOut(tc->getMemPort());
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/// Target chmod() handler.
|
||||
template <class OS>
|
||||
|
|
Loading…
Reference in a new issue