utility.hh revision 11723
12847Sksewell@umich.edu/* 27783SGiacomo.Gabrielli@arm.com * Copyright (c) 2013 ARM Limited 37783SGiacomo.Gabrielli@arm.com * Copyright (c) 2014-2015 Sven Karlsson 47783SGiacomo.Gabrielli@arm.com * All rights reserved 57783SGiacomo.Gabrielli@arm.com * 67783SGiacomo.Gabrielli@arm.com * The license below extends only to copyright in the software and shall 77783SGiacomo.Gabrielli@arm.com * not be construed as granting a license to any other intellectual 87783SGiacomo.Gabrielli@arm.com * property including but not limited to intellectual property relating 97783SGiacomo.Gabrielli@arm.com * to a hardware implementation of the functionality of the software 107783SGiacomo.Gabrielli@arm.com * licensed hereunder. You may use the software subject to the license 117783SGiacomo.Gabrielli@arm.com * terms below provided that you ensure that this notice is replicated 127783SGiacomo.Gabrielli@arm.com * unmodified and in its entirety in all distributions of the software, 137783SGiacomo.Gabrielli@arm.com * modified or unmodified, in source code or in binary form. 145596Sgblack@eecs.umich.edu * 152847Sksewell@umich.edu * Copyright (c) 2016 The University of Virginia 162847Sksewell@umich.edu * All rights reserved. 172847Sksewell@umich.edu * 182847Sksewell@umich.edu * Redistribution and use in source and binary forms, with or without 192847Sksewell@umich.edu * modification, are permitted provided that the following conditions are 202847Sksewell@umich.edu * met: redistributions of source code must retain the above copyright 212847Sksewell@umich.edu * notice, this list of conditions and the following disclaimer; 222847Sksewell@umich.edu * redistributions in binary form must reproduce the above copyright 232847Sksewell@umich.edu * notice, this list of conditions and the following disclaimer in the 242847Sksewell@umich.edu * documentation and/or other materials provided with the distribution; 252847Sksewell@umich.edu * neither the name of the copyright holders nor the names of its 262847Sksewell@umich.edu * contributors may be used to endorse or promote products derived from 272847Sksewell@umich.edu * this software without specific prior written permission. 282847Sksewell@umich.edu * 292847Sksewell@umich.edu * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 302847Sksewell@umich.edu * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 312847Sksewell@umich.edu * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 322847Sksewell@umich.edu * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 332847Sksewell@umich.edu * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 342847Sksewell@umich.edu * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 352847Sksewell@umich.edu * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 362847Sksewell@umich.edu * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 372847Sksewell@umich.edu * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 382847Sksewell@umich.edu * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 392847Sksewell@umich.edu * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 405596Sgblack@eecs.umich.edu * 412847Sksewell@umich.edu * Authors: Andreas Hansson 422847Sksewell@umich.edu * Sven Karlsson 432847Sksewell@umich.edu * Alec Roelke 442847Sksewell@umich.edu */ 452847Sksewell@umich.edu 465596Sgblack@eecs.umich.edu#ifndef __ARCH_RISCV_UTILITY_HH__ 476658Snate@binkert.org#define __ARCH_RISCV_UTILITY_HH__ 485596Sgblack@eecs.umich.edu 495596Sgblack@eecs.umich.edu#include <cmath> 505596Sgblack@eecs.umich.edu#include <cstdint> 515596Sgblack@eecs.umich.edu 522847Sksewell@umich.edu#include "base/types.hh" 535596Sgblack@eecs.umich.edu#include "cpu/static_inst.hh" 545596Sgblack@eecs.umich.edu#include "cpu/thread_context.hh" 555596Sgblack@eecs.umich.edu 565596Sgblack@eecs.umich.edunamespace RiscvISA 575596Sgblack@eecs.umich.edu{ 585596Sgblack@eecs.umich.edu 595596Sgblack@eecs.umich.eduinline PCState 605596Sgblack@eecs.umich.edubuildRetPC(const PCState &curPC, const PCState &callPC) 615596Sgblack@eecs.umich.edu{ 625596Sgblack@eecs.umich.edu PCState retPC = callPC; 635596Sgblack@eecs.umich.edu retPC.advance(); 645596Sgblack@eecs.umich.edu retPC.pc(curPC.npc()); 655596Sgblack@eecs.umich.edu return retPC; 665596Sgblack@eecs.umich.edu} 675596Sgblack@eecs.umich.edu 685596Sgblack@eecs.umich.eduinline uint64_t 695596Sgblack@eecs.umich.edugetArgument(ThreadContext *tc, int &number, uint16_t size, bool fp) 705596Sgblack@eecs.umich.edu{ 715596Sgblack@eecs.umich.edu return 0; 725596Sgblack@eecs.umich.edu} 735596Sgblack@eecs.umich.edu 745596Sgblack@eecs.umich.eduinline void startupCPU(ThreadContext *tc, int cpuId) 755596Sgblack@eecs.umich.edu{ 765596Sgblack@eecs.umich.edu} 775596Sgblack@eecs.umich.edu 785596Sgblack@eecs.umich.eduinline void 795596Sgblack@eecs.umich.educopyRegs(ThreadContext *src, ThreadContext *dest) 805596Sgblack@eecs.umich.edu{ 815596Sgblack@eecs.umich.edu // First loop through the integer registers. 825596Sgblack@eecs.umich.edu for (int i = 0; i < NumIntRegs; ++i) 835596Sgblack@eecs.umich.edu dest->setIntReg(i, src->readIntReg(i)); 845596Sgblack@eecs.umich.edu 855596Sgblack@eecs.umich.edu // Lastly copy PC/NPC 865596Sgblack@eecs.umich.edu dest->pcState(src->pcState()); 875596Sgblack@eecs.umich.edu} 885596Sgblack@eecs.umich.edu 897720Sgblack@eecs.umich.eduinline void 907720Sgblack@eecs.umich.eduskipFunction(ThreadContext *tc) 917720Sgblack@eecs.umich.edu{ 925596Sgblack@eecs.umich.edu panic("Not Implemented for Riscv"); 935596Sgblack@eecs.umich.edu} 947720Sgblack@eecs.umich.edu 957720Sgblack@eecs.umich.eduinline void 967720Sgblack@eecs.umich.eduadvancePC(PCState &pc, const StaticInstPtr &inst) 975596Sgblack@eecs.umich.edu{ 985596Sgblack@eecs.umich.edu inst->advancePC(pc); 995596Sgblack@eecs.umich.edu} 1005596Sgblack@eecs.umich.edu 1015596Sgblack@eecs.umich.edustatic inline bool 1025596Sgblack@eecs.umich.eduinUserMode(ThreadContext *tc) 1035596Sgblack@eecs.umich.edu{ 1045596Sgblack@eecs.umich.edu return true; 1055596Sgblack@eecs.umich.edu} 1065596Sgblack@eecs.umich.edu 1075596Sgblack@eecs.umich.eduinline uint64_t 1085596Sgblack@eecs.umich.edugetExecutingAsid(ThreadContext *tc) 1095596Sgblack@eecs.umich.edu{ 1105596Sgblack@eecs.umich.edu return 0; 1115596Sgblack@eecs.umich.edu} 1125596Sgblack@eecs.umich.edu 1135596Sgblack@eecs.umich.eduinline void 1147783SGiacomo.Gabrielli@arm.cominitCPU(ThreadContext *, int cpuId) 1157783SGiacomo.Gabrielli@arm.com{ 1167783SGiacomo.Gabrielli@arm.com panic("initCPU not implemented for Riscv.\n"); 1177783SGiacomo.Gabrielli@arm.com} 1187783SGiacomo.Gabrielli@arm.com 1197783SGiacomo.Gabrielli@arm.com} // namespace RiscvISA 1207783SGiacomo.Gabrielli@arm.com 1217783SGiacomo.Gabrielli@arm.com#endif // __ARCH_RISCV_UTILITY_HH__ 1227783SGiacomo.Gabrielli@arm.com