unknown.isa revision 2649
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.
282083SN/A
292649Ssaidi@eecs.umich.edu////////////////////////////////////////////////////////////////////
302649Ssaidi@eecs.umich.edu//
312649Ssaidi@eecs.umich.edu// Unknown instructions
322649Ssaidi@eecs.umich.edu//
332649Ssaidi@eecs.umich.edu
342495SN/Aoutput header {{
352495SN/A        std::string inst2string(MachInst machInst);
362495SN/A}};
372083SN/Aoutput decoder {{
382495SN/A
392495SN/Astd::string inst2string(MachInst machInst)
402495SN/A{
412495SN/A    string str = "";
422495SN/A    uint32_t mask = 0x80000000;
432495SN/A
442495SN/A    for(int i=0; i < 32; i++) {
452495SN/A        if ((machInst & mask) == 0) {
462495SN/A            str += "0";
472495SN/A        } else {
482495SN/A            str += "1";
492495SN/A        }
502495SN/A
512495SN/A        mask = mask >> 1;
522495SN/A    }
532495SN/A
542495SN/A    return str;
552495SN/A}
562495SN/A
572083SN/A    std::string
582083SN/A    Unknown::generateDisassembly(Addr pc, const SymbolTable *symtab) const
592083SN/A    {
602495SN/A        return csprintf("%-10s (inst 0x%x, opcode 0x%x, binary:%s)",
612495SN/A                        "unknown", machInst, OPCODE, inst2string(machInst));
622083SN/A    }
632083SN/A}};
642083SN/A
652083SN/Aoutput exec {{
662083SN/A    Fault
672083SN/A    Unknown::execute(%(CPU_exec_context)s *xc,
682083SN/A                     Trace::InstRecord *traceData) const
692083SN/A    {
702083SN/A        panic("attempt to execute unknown instruction "
712495SN/A              "(inst 0x%08x, opcode 0x%x, binary: %s)", machInst, OPCODE, inst2string(machInst));
722447SN/A        return new UnimplementedOpcodeFault;
732083SN/A    }
742083SN/A}};
752083SN/A
762083SN/Adef format Unknown() {{
772083SN/A    decode_block = 'return new Unknown(machInst);\n'
782083SN/A}};
792083SN/A
80