unknown.isa revision 2665
12083SN/A// -*- mode:c++ -*-
22083SN/A
32083SN/A// Copyright (c) 2003-2005 The Regents of The University of Michigan
42083SN/A// All rights reserved.
52083SN/A//
62083SN/A// Redistribution and use in source and binary forms, with or without
72083SN/A// modification, are permitted provided that the following conditions are
82083SN/A// met: redistributions of source code must retain the above copyright
92083SN/A// notice, this list of conditions and the following disclaimer;
102083SN/A// redistributions in binary form must reproduce the above copyright
112083SN/A// notice, this list of conditions and the following disclaimer in the
122083SN/A// documentation and/or other materials provided with the distribution;
132083SN/A// neither the name of the copyright holders nor the names of its
142083SN/A// contributors may be used to endorse or promote products derived from
152083SN/A// this software without specific prior written permission.
162083SN/A//
172083SN/A// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
182083SN/A// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
192083SN/A// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
202083SN/A// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
212083SN/A// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
222083SN/A// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
232083SN/A// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
242083SN/A// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
252083SN/A// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
262083SN/A// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
272083SN/A// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
282665Ssaidi@eecs.umich.edu//
292665Ssaidi@eecs.umich.edu// Authors: Korey Sewell
302083SN/A
312649Ssaidi@eecs.umich.edu////////////////////////////////////////////////////////////////////
322649Ssaidi@eecs.umich.edu//
332649Ssaidi@eecs.umich.edu// Unknown instructions
342649Ssaidi@eecs.umich.edu//
352649Ssaidi@eecs.umich.edu
362495SN/Aoutput header {{
372495SN/A        std::string inst2string(MachInst machInst);
382495SN/A}};
392083SN/Aoutput decoder {{
402495SN/A
412495SN/Astd::string inst2string(MachInst machInst)
422495SN/A{
432495SN/A    string str = "";
442495SN/A    uint32_t mask = 0x80000000;
452495SN/A
462495SN/A    for(int i=0; i < 32; i++) {
472495SN/A        if ((machInst & mask) == 0) {
482495SN/A            str += "0";
492495SN/A        } else {
502495SN/A            str += "1";
512495SN/A        }
522495SN/A
532495SN/A        mask = mask >> 1;
542495SN/A    }
552495SN/A
562495SN/A    return str;
572495SN/A}
582495SN/A
592083SN/A    std::string
602083SN/A    Unknown::generateDisassembly(Addr pc, const SymbolTable *symtab) const
612083SN/A    {
622495SN/A        return csprintf("%-10s (inst 0x%x, opcode 0x%x, binary:%s)",
632495SN/A                        "unknown", machInst, OPCODE, inst2string(machInst));
642083SN/A    }
652083SN/A}};
662083SN/A
672083SN/Aoutput exec {{
682083SN/A    Fault
692083SN/A    Unknown::execute(%(CPU_exec_context)s *xc,
702083SN/A                     Trace::InstRecord *traceData) const
712083SN/A    {
722083SN/A        panic("attempt to execute unknown instruction "
732495SN/A              "(inst 0x%08x, opcode 0x%x, binary: %s)", machInst, OPCODE, inst2string(machInst));
742447SN/A        return new UnimplementedOpcodeFault;
752083SN/A    }
762083SN/A}};
772083SN/A
782083SN/Adef format Unknown() {{
792083SN/A    decode_block = 'return new Unknown(machInst);\n'
802083SN/A}};
812083SN/A
82