process.hh revision 12141
112027Sjungma@eit.uni-kl.de/* 212027Sjungma@eit.uni-kl.de * Copyright (c) 2007 The Hewlett-Packard Development Company 312027Sjungma@eit.uni-kl.de * All rights reserved. 412027Sjungma@eit.uni-kl.de * 512027Sjungma@eit.uni-kl.de * The license below extends only to copyright in the software and shall 612027Sjungma@eit.uni-kl.de * not be construed as granting a license to any other intellectual 712027Sjungma@eit.uni-kl.de * property including but not limited to intellectual property relating 812027Sjungma@eit.uni-kl.de * to a hardware implementation of the functionality of the software 912027Sjungma@eit.uni-kl.de * licensed hereunder. You may use the software subject to the license 1012027Sjungma@eit.uni-kl.de * terms below provided that you ensure that this notice is replicated 1112027Sjungma@eit.uni-kl.de * unmodified and in its entirety in all distributions of the software, 1212027Sjungma@eit.uni-kl.de * modified or unmodified, in source code or in binary form. 1312027Sjungma@eit.uni-kl.de * 1412027Sjungma@eit.uni-kl.de * Redistribution and use in source and binary forms, with or without 1512027Sjungma@eit.uni-kl.de * modification, are permitted provided that the following conditions are 1612027Sjungma@eit.uni-kl.de * met: redistributions of source code must retain the above copyright 1712027Sjungma@eit.uni-kl.de * notice, this list of conditions and the following disclaimer; 1812027Sjungma@eit.uni-kl.de * redistributions in binary form must reproduce the above copyright 1912027Sjungma@eit.uni-kl.de * notice, this list of conditions and the following disclaimer in the 2012027Sjungma@eit.uni-kl.de * documentation and/or other materials provided with the distribution; 2112027Sjungma@eit.uni-kl.de * neither the name of the copyright holders nor the names of its 2212027Sjungma@eit.uni-kl.de * contributors may be used to endorse or promote products derived from 2312027Sjungma@eit.uni-kl.de * this software without specific prior written permission. 2412027Sjungma@eit.uni-kl.de * 2512027Sjungma@eit.uni-kl.de * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 2612027Sjungma@eit.uni-kl.de * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 2712027Sjungma@eit.uni-kl.de * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 2812027Sjungma@eit.uni-kl.de * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 2912027Sjungma@eit.uni-kl.de * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 3012027Sjungma@eit.uni-kl.de * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 3112027Sjungma@eit.uni-kl.de * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 3212027Sjungma@eit.uni-kl.de * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 3312027Sjungma@eit.uni-kl.de * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 3412027Sjungma@eit.uni-kl.de * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 3512027Sjungma@eit.uni-kl.de * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 3612027Sjungma@eit.uni-kl.de * 3712027Sjungma@eit.uni-kl.de * Authors: Gabe Black 3812027Sjungma@eit.uni-kl.de */ 3912027Sjungma@eit.uni-kl.de 4012027Sjungma@eit.uni-kl.de#ifndef __ARCH_X86_PROCESS_HH__ 4112027Sjungma@eit.uni-kl.de#define __ARCH_X86_PROCESS_HH__ 4212027Sjungma@eit.uni-kl.de 4312027Sjungma@eit.uni-kl.de#include <string> 4412027Sjungma@eit.uni-kl.de#include <vector> 4512027Sjungma@eit.uni-kl.de 4612027Sjungma@eit.uni-kl.de#include "mem/multi_level_page_table.hh" 4712027Sjungma@eit.uni-kl.de#include "sim/aux_vector.hh" 4812027Sjungma@eit.uni-kl.de#include "sim/process.hh" 4912027Sjungma@eit.uni-kl.de 5012027Sjungma@eit.uni-kl.declass SyscallDesc; 5112027Sjungma@eit.uni-kl.de 5212027Sjungma@eit.uni-kl.denamespace X86ISA 5312027Sjungma@eit.uni-kl.de{ 5412027Sjungma@eit.uni-kl.de enum X86AuxiliaryVectorTypes { 5512027Sjungma@eit.uni-kl.de M5_AT_SYSINFO = 32, 5612027Sjungma@eit.uni-kl.de M5_AT_SYSINFO_EHDR = 33 5712027Sjungma@eit.uni-kl.de }; 5812027Sjungma@eit.uni-kl.de 5912027Sjungma@eit.uni-kl.de class X86Process : public Process 6012027Sjungma@eit.uni-kl.de { 6112027Sjungma@eit.uni-kl.de protected: 6212027Sjungma@eit.uni-kl.de Addr _gdtStart; 6312027Sjungma@eit.uni-kl.de Addr _gdtSize; 6412027Sjungma@eit.uni-kl.de 6512027Sjungma@eit.uni-kl.de SyscallDesc *syscallDescs; 6612027Sjungma@eit.uni-kl.de const int numSyscallDescs; 6712027Sjungma@eit.uni-kl.de 6812027Sjungma@eit.uni-kl.de X86Process(ProcessParams * params, ObjectFile *objFile, 6912027Sjungma@eit.uni-kl.de SyscallDesc *_syscallDescs, int _numSyscallDescs); 7012027Sjungma@eit.uni-kl.de 7112027Sjungma@eit.uni-kl.de template<class IntType> 7212027Sjungma@eit.uni-kl.de void argsInit(int pageSize, 7312027Sjungma@eit.uni-kl.de std::vector<AuxVector<IntType> > extraAuxvs); 7412027Sjungma@eit.uni-kl.de 7512027Sjungma@eit.uni-kl.de public: 7612027Sjungma@eit.uni-kl.de Addr gdtStart() 7712027Sjungma@eit.uni-kl.de { return _gdtStart; } 7812027Sjungma@eit.uni-kl.de 7912027Sjungma@eit.uni-kl.de Addr gdtSize() 8012027Sjungma@eit.uni-kl.de { return _gdtSize; } 8112027Sjungma@eit.uni-kl.de 8212027Sjungma@eit.uni-kl.de SyscallDesc* getDesc(int callnum) override; 8312027Sjungma@eit.uni-kl.de 8412027Sjungma@eit.uni-kl.de void setSyscallReturn(ThreadContext *tc, 8512027Sjungma@eit.uni-kl.de SyscallReturn return_value) override; 8612027Sjungma@eit.uni-kl.de void clone(ThreadContext *old_tc, ThreadContext *new_tc, 8712027Sjungma@eit.uni-kl.de Process *process, TheISA::IntReg flags) override; 8812027Sjungma@eit.uni-kl.de 8912027Sjungma@eit.uni-kl.de X86Process & 9012027Sjungma@eit.uni-kl.de operator=(const X86Process &in) 9112027Sjungma@eit.uni-kl.de { 9212027Sjungma@eit.uni-kl.de if (this == &in) 9312027Sjungma@eit.uni-kl.de return *this; 9412027Sjungma@eit.uni-kl.de 9512027Sjungma@eit.uni-kl.de _gdtStart = in._gdtStart; 9612027Sjungma@eit.uni-kl.de _gdtSize = in._gdtSize; 9712027Sjungma@eit.uni-kl.de syscallDescs = in.syscallDescs; 9812027Sjungma@eit.uni-kl.de 9912027Sjungma@eit.uni-kl.de return *this; 10012027Sjungma@eit.uni-kl.de } 10112027Sjungma@eit.uni-kl.de }; 10212027Sjungma@eit.uni-kl.de 10312027Sjungma@eit.uni-kl.de class X86_64Process : public X86Process 10412027Sjungma@eit.uni-kl.de { 10512027Sjungma@eit.uni-kl.de protected: 10612027Sjungma@eit.uni-kl.de X86_64Process(ProcessParams *params, ObjectFile *objFile, 10712027Sjungma@eit.uni-kl.de SyscallDesc *_syscallDescs, int _numSyscallDescs); 10812027Sjungma@eit.uni-kl.de 10912027Sjungma@eit.uni-kl.de class VSyscallPage 11012027Sjungma@eit.uni-kl.de { 11112027Sjungma@eit.uni-kl.de public: 11212027Sjungma@eit.uni-kl.de Addr base; 11312027Sjungma@eit.uni-kl.de Addr size; 11412027Sjungma@eit.uni-kl.de Addr vtimeOffset; 11512027Sjungma@eit.uni-kl.de Addr vgettimeofdayOffset; 11612027Sjungma@eit.uni-kl.de 11712027Sjungma@eit.uni-kl.de VSyscallPage & 11812027Sjungma@eit.uni-kl.de operator=(const VSyscallPage &in) 11912027Sjungma@eit.uni-kl.de { 12012027Sjungma@eit.uni-kl.de if (this == &in) 12112027Sjungma@eit.uni-kl.de return *this; 12212027Sjungma@eit.uni-kl.de 12312027Sjungma@eit.uni-kl.de base = in.base; 12412027Sjungma@eit.uni-kl.de size = in.size; 12512027Sjungma@eit.uni-kl.de vtimeOffset = in.vtimeOffset; 12612027Sjungma@eit.uni-kl.de vgettimeofdayOffset = in.vgettimeofdayOffset; 12712027Sjungma@eit.uni-kl.de 12812027Sjungma@eit.uni-kl.de return *this; 12912027Sjungma@eit.uni-kl.de } 13012027Sjungma@eit.uni-kl.de }; 13112027Sjungma@eit.uni-kl.de VSyscallPage vsyscallPage; 13212027Sjungma@eit.uni-kl.de 13312027Sjungma@eit.uni-kl.de public: 13412027Sjungma@eit.uni-kl.de void argsInit(int pageSize); 13512027Sjungma@eit.uni-kl.de void initState() override; 13612027Sjungma@eit.uni-kl.de 13712027Sjungma@eit.uni-kl.de X86ISA::IntReg getSyscallArg(ThreadContext *tc, int &i) override; 13812027Sjungma@eit.uni-kl.de /// Explicitly import the otherwise hidden getSyscallArg 13912027Sjungma@eit.uni-kl.de using Process::getSyscallArg; 14012027Sjungma@eit.uni-kl.de void setSyscallArg(ThreadContext *tc, int i, 14112027Sjungma@eit.uni-kl.de X86ISA::IntReg val) override; 14212027Sjungma@eit.uni-kl.de void clone(ThreadContext *old_tc, ThreadContext *new_tc, 14312027Sjungma@eit.uni-kl.de Process *process, TheISA::IntReg flags) override; 14412027Sjungma@eit.uni-kl.de }; 14512027Sjungma@eit.uni-kl.de 14612027Sjungma@eit.uni-kl.de class I386Process : public X86Process 14712027Sjungma@eit.uni-kl.de { 14812027Sjungma@eit.uni-kl.de protected: 14912027Sjungma@eit.uni-kl.de I386Process(ProcessParams *params, ObjectFile *objFile, 15012027Sjungma@eit.uni-kl.de SyscallDesc *_syscallDescs, int _numSyscallDescs); 15112027Sjungma@eit.uni-kl.de 15212027Sjungma@eit.uni-kl.de class VSyscallPage 15312027Sjungma@eit.uni-kl.de { 15412027Sjungma@eit.uni-kl.de public: 15512027Sjungma@eit.uni-kl.de Addr base; 15612027Sjungma@eit.uni-kl.de Addr size; 15712027Sjungma@eit.uni-kl.de Addr vsyscallOffset; 15812027Sjungma@eit.uni-kl.de Addr vsysexitOffset; 15912027Sjungma@eit.uni-kl.de 16012027Sjungma@eit.uni-kl.de VSyscallPage & 16112027Sjungma@eit.uni-kl.de operator=(const VSyscallPage &in) 16212027Sjungma@eit.uni-kl.de { 16312027Sjungma@eit.uni-kl.de if (this == &in) 16412027Sjungma@eit.uni-kl.de return *this; 16512027Sjungma@eit.uni-kl.de 16612027Sjungma@eit.uni-kl.de base = in.base; 16712027Sjungma@eit.uni-kl.de size = in.size; 16812027Sjungma@eit.uni-kl.de vsyscallOffset = in.vsyscallOffset; 16912027Sjungma@eit.uni-kl.de vsysexitOffset = in.vsysexitOffset; 17012027Sjungma@eit.uni-kl.de 17112027Sjungma@eit.uni-kl.de return *this; 17212027Sjungma@eit.uni-kl.de } 17312027Sjungma@eit.uni-kl.de }; 17412027Sjungma@eit.uni-kl.de VSyscallPage vsyscallPage; 17512027Sjungma@eit.uni-kl.de 17612027Sjungma@eit.uni-kl.de public: 17712027Sjungma@eit.uni-kl.de void argsInit(int pageSize); 17812027Sjungma@eit.uni-kl.de void initState() override; 17912027Sjungma@eit.uni-kl.de 18012027Sjungma@eit.uni-kl.de void syscall(int64_t callnum, ThreadContext *tc, 18112027Sjungma@eit.uni-kl.de Fault *fault) override; 18212027Sjungma@eit.uni-kl.de X86ISA::IntReg getSyscallArg(ThreadContext *tc, 18312027Sjungma@eit.uni-kl.de int &i) override; 18412027Sjungma@eit.uni-kl.de X86ISA::IntReg getSyscallArg(ThreadContext *tc, int &i, 18512027Sjungma@eit.uni-kl.de int width) override; 18612027Sjungma@eit.uni-kl.de void setSyscallArg(ThreadContext *tc, int i, 18712027Sjungma@eit.uni-kl.de X86ISA::IntReg val) override; 18812027Sjungma@eit.uni-kl.de void clone(ThreadContext *old_tc, ThreadContext *new_tc, 18912027Sjungma@eit.uni-kl.de Process *process, TheISA::IntReg flags) override; 19012027Sjungma@eit.uni-kl.de }; 19112027Sjungma@eit.uni-kl.de 19212027Sjungma@eit.uni-kl.de /** 19312027Sjungma@eit.uni-kl.de * Declaration of architectural page table for x86. 19412027Sjungma@eit.uni-kl.de * 19512027Sjungma@eit.uni-kl.de * These page tables are stored in system memory and respect x86 19612027Sjungma@eit.uni-kl.de * specification. 19712027Sjungma@eit.uni-kl.de */ 19812027Sjungma@eit.uni-kl.de typedef MultiLevelPageTable<PageTableOps> ArchPageTable; 19912027Sjungma@eit.uni-kl.de 20012027Sjungma@eit.uni-kl.de} 20112027Sjungma@eit.uni-kl.de 20212027Sjungma@eit.uni-kl.de#endif // __ARCH_X86_PROCESS_HH__ 20312027Sjungma@eit.uni-kl.de