14712Sgblack@eecs.umich.edu// -*- mode:c++ -*-
24712Sgblack@eecs.umich.edu
34712Sgblack@eecs.umich.edu// Copyright (c) 2007 The Hewlett-Packard Development Company
44712Sgblack@eecs.umich.edu// All rights reserved.
54712Sgblack@eecs.umich.edu//
67087Snate@binkert.org// The license below extends only to copyright in the software and shall
77087Snate@binkert.org// not be construed as granting a license to any other intellectual
87087Snate@binkert.org// property including but not limited to intellectual property relating
97087Snate@binkert.org// to a hardware implementation of the functionality of the software
107087Snate@binkert.org// licensed hereunder.  You may use the software subject to the license
117087Snate@binkert.org// terms below provided that you ensure that this notice is replicated
127087Snate@binkert.org// unmodified and in its entirety in all distributions of the software,
137087Snate@binkert.org// modified or unmodified, in source code or in binary form.
144712Sgblack@eecs.umich.edu//
157087Snate@binkert.org// Redistribution and use in source and binary forms, with or without
167087Snate@binkert.org// modification, are permitted provided that the following conditions are
177087Snate@binkert.org// met: redistributions of source code must retain the above copyright
187087Snate@binkert.org// notice, this list of conditions and the following disclaimer;
197087Snate@binkert.org// redistributions in binary form must reproduce the above copyright
207087Snate@binkert.org// notice, this list of conditions and the following disclaimer in the
217087Snate@binkert.org// documentation and/or other materials provided with the distribution;
227087Snate@binkert.org// neither the name of the copyright holders nor the names of its
234712Sgblack@eecs.umich.edu// contributors may be used to endorse or promote products derived from
247087Snate@binkert.org// this software without specific prior written permission.
254712Sgblack@eecs.umich.edu//
264712Sgblack@eecs.umich.edu// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
274712Sgblack@eecs.umich.edu// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
284712Sgblack@eecs.umich.edu// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
294712Sgblack@eecs.umich.edu// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
304712Sgblack@eecs.umich.edu// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
314712Sgblack@eecs.umich.edu// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
324712Sgblack@eecs.umich.edu// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
334712Sgblack@eecs.umich.edu// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
344712Sgblack@eecs.umich.edu// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
354712Sgblack@eecs.umich.edu// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
364712Sgblack@eecs.umich.edu// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
374712Sgblack@eecs.umich.edu//
384712Sgblack@eecs.umich.edu// Authors: Gabe Black
394712Sgblack@eecs.umich.edu
404712Sgblack@eecs.umich.edu////////////////////////////////////////////////////////////////////
414712Sgblack@eecs.umich.edu//
424712Sgblack@eecs.umich.edu// "Format" which describes an instruction whose only purpose is to
434712Sgblack@eecs.umich.edu// call a syscall in SE mode.
444712Sgblack@eecs.umich.edu//
454712Sgblack@eecs.umich.edu
464712Sgblack@eecs.umich.eduoutput header {{
474712Sgblack@eecs.umich.edu    class SyscallInst : public X86ISA::X86StaticInst
484712Sgblack@eecs.umich.edu    {
494712Sgblack@eecs.umich.edu      public:
504806Sgblack@eecs.umich.edu        static const RegIndex foldOBit = 0;
514712Sgblack@eecs.umich.edu        /// Constructor
524712Sgblack@eecs.umich.edu        SyscallInst(const char *_mnemonic, ExtMachInst _machInst,
534712Sgblack@eecs.umich.edu                OpClass __opClass) :
544712Sgblack@eecs.umich.edu            X86ISA::X86StaticInst(_mnemonic, _machInst, __opClass)
554712Sgblack@eecs.umich.edu        {
564712Sgblack@eecs.umich.edu        }
574712Sgblack@eecs.umich.edu
584712Sgblack@eecs.umich.edu        std::string generateDisassembly(Addr pc,
594712Sgblack@eecs.umich.edu                const SymbolTable *symtab) const;
604712Sgblack@eecs.umich.edu    };
614712Sgblack@eecs.umich.edu}};
624712Sgblack@eecs.umich.edu
634712Sgblack@eecs.umich.eduoutput decoder {{
644712Sgblack@eecs.umich.edu    std::string SyscallInst::generateDisassembly(Addr PC,
654712Sgblack@eecs.umich.edu            const SymbolTable *symtab) const
664712Sgblack@eecs.umich.edu    {
674712Sgblack@eecs.umich.edu        std::stringstream response;
684712Sgblack@eecs.umich.edu
694712Sgblack@eecs.umich.edu        printMnemonic(response, mnemonic);
704712Sgblack@eecs.umich.edu        ccprintf(response, " ");
714712Sgblack@eecs.umich.edu        printReg(response, _srcRegIdx[0], machInst.opSize);
724712Sgblack@eecs.umich.edu        return response.str();
734712Sgblack@eecs.umich.edu    }
744712Sgblack@eecs.umich.edu}};
754712Sgblack@eecs.umich.edu
764712Sgblack@eecs.umich.edudef template SyscallExecute {{
7712234Sgabeblack@google.com    Fault %(class_name)s::execute(ExecContext *xc,
784712Sgblack@eecs.umich.edu            Trace::InstRecord *traceData) const
794712Sgblack@eecs.umich.edu    {
804712Sgblack@eecs.umich.edu        Fault fault = NoFault;
814712Sgblack@eecs.umich.edu        %(op_decl)s;
824712Sgblack@eecs.umich.edu        %(op_rd)s;
834712Sgblack@eecs.umich.edu        %(code)s;
844712Sgblack@eecs.umich.edu        return fault;
854712Sgblack@eecs.umich.edu    }
864712Sgblack@eecs.umich.edu}};
874712Sgblack@eecs.umich.edu
884712Sgblack@eecs.umich.edudef format SyscallInst(code, *opt_flags) {{
894712Sgblack@eecs.umich.edu    iop = InstObjParams(name, Name, 'SyscallInst', code, opt_flags)
904712Sgblack@eecs.umich.edu    header_output = BasicDeclare.subst(iop)
914712Sgblack@eecs.umich.edu    decoder_output = BasicConstructor.subst(iop)
924712Sgblack@eecs.umich.edu    decode_block = BasicDecode.subst(iop)
934712Sgblack@eecs.umich.edu    exec_output = SyscallExecute.subst(iop)
944712Sgblack@eecs.umich.edu}};
954712Sgblack@eecs.umich.edu
96