syscall_emul.hh (10496:0a5a8ecd0ec6) | syscall_emul.hh (10497:73a59d5e0923) |
---|---|
1/* 2 * Copyright (c) 2012-2013 ARM Limited 3 * All rights reserved 4 * 5 * The license below extends only to copyright in the software and shall 6 * not be construed as granting a license to any other intellectual 7 * property including but not limited to intellectual property relating 8 * to a hardware implementation of the functionality of the software --- 61 unchanged lines hidden (view full) --- 70#include "base/misc.hh" 71#include "base/trace.hh" 72#include "base/types.hh" 73#include "config/the_isa.hh" 74#include "cpu/base.hh" 75#include "cpu/thread_context.hh" 76#include "debug/SyscallVerbose.hh" 77#include "mem/page_table.hh" | 1/* 2 * Copyright (c) 2012-2013 ARM Limited 3 * All rights reserved 4 * 5 * The license below extends only to copyright in the software and shall 6 * not be construed as granting a license to any other intellectual 7 * property including but not limited to intellectual property relating 8 * to a hardware implementation of the functionality of the software --- 61 unchanged lines hidden (view full) --- 70#include "base/misc.hh" 71#include "base/trace.hh" 72#include "base/types.hh" 73#include "config/the_isa.hh" 74#include "cpu/base.hh" 75#include "cpu/thread_context.hh" 76#include "debug/SyscallVerbose.hh" 77#include "mem/page_table.hh" |
78#include "mem/se_translating_port_proxy.hh" | |
79#include "sim/byteswap.hh" 80#include "sim/emul_driver.hh" 81#include "sim/process.hh" | 78#include "sim/byteswap.hh" 79#include "sim/emul_driver.hh" 80#include "sim/process.hh" |
81#include "sim/syscall_emul_buf.hh" |
|
82#include "sim/syscallreturn.hh" 83#include "sim/system.hh" 84 85/// 86/// System call descriptor. 87/// 88class SyscallDesc { 89 --- 22 unchanged lines hidden (view full) --- 112 { 113 } 114 115 /// Emulate the syscall. Public interface for calling through funcPtr. 116 void doSyscall(int callnum, LiveProcess *proc, ThreadContext *tc); 117}; 118 119 | 82#include "sim/syscallreturn.hh" 83#include "sim/system.hh" 84 85/// 86/// System call descriptor. 87/// 88class SyscallDesc { 89 --- 22 unchanged lines hidden (view full) --- 112 { 113 } 114 115 /// Emulate the syscall. Public interface for calling through funcPtr. 116 void doSyscall(int callnum, LiveProcess *proc, ThreadContext *tc); 117}; 118 119 |
120class BaseBufferArg { 121 122 public: 123 124 BaseBufferArg(Addr _addr, int _size) : addr(_addr), size(_size) 125 { 126 bufPtr = new uint8_t[size]; 127 // clear out buffer: in case we only partially populate this, 128 // and then do a copyOut(), we want to make sure we don't 129 // introduce any random junk into the simulated address space 130 memset(bufPtr, 0, size); 131 } 132 133 virtual ~BaseBufferArg() { delete [] bufPtr; } 134 135 // 136 // copy data into simulator space (read from target memory) 137 // 138 virtual bool copyIn(SETranslatingPortProxy &memproxy) 139 { 140 memproxy.readBlob(addr, bufPtr, size); 141 return true; // no EFAULT detection for now 142 } 143 144 // 145 // copy data out of simulator space (write to target memory) 146 // 147 virtual bool copyOut(SETranslatingPortProxy &memproxy) 148 { 149 memproxy.writeBlob(addr, bufPtr, size); 150 return true; // no EFAULT detection for now 151 } 152 153 protected: 154 Addr addr; 155 int size; 156 uint8_t *bufPtr; 157}; 158 159 160class BufferArg : public BaseBufferArg 161{ 162 public: 163 BufferArg(Addr _addr, int _size) : BaseBufferArg(_addr, _size) { } 164 void *bufferPtr() { return bufPtr; } 165}; 166 167template <class T> 168class TypedBufferArg : public BaseBufferArg 169{ 170 public: 171 // user can optionally specify a specific number of bytes to 172 // allocate to deal with those structs that have variable-size 173 // arrays at the end 174 TypedBufferArg(Addr _addr, int _size = sizeof(T)) 175 : BaseBufferArg(_addr, _size) 176 { } 177 178 // type case 179 operator T*() { return (T *)bufPtr; } 180 181 // dereference operators 182 T &operator*() { return *((T *)bufPtr); } 183 T* operator->() { return (T *)bufPtr; } 184 T &operator[](int i) { return ((T *)bufPtr)[i]; } 185}; 186 | |
187////////////////////////////////////////////////////////////////////// 188// 189// The following emulation functions are generic enough that they 190// don't need to be recompiled for different emulated OS's. They are 191// defined in sim/syscall_emul.cc. 192// 193////////////////////////////////////////////////////////////////////// 194 --- 1298 unchanged lines hidden --- | 120////////////////////////////////////////////////////////////////////// 121// 122// The following emulation functions are generic enough that they 123// don't need to be recompiled for different emulated OS's. They are 124// defined in sim/syscall_emul.cc. 125// 126////////////////////////////////////////////////////////////////////// 127 --- 1298 unchanged lines hidden --- |