utility.hh revision 6335
12501SN/A/*
22501SN/A * Copyright (c) 2003-2005 The Regents of The University of Michigan
32501SN/A * All rights reserved.
42501SN/A *
52501SN/A * Redistribution and use in source and binary forms, with or without
62501SN/A * modification, are permitted provided that the following conditions are
72501SN/A * met: redistributions of source code must retain the above copyright
82501SN/A * notice, this list of conditions and the following disclaimer;
92501SN/A * redistributions in binary form must reproduce the above copyright
102501SN/A * notice, this list of conditions and the following disclaimer in the
112501SN/A * documentation and/or other materials provided with the distribution;
122501SN/A * neither the name of the copyright holders nor the names of its
132501SN/A * contributors may be used to endorse or promote products derived from
142501SN/A * this software without specific prior written permission.
152501SN/A *
162501SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
172501SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
182501SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
192501SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
202501SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
212501SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
222501SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
232501SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
242501SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
252501SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
262501SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
272665Ssaidi@eecs.umich.edu *
282665Ssaidi@eecs.umich.edu * Authors: Gabe Black
292501SN/A */
302501SN/A
312501SN/A#ifndef __ARCH_SPARC_UTILITY_HH__
322501SN/A#define __ARCH_SPARC_UTILITY_HH__
332501SN/A
343532Sgblack@eecs.umich.edu#include "arch/sparc/faults.hh"
352501SN/A#include "arch/sparc/isa_traits.hh"
366335Sgblack@eecs.umich.edu#include "arch/sparc/registers.hh"
373603Ssaidi@eecs.umich.edu#include "arch/sparc/tlb.hh"
382501SN/A#include "base/misc.hh"
393278Sgblack@eecs.umich.edu#include "base/bitfield.hh"
403272Sgblack@eecs.umich.edu#include "cpu/thread_context.hh"
412501SN/A
422501SN/Anamespace SparcISA
432501SN/A{
443577Sgblack@eecs.umich.edu
454826Ssaidi@eecs.umich.edu
464826Ssaidi@eecs.umich.edu    uint64_t getArgument(ThreadContext *tc, int number, bool fp);
474826Ssaidi@eecs.umich.edu
483577Sgblack@eecs.umich.edu    static inline bool
493577Sgblack@eecs.umich.edu    inUserMode(ThreadContext *tc)
503577Sgblack@eecs.umich.edu    {
516283Sgblack@eecs.umich.edu        return !((tc->readMiscRegNoEffect(MISCREG_PSTATE) & (1 << 2)) ||
526283Sgblack@eecs.umich.edu                 (tc->readMiscRegNoEffect(MISCREG_HPSTATE) & (1 << 2)));
533577Sgblack@eecs.umich.edu    }
543577Sgblack@eecs.umich.edu
552501SN/A    inline bool isCallerSaveIntegerRegister(unsigned int reg) {
562501SN/A        panic("register classification not implemented");
572501SN/A        return false;
582501SN/A    }
592501SN/A
602501SN/A    inline bool isCalleeSaveIntegerRegister(unsigned int reg) {
612501SN/A        panic("register classification not implemented");
622501SN/A        return false;
632501SN/A    }
642501SN/A
652501SN/A    inline bool isCallerSaveFloatRegister(unsigned int reg) {
662501SN/A        panic("register classification not implemented");
672501SN/A        return false;
682501SN/A    }
692501SN/A
702501SN/A    inline bool isCalleeSaveFloatRegister(unsigned int reg) {
712501SN/A        panic("register classification not implemented");
722501SN/A        return false;
732501SN/A    }
742501SN/A
752501SN/A    // Instruction address compression hooks
762501SN/A    inline Addr realPCToFetchPC(const Addr &addr)
772501SN/A    {
782501SN/A        return addr;
792501SN/A    }
802501SN/A
812501SN/A    inline Addr fetchPCToRealPC(const Addr &addr)
822501SN/A    {
832501SN/A        return addr;
842501SN/A    }
852501SN/A
862501SN/A    // the size of "fetched" instructions (not necessarily the size
872501SN/A    // of real instructions for PISA)
882501SN/A    inline size_t fetchInstSize()
892501SN/A    {
902501SN/A        return sizeof(MachInst);
912501SN/A    }
922501SN/A
932501SN/A    /**
942501SN/A     * Function to insure ISA semantics about 0 registers.
952680Sktlim@umich.edu     * @param tc The thread context.
962501SN/A     */
972680Sktlim@umich.edu    template <class TC>
982680Sktlim@umich.edu    void zeroRegisters(TC *tc);
992501SN/A
1003532Sgblack@eecs.umich.edu    inline void initCPU(ThreadContext *tc, int cpuId)
1013528Sgblack@eecs.umich.edu    {
1023532Sgblack@eecs.umich.edu        static Fault por = new PowerOnReset();
1034194Ssaidi@eecs.umich.edu        if (cpuId == 0)
1044194Ssaidi@eecs.umich.edu            por->invoke(tc);
1054194Ssaidi@eecs.umich.edu
1064194Ssaidi@eecs.umich.edu    }
1074194Ssaidi@eecs.umich.edu
1084194Ssaidi@eecs.umich.edu    inline void startupCPU(ThreadContext *tc, int cpuId)
1094194Ssaidi@eecs.umich.edu    {
1104194Ssaidi@eecs.umich.edu#if FULL_SYSTEM
1114194Ssaidi@eecs.umich.edu        // Other CPUs will get activated by IPIs
1124194Ssaidi@eecs.umich.edu        if (cpuId == 0)
1134194Ssaidi@eecs.umich.edu            tc->activate(0);
1144194Ssaidi@eecs.umich.edu#else
1154194Ssaidi@eecs.umich.edu        tc->activate(0);
1164194Ssaidi@eecs.umich.edu#endif
1173528Sgblack@eecs.umich.edu    }
1183528Sgblack@eecs.umich.edu
1196329Sgblack@eecs.umich.edu    void copyRegs(ThreadContext *src, ThreadContext *dest);
1206329Sgblack@eecs.umich.edu
1216329Sgblack@eecs.umich.edu    void copyMiscRegs(ThreadContext *src, ThreadContext *dest);
1226329Sgblack@eecs.umich.edu
1232501SN/A} // namespace SparcISA
1242501SN/A
1252501SN/A#endif
126