process.hh revision 11886
14120Sgblack@eecs.umich.edu/* 24120Sgblack@eecs.umich.edu * Copyright (c) 2007 The Hewlett-Packard Development Company 34120Sgblack@eecs.umich.edu * All rights reserved. 44120Sgblack@eecs.umich.edu * 57087Snate@binkert.org * The license below extends only to copyright in the software and shall 67087Snate@binkert.org * not be construed as granting a license to any other intellectual 77087Snate@binkert.org * property including but not limited to intellectual property relating 87087Snate@binkert.org * to a hardware implementation of the functionality of the software 97087Snate@binkert.org * licensed hereunder. You may use the software subject to the license 107087Snate@binkert.org * terms below provided that you ensure that this notice is replicated 117087Snate@binkert.org * unmodified and in its entirety in all distributions of the software, 127087Snate@binkert.org * modified or unmodified, in source code or in binary form. 134120Sgblack@eecs.umich.edu * 147087Snate@binkert.org * Redistribution and use in source and binary forms, with or without 157087Snate@binkert.org * modification, are permitted provided that the following conditions are 167087Snate@binkert.org * met: redistributions of source code must retain the above copyright 177087Snate@binkert.org * notice, this list of conditions and the following disclaimer; 187087Snate@binkert.org * redistributions in binary form must reproduce the above copyright 197087Snate@binkert.org * notice, this list of conditions and the following disclaimer in the 207087Snate@binkert.org * documentation and/or other materials provided with the distribution; 217087Snate@binkert.org * neither the name of the copyright holders nor the names of its 224120Sgblack@eecs.umich.edu * contributors may be used to endorse or promote products derived from 237087Snate@binkert.org * this software without specific prior written permission. 244120Sgblack@eecs.umich.edu * 254120Sgblack@eecs.umich.edu * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 264120Sgblack@eecs.umich.edu * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 274120Sgblack@eecs.umich.edu * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 284120Sgblack@eecs.umich.edu * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 294120Sgblack@eecs.umich.edu * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 304120Sgblack@eecs.umich.edu * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 314120Sgblack@eecs.umich.edu * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 324120Sgblack@eecs.umich.edu * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 334120Sgblack@eecs.umich.edu * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 344120Sgblack@eecs.umich.edu * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 354120Sgblack@eecs.umich.edu * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 364120Sgblack@eecs.umich.edu * 374120Sgblack@eecs.umich.edu * Authors: Gabe Black 384120Sgblack@eecs.umich.edu */ 394120Sgblack@eecs.umich.edu 404120Sgblack@eecs.umich.edu#ifndef __ARCH_X86_PROCESS_HH__ 414120Sgblack@eecs.umich.edu#define __ARCH_X86_PROCESS_HH__ 424120Sgblack@eecs.umich.edu 434166Sgblack@eecs.umich.edu#include <string> 444166Sgblack@eecs.umich.edu#include <vector> 458229Snate@binkert.org 4611854Sbrandon.potter@amd.com#include "sim/aux_vector.hh" 474166Sgblack@eecs.umich.edu#include "sim/process.hh" 4810299Salexandru.dutu@amd.com#include "mem/multi_level_page_table.hh" 494120Sgblack@eecs.umich.edu 505956Sgblack@eecs.umich.educlass SyscallDesc; 515956Sgblack@eecs.umich.edu 524120Sgblack@eecs.umich.edunamespace X86ISA 534120Sgblack@eecs.umich.edu{ 547073Sgblack@eecs.umich.edu enum X86AuxiliaryVectorTypes { 557073Sgblack@eecs.umich.edu M5_AT_SYSINFO = 32, 567073Sgblack@eecs.umich.edu M5_AT_SYSINFO_EHDR = 33 577073Sgblack@eecs.umich.edu }; 584166Sgblack@eecs.umich.edu 5911851Sbrandon.potter@amd.com class X86Process : public Process 604166Sgblack@eecs.umich.edu { 614166Sgblack@eecs.umich.edu protected: 625962Sgblack@eecs.umich.edu Addr _gdtStart; 635962Sgblack@eecs.umich.edu Addr _gdtSize; 645962Sgblack@eecs.umich.edu 655956Sgblack@eecs.umich.edu SyscallDesc *syscallDescs; 665956Sgblack@eecs.umich.edu const int numSyscallDescs; 674166Sgblack@eecs.umich.edu 6811851Sbrandon.potter@amd.com X86Process(ProcessParams * params, ObjectFile *objFile, 6911851Sbrandon.potter@amd.com SyscallDesc *_syscallDescs, int _numSyscallDescs); 705956Sgblack@eecs.umich.edu 715956Sgblack@eecs.umich.edu template<class IntType> 725973Sgblack@eecs.umich.edu void argsInit(int pageSize, 7311884Sbrandon.potter@amd.com std::vector<AuxVector<IntType> > extraAuxvs); 744166Sgblack@eecs.umich.edu 754166Sgblack@eecs.umich.edu public: 765962Sgblack@eecs.umich.edu Addr gdtStart() 775962Sgblack@eecs.umich.edu { return _gdtStart; } 7811320Ssteve.reinhardt@amd.com 795962Sgblack@eecs.umich.edu Addr gdtSize() 805962Sgblack@eecs.umich.edu { return _gdtSize; } 815962Sgblack@eecs.umich.edu 825956Sgblack@eecs.umich.edu SyscallDesc* getDesc(int callnum); 835958Sgblack@eecs.umich.edu 845958Sgblack@eecs.umich.edu void setSyscallReturn(ThreadContext *tc, SyscallReturn return_value); 8511886Sbrandon.potter@amd.com void clone(ThreadContext *old_tc, ThreadContext *new_tc, 8611886Sbrandon.potter@amd.com Process *process, TheISA::IntReg flags); 8711886Sbrandon.potter@amd.com 8811886Sbrandon.potter@amd.com X86Process & 8911886Sbrandon.potter@amd.com operator=(const X86Process &in) 9011886Sbrandon.potter@amd.com { 9111886Sbrandon.potter@amd.com if (this == &in) 9211886Sbrandon.potter@amd.com return *this; 9311886Sbrandon.potter@amd.com 9411886Sbrandon.potter@amd.com _gdtStart = in._gdtStart; 9511886Sbrandon.potter@amd.com _gdtSize = in._gdtSize; 9611886Sbrandon.potter@amd.com syscallDescs = in.syscallDescs; 9711886Sbrandon.potter@amd.com 9811886Sbrandon.potter@amd.com return *this; 9911886Sbrandon.potter@amd.com } 1005956Sgblack@eecs.umich.edu }; 1014166Sgblack@eecs.umich.edu 10211851Sbrandon.potter@amd.com class X86_64Process : public X86Process 1035956Sgblack@eecs.umich.edu { 1045956Sgblack@eecs.umich.edu protected: 10511851Sbrandon.potter@amd.com X86_64Process(ProcessParams *params, ObjectFile *objFile, 10611851Sbrandon.potter@amd.com SyscallDesc *_syscallDescs, int _numSyscallDescs); 1074166Sgblack@eecs.umich.edu 1086709Svince@csl.cornell.edu class VSyscallPage 1096709Svince@csl.cornell.edu { 1106709Svince@csl.cornell.edu public: 1116709Svince@csl.cornell.edu Addr base; 1126709Svince@csl.cornell.edu Addr size; 1136709Svince@csl.cornell.edu Addr vtimeOffset; 1146709Svince@csl.cornell.edu Addr vgettimeofdayOffset; 11511886Sbrandon.potter@amd.com 11611886Sbrandon.potter@amd.com VSyscallPage & 11711886Sbrandon.potter@amd.com operator=(const VSyscallPage &in) 11811886Sbrandon.potter@amd.com { 11911886Sbrandon.potter@amd.com if (this == &in) 12011886Sbrandon.potter@amd.com return *this; 12111886Sbrandon.potter@amd.com 12211886Sbrandon.potter@amd.com base = in.base; 12311886Sbrandon.potter@amd.com size = in.size; 12411886Sbrandon.potter@amd.com vtimeOffset = in.vtimeOffset; 12511886Sbrandon.potter@amd.com vgettimeofdayOffset = in.vgettimeofdayOffset; 12611886Sbrandon.potter@amd.com 12711886Sbrandon.potter@amd.com return *this; 12811886Sbrandon.potter@amd.com } 1296709Svince@csl.cornell.edu }; 1306709Svince@csl.cornell.edu VSyscallPage vsyscallPage; 1316709Svince@csl.cornell.edu 1325956Sgblack@eecs.umich.edu public: 13311884Sbrandon.potter@amd.com void argsInit(int pageSize); 1347532Ssteve.reinhardt@amd.com void initState(); 1355958Sgblack@eecs.umich.edu 1366701Sgblack@eecs.umich.edu X86ISA::IntReg getSyscallArg(ThreadContext *tc, int &i); 1379552Sandreas.hansson@arm.com /// Explicitly import the otherwise hidden getSyscallArg 13811851Sbrandon.potter@amd.com using Process::getSyscallArg; 1395958Sgblack@eecs.umich.edu void setSyscallArg(ThreadContext *tc, int i, X86ISA::IntReg val); 14011886Sbrandon.potter@amd.com void clone(ThreadContext *old_tc, ThreadContext *new_tc, 14111886Sbrandon.potter@amd.com Process *process, TheISA::IntReg flags); 1425956Sgblack@eecs.umich.edu }; 1435956Sgblack@eecs.umich.edu 14411851Sbrandon.potter@amd.com class I386Process : public X86Process 1455956Sgblack@eecs.umich.edu { 1465956Sgblack@eecs.umich.edu protected: 14711851Sbrandon.potter@amd.com I386Process(ProcessParams *params, ObjectFile *objFile, 14811851Sbrandon.potter@amd.com SyscallDesc *_syscallDescs, int _numSyscallDescs); 1495956Sgblack@eecs.umich.edu 1505973Sgblack@eecs.umich.edu class VSyscallPage 1515973Sgblack@eecs.umich.edu { 1525973Sgblack@eecs.umich.edu public: 1535973Sgblack@eecs.umich.edu Addr base; 1545973Sgblack@eecs.umich.edu Addr size; 1555973Sgblack@eecs.umich.edu Addr vsyscallOffset; 1565973Sgblack@eecs.umich.edu Addr vsysexitOffset; 15711886Sbrandon.potter@amd.com 15811886Sbrandon.potter@amd.com VSyscallPage & 15911886Sbrandon.potter@amd.com operator=(const VSyscallPage &in) 16011886Sbrandon.potter@amd.com { 16111886Sbrandon.potter@amd.com if (this == &in) 16211886Sbrandon.potter@amd.com return *this; 16311886Sbrandon.potter@amd.com 16411886Sbrandon.potter@amd.com base = in.base; 16511886Sbrandon.potter@amd.com size = in.size; 16611886Sbrandon.potter@amd.com vsyscallOffset = in.vsyscallOffset; 16711886Sbrandon.potter@amd.com vsysexitOffset = in.vsysexitOffset; 16811886Sbrandon.potter@amd.com 16911886Sbrandon.potter@amd.com return *this; 17011886Sbrandon.potter@amd.com } 1715973Sgblack@eecs.umich.edu }; 1725973Sgblack@eecs.umich.edu VSyscallPage vsyscallPage; 1735973Sgblack@eecs.umich.edu 1745956Sgblack@eecs.umich.edu public: 17511884Sbrandon.potter@amd.com void argsInit(int pageSize); 1767532Ssteve.reinhardt@amd.com void initState(); 1775958Sgblack@eecs.umich.edu 17811877Sbrandon.potter@amd.com void syscall(int64_t callnum, ThreadContext *tc, Fault *fault); 1796701Sgblack@eecs.umich.edu X86ISA::IntReg getSyscallArg(ThreadContext *tc, int &i); 1806701Sgblack@eecs.umich.edu X86ISA::IntReg getSyscallArg(ThreadContext *tc, int &i, int width); 1815958Sgblack@eecs.umich.edu void setSyscallArg(ThreadContext *tc, int i, X86ISA::IntReg val); 18211886Sbrandon.potter@amd.com void clone(ThreadContext *old_tc, ThreadContext *new_tc, 18311886Sbrandon.potter@amd.com Process *process, TheISA::IntReg flags); 1844166Sgblack@eecs.umich.edu }; 18510299Salexandru.dutu@amd.com 18610299Salexandru.dutu@amd.com /** 18710299Salexandru.dutu@amd.com * Declaration of architectural page table for x86. 18810299Salexandru.dutu@amd.com * 18910299Salexandru.dutu@amd.com * These page tables are stored in system memory and respect x86 specification. 19010299Salexandru.dutu@amd.com */ 19110299Salexandru.dutu@amd.com typedef MultiLevelPageTable<PageTableOps> ArchPageTable; 19210299Salexandru.dutu@amd.com 1934166Sgblack@eecs.umich.edu} 1944120Sgblack@eecs.umich.edu 1954120Sgblack@eecs.umich.edu#endif // __ARCH_X86_PROCESS_HH__ 196