2006-03-04 09:09:23 +01:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2003-2004 The Regents of The University of Michigan
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions are
|
|
|
|
* met: redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer;
|
|
|
|
* redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution;
|
|
|
|
* neither the name of the copyright holders nor the names of its
|
|
|
|
* contributors may be used to endorse or promote products derived from
|
|
|
|
* this software without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
|
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
|
|
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
|
|
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
|
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
|
|
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
|
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
2006-06-01 01:26:56 +02:00
|
|
|
*
|
|
|
|
* Authors: Gabe Black
|
|
|
|
* Ali Saidi
|
2006-03-04 09:09:23 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __SPARC_PROCESS_HH__
|
|
|
|
#define __SPARC_PROCESS_HH__
|
|
|
|
|
2017-03-01 20:07:43 +01:00
|
|
|
#include <memory>
|
2006-03-12 22:27:52 +01:00
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
2011-04-15 19:44:06 +02:00
|
|
|
|
2017-03-01 20:07:43 +01:00
|
|
|
#include "arch/sparc/isa_traits.hh"
|
|
|
|
#include "base/loader/object_file.hh"
|
2016-11-09 21:27:40 +01:00
|
|
|
#include "mem/page_table.hh"
|
2007-11-29 09:00:02 +01:00
|
|
|
#include "sim/byteswap.hh"
|
2006-03-15 23:04:50 +01:00
|
|
|
#include "sim/process.hh"
|
2006-03-12 22:27:52 +01:00
|
|
|
|
2016-11-09 21:27:40 +01:00
|
|
|
class SparcProcess : public Process
|
2006-03-04 09:09:23 +01:00
|
|
|
{
|
2006-03-15 23:04:50 +01:00
|
|
|
protected:
|
2006-04-18 15:27:22 +02:00
|
|
|
|
2007-11-29 09:00:02 +01:00
|
|
|
const Addr StackBias;
|
|
|
|
|
2010-11-11 11:03:58 +01:00
|
|
|
// The locations of the fill and spill handlers
|
2006-10-25 23:49:41 +02:00
|
|
|
Addr fillStart, spillStart;
|
|
|
|
|
2016-11-09 21:27:40 +01:00
|
|
|
SparcProcess(ProcessParams * params, ObjectFile *objFile,
|
|
|
|
Addr _StackBias);
|
2007-11-29 09:00:02 +01:00
|
|
|
|
2010-08-17 14:17:06 +02:00
|
|
|
void initState();
|
2007-11-29 09:00:02 +01:00
|
|
|
|
|
|
|
template<class IntType>
|
|
|
|
void argsInit(int pageSize);
|
2006-03-04 09:09:23 +01:00
|
|
|
|
2006-03-15 23:04:50 +01:00
|
|
|
public:
|
|
|
|
|
2010-11-11 11:03:58 +01:00
|
|
|
// Handles traps which request services from the operating system
|
2015-07-20 16:15:21 +02:00
|
|
|
virtual void handleTrap(int trapNum, ThreadContext *tc, Fault *fault);
|
2006-04-18 15:27:22 +02:00
|
|
|
|
2010-11-11 11:03:58 +01:00
|
|
|
Addr readFillStart() { return fillStart; }
|
|
|
|
Addr readSpillStart() { return spillStart; }
|
2006-10-25 23:49:41 +02:00
|
|
|
|
2007-10-04 21:24:16 +02:00
|
|
|
virtual void flushWindows(ThreadContext *tc) = 0;
|
2009-02-27 18:22:14 +01:00
|
|
|
void setSyscallReturn(ThreadContext *tc, SyscallReturn return_value);
|
2006-03-15 23:04:50 +01:00
|
|
|
};
|
2006-03-04 09:09:23 +01:00
|
|
|
|
2016-11-09 21:27:40 +01:00
|
|
|
class Sparc32Process : public SparcProcess
|
2007-02-28 17:36:38 +01:00
|
|
|
{
|
|
|
|
protected:
|
|
|
|
|
2016-11-09 21:27:40 +01:00
|
|
|
Sparc32Process(ProcessParams * params, ObjectFile *objFile)
|
|
|
|
: SparcProcess(params, objFile, 0)
|
2007-02-28 17:36:38 +01:00
|
|
|
{
|
2017-03-01 20:07:43 +01:00
|
|
|
Addr brk_point = objFile->dataBase() + objFile->dataSize() +
|
|
|
|
objFile->bssSize();
|
|
|
|
brk_point = roundUp(brk_point, SparcISA::PageBytes);
|
|
|
|
|
|
|
|
// Reserve 8M for main stack.
|
|
|
|
Addr max_stack_size = 8 * 1024 * 1024;
|
|
|
|
|
2007-02-28 17:36:38 +01:00
|
|
|
// Set up stack. On SPARC Linux, stack goes from the top of memory
|
|
|
|
// downward, less the hole for the kernel address space.
|
2017-03-01 20:07:43 +01:00
|
|
|
Addr stack_base = 0xf0000000ULL;
|
|
|
|
|
|
|
|
// Set pointer for next thread stack.
|
|
|
|
Addr next_thread_stack_base = stack_base - max_stack_size;
|
2007-02-28 17:36:38 +01:00
|
|
|
|
|
|
|
// Set up region for mmaps.
|
2017-03-01 20:07:43 +01:00
|
|
|
Addr mmap_end = 0x70000000;
|
|
|
|
|
|
|
|
memState = std::make_shared<MemState>(brk_point, stack_base,
|
|
|
|
max_stack_size,
|
|
|
|
next_thread_stack_base,
|
|
|
|
mmap_end);
|
2007-02-28 17:36:38 +01:00
|
|
|
}
|
|
|
|
|
2010-08-17 14:17:06 +02:00
|
|
|
void initState();
|
2007-02-28 17:36:38 +01:00
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
void argsInit(int intSize, int pageSize);
|
|
|
|
|
2007-10-04 21:24:16 +02:00
|
|
|
void flushWindows(ThreadContext *tc);
|
2009-02-27 18:22:14 +01:00
|
|
|
|
2009-10-30 08:44:55 +01:00
|
|
|
SparcISA::IntReg getSyscallArg(ThreadContext *tc, int &i);
|
2013-02-19 11:56:06 +01:00
|
|
|
/// Explicitly import the otherwise hidden getSyscallArg
|
2016-11-09 21:27:40 +01:00
|
|
|
using Process::getSyscallArg;
|
2013-02-19 11:56:06 +01:00
|
|
|
|
2009-02-27 18:22:14 +01:00
|
|
|
void setSyscallArg(ThreadContext *tc, int i, SparcISA::IntReg val);
|
2007-02-28 17:36:38 +01:00
|
|
|
};
|
|
|
|
|
2016-11-09 21:27:40 +01:00
|
|
|
class Sparc64Process : public SparcProcess
|
2007-02-28 17:36:38 +01:00
|
|
|
{
|
|
|
|
protected:
|
|
|
|
|
2016-11-09 21:27:40 +01:00
|
|
|
Sparc64Process(ProcessParams * params, ObjectFile *objFile)
|
|
|
|
: SparcProcess(params, objFile, 2047)
|
2007-02-28 17:36:38 +01:00
|
|
|
{
|
2017-03-01 20:07:43 +01:00
|
|
|
Addr brk_point = objFile->dataBase() + objFile->dataSize() +
|
|
|
|
objFile->bssSize();
|
|
|
|
brk_point = roundUp(brk_point, SparcISA::PageBytes);
|
|
|
|
|
|
|
|
Addr max_stack_size = 8 * 1024 * 1024;
|
|
|
|
|
2007-02-28 17:36:38 +01:00
|
|
|
// Set up stack. On SPARC Linux, stack goes from the top of memory
|
|
|
|
// downward, less the hole for the kernel address space.
|
2017-03-01 20:07:43 +01:00
|
|
|
Addr stack_base = 0x80000000000ULL;
|
|
|
|
|
|
|
|
// Set pointer for next thread stack. Reserve 8M for main stack.
|
|
|
|
Addr next_thread_stack_base = stack_base - max_stack_size;
|
2007-02-28 17:36:38 +01:00
|
|
|
|
2016-03-17 18:29:32 +01:00
|
|
|
// Set up region for mmaps.
|
2017-03-01 20:07:43 +01:00
|
|
|
Addr mmap_end = 0xfffff80000000000ULL;
|
|
|
|
|
|
|
|
memState = std::make_shared<MemState>(brk_point, stack_base,
|
|
|
|
max_stack_size,
|
|
|
|
next_thread_stack_base,
|
|
|
|
mmap_end);
|
2007-02-28 17:36:38 +01:00
|
|
|
}
|
|
|
|
|
2010-08-17 14:17:06 +02:00
|
|
|
void initState();
|
2007-02-28 17:36:38 +01:00
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
void argsInit(int intSize, int pageSize);
|
|
|
|
|
2007-10-04 21:24:16 +02:00
|
|
|
void flushWindows(ThreadContext *tc);
|
2009-02-27 18:22:14 +01:00
|
|
|
|
2009-10-30 08:44:55 +01:00
|
|
|
SparcISA::IntReg getSyscallArg(ThreadContext *tc, int &i);
|
2013-02-19 11:56:06 +01:00
|
|
|
/// Explicitly import the otherwise hidden getSyscallArg
|
2016-11-09 21:27:40 +01:00
|
|
|
using Process::getSyscallArg;
|
2013-02-19 11:56:06 +01:00
|
|
|
|
2009-02-27 18:22:14 +01:00
|
|
|
void setSyscallArg(ThreadContext *tc, int i, SparcISA::IntReg val);
|
2007-02-28 17:36:38 +01:00
|
|
|
};
|
|
|
|
|
2014-08-28 17:11:44 +02:00
|
|
|
/* No architectural page table defined for this ISA */
|
|
|
|
typedef NoArchPageTable ArchPageTable;
|
|
|
|
|
2006-03-04 09:09:23 +01:00
|
|
|
#endif // __SPARC_PROCESS_HH__
|