add OSFlags struct to AlphaISA/MipsISA namespace. The OS classes then use these OSFlags to access architecture-specific AND OS-specific

flags for their functions (e.g. OS::OSFlags::TG_MAP_ANONYMOUS)...

arch/alpha/tru64/process.cc:
sim/syscall_emul.hh:
    Add OSFlags to code
arch/mips/isa/decoder.isa:
    slight decoder changes (more stylistic then anything)
arch/mips/isa/formats/util.isa:
    spacing
arch/mips/isa_traits.hh:
    add OSFlags struct to MipsISA namespace. The OS classes then use these OSFlags to access architecture-specific and OS-specific
    flags for their functions
kern/linux/linux.hh:
    remove constant placement ... define OSFlags in linux.hh
kern/tru64/tru64.hh:
    define OSFlags in tru64

--HG--
extra : convert_revision : 59be1036eb439ca4ea1eea1d3b52e508023de6c9
This commit is contained in:
Korey Sewell 2006-04-12 03:44:45 -04:00
parent da7990ab33
commit 4fe89f7232
7 changed files with 74 additions and 143 deletions

View file

@ -63,28 +63,28 @@ getsysinfoFunc(SyscallDesc *desc, int callnum, Process *process,
switch (op) { switch (op) {
case Tru64::GSI_MAX_CPU: { case Tru64::OSFlags::GSI_MAX_CPU: {
TypedBufferArg<uint32_t> max_cpu(xc->getSyscallArg(1)); TypedBufferArg<uint32_t> max_cpu(xc->getSyscallArg(1));
*max_cpu = htog((uint32_t)process->numCpus()); *max_cpu = htog((uint32_t)process->numCpus());
max_cpu.copyOut(xc->getMemPort()); max_cpu.copyOut(xc->getMemPort());
return 1; return 1;
} }
case Tru64::GSI_CPUS_IN_BOX: { case Tru64::OSFlags::GSI_CPUS_IN_BOX: {
TypedBufferArg<uint32_t> cpus_in_box(xc->getSyscallArg(1)); TypedBufferArg<uint32_t> cpus_in_box(xc->getSyscallArg(1));
*cpus_in_box = htog((uint32_t)process->numCpus()); *cpus_in_box = htog((uint32_t)process->numCpus());
cpus_in_box.copyOut(xc->getMemPort()); cpus_in_box.copyOut(xc->getMemPort());
return 1; return 1;
} }
case Tru64::GSI_PHYSMEM: { case Tru64::OSFlags::GSI_PHYSMEM: {
TypedBufferArg<uint64_t> physmem(xc->getSyscallArg(1)); TypedBufferArg<uint64_t> physmem(xc->getSyscallArg(1));
*physmem = htog((uint64_t)1024 * 1024); // physical memory in KB *physmem = htog((uint64_t)1024 * 1024); // physical memory in KB
physmem.copyOut(xc->getMemPort()); physmem.copyOut(xc->getMemPort());
return 1; return 1;
} }
case Tru64::GSI_CPU_INFO: { case Tru64::OSFlags::GSI_CPU_INFO: {
TypedBufferArg<Tru64::cpu_info> infop(xc->getSyscallArg(1)); TypedBufferArg<Tru64::cpu_info> infop(xc->getSyscallArg(1));
infop->current_cpu = htog(0); infop->current_cpu = htog(0);
@ -101,14 +101,14 @@ getsysinfoFunc(SyscallDesc *desc, int callnum, Process *process,
return 1; return 1;
} }
case Tru64::GSI_PROC_TYPE: { case Tru64::OSFlags::GSI_PROC_TYPE: {
TypedBufferArg<uint64_t> proc_type(xc->getSyscallArg(1)); TypedBufferArg<uint64_t> proc_type(xc->getSyscallArg(1));
*proc_type = htog((uint64_t)11); *proc_type = htog((uint64_t)11);
proc_type.copyOut(xc->getMemPort()); proc_type.copyOut(xc->getMemPort());
return 1; return 1;
} }
case Tru64::GSI_PLATFORM_NAME: { case Tru64::OSFlags::GSI_PLATFORM_NAME: {
BufferArg bufArg(xc->getSyscallArg(1), nbytes); BufferArg bufArg(xc->getSyscallArg(1), nbytes);
strncpy((char *)bufArg.bufferPtr(), strncpy((char *)bufArg.bufferPtr(),
"COMPAQ Professional Workstation XP1000", "COMPAQ Professional Workstation XP1000",
@ -117,7 +117,7 @@ getsysinfoFunc(SyscallDesc *desc, int callnum, Process *process,
return 1; return 1;
} }
case Tru64::GSI_CLK_TCK: { case Tru64::OSFlags::GSI_CLK_TCK: {
TypedBufferArg<uint64_t> clk_hz(xc->getSyscallArg(1)); TypedBufferArg<uint64_t> clk_hz(xc->getSyscallArg(1));
*clk_hz = htog((uint64_t)1024); *clk_hz = htog((uint64_t)1024);
clk_hz.copyOut(xc->getMemPort()); clk_hz.copyOut(xc->getMemPort());
@ -140,7 +140,7 @@ setsysinfoFunc(SyscallDesc *desc, int callnum, Process *process,
unsigned op = xc->getSyscallArg(0); unsigned op = xc->getSyscallArg(0);
switch (op) { switch (op) {
case Tru64::SSI_IEEE_FP_CONTROL: case Tru64::OSFlags::SSI_IEEE_FP_CONTROL:
warn("setsysinfo: ignoring ieee_set_fp_control() arg 0x%x\n", warn("setsysinfo: ignoring ieee_set_fp_control() arg 0x%x\n",
xc->getSyscallArg(1)); xc->getSyscallArg(1));
break; break;

View file

@ -143,9 +143,11 @@ decode OPCODE_HI default Unknown::unknown() {
}}); }});
0x1: multu({{ 0x1: multu({{
int64_t temp1 = Rs.uw * Rt.uw; uint64_t temp1 = Rs.uw * Rt.uw;
xc->setMiscReg(Hi,temp1<63:32>); uint32_t hi_val = temp1<63:32>;
xc->setMiscReg(Lo,temp1<31:0>); uint32_t lo_val = temp1<31:0>;
xc->setMiscReg(Hi,hi_val);
xc->setMiscReg(Lo,lo_val);
}}); }});
0x2: div({{ 0x2: div({{
@ -154,8 +156,8 @@ decode OPCODE_HI default Unknown::unknown() {
}}); }});
0x3: divu({{ 0x3: divu({{
xc->setMiscReg(Hi,Rs.uw % Rt.uw); xc->setMiscReg(Hi,Rs.uw % Rt.uw);
xc->setMiscReg(Lo,Rs.uw / Rt.uw); xc->setMiscReg(Lo,Rs.uw / Rt.uw);
}}); }});
} }
} }

View file

@ -93,7 +93,9 @@ def LoadStoreBase(name, Name, ea_code, memacc_code, mem_flags, inst_flags,
output exec {{ output exec {{
using namespace MipsISA; using namespace MipsISA;
/// CLEAR ALL CPU INST/EXE HAZARDS /// CLEAR ALL CPU INST/EXE HAZARDS

View file

@ -163,8 +163,46 @@ namespace MipsISA
MiscReg_DepTag = 67 MiscReg_DepTag = 67
}; };
typedef uint64_t IntReg; struct OSFlags
{
//@{
/// open(2) flag values.
static const int TGT_O_RDONLY = 00000000; //!< O_RDONLY
static const int TGT_O_WRONLY = 00000001; //!< O_WRONLY
static const int TGT_O_RDWR = 00000002; //!< O_RDWR
static const int TGT_O_NONBLOCK = 00000004; //!< O_NONBLOCK
static const int TGT_O_APPEND = 00000010; //!< O_APPEND
static const int TGT_O_CREAT = 00001000; //!< O_CREAT
static const int TGT_O_TRUNC = 00002000; //!< O_TRUNC
static const int TGT_O_EXCL = 00004000; //!< O_EXCL
static const int TGT_O_NOCTTY = 00010000; //!< O_NOCTTY
static const int TGT_O_SYNC = 00040000; //!< O_SYNC
static const int TGT_O_DRD = 00100000; //!< O_DRD
static const int TGT_O_DIRECTIO = 00200000; //!< O_DIRECTIO
static const int TGT_O_CACHE = 00400000; //!< O_CACHE
static const int TGT_O_DSYNC = 02000000; //!< O_DSYNC
static const int TGT_O_RSYNC = 04000000; //!< O_RSYNC
//@}
/// For mmap().
static const unsigned TGT_MAP_ANONYMOUS = 0x800;
//@{
/// ioctl() command codes.
static const unsigned TIOCGETP = 0x40067408;
static const unsigned TIOCSETP = 0x80067409;
static const unsigned TIOCSETN = 0x8006740a;
static const unsigned TIOCSETC = 0x80067411;
static const unsigned TIOCGETC = 0x40067412;
static const unsigned FIONREAD = 0x4004667f;
static const unsigned TIOCISATTY = 0x2000745e;
static const unsigned TIOCGETS = 0x402c7413;
static const unsigned TIOCGETA = 0x40127417;
//@}
};
typedef uint64_t IntReg;
class IntRegFile class IntRegFile
{ {
protected: protected:
@ -188,21 +226,9 @@ namespace MipsISA
}; };
/* floating point register file entry type
typedef union {
uint64_t q;
double d;
} FloatReg;*/
typedef double FloatReg; typedef double FloatReg;
typedef uint64_t FloatRegBits; typedef uint64_t FloatRegBits;
class FloatRegFile
/*typedef union {
uint64_t q[NumFloatRegs]; // integer qword view
double d[NumFloatRegs]; // double-precision floating point view
} FloatRegFile;*/
class FloatRegFile
{ {
protected: protected:

View file

@ -45,6 +45,7 @@ class Linux {};
#include <unistd.h> #include <unistd.h>
#include "sim/syscall_emul.hh" #include "sim/syscall_emul.hh"
#include "arch/isa_traits.hh"
class TranslatingPort; class TranslatingPort;
@ -66,6 +67,8 @@ class Linux {
typedef uint32_t gid_t; typedef uint32_t gid_t;
//@} //@}
typedef TheISA::OSFlags OSFlags;
#if BSD_HOST #if BSD_HOST
typedef struct stat hst_stat; typedef struct stat hst_stat;
typedef struct stat hst_stat64; typedef struct stat hst_stat64;
@ -75,25 +78,6 @@ class Linux {
#endif #endif
//@{
/// open(2) flag values.
static const int TGT_O_RDONLY = 00000000; //!< O_RDONLY
static const int TGT_O_WRONLY = 00000001; //!< O_WRONLY
static const int TGT_O_RDWR = 00000002; //!< O_RDWR
static const int TGT_O_NONBLOCK = 00000004; //!< O_NONBLOCK
static const int TGT_O_APPEND = 00000010; //!< O_APPEND
static const int TGT_O_CREAT = 00001000; //!< O_CREAT
static const int TGT_O_TRUNC = 00002000; //!< O_TRUNC
static const int TGT_O_EXCL = 00004000; //!< O_EXCL
static const int TGT_O_NOCTTY = 00010000; //!< O_NOCTTY
static const int TGT_O_SYNC = 00040000; //!< O_SYNC
static const int TGT_O_DRD = 00100000; //!< O_DRD
static const int TGT_O_DIRECTIO = 00200000; //!< O_DIRECTIO
static const int TGT_O_CACHE = 00400000; //!< O_CACHE
static const int TGT_O_DSYNC = 02000000; //!< O_DSYNC
static const int TGT_O_RSYNC = 04000000; //!< O_RSYNC
//@}
/// This table maps the target open() flags to the corresponding /// This table maps the target open() flags to the corresponding
/// host open() flags. /// host open() flags.
static OpenFlagTransTable openFlagTable[]; static OpenFlagTransTable openFlagTable[];
@ -159,19 +143,6 @@ class Linux {
}; };
//@{
/// ioctl() command codes.
static const unsigned TIOCGETP = 0x40067408;
static const unsigned TIOCSETP = 0x80067409;
static const unsigned TIOCSETN = 0x8006740a;
static const unsigned TIOCSETC = 0x80067411;
static const unsigned TIOCGETC = 0x40067412;
static const unsigned FIONREAD = 0x4004667f;
static const unsigned TIOCISATTY = 0x2000745e;
static const unsigned TIOCGETS = 0x402c7413;
static const unsigned TIOCGETA = 0x40127417;
//@}
/// Resource enumeration for getrlimit(). /// Resource enumeration for getrlimit().
enum rlimit_resources { enum rlimit_resources {
TGT_RLIMIT_CPU = 0, TGT_RLIMIT_CPU = 0,
@ -194,10 +165,6 @@ class Linux {
uint64_t rlim_max; //!< hard limit uint64_t rlim_max; //!< hard limit
}; };
/// For mmap().
static const unsigned TGT_MAP_ANONYMOUS = 0x10;
/// For gettimeofday(). /// For gettimeofday().
struct timeval { struct timeval {
int64_t tv_sec; //!< seconds int64_t tv_sec; //!< seconds
@ -210,12 +177,6 @@ class Linux {
uint64_t iov_len; uint64_t iov_len;
}; };
//@{
/// For getrusage().
static const int TGT_RUSAGE_SELF = 0;
static const int TGT_RUSAGE_CHILDREN = -1;
static const int TGT_RUSAGE_BOTH = -2;
//@}
/// For getrusage(). /// For getrusage().
struct rusage { struct rusage {

View file

@ -70,6 +70,8 @@ class Tru64 {
public: public:
typedef TheISA::OSFlags OSFlags;
//@{ //@{
/// Basic Tru64 types. /// Basic Tru64 types.
typedef uint64_t size_t; typedef uint64_t size_t;
@ -85,25 +87,6 @@ class Tru64 {
typedef quad fsid_t; typedef quad fsid_t;
//@} //@}
//@{
/// open(2) flag values.
static const int TGT_O_RDONLY = 00000000;
static const int TGT_O_WRONLY = 00000001;
static const int TGT_O_RDWR = 00000002;
static const int TGT_O_NONBLOCK = 00000004;
static const int TGT_O_APPEND = 00000010;
static const int TGT_O_CREAT = 00001000;
static const int TGT_O_TRUNC = 00002000;
static const int TGT_O_EXCL = 00004000;
static const int TGT_O_NOCTTY = 00010000;
static const int TGT_O_SYNC = 00040000;
static const int TGT_O_DRD = 00100000;
static const int TGT_O_DIRECTIO = 00200000;
static const int TGT_O_CACHE = 00400000;
static const int TGT_O_DSYNC = 02000000;
static const int TGT_O_RSYNC = 04000000;
//@}
/// This table maps the target open() flags to the corresponding /// This table maps the target open() flags to the corresponding
/// host open() flags. /// host open() flags.
static OpenFlagTransTable openFlagTable[]; static OpenFlagTransTable openFlagTable[];
@ -246,20 +229,6 @@ class Tru64 {
char machine[_SYS_NMLN]; //!< Machine type. char machine[_SYS_NMLN]; //!< Machine type.
}; };
//@{
/// ioctl() command codes.
static const unsigned TIOCGETP = 0x40067408;
static const unsigned TIOCSETP = 0x80067409;
static const unsigned TIOCSETN = 0x8006740a;
static const unsigned TIOCSETC = 0x80067411;
static const unsigned TIOCGETC = 0x40067412;
static const unsigned FIONREAD = 0x4004667f;
static const unsigned TIOCISATTY = 0x2000745e;
// TIOCGETS not defined in tru64, so I made up a number
static const unsigned TIOCGETS = 0x40000000;
static const unsigned TIOCGETA = 0x402c7413;
//@}
/// Resource enumeration for getrlimit(). /// Resource enumeration for getrlimit().
enum rlimit_resources { enum rlimit_resources {
TGT_RLIMIT_CPU = 0, TGT_RLIMIT_CPU = 0,
@ -280,21 +249,6 @@ class Tru64 {
}; };
/// For mmap().
static const unsigned TGT_MAP_ANONYMOUS = 0x10;
//@{
/// For getsysinfo().
static const unsigned GSI_PLATFORM_NAME = 103; //!< platform name as string
static const unsigned GSI_CPU_INFO = 59; //!< CPU information
static const unsigned GSI_PROC_TYPE = 60; //!< get proc_type
static const unsigned GSI_MAX_CPU = 30; //!< max # cpu's on this machine
static const unsigned GSI_CPUS_IN_BOX = 55; //!< number of CPUs in system
static const unsigned GSI_PHYSMEM = 19; //!< Physical memory in KB
static const unsigned GSI_CLK_TCK = 42; //!< clock freq in Hz
//@}
/// For getsysinfo() GSI_CPU_INFO option. /// For getsysinfo() GSI_CPU_INFO option.
struct cpu_info { struct cpu_info {
uint32_t current_cpu; //!< current_cpu uint32_t current_cpu; //!< current_cpu
@ -309,24 +263,12 @@ class Tru64 {
uint32_t unused[3]; //!< future expansion uint32_t unused[3]; //!< future expansion
}; };
//@{
/// For setsysinfo().
static const unsigned SSI_IEEE_FP_CONTROL = 14; //!< ieee_set_fp_control()
//@}
/// For gettimeofday. /// For gettimeofday.
struct timeval { struct timeval {
uint32_t tv_sec; //!< seconds uint32_t tv_sec; //!< seconds
uint32_t tv_usec; //!< microseconds uint32_t tv_usec; //!< microseconds
}; };
//@{
/// For getrusage().
static const int TGT_RUSAGE_THREAD = 1;
static const int TGT_RUSAGE_SELF = 0;
static const int TGT_RUSAGE_CHILDREN = -1;
//@}
/// For getrusage(). /// For getrusage().
struct rusage { struct rusage {
struct timeval ru_utime; //!< user time used struct timeval ru_utime; //!< user time used
@ -372,8 +314,6 @@ class Tru64 {
}; };
/// For table().
static const int TBL_SYSINFO = 12;
/// For table(). /// For table().
struct tbl_sysinfo { struct tbl_sysinfo {
@ -759,7 +699,7 @@ class Tru64 {
int lel = xc->getSyscallArg(4); // expected element size int lel = xc->getSyscallArg(4); // expected element size
switch (id) { switch (id) {
case Tru64::TBL_SYSINFO: { case Tru64::OSFlags::TBL_SYSINFO: {
if (index != 0 || nel != 1 || lel != sizeof(Tru64::tbl_sysinfo)) if (index != 0 || nel != 1 || lel != sizeof(Tru64::tbl_sysinfo))
return -EINVAL; return -EINVAL;
TypedBufferArg<Tru64::tbl_sysinfo> elp(xc->getSyscallArg(2)); TypedBufferArg<Tru64::tbl_sysinfo> elp(xc->getSyscallArg(2));

View file

@ -348,14 +348,14 @@ ioctlFunc(SyscallDesc *desc, int callnum, Process *process,
} }
switch (req) { switch (req) {
case OS::TIOCISATTY: case OS::OSFlags::TIOCISATTY:
case OS::TIOCGETP: case OS::OSFlags::TIOCGETP:
case OS::TIOCSETP: case OS::OSFlags::TIOCSETP:
case OS::TIOCSETN: case OS::OSFlags::TIOCSETN:
case OS::TIOCSETC: case OS::OSFlags::TIOCSETC:
case OS::TIOCGETC: case OS::OSFlags::TIOCGETC:
case OS::TIOCGETS: case OS::OSFlags::TIOCGETS:
case OS::TIOCGETA: case OS::OSFlags::TIOCGETA:
return -ENOTTY; return -ENOTTY;
default: default:
@ -719,7 +719,7 @@ mmapFunc(SyscallDesc *desc, int num, Process *p, ExecContext *xc)
p->pTable->allocate(start, length); p->pTable->allocate(start, length);
p->mmap_end += length; p->mmap_end += length;
if (!(flags & OS::TGT_MAP_ANONYMOUS)) { if (!(flags & OS::OSFlags::TGT_MAP_ANONYMOUS)) {
warn("allowing mmap of file @ fd %d. " warn("allowing mmap of file @ fd %d. "
"This will break if not /dev/zero.", xc->getSyscallArg(4)); "This will break if not /dev/zero.", xc->getSyscallArg(4));
} }
@ -810,7 +810,7 @@ getrusageFunc(SyscallDesc *desc, int callnum, Process *process,
int who = xc->getSyscallArg(0); // THREAD, SELF, or CHILDREN int who = xc->getSyscallArg(0); // THREAD, SELF, or CHILDREN
TypedBufferArg<typename OS::rusage> rup(xc->getSyscallArg(1)); TypedBufferArg<typename OS::rusage> rup(xc->getSyscallArg(1));
if (who != OS::TGT_RUSAGE_SELF) { if (who != OS::OSFlags::TGT_RUSAGE_SELF) {
// don't really handle THREAD or CHILDREN, but just warn and // don't really handle THREAD or CHILDREN, but just warn and
// plow ahead // plow ahead
warn("getrusage() only supports RUSAGE_SELF. Parameter %d ignored.", warn("getrusage() only supports RUSAGE_SELF. Parameter %d ignored.",