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 4612460Sgabeblack@google.com#include "arch/x86/pagetable.hh" 4712044Sgabeblack@google.com#include "mem/multi_level_page_table.hh" 4811854Sbrandon.potter@amd.com#include "sim/aux_vector.hh" 494166Sgblack@eecs.umich.edu#include "sim/process.hh" 504120Sgblack@eecs.umich.edu 515956Sgblack@eecs.umich.educlass SyscallDesc; 525956Sgblack@eecs.umich.edu 534120Sgblack@eecs.umich.edunamespace X86ISA 544120Sgblack@eecs.umich.edu{ 557073Sgblack@eecs.umich.edu enum X86AuxiliaryVectorTypes { 567073Sgblack@eecs.umich.edu M5_AT_SYSINFO = 32, 577073Sgblack@eecs.umich.edu M5_AT_SYSINFO_EHDR = 33 587073Sgblack@eecs.umich.edu }; 594166Sgblack@eecs.umich.edu 6011851Sbrandon.potter@amd.com class X86Process : public Process 614166Sgblack@eecs.umich.edu { 624166Sgblack@eecs.umich.edu protected: 635962Sgblack@eecs.umich.edu Addr _gdtStart; 645962Sgblack@eecs.umich.edu Addr _gdtSize; 655962Sgblack@eecs.umich.edu 665956Sgblack@eecs.umich.edu SyscallDesc *syscallDescs; 675956Sgblack@eecs.umich.edu const int numSyscallDescs; 684166Sgblack@eecs.umich.edu 6911851Sbrandon.potter@amd.com X86Process(ProcessParams * params, ObjectFile *objFile, 7011851Sbrandon.potter@amd.com SyscallDesc *_syscallDescs, int _numSyscallDescs); 715956Sgblack@eecs.umich.edu 725956Sgblack@eecs.umich.edu template<class IntType> 735973Sgblack@eecs.umich.edu void argsInit(int pageSize, 7411884Sbrandon.potter@amd.com std::vector<AuxVector<IntType> > extraAuxvs); 754166Sgblack@eecs.umich.edu 764166Sgblack@eecs.umich.edu public: 775962Sgblack@eecs.umich.edu Addr gdtStart() 785962Sgblack@eecs.umich.edu { return _gdtStart; } 7911320Ssteve.reinhardt@amd.com 805962Sgblack@eecs.umich.edu Addr gdtSize() 815962Sgblack@eecs.umich.edu { return _gdtSize; } 825962Sgblack@eecs.umich.edu 8312074Sspwilson2@wisc.edu SyscallDesc* getDesc(int callnum) override; 845958Sgblack@eecs.umich.edu 8512074Sspwilson2@wisc.edu void setSyscallReturn(ThreadContext *tc, 8612074Sspwilson2@wisc.edu SyscallReturn return_value) override; 8711886Sbrandon.potter@amd.com void clone(ThreadContext *old_tc, ThreadContext *new_tc, 8813613Sgabeblack@google.com Process *process, RegVal flags) override; 8911886Sbrandon.potter@amd.com 9011886Sbrandon.potter@amd.com X86Process & 9111886Sbrandon.potter@amd.com operator=(const X86Process &in) 9211886Sbrandon.potter@amd.com { 9311886Sbrandon.potter@amd.com if (this == &in) 9411886Sbrandon.potter@amd.com return *this; 9511886Sbrandon.potter@amd.com 9611886Sbrandon.potter@amd.com _gdtStart = in._gdtStart; 9711886Sbrandon.potter@amd.com _gdtSize = in._gdtSize; 9811886Sbrandon.potter@amd.com syscallDescs = in.syscallDescs; 9911886Sbrandon.potter@amd.com 10011886Sbrandon.potter@amd.com return *this; 10111886Sbrandon.potter@amd.com } 1025956Sgblack@eecs.umich.edu }; 1034166Sgblack@eecs.umich.edu 10411851Sbrandon.potter@amd.com class X86_64Process : public X86Process 1055956Sgblack@eecs.umich.edu { 1065956Sgblack@eecs.umich.edu protected: 10711851Sbrandon.potter@amd.com X86_64Process(ProcessParams *params, ObjectFile *objFile, 10811851Sbrandon.potter@amd.com SyscallDesc *_syscallDescs, int _numSyscallDescs); 1094166Sgblack@eecs.umich.edu 1106709Svince@csl.cornell.edu class VSyscallPage 1116709Svince@csl.cornell.edu { 1126709Svince@csl.cornell.edu public: 1136709Svince@csl.cornell.edu Addr base; 1146709Svince@csl.cornell.edu Addr size; 1156709Svince@csl.cornell.edu Addr vtimeOffset; 1166709Svince@csl.cornell.edu Addr vgettimeofdayOffset; 11711886Sbrandon.potter@amd.com 11811886Sbrandon.potter@amd.com VSyscallPage & 11911886Sbrandon.potter@amd.com operator=(const VSyscallPage &in) 12011886Sbrandon.potter@amd.com { 12111886Sbrandon.potter@amd.com if (this == &in) 12211886Sbrandon.potter@amd.com return *this; 12311886Sbrandon.potter@amd.com 12411886Sbrandon.potter@amd.com base = in.base; 12511886Sbrandon.potter@amd.com size = in.size; 12611886Sbrandon.potter@amd.com vtimeOffset = in.vtimeOffset; 12711886Sbrandon.potter@amd.com vgettimeofdayOffset = in.vgettimeofdayOffset; 12811886Sbrandon.potter@amd.com 12911886Sbrandon.potter@amd.com return *this; 13011886Sbrandon.potter@amd.com } 1316709Svince@csl.cornell.edu }; 1326709Svince@csl.cornell.edu VSyscallPage vsyscallPage; 1336709Svince@csl.cornell.edu 1345956Sgblack@eecs.umich.edu public: 13511884Sbrandon.potter@amd.com void argsInit(int pageSize); 13612074Sspwilson2@wisc.edu void initState() override; 1375958Sgblack@eecs.umich.edu 13813613Sgabeblack@google.com RegVal getSyscallArg(ThreadContext *tc, int &i) override; 1399552Sandreas.hansson@arm.com /// Explicitly import the otherwise hidden getSyscallArg 14011851Sbrandon.potter@amd.com using Process::getSyscallArg; 14113613Sgabeblack@google.com void setSyscallArg(ThreadContext *tc, int i, RegVal val) override; 14211886Sbrandon.potter@amd.com void clone(ThreadContext *old_tc, ThreadContext *new_tc, 14313613Sgabeblack@google.com Process *process, RegVal flags) override; 1445956Sgblack@eecs.umich.edu }; 1455956Sgblack@eecs.umich.edu 14611851Sbrandon.potter@amd.com class I386Process : public X86Process 1475956Sgblack@eecs.umich.edu { 1485956Sgblack@eecs.umich.edu protected: 14911851Sbrandon.potter@amd.com I386Process(ProcessParams *params, ObjectFile *objFile, 15011851Sbrandon.potter@amd.com SyscallDesc *_syscallDescs, int _numSyscallDescs); 1515956Sgblack@eecs.umich.edu 1525973Sgblack@eecs.umich.edu class VSyscallPage 1535973Sgblack@eecs.umich.edu { 1545973Sgblack@eecs.umich.edu public: 1555973Sgblack@eecs.umich.edu Addr base; 1565973Sgblack@eecs.umich.edu Addr size; 1575973Sgblack@eecs.umich.edu Addr vsyscallOffset; 1585973Sgblack@eecs.umich.edu Addr vsysexitOffset; 15911886Sbrandon.potter@amd.com 16011886Sbrandon.potter@amd.com VSyscallPage & 16111886Sbrandon.potter@amd.com operator=(const VSyscallPage &in) 16211886Sbrandon.potter@amd.com { 16311886Sbrandon.potter@amd.com if (this == &in) 16411886Sbrandon.potter@amd.com return *this; 16511886Sbrandon.potter@amd.com 16611886Sbrandon.potter@amd.com base = in.base; 16711886Sbrandon.potter@amd.com size = in.size; 16811886Sbrandon.potter@amd.com vsyscallOffset = in.vsyscallOffset; 16911886Sbrandon.potter@amd.com vsysexitOffset = in.vsysexitOffset; 17011886Sbrandon.potter@amd.com 17111886Sbrandon.potter@amd.com return *this; 17211886Sbrandon.potter@amd.com } 1735973Sgblack@eecs.umich.edu }; 1745973Sgblack@eecs.umich.edu VSyscallPage vsyscallPage; 1755973Sgblack@eecs.umich.edu 1765956Sgblack@eecs.umich.edu public: 17711884Sbrandon.potter@amd.com void argsInit(int pageSize); 17812074Sspwilson2@wisc.edu void initState() override; 1795958Sgblack@eecs.umich.edu 18012044Sgabeblack@google.com void syscall(int64_t callnum, ThreadContext *tc, 18112044Sgabeblack@google.com Fault *fault) override; 18213613Sgabeblack@google.com RegVal getSyscallArg(ThreadContext *tc, int &i) override; 18313613Sgabeblack@google.com RegVal getSyscallArg(ThreadContext *tc, int &i, int width) override; 18413613Sgabeblack@google.com void setSyscallArg(ThreadContext *tc, int i, RegVal val) override; 18511886Sbrandon.potter@amd.com void clone(ThreadContext *old_tc, ThreadContext *new_tc, 18613613Sgabeblack@google.com Process *process, RegVal flags) override; 1874166Sgblack@eecs.umich.edu }; 18810299Salexandru.dutu@amd.com 1894166Sgblack@eecs.umich.edu} 1904120Sgblack@eecs.umich.edu 1914120Sgblack@eecs.umich.edu#endif // __ARCH_X86_PROCESS_HH__ 192