summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Sandberg <andreas@sandberg.pp.se>2013-09-30 09:37:17 +0200
committerAndreas Sandberg <andreas@sandberg.pp.se>2013-09-30 09:37:17 +0200
commit3af2d8eab0e5b1ba4e936291b01895cc82fb124e (patch)
treeaf4b89fa6548956cabaa9f921e279c06375d9a65
parent30841926a3de0895152df31ce9294233db59be76 (diff)
downloadgem5-3af2d8eab0e5b1ba4e936291b01895cc82fb124e.tar.xz
x86: Add limited support for extracting function call arguments
Add support for extracting the first 6 64-bit integer argumements to a function call in X86ISA::getArgument().
-rw-r--r--src/arch/x86/utility.cc21
1 files changed, 19 insertions, 2 deletions
diff --git a/src/arch/x86/utility.cc b/src/arch/x86/utility.cc
index 7f5ae980a..41f5aee0b 100644
--- a/src/arch/x86/utility.cc
+++ b/src/arch/x86/utility.cc
@@ -51,8 +51,25 @@ namespace X86ISA {
uint64_t
getArgument(ThreadContext *tc, int &number, uint16_t size, bool fp)
{
- panic("getArgument() not implemented for x86!\n");
- M5_DUMMY_RETURN
+ if (!FullSystem) {
+ panic("getArgument() only implemented for full system mode.\n");
+ } else if (fp) {
+ panic("getArgument(): Floating point arguments not implemented\n");
+ } else if (size != 8) {
+ panic("getArgument(): Can only handle 64-bit arguments.\n");
+ }
+
+ // The first 6 integer arguments are passed in registers, the rest
+ // are passed on the stack.
+ const int int_reg_map[] = {
+ INTREG_RDI, INTREG_RSI, INTREG_RDX,
+ INTREG_RCX, INTREG_R8, INTREG_R9
+ };
+ if (number < sizeof(int_reg_map) / sizeof(*int_reg_map)) {
+ return tc->readIntReg(int_reg_map[number]);
+ } else {
+ panic("getArgument(): Don't know how to handle stack arguments.\n");
+ }
}
void initCPU(ThreadContext *tc, int cpuId)