43 #include "debug/Stack.hh" 45 #include "params/Process.hh" 64 fatal_if(params->useArchPT,
"Arch page tables not implemented.");
76 warn(
"Software breakpoint encountered at pc %#x.\n", pc.
pc());
79 warn(
"Software signaled a division by zero at pc %#x.\n", pc.
pc());
85 warn(
"Ignoring process request for clean register " 86 "windows at pc %#x.\n", pc.
pc());
89 warn(
"Software signaled a range check at pc %#x.\n", pc.
pc());
92 warn(
"Ignoring process request for os assisted unaligned accesses " 93 "at pc %#x.\n", pc.
pc());
96 warn(
"Software signaled an integer overflow at pc %#x.\n", pc.
pc());
99 warn(
"Ignoring process request to get the integer condition codes " 100 "at pc %#x.\n", pc.
pc());
103 warn(
"Ignoring process request to set the integer condition codes " 104 "at pc %#x.\n", pc.
pc());
107 panic(
"Unimplemented trap to operating system: trap number %#x.\n", trapNum);
189 template<
class IntType>
193 int intSize =
sizeof(IntType);
209 M5_HWCAP_SPARC_FLUSH = 1,
210 M5_HWCAP_SPARC_STBAR = 2,
211 M5_HWCAP_SPARC_SWAP = 4,
212 M5_HWCAP_SPARC_MULDIV = 8,
213 M5_HWCAP_SPARC_V9 = 16,
217 M5_HWCAP_SPARC_ULTRA3 = 32
220 const int64_t hwcap =
221 M5_HWCAP_SPARC_FLUSH |
222 M5_HWCAP_SPARC_STBAR |
223 M5_HWCAP_SPARC_SWAP |
224 M5_HWCAP_SPARC_MULDIV |
226 M5_HWCAP_SPARC_ULTRA3;
270 int file_name_size = filename.size() + 1;
272 int env_data_size = 0;
273 for (
int i = 0;
i <
envp.size(); ++
i) {
274 env_data_size +=
envp[
i].size() + 1;
276 int arg_data_size = 0;
277 for (
int i = 0;
i <
argv.size(); ++
i) {
278 arg_data_size +=
argv[
i].size() + 1;
282 int base_info_block_size =
283 sentry_size + file_name_size + env_data_size + arg_data_size;
285 int info_block_size =
roundUp(base_info_block_size, align);
287 int info_block_padding = info_block_size - base_info_block_size;
290 int aux_array_size = intSize * 2 * (auxv.size() + 1);
292 int envp_array_size = intSize * (
envp.size() + 1);
293 int argv_array_size = intSize * (
argv.size() + 1);
295 int argc_size = intSize;
296 int window_save_size = intSize * 16;
308 int aligned_partial_size =
roundUp(frame_size, align);
309 int aux_padding = aligned_partial_size - frame_size;
325 IntType sentry_base =
memState->getStackBase() - sentry_size;
326 IntType file_name_base = sentry_base - file_name_size;
327 IntType env_data_base = file_name_base - env_data_size;
328 IntType arg_data_base = env_data_base - arg_data_size;
329 IntType auxv_array_base = arg_data_base -
330 info_block_padding - aux_array_size - aux_padding;
331 IntType envp_array_base = auxv_array_base - envp_array_size;
332 IntType argv_array_base = envp_array_base - argv_array_size;
333 IntType argc_base = argv_array_base - argc_size;
335 IntType window_save_base = argc_base - window_save_size;
338 DPRINTF(Stack,
"The addresses of items on the initial stack:\n");
339 DPRINTF(Stack,
"%#x - sentry NULL\n", sentry_base);
340 DPRINTF(Stack,
"filename = %s\n", filename);
341 DPRINTF(Stack,
"%#x - file name\n", file_name_base);
342 DPRINTF(Stack,
"%#x - env data\n", env_data_base);
343 DPRINTF(Stack,
"%#x - arg data\n", arg_data_base);
344 DPRINTF(Stack,
"%#x - auxv array\n", auxv_array_base);
345 DPRINTF(Stack,
"%#x - envp array\n", envp_array_base);
346 DPRINTF(Stack,
"%#x - argv array\n", argv_array_base);
347 DPRINTF(Stack,
"%#x - argc \n", argc_base);
348 DPRINTF(Stack,
"%#x - window save\n", window_save_base);
351 assert(window_save_base ==
memState->getStackMin());
356 IntType argc =
argv.size();
357 IntType guestArgc =
htobe(argc);
360 uint64_t sentry_NULL = 0;
367 Addr auxv_array_end = auxv_array_base;
368 for (
const auto &aux: auxv) {
370 auxv_array_end +=
sizeof(aux);
376 auxv_array_end +=
sizeof(zero);
411 SparcProcess::argsInit<uint64_t>(pageSize);
423 SparcProcess::argsInit<uint32_t>(pageSize);
439 CWP = (CWP + Cansave + 2) %
NWindows;
440 while (
NWindows - 2 - Cansave != 0) {
442 panic(
"Otherwin non-zero.\n");
449 regVal =
htobe(regVal);
451 sp + (
index - 16) * 4, (uint8_t *)®Val, 4)) {
452 warn(
"Failed to save register to the stack when " 453 "flushing windows.\n");
474 CWP = (CWP + Cansave + 2) %
NWindows;
475 while (
NWindows - 2 - Cansave != 0) {
477 panic(
"Otherwin non-zero.\n");
484 regVal =
htobe(regVal);
486 sp + 2047 + (
index - 16) * 8, (uint8_t *)®Val, 8)) {
487 warn(
"Failed to save register to the stack when " 488 "flushing windows.\n");
528 val =
bits(val, 31, 0);
536 val =
bits(val, 31, 0);
#define panic(...)
This implements a cprintf based panic() function.
virtual void setMiscReg(RegIndex misc_reg, RegVal val)=0
Addr programHeaderTable()
const std::string & name()
void flushWindows(ThreadContext *tc) override
virtual bool tryWriteBlob(Addr addr, const void *p, int size) const
Write size bytes from p to address.
virtual TheISA::PCState pcState() const =0
virtual RegVal readIntReg(RegIndex reg_idx) const =0
bool successful() const
Was the system call successful?
std::vector< ContextID > contextIds
void writeString(Addr addr, const char *str) const
Same as tryWriteString, but insists on success.
void argsInit(int pageSize)
virtual void setMiscRegNoEffect(RegIndex misc_reg, RegVal val)=0
void allocateMem(Addr vaddr, int64_t size, bool clobber=false)
SparcProcess(ProcessParams *params, ObjectFile *objFile, Addr _StackBias)
SETranslatingPortProxy initVirtMem
const MachInst fillHandler64[numFillInsts]
virtual PortProxy & getVirtProxy()=0
Overload hash function for BasicBlockRange type.
void initState() override
initState() is called on each SimObject when not restoring from a checkpoint.
T roundUp(const T &val, const U &align)
This function is used to align addresses in memory.
std::shared_ptr< MemState > memState
void setSyscallReturn(ThreadContext *tc, SyscallReturn return_value) override
ThreadContext is the external interface to all thread state for anything outside of the CPU...
int errnoValue() const
The errno value.
const ByteOrder GuestByteOrder
ThreadContext * getThreadContext(ContextID tid) const
void flushWindows(ThreadContext *tc) override
void align(const scfx_rep &lhs, const scfx_rep &rhs, int &new_wp, int &len_mant, scfx_mant_ref &lhs_mant, scfx_mant_ref &rhs_mant)
void writeBlob(Addr addr, const void *p, int size) const
Same as tryWriteBlob, but insists on success.
void copyStringArray(std::vector< std::string > &strings, AddrType array_ptr, AddrType data_ptr, const ByteOrder bo, PortProxy &memProxy)
virtual void flushWindows(ThreadContext *tc)=0
#define fatal_if(cond,...)
Conditional fatal macro that checks the supplied condition and only causes a fatal error if the condi...
const RegIndex StackPointerReg
T roundDown(const T &val, const U &align)
This function is used to align addresses in memory.
std::vector< std::string > envp
void initState() override
initState() is called on each SimObject when not restoring from a checkpoint.
virtual void setIntReg(RegIndex reg_idx, RegVal val)=0
RegVal getSyscallArg(ThreadContext *tc, int &i) override
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
int64_t returnValue() const
The return value.
const MachInst spillHandler32[numSpillInsts]
void argsInit(int intSize, int pageSize)
const MachInst fillHandler32[numFillInsts]
Ancillary State Registers.
uint16_t programHeaderSize()
RegVal getSyscallArg(ThreadContext *tc, int &i) override
virtual RegVal readMiscRegNoEffect(RegIndex misc_reg) const =0
Declarations of a non-full system Page Table.
uint16_t programHeaderCount()
static const int FirstArgumentReg
virtual void handleTrap(int trapNum, ThreadContext *tc, Fault *fault)
void initState() override
initState() is called on each SimObject when not restoring from a checkpoint.
void argsInit(int intSize, int pageSize)
void write(Addr address, const T &data) const
Write object T to address.
const RegIndex ReturnValueReg
std::vector< std::string > argv
This class represents the return value from an emulated system call, including any errno setting...
T bits(T val, int first, int last)
Extract the bitfield from position 'first' to 'last' (inclusive) from 'val' and right justify it...
virtual RegVal readMiscReg(RegIndex misc_reg)=0
std::shared_ptr< FaultBase > Fault
const MachInst spillHandler64[numSpillInsts]
void initState() override
initState() is called on each SimObject when not restoring from a checkpoint.
Floating Point Status Register.