utility.hh revision 10417:710ee116eb68
112027Sjungma@eit.uni-kl.de/*
212027Sjungma@eit.uni-kl.de * Copyright (c) 2003-2005 The Regents of The University of Michigan
312027Sjungma@eit.uni-kl.de * All rights reserved.
412027Sjungma@eit.uni-kl.de *
512027Sjungma@eit.uni-kl.de * Redistribution and use in source and binary forms, with or without
612027Sjungma@eit.uni-kl.de * modification, are permitted provided that the following conditions are
712027Sjungma@eit.uni-kl.de * met: redistributions of source code must retain the above copyright
812027Sjungma@eit.uni-kl.de * notice, this list of conditions and the following disclaimer;
912027Sjungma@eit.uni-kl.de * redistributions in binary form must reproduce the above copyright
1012027Sjungma@eit.uni-kl.de * notice, this list of conditions and the following disclaimer in the
1112027Sjungma@eit.uni-kl.de * documentation and/or other materials provided with the distribution;
1212027Sjungma@eit.uni-kl.de * neither the name of the copyright holders nor the names of its
1312027Sjungma@eit.uni-kl.de * contributors may be used to endorse or promote products derived from
1412027Sjungma@eit.uni-kl.de * this software without specific prior written permission.
1512027Sjungma@eit.uni-kl.de *
1612027Sjungma@eit.uni-kl.de * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
1712027Sjungma@eit.uni-kl.de * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
1812027Sjungma@eit.uni-kl.de * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
1912027Sjungma@eit.uni-kl.de * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
2012027Sjungma@eit.uni-kl.de * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
2112027Sjungma@eit.uni-kl.de * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
2212027Sjungma@eit.uni-kl.de * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
2312027Sjungma@eit.uni-kl.de * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
2412027Sjungma@eit.uni-kl.de * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2512027Sjungma@eit.uni-kl.de * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
2612027Sjungma@eit.uni-kl.de * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2712027Sjungma@eit.uni-kl.de *
2812027Sjungma@eit.uni-kl.de * Authors: Nathan Binkert
2912027Sjungma@eit.uni-kl.de *          Steve Reinhardt
3012027Sjungma@eit.uni-kl.de */
3112027Sjungma@eit.uni-kl.de
3212027Sjungma@eit.uni-kl.de#ifndef __ARCH_ALPHA_UTILITY_HH__
3312027Sjungma@eit.uni-kl.de#define __ARCH_ALPHA_UTILITY_HH__
3412027Sjungma@eit.uni-kl.de
3512027Sjungma@eit.uni-kl.de#include "arch/alpha/isa_traits.hh"
3612027Sjungma@eit.uni-kl.de#include "arch/alpha/registers.hh"
3712027Sjungma@eit.uni-kl.de#include "arch/alpha/types.hh"
3812027Sjungma@eit.uni-kl.de#include "base/misc.hh"
3912027Sjungma@eit.uni-kl.de#include "cpu/static_inst.hh"
4012027Sjungma@eit.uni-kl.de#include "cpu/thread_context.hh"
4112027Sjungma@eit.uni-kl.de#include "arch/alpha/ev5.hh"
4212027Sjungma@eit.uni-kl.de
4312027Sjungma@eit.uni-kl.denamespace AlphaISA {
4412027Sjungma@eit.uni-kl.de
4512027Sjungma@eit.uni-kl.deinline PCState
4612027Sjungma@eit.uni-kl.debuildRetPC(const PCState &curPC, const PCState &callPC)
4712027Sjungma@eit.uni-kl.de{
4812027Sjungma@eit.uni-kl.de    PCState retPC = callPC;
4912027Sjungma@eit.uni-kl.de    retPC.advance();
5012027Sjungma@eit.uni-kl.de    return retPC;
5112027Sjungma@eit.uni-kl.de}
5212027Sjungma@eit.uni-kl.de
5312027Sjungma@eit.uni-kl.deuint64_t getArgument(ThreadContext *tc, int &number, uint16_t size, bool fp);
5412027Sjungma@eit.uni-kl.de
5512027Sjungma@eit.uni-kl.deinline bool
5612027Sjungma@eit.uni-kl.deinUserMode(ThreadContext *tc)
5712027Sjungma@eit.uni-kl.de{
5812027Sjungma@eit.uni-kl.de    return (tc->readMiscRegNoEffect(IPR_DTB_CM) & 0x18) != 0;
5912027Sjungma@eit.uni-kl.de}
6012027Sjungma@eit.uni-kl.de
6112027Sjungma@eit.uni-kl.de/**
6212027Sjungma@eit.uni-kl.de * Function to insure ISA semantics about 0 registers.
6312027Sjungma@eit.uni-kl.de * @param tc The thread context.
6412027Sjungma@eit.uni-kl.de */
6512027Sjungma@eit.uni-kl.detemplate <class TC>
6612027Sjungma@eit.uni-kl.devoid zeroRegisters(TC *tc);
6712027Sjungma@eit.uni-kl.de
6812027Sjungma@eit.uni-kl.de// Alpha IPR register accessors
6912027Sjungma@eit.uni-kl.deinline bool PcPAL(Addr addr) { return addr & 0x3; }
7012027Sjungma@eit.uni-kl.deinline void startupCPU(ThreadContext *tc, int cpuId)
7112027Sjungma@eit.uni-kl.de{ tc->activate(); }
7212027Sjungma@eit.uni-kl.de
7312027Sjungma@eit.uni-kl.de////////////////////////////////////////////////////////////////////////
7412027Sjungma@eit.uni-kl.de//
7512027Sjungma@eit.uni-kl.de//  Translation stuff
7612027Sjungma@eit.uni-kl.de//
7712027Sjungma@eit.uni-kl.de
7812027Sjungma@eit.uni-kl.deinline Addr PteAddr(Addr a) { return (a & PteMask) << PteShift; }
7912027Sjungma@eit.uni-kl.de
8012027Sjungma@eit.uni-kl.de// User Virtual
8112027Sjungma@eit.uni-kl.deinline bool IsUSeg(Addr a) { return USegBase <= a && a <= USegEnd; }
8212027Sjungma@eit.uni-kl.de
8312027Sjungma@eit.uni-kl.de// Kernel Direct Mapped
8412027Sjungma@eit.uni-kl.deinline bool IsK0Seg(Addr a) { return K0SegBase <= a && a <= K0SegEnd; }
8512027Sjungma@eit.uni-kl.deinline Addr K0Seg2Phys(Addr addr) { return addr & ~K0SegBase; }
8612027Sjungma@eit.uni-kl.de
8712027Sjungma@eit.uni-kl.de// Kernel Virtual
8812027Sjungma@eit.uni-kl.deinline bool IsK1Seg(Addr a) { return K1SegBase <= a && a <= K1SegEnd; }
8912027Sjungma@eit.uni-kl.de
9012027Sjungma@eit.uni-kl.deinline Addr
9112027Sjungma@eit.uni-kl.deTruncPage(Addr addr)
9212027Sjungma@eit.uni-kl.de{ return addr & ~(PageBytes - 1); }
9312027Sjungma@eit.uni-kl.de
9412027Sjungma@eit.uni-kl.deinline Addr
9512027Sjungma@eit.uni-kl.deRoundPage(Addr addr)
9612027Sjungma@eit.uni-kl.de{ return (addr + PageBytes - 1) & ~(PageBytes - 1); }
9712027Sjungma@eit.uni-kl.de
9812027Sjungma@eit.uni-kl.devoid initIPRs(ThreadContext *tc, int cpuId);
9912027Sjungma@eit.uni-kl.devoid initCPU(ThreadContext *tc, int cpuId);
10012027Sjungma@eit.uni-kl.de
10112027Sjungma@eit.uni-kl.devoid copyRegs(ThreadContext *src, ThreadContext *dest);
10212027Sjungma@eit.uni-kl.de
10312027Sjungma@eit.uni-kl.devoid copyMiscRegs(ThreadContext *src, ThreadContext *dest);
10412027Sjungma@eit.uni-kl.de
10512027Sjungma@eit.uni-kl.devoid skipFunction(ThreadContext *tc);
10612027Sjungma@eit.uni-kl.de
10712027Sjungma@eit.uni-kl.deinline void
10812027Sjungma@eit.uni-kl.deadvancePC(PCState &pc, const StaticInstPtr &inst)
10912027Sjungma@eit.uni-kl.de{
11012027Sjungma@eit.uni-kl.de    pc.advance();
11112027Sjungma@eit.uni-kl.de}
11212027Sjungma@eit.uni-kl.de
11312027Sjungma@eit.uni-kl.deinline uint64_t
11412027Sjungma@eit.uni-kl.degetExecutingAsid(ThreadContext *tc)
11512027Sjungma@eit.uni-kl.de{
11612027Sjungma@eit.uni-kl.de    return DTB_ASN_ASN(tc->readMiscRegNoEffect(IPR_DTB_ASN));
11712027Sjungma@eit.uni-kl.de}
11812027Sjungma@eit.uni-kl.de
11912027Sjungma@eit.uni-kl.de} // namespace AlphaISA
12012027Sjungma@eit.uni-kl.de
12112027Sjungma@eit.uni-kl.de#endif // __ARCH_ALPHA_UTILITY_HH__
12212027Sjungma@eit.uni-kl.de