utility.cc revision 5958
14120Sgblack@eecs.umich.edu/*
24120Sgblack@eecs.umich.edu * Copyright (c) 2003-2005 The Regents of The University of Michigan
37087Snate@binkert.org * All rights reserved.
47087Snate@binkert.org *
57087Snate@binkert.org * Redistribution and use in source and binary forms, with or without
67087Snate@binkert.org * modification, are permitted provided that the following conditions are
77087Snate@binkert.org * met: redistributions of source code must retain the above copyright
87087Snate@binkert.org * notice, this list of conditions and the following disclaimer;
97087Snate@binkert.org * redistributions in binary form must reproduce the above copyright
107087Snate@binkert.org * notice, this list of conditions and the following disclaimer in the
117087Snate@binkert.org * documentation and/or other materials provided with the distribution;
127087Snate@binkert.org * neither the name of the copyright holders nor the names of its
137087Snate@binkert.org * contributors may be used to endorse or promote products derived from
147087Snate@binkert.org * this software without specific prior written permission.
154120Sgblack@eecs.umich.edu *
164120Sgblack@eecs.umich.edu * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
174120Sgblack@eecs.umich.edu * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
184120Sgblack@eecs.umich.edu * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
194120Sgblack@eecs.umich.edu * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
204120Sgblack@eecs.umich.edu * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
214120Sgblack@eecs.umich.edu * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
224120Sgblack@eecs.umich.edu * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
234120Sgblack@eecs.umich.edu * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
244120Sgblack@eecs.umich.edu * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
254120Sgblack@eecs.umich.edu * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
264120Sgblack@eecs.umich.edu * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
274120Sgblack@eecs.umich.edu *
284120Sgblack@eecs.umich.edu * Authors: Nathan Binkert
294120Sgblack@eecs.umich.edu *          Ali Saidi
304120Sgblack@eecs.umich.edu */
314120Sgblack@eecs.umich.edu
324120Sgblack@eecs.umich.edu#include "arch/alpha/utility.hh"
334120Sgblack@eecs.umich.edu
344120Sgblack@eecs.umich.edu#if FULL_SYSTEM
354120Sgblack@eecs.umich.edu#include "arch/alpha/vtophys.hh"
364120Sgblack@eecs.umich.edu#include "mem/vport.hh"
374120Sgblack@eecs.umich.edu#endif
384120Sgblack@eecs.umich.edu
394120Sgblack@eecs.umich.edunamespace AlphaISA {
404120Sgblack@eecs.umich.edu
414120Sgblack@eecs.umich.eduuint64_t
424120Sgblack@eecs.umich.edugetArgument(ThreadContext *tc, int number, bool fp)
434202Sbinkertn@umich.edu{
445069Sgblack@eecs.umich.edu#if FULL_SYSTEM
454202Sbinkertn@umich.edu    const int NumArgumentRegs = 6;
465659Sgblack@eecs.umich.edu    if (number < NumArgumentRegs) {
479022Sgblack@eecs.umich.edu        if (fp)
489023Sgblack@eecs.umich.edu            return tc->readFloatRegBits(16 + number);
494601Sgblack@eecs.umich.edu        else
505124Sgblack@eecs.umich.edu            return tc->readIntReg(16 + number);
517966Sgblack@eecs.umich.edu    } else {
525083Sgblack@eecs.umich.edu        Addr sp = tc->readIntReg(StackPointerReg);
534679Sgblack@eecs.umich.edu        VirtualPort *vp = tc->getVirtPort();
546515Sgblack@eecs.umich.edu        uint64_t arg = vp->read<uint64_t>(sp +
555083Sgblack@eecs.umich.edu                           (number-NumArgumentRegs) * sizeof(uint64_t));
564679Sgblack@eecs.umich.edu        return arg;
574679Sgblack@eecs.umich.edu    }
588745Sgblack@eecs.umich.edu#else
596313Sgblack@eecs.umich.edu    panic("getArgument() is Full system only\n");
608771Sgblack@eecs.umich.edu    M5_DUMMY_RETURN;
618771Sgblack@eecs.umich.edu#endif
628771Sgblack@eecs.umich.edu}
638771Sgblack@eecs.umich.edu
646365Sgblack@eecs.umich.edu} // namespace AlphaISA
655124Sgblack@eecs.umich.edu
668752Sgblack@eecs.umich.edu