process.hh revision 10299
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
464166Sgblack@eecs.umich.edu#include "sim/process.hh"
4710299Salexandru.dutu@amd.com#include "mem/multi_level_page_table.hh"
484120Sgblack@eecs.umich.edu
495956Sgblack@eecs.umich.educlass SyscallDesc;
505956Sgblack@eecs.umich.edu
514120Sgblack@eecs.umich.edunamespace X86ISA
524120Sgblack@eecs.umich.edu{
537073Sgblack@eecs.umich.edu    enum X86AuxiliaryVectorTypes {
547073Sgblack@eecs.umich.edu        M5_AT_SYSINFO = 32,
557073Sgblack@eecs.umich.edu        M5_AT_SYSINFO_EHDR = 33
567073Sgblack@eecs.umich.edu    };
574166Sgblack@eecs.umich.edu
584166Sgblack@eecs.umich.edu    class X86LiveProcess : public LiveProcess
594166Sgblack@eecs.umich.edu    {
604166Sgblack@eecs.umich.edu      protected:
615962Sgblack@eecs.umich.edu        Addr _gdtStart;
625962Sgblack@eecs.umich.edu        Addr _gdtSize;
635962Sgblack@eecs.umich.edu
645956Sgblack@eecs.umich.edu        SyscallDesc *syscallDescs;
655956Sgblack@eecs.umich.edu        const int numSyscallDescs;
664166Sgblack@eecs.umich.edu
675956Sgblack@eecs.umich.edu        X86LiveProcess(LiveProcessParams * params, ObjectFile *objFile,
685956Sgblack@eecs.umich.edu                SyscallDesc *_syscallDescs, int _numSyscallDescs);
695956Sgblack@eecs.umich.edu
705956Sgblack@eecs.umich.edu        template<class IntType>
715973Sgblack@eecs.umich.edu        void argsInit(int pageSize,
725973Sgblack@eecs.umich.edu                std::vector<AuxVector<IntType> > extraAuxvs);
734166Sgblack@eecs.umich.edu
744166Sgblack@eecs.umich.edu      public:
755962Sgblack@eecs.umich.edu        Addr gdtStart()
765962Sgblack@eecs.umich.edu        { return _gdtStart; }
775962Sgblack@eecs.umich.edu
785962Sgblack@eecs.umich.edu        Addr gdtSize()
795962Sgblack@eecs.umich.edu        { return _gdtSize; }
805962Sgblack@eecs.umich.edu
815956Sgblack@eecs.umich.edu        SyscallDesc* getDesc(int callnum);
825958Sgblack@eecs.umich.edu
835958Sgblack@eecs.umich.edu        void setSyscallReturn(ThreadContext *tc, SyscallReturn return_value);
845956Sgblack@eecs.umich.edu    };
854166Sgblack@eecs.umich.edu
865956Sgblack@eecs.umich.edu    class X86_64LiveProcess : public X86LiveProcess
875956Sgblack@eecs.umich.edu    {
885956Sgblack@eecs.umich.edu      protected:
895956Sgblack@eecs.umich.edu        X86_64LiveProcess(LiveProcessParams *params, ObjectFile *objFile,
905956Sgblack@eecs.umich.edu                SyscallDesc *_syscallDescs, int _numSyscallDescs);
914166Sgblack@eecs.umich.edu
926709Svince@csl.cornell.edu        class VSyscallPage
936709Svince@csl.cornell.edu        {
946709Svince@csl.cornell.edu          public:
956709Svince@csl.cornell.edu            Addr base;
966709Svince@csl.cornell.edu            Addr size;
976709Svince@csl.cornell.edu            Addr vtimeOffset;
986709Svince@csl.cornell.edu            Addr vgettimeofdayOffset;
996709Svince@csl.cornell.edu        };
1006709Svince@csl.cornell.edu        VSyscallPage vsyscallPage;
1016709Svince@csl.cornell.edu
1025956Sgblack@eecs.umich.edu      public:
1034166Sgblack@eecs.umich.edu        void argsInit(int intSize, int pageSize);
1047532Ssteve.reinhardt@amd.com        void initState();
1055958Sgblack@eecs.umich.edu
1066701Sgblack@eecs.umich.edu        X86ISA::IntReg getSyscallArg(ThreadContext *tc, int &i);
1079552Sandreas.hansson@arm.com        /// Explicitly import the otherwise hidden getSyscallArg
1089552Sandreas.hansson@arm.com        using LiveProcess::getSyscallArg;
1095958Sgblack@eecs.umich.edu        void setSyscallArg(ThreadContext *tc, int i, X86ISA::IntReg val);
1105956Sgblack@eecs.umich.edu    };
1115956Sgblack@eecs.umich.edu
1125956Sgblack@eecs.umich.edu    class I386LiveProcess : public X86LiveProcess
1135956Sgblack@eecs.umich.edu    {
1145956Sgblack@eecs.umich.edu      protected:
1155956Sgblack@eecs.umich.edu        I386LiveProcess(LiveProcessParams *params, ObjectFile *objFile,
1165956Sgblack@eecs.umich.edu                SyscallDesc *_syscallDescs, int _numSyscallDescs);
1175956Sgblack@eecs.umich.edu
1185973Sgblack@eecs.umich.edu        class VSyscallPage
1195973Sgblack@eecs.umich.edu        {
1205973Sgblack@eecs.umich.edu          public:
1215973Sgblack@eecs.umich.edu            Addr base;
1225973Sgblack@eecs.umich.edu            Addr size;
1235973Sgblack@eecs.umich.edu            Addr vsyscallOffset;
1245973Sgblack@eecs.umich.edu            Addr vsysexitOffset;
1255973Sgblack@eecs.umich.edu        };
1265973Sgblack@eecs.umich.edu        VSyscallPage vsyscallPage;
1275973Sgblack@eecs.umich.edu
1285956Sgblack@eecs.umich.edu      public:
1295956Sgblack@eecs.umich.edu        void argsInit(int intSize, int pageSize);
1307532Ssteve.reinhardt@amd.com        void initState();
1315958Sgblack@eecs.umich.edu
1325973Sgblack@eecs.umich.edu        void syscall(int64_t callnum, ThreadContext *tc);
1336701Sgblack@eecs.umich.edu        X86ISA::IntReg getSyscallArg(ThreadContext *tc, int &i);
1346701Sgblack@eecs.umich.edu        X86ISA::IntReg getSyscallArg(ThreadContext *tc, int &i, int width);
1355958Sgblack@eecs.umich.edu        void setSyscallArg(ThreadContext *tc, int i, X86ISA::IntReg val);
1364166Sgblack@eecs.umich.edu    };
13710299Salexandru.dutu@amd.com
13810299Salexandru.dutu@amd.com    /**
13910299Salexandru.dutu@amd.com     * Declaration of architectural page table for x86.
14010299Salexandru.dutu@amd.com     *
14110299Salexandru.dutu@amd.com     * These page tables are stored in system memory and respect x86 specification.
14210299Salexandru.dutu@amd.com     */
14310299Salexandru.dutu@amd.com    typedef MultiLevelPageTable<PageTableOps> ArchPageTable;
14410299Salexandru.dutu@amd.com
1454166Sgblack@eecs.umich.edu}
1464120Sgblack@eecs.umich.edu
1474120Sgblack@eecs.umich.edu#endif // __ARCH_X86_PROCESS_HH__
148