utility.hh revision 8300
12SN/A/*
21762SN/A * Copyright (c) 2003-2005 The Regents of The University of Michigan
32SN/A * All rights reserved.
42SN/A *
52SN/A * Redistribution and use in source and binary forms, with or without
62SN/A * modification, are permitted provided that the following conditions are
72SN/A * met: redistributions of source code must retain the above copyright
82SN/A * notice, this list of conditions and the following disclaimer;
92SN/A * redistributions in binary form must reproduce the above copyright
102SN/A * notice, this list of conditions and the following disclaimer in the
112SN/A * documentation and/or other materials provided with the distribution;
122SN/A * neither the name of the copyright holders nor the names of its
132SN/A * contributors may be used to endorse or promote products derived from
142SN/A * this software without specific prior written permission.
152SN/A *
162SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
172SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
182SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
192SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
202SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
212SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
222SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
232SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
242SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
252SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
262SN/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
302665Ssaidi@eecs.umich.edu */
312SN/A
322SN/A#ifndef __ARCH_ALPHA_UTILITY_HH__
332623SN/A#define __ARCH_ALPHA_UTILITY_HH__
342623SN/A
352SN/A#include "arch/alpha/isa_traits.hh"
364182Sgblack@eecs.umich.edu#include "arch/alpha/registers.hh"
371354SN/A#include "arch/alpha/types.hh"
381858SN/A#include "base/misc.hh"
396658Snate@binkert.org#include "config/full_system.hh"
401717SN/A#include "cpu/static_inst.hh"
418541Sgblack@eecs.umich.edu#include "cpu/thread_context.hh"
428229Snate@binkert.org#include "arch/alpha/ev5.hh"
432683Sktlim@umich.edu
441354SN/Anamespace AlphaISA {
452387SN/A
462387SN/Ainline PCState
472387SN/AbuildRetPC(const PCState &curPC, const PCState &callPC)
4856SN/A{
495348Ssaidi@eecs.umich.edu    PCState retPC = callPC;
502SN/A    retPC.advance();
512SN/A    return retPC;
521858SN/A}
532SN/A
543453Sgblack@eecs.umich.eduuint64_t getArgument(ThreadContext *tc, int &number, uint16_t size, bool fp);
553453Sgblack@eecs.umich.edu
563453Sgblack@eecs.umich.eduinline bool
573453Sgblack@eecs.umich.eduinUserMode(ThreadContext *tc)
583453Sgblack@eecs.umich.edu{
592462SN/A    return (tc->readMiscRegNoEffect(IPR_DTB_CM) & 0x18) != 0;
602SN/A}
61715SN/A
62715SN/A/**
63715SN/A * Function to insure ISA semantics about 0 registers.
64715SN/A * @param tc The thread context.
652SN/A */
662SN/Atemplate <class TC>
674182Sgblack@eecs.umich.eduvoid zeroRegisters(TC *tc);
684182Sgblack@eecs.umich.edu
694182Sgblack@eecs.umich.edu// Alpha IPR register accessors
704182Sgblack@eecs.umich.eduinline bool PcPAL(Addr addr) { return addr & 0x3; }
712680Sktlim@umich.eduinline void startupCPU(ThreadContext *tc, int cpuId) { tc->activate(0); }
72237SN/A
732SN/A////////////////////////////////////////////////////////////////////////
742SN/A//
752SN/A//  Translation stuff
762SN/A//
772SN/A
785529Snate@binkert.orginline Addr PteAddr(Addr a) { return (a & PteMask) << PteShift; }
795529Snate@binkert.org
802420SN/A// User Virtual
812623SN/Ainline bool IsUSeg(Addr a) { return USegBase <= a && a <= USegEnd; }
822SN/A
832107SN/A// Kernel Direct Mapped
842159SN/Ainline bool IsK0Seg(Addr a) { return K0SegBase <= a && a <= K0SegEnd; }
852455SN/Ainline Addr K0Seg2Phys(Addr addr) { return addr & ~K0SegBase; }
862455SN/A
872386SN/A// Kernel Virtual
882623SN/Ainline bool IsK1Seg(Addr a) { return K1SegBase <= a && a <= K1SegEnd; }
892SN/A
901371SN/Ainline Addr
915348Ssaidi@eecs.umich.eduTruncPage(Addr addr)
927720Sgblack@eecs.umich.edu{ return addr & ~(PageBytes - 1); }
935348Ssaidi@eecs.umich.edu
947720Sgblack@eecs.umich.eduinline Addr
955348Ssaidi@eecs.umich.eduRoundPage(Addr addr)
967720Sgblack@eecs.umich.edu{ return (addr + PageBytes - 1) & ~(PageBytes - 1); }
977720Sgblack@eecs.umich.edu
985348Ssaidi@eecs.umich.eduvoid initIPRs(ThreadContext *tc, int cpuId);
995348Ssaidi@eecs.umich.edu#if FULL_SYSTEM
1002SN/Avoid initCPU(ThreadContext *tc, int cpuId);
1015807Snate@binkert.org#endif
1022SN/A
1032SN/Avoid copyRegs(ThreadContext *src, ThreadContext *dest);
1042SN/A
1052SN/Avoid copyMiscRegs(ThreadContext *src, ThreadContext *dest);
1062SN/A
1072SN/Avoid skipFunction(ThreadContext *tc);
1082SN/A
1092SN/Ainline void
1102SN/AadvancePC(PCState &pc, const StaticInstPtr inst)
1111400SN/A{
1125529Snate@binkert.org    pc.advance();
1132623SN/A}
1142SN/A
1151400SN/Ainline uint64_t
1162683Sktlim@umich.edugetExecutingAsid(ThreadContext *tc)
1172683Sktlim@umich.edu{
1182190SN/A    return DTB_ASN_ASN(tc->readMiscRegNoEffect(IPR_DTB_ASN));
1192683Sktlim@umich.edu}
1202683Sktlim@umich.edu
1212683Sktlim@umich.edu} // namespace AlphaISA
1222680Sktlim@umich.edu
1235169Ssaidi@eecs.umich.edu#endif // __ARCH_ALPHA_UTILITY_HH__
1245169Ssaidi@eecs.umich.edu