process.hh revision 7741
12SN/A/*
21458SN/A * Copyright (c) 2007 The Hewlett-Packard Development Company
32SN/A * All rights reserved.
42SN/A *
52SN/A * The license below extends only to copyright in the software and shall
62SN/A * not be construed as granting a license to any other intellectual
72SN/A * property including but not limited to intellectual property relating
82SN/A * to a hardware implementation of the functionality of the software
92SN/A * licensed hereunder.  You may use the software subject to the license
102SN/A * terms below provided that you ensure that this notice is replicated
112SN/A * unmodified and in its entirety in all distributions of the software,
122SN/A * modified or unmodified, in source code or in binary form.
132SN/A *
142SN/A * Redistribution and use in source and binary forms, with or without
152SN/A * modification, are permitted provided that the following conditions are
162SN/A * met: redistributions of source code must retain the above copyright
172SN/A * notice, this list of conditions and the following disclaimer;
182SN/A * redistributions in binary form must reproduce the above copyright
192SN/A * notice, this list of conditions and the following disclaimer in the
202SN/A * documentation and/or other materials provided with the distribution;
212SN/A * neither the name of the copyright holders nor the names of its
222SN/A * contributors may be used to endorse or promote products derived from
232SN/A * this software without specific prior written permission.
242SN/A *
252SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
262SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
272665Ssaidi@eecs.umich.edu * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
282665Ssaidi@eecs.umich.edu * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
292665Ssaidi@eecs.umich.edu * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
302SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
312SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
321147SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
331147SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
342SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
352037SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
362037SN/A *
372428SN/A * Authors: Gabe Black
386216Snate@binkert.org */
398542Sgblack@eecs.umich.edu
402SN/A#ifndef __ARCH_X86_PROCESS_HH__
415569Snate@binkert.org#define __ARCH_X86_PROCESS_HH__
422238SN/A
435569Snate@binkert.org#include <string>
442107SN/A#include <vector>
455569Snate@binkert.org#include "sim/process.hh"
465569Snate@binkert.org
475569Snate@binkert.orgclass SyscallDesc;
485569Snate@binkert.org
495569Snate@binkert.orgnamespace X86ISA
505569Snate@binkert.org{
515569Snate@binkert.org    enum X86AuxiliaryVectorTypes {
525569Snate@binkert.org        M5_AT_SYSINFO = 32,
535569Snate@binkert.org        M5_AT_SYSINFO_EHDR = 33
545569Snate@binkert.org    };
555569Snate@binkert.org
565569Snate@binkert.org    class X86LiveProcess : public LiveProcess
575569Snate@binkert.org    {
585569Snate@binkert.org      protected:
595569Snate@binkert.org        Addr _gdtStart;
605569Snate@binkert.org        Addr _gdtSize;
615569Snate@binkert.org
625569Snate@binkert.org        SyscallDesc *syscallDescs;
635569Snate@binkert.org        const int numSyscallDescs;
645569Snate@binkert.org
655569Snate@binkert.org        X86LiveProcess(LiveProcessParams * params, ObjectFile *objFile,
665569Snate@binkert.org                SyscallDesc *_syscallDescs, int _numSyscallDescs);
675569Snate@binkert.org
685569Snate@binkert.org        template<class IntType>
695569Snate@binkert.org        void argsInit(int pageSize,
705569Snate@binkert.org                std::vector<AuxVector<IntType> > extraAuxvs);
715569Snate@binkert.org
725569Snate@binkert.org      public:
735569Snate@binkert.org        Addr gdtStart()
745569Snate@binkert.org        { return _gdtStart; }
755569Snate@binkert.org
765569Snate@binkert.org        Addr gdtSize()
775569Snate@binkert.org        { return _gdtSize; }
785569Snate@binkert.org
795569Snate@binkert.org        SyscallDesc* getDesc(int callnum);
805569Snate@binkert.org
815569Snate@binkert.org        void setSyscallReturn(ThreadContext *tc, SyscallReturn return_value);
825569Snate@binkert.org    };
835569Snate@binkert.org
845569Snate@binkert.org    class X86_64LiveProcess : public X86LiveProcess
855569Snate@binkert.org    {
865569Snate@binkert.org      protected:
875569Snate@binkert.org        X86_64LiveProcess(LiveProcessParams *params, ObjectFile *objFile,
885569Snate@binkert.org                SyscallDesc *_syscallDescs, int _numSyscallDescs);
895569Snate@binkert.org
905569Snate@binkert.org        class VSyscallPage
915569Snate@binkert.org        {
925569Snate@binkert.org          public:
935569Snate@binkert.org            Addr base;
945569Snate@binkert.org            Addr size;
955569Snate@binkert.org            Addr vtimeOffset;
965569Snate@binkert.org            Addr vgettimeofdayOffset;
975569Snate@binkert.org        };
985569Snate@binkert.org        VSyscallPage vsyscallPage;
995569Snate@binkert.org
1005569Snate@binkert.org      public:
1015569Snate@binkert.org        void argsInit(int intSize, int pageSize);
1025569Snate@binkert.org        void initState();
1035569Snate@binkert.org
1045569Snate@binkert.org        X86ISA::IntReg getSyscallArg(ThreadContext *tc, int &i);
1055569Snate@binkert.org        void setSyscallArg(ThreadContext *tc, int i, X86ISA::IntReg val);
1065569Snate@binkert.org    };
1075569Snate@binkert.org
1085569Snate@binkert.org    class I386LiveProcess : public X86LiveProcess
1095569Snate@binkert.org    {
1105569Snate@binkert.org      protected:
1115569Snate@binkert.org        I386LiveProcess(LiveProcessParams *params, ObjectFile *objFile,
1125569Snate@binkert.org                SyscallDesc *_syscallDescs, int _numSyscallDescs);
1136227Snate@binkert.org
1146227Snate@binkert.org        class VSyscallPage
1156227Snate@binkert.org        {
1165569Snate@binkert.org          public:
1176227Snate@binkert.org            Addr base;
1185569Snate@binkert.org            Addr size;
1196227Snate@binkert.org            Addr vsyscallOffset;
1206227Snate@binkert.org            Addr vsysexitOffset;
1216227Snate@binkert.org        };
1228902Sandreas.hansson@arm.com        VSyscallPage vsyscallPage;
1236227Snate@binkert.org
1245569Snate@binkert.org      public:
1255569Snate@binkert.org        void argsInit(int intSize, int pageSize);
1265569Snate@binkert.org        void initState();
1275569Snate@binkert.org
1285569Snate@binkert.org        void syscall(int64_t callnum, ThreadContext *tc);
1296974Stjones1@inf.ed.ac.uk        X86ISA::IntReg getSyscallArg(ThreadContext *tc, int &i);
1306974Stjones1@inf.ed.ac.uk        X86ISA::IntReg getSyscallArg(ThreadContext *tc, int &i, int width);
1316974Stjones1@inf.ed.ac.uk        void setSyscallArg(ThreadContext *tc, int i, X86ISA::IntReg val);
1325569Snate@binkert.org    };
1335569Snate@binkert.org}
1341147SN/A
135#endif // __ARCH_X86_PROCESS_HH__
136