utility.hh revision 11294
12440SN/A/*
22440SN/A * Copyright (c) 2003-2005 The Regents of The University of Michigan
32440SN/A * All rights reserved.
42440SN/A *
52440SN/A * Redistribution and use in source and binary forms, with or without
62440SN/A * modification, are permitted provided that the following conditions are
72440SN/A * met: redistributions of source code must retain the above copyright
82440SN/A * notice, this list of conditions and the following disclaimer;
92440SN/A * redistributions in binary form must reproduce the above copyright
102440SN/A * notice, this list of conditions and the following disclaimer in the
112440SN/A * documentation and/or other materials provided with the distribution;
122440SN/A * neither the name of the copyright holders nor the names of its
132440SN/A * contributors may be used to endorse or promote products derived from
142440SN/A * this software without specific prior written permission.
152440SN/A *
162440SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
172440SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
182440SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
192440SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
202440SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
212440SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
222440SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
232440SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
242440SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
252440SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
262440SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
272665Ssaidi@eecs.umich.edu *
282665Ssaidi@eecs.umich.edu * Authors: Nathan Binkert
292665Ssaidi@eecs.umich.edu *          Steve Reinhardt
302440SN/A */
312440SN/A
322440SN/A#ifndef __ARCH_ALPHA_UTILITY_HH__
332440SN/A#define __ARCH_ALPHA_UTILITY_HH__
342440SN/A
352972Sgblack@eecs.umich.edu#include "arch/alpha/isa_traits.hh"
366330Sgblack@eecs.umich.edu#include "arch/alpha/registers.hh"
378229Snate@binkert.org#include "arch/alpha/types.hh"
382440SN/A#include "base/misc.hh"
397720Sgblack@eecs.umich.edu#include "cpu/static_inst.hh"
403120Sgblack@eecs.umich.edu#include "cpu/thread_context.hh"
418300Schander.sudanthi@arm.com#include "arch/alpha/ev5.hh"
422440SN/A
435569Snate@binkert.orgnamespace AlphaISA {
445569Snate@binkert.org
457720Sgblack@eecs.umich.eduinline PCState
467720Sgblack@eecs.umich.edubuildRetPC(const PCState &curPC, const PCState &callPC)
477720Sgblack@eecs.umich.edu{
487720Sgblack@eecs.umich.edu    PCState retPC = callPC;
497720Sgblack@eecs.umich.edu    retPC.advance();
507720Sgblack@eecs.umich.edu    return retPC;
517720Sgblack@eecs.umich.edu}
527720Sgblack@eecs.umich.edu
537707Sgblack@eecs.umich.eduuint64_t getArgument(ThreadContext *tc, int &number, uint16_t size, bool fp);
545569Snate@binkert.org
555569Snate@binkert.orginline bool
565569Snate@binkert.orginUserMode(ThreadContext *tc)
572440SN/A{
585569Snate@binkert.org    return (tc->readMiscRegNoEffect(IPR_DTB_CM) & 0x18) != 0;
595569Snate@binkert.org}
604826Ssaidi@eecs.umich.edu
615569Snate@binkert.org/**
625569Snate@binkert.org * Function to insure ISA semantics about 0 registers.
635569Snate@binkert.org * @param tc The thread context.
645569Snate@binkert.org */
655569Snate@binkert.orgtemplate <class TC>
665569Snate@binkert.orgvoid zeroRegisters(TC *tc);
672440SN/A
685569Snate@binkert.org// Alpha IPR register accessors
695569Snate@binkert.orginline bool PcPAL(Addr addr) { return addr & 0x3; }
709180Sandreas.hansson@arm.cominline void startupCPU(ThreadContext *tc, int cpuId)
7110407Smitch.hayenga@arm.com{ tc->activate(); }
722440SN/A
735569Snate@binkert.org////////////////////////////////////////////////////////////////////////
745569Snate@binkert.org//
755569Snate@binkert.org//  Translation stuff
765569Snate@binkert.org//
772440SN/A
785569Snate@binkert.orginline Addr PteAddr(Addr a) { return (a & PteMask) << PteShift; }
792440SN/A
805569Snate@binkert.org// User Virtual
8111294Sandreas.hansson@arm.cominline bool IsUSeg(Addr a) { assert(USegBase == 0); return a <= USegEnd; }
822440SN/A
835569Snate@binkert.org// Kernel Direct Mapped
845569Snate@binkert.orginline bool IsK0Seg(Addr a) { return K0SegBase <= a && a <= K0SegEnd; }
855569Snate@binkert.orginline Addr K0Seg2Phys(Addr addr) { return addr & ~K0SegBase; }
862440SN/A
875569Snate@binkert.org// Kernel Virtual
885569Snate@binkert.orginline bool IsK1Seg(Addr a) { return K1SegBase <= a && a <= K1SegEnd; }
892440SN/A
905569Snate@binkert.orginline Addr
915569Snate@binkert.orgTruncPage(Addr addr)
925569Snate@binkert.org{ return addr & ~(PageBytes - 1); }
932440SN/A
945569Snate@binkert.orginline Addr
955569Snate@binkert.orgRoundPage(Addr addr)
965569Snate@binkert.org{ return (addr + PageBytes - 1) & ~(PageBytes - 1); }
972440SN/A
985569Snate@binkert.orgvoid initIPRs(ThreadContext *tc, int cpuId);
995569Snate@binkert.orgvoid initCPU(ThreadContext *tc, int cpuId);
1002440SN/A
1016329Sgblack@eecs.umich.eduvoid copyRegs(ThreadContext *src, ThreadContext *dest);
1026329Sgblack@eecs.umich.edu
1036329Sgblack@eecs.umich.eduvoid copyMiscRegs(ThreadContext *src, ThreadContext *dest);
1046329Sgblack@eecs.umich.edu
1057693SAli.Saidi@ARM.comvoid skipFunction(ThreadContext *tc);
1067720Sgblack@eecs.umich.edu
1077720Sgblack@eecs.umich.eduinline void
10810417Sandreas.hansson@arm.comadvancePC(PCState &pc, const StaticInstPtr &inst)
1097720Sgblack@eecs.umich.edu{
1107720Sgblack@eecs.umich.edu    pc.advance();
1117720Sgblack@eecs.umich.edu}
1127720Sgblack@eecs.umich.edu
1138300Schander.sudanthi@arm.cominline uint64_t
1148300Schander.sudanthi@arm.comgetExecutingAsid(ThreadContext *tc)
1158300Schander.sudanthi@arm.com{
1168300Schander.sudanthi@arm.com    return DTB_ASN_ASN(tc->readMiscRegNoEffect(IPR_DTB_ASN));
1178300Schander.sudanthi@arm.com}
1188300Schander.sudanthi@arm.com
1192440SN/A} // namespace AlphaISA
1202440SN/A
1215569Snate@binkert.org#endif // __ARCH_ALPHA_UTILITY_HH__
122