utility.hh revision 6335
1793SN/A/*
29957SN/A * Copyright (c) 2003-2005 The Regents of The University of Michigan
39957SN/A * All rights reserved.
49957SN/A *
59957SN/A * Redistribution and use in source and binary forms, with or without
69957SN/A * modification, are permitted provided that the following conditions are
79957SN/A * met: redistributions of source code must retain the above copyright
89957SN/A * notice, this list of conditions and the following disclaimer;
99957SN/A * redistributions in binary form must reproduce the above copyright
109957SN/A * notice, this list of conditions and the following disclaimer in the
119957SN/A * documentation and/or other materials provided with the distribution;
129957SN/A * neither the name of the copyright holders nor the names of its
139957SN/A * contributors may be used to endorse or promote products derived from
141762SN/A * this software without specific prior written permission.
15793SN/A *
16793SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17793SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18793SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19793SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20793SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21793SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22793SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23793SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24793SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25793SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26793SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27793SN/A *
28793SN/A * Authors: Gabe Black
29793SN/A */
30793SN/A
31793SN/A#ifndef __ARCH_SPARC_UTILITY_HH__
32793SN/A#define __ARCH_SPARC_UTILITY_HH__
33793SN/A
34793SN/A#include "arch/sparc/faults.hh"
35793SN/A#include "arch/sparc/isa_traits.hh"
36793SN/A#include "arch/sparc/registers.hh"
37793SN/A#include "arch/sparc/tlb.hh"
38793SN/A#include "base/misc.hh"
392665SN/A#include "base/bitfield.hh"
402665SN/A#include "cpu/thread_context.hh"
412665SN/A
422665SN/Anamespace SparcISA
43793SN/A{
44793SN/A
45793SN/A
46845SN/A    uint64_t getArgument(ThreadContext *tc, int number, bool fp);
47793SN/A
48793SN/A    static inline bool
4911260Sandreas.sandberg@arm.com    inUserMode(ThreadContext *tc)
5011260Sandreas.sandberg@arm.com    {
51793SN/A        return !((tc->readMiscRegNoEffect(MISCREG_PSTATE) & (1 << 2)) ||
523918SN/A                 (tc->readMiscRegNoEffect(MISCREG_HPSTATE) & (1 << 2)));
539957SN/A    }
543918SN/A
559016SN/A    inline bool isCallerSaveIntegerRegister(unsigned int reg) {
5611244SN/A        panic("register classification not implemented");
5711260Sandreas.sandberg@arm.com        return false;
584762SN/A    }
593348SN/A
60795SN/A    inline bool isCalleeSaveIntegerRegister(unsigned int reg) {
611817SN/A        panic("register classification not implemented");
621817SN/A        return false;
631817SN/A    }
641817SN/A
651817SN/A    inline bool isCallerSaveFloatRegister(unsigned int reg) {
661817SN/A        panic("register classification not implemented");
67795SN/A        return false;
683083SN/A    }
69793SN/A
709807SN/A    inline bool isCalleeSaveFloatRegister(unsigned int reg) {
71793SN/A        panic("register classification not implemented");
7211244SN/A        return false;
7311244SN/A    }
742846SN/A
754982SN/A    // Instruction address compression hooks
76793SN/A    inline Addr realPCToFetchPC(const Addr &addr)
7711244SN/A    {
789957SN/A        return addr;
799957SN/A    }
809957SN/A
819957SN/A    inline Addr fetchPCToRealPC(const Addr &addr)
8210479SN/A    {
8310479SN/A        return addr;
8410479SN/A    }
859957SN/A
869957SN/A    // the size of "fetched" instructions (not necessarily the size
879957SN/A    // of real instructions for PISA)
889957SN/A    inline size_t fetchInstSize()
899957SN/A    {
909957SN/A        return sizeof(MachInst);
9110479SN/A    }
9210479SN/A
9310479SN/A    /**
9410479SN/A     * Function to insure ISA semantics about 0 registers.
9510479SN/A     * @param tc The thread context.
9610479SN/A     */
9710479SN/A    template <class TC>
9810479SN/A    void zeroRegisters(TC *tc);
999957SN/A
1009957SN/A    inline void initCPU(ThreadContext *tc, int cpuId)
1019957SN/A    {
1029957SN/A        static Fault por = new PowerOnReset();
1039957SN/A        if (cpuId == 0)
1049957SN/A            por->invoke(tc);
1059957SN/A
1069957SN/A    }
1079957SN/A
108885SN/A    inline void startupCPU(ThreadContext *tc, int cpuId)
109885SN/A    {
110793SN/A#if FULL_SYSTEM
111885SN/A        // Other CPUs will get activated by IPIs
112885SN/A        if (cpuId == 0)
113795SN/A            tc->activate(0);
114793SN/A#else
1155834SN/A        tc->activate(0);
1165834SN/A#endif
1175834SN/A    }
1183083SN/A
1193083SN/A    void copyRegs(ThreadContext *src, ThreadContext *dest);
1203083SN/A
1213083SN/A    void copyMiscRegs(ThreadContext *src, ThreadContext *dest);
1221992SN/A
1231992SN/A} // namespace SparcISA
1241992SN/A
1251992SN/A#endif
1261992SN/A