utility.hh revision 7693
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
352440SN/A#include "arch/alpha/types.hh"
362972Sgblack@eecs.umich.edu#include "arch/alpha/isa_traits.hh"
376330Sgblack@eecs.umich.edu#include "arch/alpha/registers.hh"
382440SN/A#include "base/misc.hh"
395569Snate@binkert.org#include "config/full_system.hh"
403120Sgblack@eecs.umich.edu#include "cpu/thread_context.hh"
412440SN/A
425569Snate@binkert.orgnamespace AlphaISA {
435569Snate@binkert.org
447693SAli.Saidi@ARM.comuint64_t getArgument(ThreadContext *tc, int &number, uint8_t size,  bool fp);
455569Snate@binkert.org
465569Snate@binkert.orginline bool
475569Snate@binkert.orginUserMode(ThreadContext *tc)
482440SN/A{
495569Snate@binkert.org    return (tc->readMiscRegNoEffect(IPR_DTB_CM) & 0x18) != 0;
505569Snate@binkert.org}
514826Ssaidi@eecs.umich.edu
525569Snate@binkert.org/**
535569Snate@binkert.org * Function to insure ISA semantics about 0 registers.
545569Snate@binkert.org * @param tc The thread context.
555569Snate@binkert.org */
565569Snate@binkert.orgtemplate <class TC>
575569Snate@binkert.orgvoid zeroRegisters(TC *tc);
582440SN/A
595569Snate@binkert.org// Alpha IPR register accessors
605569Snate@binkert.orginline bool PcPAL(Addr addr) { return addr & 0x3; }
615569Snate@binkert.orginline void startupCPU(ThreadContext *tc, int cpuId) { tc->activate(0); }
622440SN/A
635569Snate@binkert.org////////////////////////////////////////////////////////////////////////
645569Snate@binkert.org//
655569Snate@binkert.org//  Translation stuff
665569Snate@binkert.org//
672440SN/A
685569Snate@binkert.orginline Addr PteAddr(Addr a) { return (a & PteMask) << PteShift; }
692440SN/A
705569Snate@binkert.org// User Virtual
715569Snate@binkert.orginline bool IsUSeg(Addr a) { return USegBase <= a && a <= USegEnd; }
722440SN/A
735569Snate@binkert.org// Kernel Direct Mapped
745569Snate@binkert.orginline bool IsK0Seg(Addr a) { return K0SegBase <= a && a <= K0SegEnd; }
755569Snate@binkert.orginline Addr K0Seg2Phys(Addr addr) { return addr & ~K0SegBase; }
762440SN/A
775569Snate@binkert.org// Kernel Virtual
785569Snate@binkert.orginline bool IsK1Seg(Addr a) { return K1SegBase <= a && a <= K1SegEnd; }
792440SN/A
805569Snate@binkert.orginline Addr
815569Snate@binkert.orgTruncPage(Addr addr)
825569Snate@binkert.org{ return addr & ~(PageBytes - 1); }
832440SN/A
845569Snate@binkert.orginline Addr
855569Snate@binkert.orgRoundPage(Addr addr)
865569Snate@binkert.org{ return (addr + PageBytes - 1) & ~(PageBytes - 1); }
872440SN/A
885569Snate@binkert.orgvoid initIPRs(ThreadContext *tc, int cpuId);
895569Snate@binkert.org#if FULL_SYSTEM
905569Snate@binkert.orgvoid initCPU(ThreadContext *tc, int cpuId);
912440SN/A#endif
922440SN/A
936329Sgblack@eecs.umich.eduvoid copyRegs(ThreadContext *src, ThreadContext *dest);
946329Sgblack@eecs.umich.edu
956329Sgblack@eecs.umich.eduvoid copyMiscRegs(ThreadContext *src, ThreadContext *dest);
966329Sgblack@eecs.umich.edu
977693SAli.Saidi@ARM.comvoid skipFunction(ThreadContext *tc);
982440SN/A} // namespace AlphaISA
992440SN/A
1005569Snate@binkert.org#endif // __ARCH_ALPHA_UTILITY_HH__
101