process.hh revision 12460
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:
6312431Sgabeblack@google.com        /**
6412431Sgabeblack@google.com         * Declaration of architectural page table for x86.
6512431Sgabeblack@google.com         *
6612431Sgabeblack@google.com         * These page tables are stored in system memory and respect x86
6712431Sgabeblack@google.com         * specification.
6812431Sgabeblack@google.com         */
6912431Sgabeblack@google.com
705962Sgblack@eecs.umich.edu        Addr _gdtStart;
715962Sgblack@eecs.umich.edu        Addr _gdtSize;
725962Sgblack@eecs.umich.edu
735956Sgblack@eecs.umich.edu        SyscallDesc *syscallDescs;
745956Sgblack@eecs.umich.edu        const int numSyscallDescs;
754166Sgblack@eecs.umich.edu
7611851Sbrandon.potter@amd.com        X86Process(ProcessParams * params, ObjectFile *objFile,
7711851Sbrandon.potter@amd.com                   SyscallDesc *_syscallDescs, int _numSyscallDescs);
785956Sgblack@eecs.umich.edu
795956Sgblack@eecs.umich.edu        template<class IntType>
805973Sgblack@eecs.umich.edu        void argsInit(int pageSize,
8111884Sbrandon.potter@amd.com                      std::vector<AuxVector<IntType> > extraAuxvs);
824166Sgblack@eecs.umich.edu
834166Sgblack@eecs.umich.edu      public:
845962Sgblack@eecs.umich.edu        Addr gdtStart()
855962Sgblack@eecs.umich.edu        { return _gdtStart; }
8611320Ssteve.reinhardt@amd.com
875962Sgblack@eecs.umich.edu        Addr gdtSize()
885962Sgblack@eecs.umich.edu        { return _gdtSize; }
895962Sgblack@eecs.umich.edu
9012074Sspwilson2@wisc.edu        SyscallDesc* getDesc(int callnum) override;
915958Sgblack@eecs.umich.edu
9212074Sspwilson2@wisc.edu        void setSyscallReturn(ThreadContext *tc,
9312074Sspwilson2@wisc.edu                              SyscallReturn return_value) override;
9411886Sbrandon.potter@amd.com        void clone(ThreadContext *old_tc, ThreadContext *new_tc,
9512141Sspwilson2@wisc.edu                   Process *process, TheISA::IntReg flags) override;
9611886Sbrandon.potter@amd.com
9711886Sbrandon.potter@amd.com        X86Process &
9811886Sbrandon.potter@amd.com        operator=(const X86Process &in)
9911886Sbrandon.potter@amd.com        {
10011886Sbrandon.potter@amd.com            if (this == &in)
10111886Sbrandon.potter@amd.com                return *this;
10211886Sbrandon.potter@amd.com
10311886Sbrandon.potter@amd.com            _gdtStart = in._gdtStart;
10411886Sbrandon.potter@amd.com            _gdtSize = in._gdtSize;
10511886Sbrandon.potter@amd.com            syscallDescs = in.syscallDescs;
10611886Sbrandon.potter@amd.com
10711886Sbrandon.potter@amd.com            return *this;
10811886Sbrandon.potter@amd.com        }
1095956Sgblack@eecs.umich.edu    };
1104166Sgblack@eecs.umich.edu
11111851Sbrandon.potter@amd.com    class X86_64Process : public X86Process
1125956Sgblack@eecs.umich.edu    {
1135956Sgblack@eecs.umich.edu      protected:
11411851Sbrandon.potter@amd.com        X86_64Process(ProcessParams *params, ObjectFile *objFile,
11511851Sbrandon.potter@amd.com                      SyscallDesc *_syscallDescs, int _numSyscallDescs);
1164166Sgblack@eecs.umich.edu
1176709Svince@csl.cornell.edu        class VSyscallPage
1186709Svince@csl.cornell.edu        {
1196709Svince@csl.cornell.edu          public:
1206709Svince@csl.cornell.edu            Addr base;
1216709Svince@csl.cornell.edu            Addr size;
1226709Svince@csl.cornell.edu            Addr vtimeOffset;
1236709Svince@csl.cornell.edu            Addr vgettimeofdayOffset;
12411886Sbrandon.potter@amd.com
12511886Sbrandon.potter@amd.com            VSyscallPage &
12611886Sbrandon.potter@amd.com            operator=(const VSyscallPage &in)
12711886Sbrandon.potter@amd.com            {
12811886Sbrandon.potter@amd.com                if (this == &in)
12911886Sbrandon.potter@amd.com                    return *this;
13011886Sbrandon.potter@amd.com
13111886Sbrandon.potter@amd.com                base = in.base;
13211886Sbrandon.potter@amd.com                size = in.size;
13311886Sbrandon.potter@amd.com                vtimeOffset = in.vtimeOffset;
13411886Sbrandon.potter@amd.com                vgettimeofdayOffset = in.vgettimeofdayOffset;
13511886Sbrandon.potter@amd.com
13611886Sbrandon.potter@amd.com                return *this;
13711886Sbrandon.potter@amd.com            }
1386709Svince@csl.cornell.edu        };
1396709Svince@csl.cornell.edu        VSyscallPage vsyscallPage;
1406709Svince@csl.cornell.edu
1415956Sgblack@eecs.umich.edu      public:
14211884Sbrandon.potter@amd.com        void argsInit(int pageSize);
14312074Sspwilson2@wisc.edu        void initState() override;
1445958Sgblack@eecs.umich.edu
14512074Sspwilson2@wisc.edu        X86ISA::IntReg getSyscallArg(ThreadContext *tc, int &i) override;
1469552Sandreas.hansson@arm.com        /// Explicitly import the otherwise hidden getSyscallArg
14711851Sbrandon.potter@amd.com        using Process::getSyscallArg;
14812074Sspwilson2@wisc.edu        void setSyscallArg(ThreadContext *tc, int i,
14912074Sspwilson2@wisc.edu                           X86ISA::IntReg val) override;
15011886Sbrandon.potter@amd.com        void clone(ThreadContext *old_tc, ThreadContext *new_tc,
15112141Sspwilson2@wisc.edu                   Process *process, TheISA::IntReg flags) override;
1525956Sgblack@eecs.umich.edu    };
1535956Sgblack@eecs.umich.edu
15411851Sbrandon.potter@amd.com    class I386Process : public X86Process
1555956Sgblack@eecs.umich.edu    {
1565956Sgblack@eecs.umich.edu      protected:
15711851Sbrandon.potter@amd.com        I386Process(ProcessParams *params, ObjectFile *objFile,
15811851Sbrandon.potter@amd.com                    SyscallDesc *_syscallDescs, int _numSyscallDescs);
1595956Sgblack@eecs.umich.edu
1605973Sgblack@eecs.umich.edu        class VSyscallPage
1615973Sgblack@eecs.umich.edu        {
1625973Sgblack@eecs.umich.edu          public:
1635973Sgblack@eecs.umich.edu            Addr base;
1645973Sgblack@eecs.umich.edu            Addr size;
1655973Sgblack@eecs.umich.edu            Addr vsyscallOffset;
1665973Sgblack@eecs.umich.edu            Addr vsysexitOffset;
16711886Sbrandon.potter@amd.com
16811886Sbrandon.potter@amd.com            VSyscallPage &
16911886Sbrandon.potter@amd.com            operator=(const VSyscallPage &in)
17011886Sbrandon.potter@amd.com            {
17111886Sbrandon.potter@amd.com                if (this == &in)
17211886Sbrandon.potter@amd.com                    return *this;
17311886Sbrandon.potter@amd.com
17411886Sbrandon.potter@amd.com                base = in.base;
17511886Sbrandon.potter@amd.com                size = in.size;
17611886Sbrandon.potter@amd.com                vsyscallOffset = in.vsyscallOffset;
17711886Sbrandon.potter@amd.com                vsysexitOffset = in.vsysexitOffset;
17811886Sbrandon.potter@amd.com
17911886Sbrandon.potter@amd.com                return *this;
18011886Sbrandon.potter@amd.com            }
1815973Sgblack@eecs.umich.edu        };
1825973Sgblack@eecs.umich.edu        VSyscallPage vsyscallPage;
1835973Sgblack@eecs.umich.edu
1845956Sgblack@eecs.umich.edu      public:
18511884Sbrandon.potter@amd.com        void argsInit(int pageSize);
18612074Sspwilson2@wisc.edu        void initState() override;
1875958Sgblack@eecs.umich.edu
18812044Sgabeblack@google.com        void syscall(int64_t callnum, ThreadContext *tc,
18912044Sgabeblack@google.com                     Fault *fault) override;
19012074Sspwilson2@wisc.edu        X86ISA::IntReg getSyscallArg(ThreadContext *tc,
19112074Sspwilson2@wisc.edu                                     int &i) override;
19212074Sspwilson2@wisc.edu        X86ISA::IntReg getSyscallArg(ThreadContext *tc, int &i,
19312074Sspwilson2@wisc.edu                                     int width) override;
19412074Sspwilson2@wisc.edu        void setSyscallArg(ThreadContext *tc, int i,
19512074Sspwilson2@wisc.edu                           X86ISA::IntReg val) override;
19611886Sbrandon.potter@amd.com        void clone(ThreadContext *old_tc, ThreadContext *new_tc,
19712141Sspwilson2@wisc.edu                   Process *process, TheISA::IntReg flags) override;
1984166Sgblack@eecs.umich.edu    };
19910299Salexandru.dutu@amd.com
2004166Sgblack@eecs.umich.edu}
2014120Sgblack@eecs.umich.edu
2024120Sgblack@eecs.umich.edu#endif // __ARCH_X86_PROCESS_HH__
203