12207SN/A/* 22207SN/A * Copyright (c) 2003-2004 The Regents of The University of Michigan 32207SN/A * All rights reserved. 42207SN/A * 52207SN/A * Redistribution and use in source and binary forms, with or without 62207SN/A * modification, are permitted provided that the following conditions are 72207SN/A * met: redistributions of source code must retain the above copyright 82207SN/A * notice, this list of conditions and the following disclaimer; 92207SN/A * redistributions in binary form must reproduce the above copyright 102207SN/A * notice, this list of conditions and the following disclaimer in the 112207SN/A * documentation and/or other materials provided with the distribution; 122207SN/A * neither the name of the copyright holders nor the names of its 132207SN/A * contributors may be used to endorse or promote products derived from 142207SN/A * this software without specific prior written permission. 152207SN/A * 162207SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 172207SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 182207SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 192207SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 202207SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 212207SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 222207SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 232207SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 242207SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 252207SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 262207SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 272665Ssaidi@eecs.umich.edu * 282665Ssaidi@eecs.umich.edu * Authors: Gabe Black 292665Ssaidi@eecs.umich.edu * Ali Saidi 302207SN/A */ 312207SN/A 322207SN/A#ifndef __SPARC_PROCESS_HH__ 332207SN/A#define __SPARC_PROCESS_HH__ 342207SN/A 3511905SBrandon.Potter@amd.com#include <memory> 362454SN/A#include <string> 372454SN/A#include <vector> 388229Snate@binkert.org 3911905SBrandon.Potter@amd.com#include "arch/sparc/isa_traits.hh" 4011905SBrandon.Potter@amd.com#include "base/loader/object_file.hh" 4111800Sbrandon.potter@amd.com#include "mem/page_table.hh" 425285Sgblack@eecs.umich.edu#include "sim/byteswap.hh" 432474SN/A#include "sim/process.hh" 442454SN/A 4511851Sbrandon.potter@amd.comclass SparcProcess : public Process 462207SN/A{ 472474SN/A protected: 482561SN/A 495285Sgblack@eecs.umich.edu const Addr StackBias; 505285Sgblack@eecs.umich.edu 517741Sgblack@eecs.umich.edu // The locations of the fill and spill handlers 523415Sgblack@eecs.umich.edu Addr fillStart, spillStart; 533415Sgblack@eecs.umich.edu 5411851Sbrandon.potter@amd.com SparcProcess(ProcessParams * params, ObjectFile *objFile, 5511851Sbrandon.potter@amd.com Addr _StackBias); 565285Sgblack@eecs.umich.edu 577532Ssteve.reinhardt@amd.com void initState(); 585285Sgblack@eecs.umich.edu 595285Sgblack@eecs.umich.edu template<class IntType> 605285Sgblack@eecs.umich.edu void argsInit(int pageSize); 612207SN/A 622474SN/A public: 632474SN/A 647741Sgblack@eecs.umich.edu // Handles traps which request services from the operating system 6511877Sbrandon.potter@amd.com virtual void handleTrap(int trapNum, ThreadContext *tc, Fault *fault); 662561SN/A 677741Sgblack@eecs.umich.edu Addr readFillStart() { return fillStart; } 687741Sgblack@eecs.umich.edu Addr readSpillStart() { return spillStart; } 693415Sgblack@eecs.umich.edu 705128Sgblack@eecs.umich.edu virtual void flushWindows(ThreadContext *tc) = 0; 715958Sgblack@eecs.umich.edu void setSyscallReturn(ThreadContext *tc, SyscallReturn return_value); 722474SN/A}; 732207SN/A 7411851Sbrandon.potter@amd.comclass Sparc32Process : public SparcProcess 754111Sgblack@eecs.umich.edu{ 764111Sgblack@eecs.umich.edu protected: 774111Sgblack@eecs.umich.edu 7811851Sbrandon.potter@amd.com Sparc32Process(ProcessParams * params, ObjectFile *objFile) 7911851Sbrandon.potter@amd.com : SparcProcess(params, objFile, 0) 804111Sgblack@eecs.umich.edu { 8111905SBrandon.Potter@amd.com Addr brk_point = objFile->dataBase() + objFile->dataSize() + 8211905SBrandon.Potter@amd.com objFile->bssSize(); 8311905SBrandon.Potter@amd.com brk_point = roundUp(brk_point, SparcISA::PageBytes); 8411905SBrandon.Potter@amd.com 8511905SBrandon.Potter@amd.com // Reserve 8M for main stack. 8611905SBrandon.Potter@amd.com Addr max_stack_size = 8 * 1024 * 1024; 8711905SBrandon.Potter@amd.com 884111Sgblack@eecs.umich.edu // Set up stack. On SPARC Linux, stack goes from the top of memory 894111Sgblack@eecs.umich.edu // downward, less the hole for the kernel address space. 9011905SBrandon.Potter@amd.com Addr stack_base = 0xf0000000ULL; 9111905SBrandon.Potter@amd.com 9211905SBrandon.Potter@amd.com // Set pointer for next thread stack. 9311905SBrandon.Potter@amd.com Addr next_thread_stack_base = stack_base - max_stack_size; 944111Sgblack@eecs.umich.edu 954111Sgblack@eecs.umich.edu // Set up region for mmaps. 9611905SBrandon.Potter@amd.com Addr mmap_end = 0x70000000; 9711905SBrandon.Potter@amd.com 9811905SBrandon.Potter@amd.com memState = std::make_shared<MemState>(brk_point, stack_base, 9911905SBrandon.Potter@amd.com max_stack_size, 10011905SBrandon.Potter@amd.com next_thread_stack_base, 10111905SBrandon.Potter@amd.com mmap_end); 1024111Sgblack@eecs.umich.edu } 1034111Sgblack@eecs.umich.edu 1047532Ssteve.reinhardt@amd.com void initState(); 1054111Sgblack@eecs.umich.edu 1064111Sgblack@eecs.umich.edu public: 1074111Sgblack@eecs.umich.edu 1084111Sgblack@eecs.umich.edu void argsInit(int intSize, int pageSize); 1094111Sgblack@eecs.umich.edu 1105128Sgblack@eecs.umich.edu void flushWindows(ThreadContext *tc); 1115958Sgblack@eecs.umich.edu 11213583Sgabeblack@google.com RegVal getSyscallArg(ThreadContext *tc, int &i); 1139552Sandreas.hansson@arm.com /// Explicitly import the otherwise hidden getSyscallArg 11411851Sbrandon.potter@amd.com using Process::getSyscallArg; 1159552Sandreas.hansson@arm.com 11613583Sgabeblack@google.com void setSyscallArg(ThreadContext *tc, int i, RegVal val); 1174111Sgblack@eecs.umich.edu}; 1184111Sgblack@eecs.umich.edu 11911851Sbrandon.potter@amd.comclass Sparc64Process : public SparcProcess 1204111Sgblack@eecs.umich.edu{ 1214111Sgblack@eecs.umich.edu protected: 1224111Sgblack@eecs.umich.edu 12311851Sbrandon.potter@amd.com Sparc64Process(ProcessParams * params, ObjectFile *objFile) 12411851Sbrandon.potter@amd.com : SparcProcess(params, objFile, 2047) 1254111Sgblack@eecs.umich.edu { 12611905SBrandon.Potter@amd.com Addr brk_point = objFile->dataBase() + objFile->dataSize() + 12711905SBrandon.Potter@amd.com objFile->bssSize(); 12811905SBrandon.Potter@amd.com brk_point = roundUp(brk_point, SparcISA::PageBytes); 12911905SBrandon.Potter@amd.com 13011905SBrandon.Potter@amd.com Addr max_stack_size = 8 * 1024 * 1024; 13111905SBrandon.Potter@amd.com 1324111Sgblack@eecs.umich.edu // Set up stack. On SPARC Linux, stack goes from the top of memory 1334111Sgblack@eecs.umich.edu // downward, less the hole for the kernel address space. 13411905SBrandon.Potter@amd.com Addr stack_base = 0x80000000000ULL; 13511905SBrandon.Potter@amd.com 13611905SBrandon.Potter@amd.com // Set pointer for next thread stack. Reserve 8M for main stack. 13711905SBrandon.Potter@amd.com Addr next_thread_stack_base = stack_base - max_stack_size; 1384111Sgblack@eecs.umich.edu 13911386Ssteve.reinhardt@amd.com // Set up region for mmaps. 14011905SBrandon.Potter@amd.com Addr mmap_end = 0xfffff80000000000ULL; 14111905SBrandon.Potter@amd.com 14211905SBrandon.Potter@amd.com memState = std::make_shared<MemState>(brk_point, stack_base, 14311905SBrandon.Potter@amd.com max_stack_size, 14411905SBrandon.Potter@amd.com next_thread_stack_base, 14511905SBrandon.Potter@amd.com mmap_end); 1464111Sgblack@eecs.umich.edu } 1474111Sgblack@eecs.umich.edu 1487532Ssteve.reinhardt@amd.com void initState(); 1494111Sgblack@eecs.umich.edu 1504111Sgblack@eecs.umich.edu public: 1514111Sgblack@eecs.umich.edu 1524111Sgblack@eecs.umich.edu void argsInit(int intSize, int pageSize); 1534111Sgblack@eecs.umich.edu 1545128Sgblack@eecs.umich.edu void flushWindows(ThreadContext *tc); 1555958Sgblack@eecs.umich.edu 15613583Sgabeblack@google.com RegVal getSyscallArg(ThreadContext *tc, int &i); 1579552Sandreas.hansson@arm.com /// Explicitly import the otherwise hidden getSyscallArg 15811851Sbrandon.potter@amd.com using Process::getSyscallArg; 1599552Sandreas.hansson@arm.com 16013583Sgabeblack@google.com void setSyscallArg(ThreadContext *tc, int i, RegVal val); 1614111Sgblack@eecs.umich.edu}; 1624111Sgblack@eecs.umich.edu 1632207SN/A#endif // __SPARC_PROCESS_HH__ 164