From 096598c05a6c352bfd4b93adf06143a43a8f4e11 Mon Sep 17 00:00:00 2001 From: Gabe Black Date: Wed, 1 May 2019 21:43:09 -0700 Subject: arch, base, sim: Replace Copy(String)?(In|Out) with equivalent code. This expands those functions into code which extracts the virt proxy and then uses the appropriate method on it. This has two benefits. First, the Copy* functions where mostly redundant wrappers around the methods the proxy port already had. Second, using them forced a particular port which might not actually be what the user wanted. Change-Id: I62084631dd080061e3c74997125164f40da2d77c Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/18575 Reviewed-by: Jason Lowe-Power Maintainer: Jason Lowe-Power Tested-by: kokoro --- src/arch/generic/linux/threadinfo.hh | 43 +++++++++++------------------------- 1 file changed, 13 insertions(+), 30 deletions(-) (limited to 'src/arch/generic/linux/threadinfo.hh') diff --git a/src/arch/generic/linux/threadinfo.hh b/src/arch/generic/linux/threadinfo.hh index 1595da499..626de58e8 100644 --- a/src/arch/generic/linux/threadinfo.hh +++ b/src/arch/generic/linux/threadinfo.hh @@ -58,9 +58,7 @@ class ThreadInfo return false; } - CopyOut(tc, &data, addr, sizeof(T)); - - data = TheISA::gtoh(data); + data = tc->getVirtProxy().read(addr, TheISA::GuestByteOrder); return true; } @@ -98,29 +96,23 @@ class ThreadInfo // Note that in Linux 4.10 the thread_info struct will no longer have a // pointer to the task_struct for arm64. See: // https://patchwork.kernel.org/patch/9333699/ - int32_t offset; + int32_t offset = 0; if (!get_data("thread_info_task", offset)) return 0; if (!thread_info) thread_info = curThreadInfo(); - Addr addr; - CopyOut(tc, &addr, thread_info + offset, sizeof(addr)); - - return addr; + return tc->getVirtProxy().read(thread_info + offset); } int32_t curTaskPIDFromTaskStruct(Addr task_struct) { - int32_t offset; + int32_t offset = 0; if (!get_data("task_struct_pid", offset)) return -1; - int32_t pid; - CopyOut(tc, &pid, task_struct + offset, sizeof(pid)); - - return pid; + return tc->getVirtProxy().read(task_struct + offset); } int32_t @@ -132,14 +124,11 @@ class ThreadInfo int32_t curTaskTGIDFromTaskStruct(Addr task_struct) { - int32_t offset; + int32_t offset = 0; if (!get_data("task_struct_tgid", offset)) return -1; - int32_t tgid; - CopyOut(tc, &tgid, task_struct + offset, sizeof(tgid)); - - return tgid; + return tc->getVirtProxy().read(task_struct + offset); } int32_t @@ -151,16 +140,13 @@ class ThreadInfo int64_t curTaskStartFromTaskStruct(Addr task_struct) { - int32_t offset; + int32_t offset = 0; if (!get_data("task_struct_start_time", offset)) return -1; - int64_t data; // start_time is actually of type timespec, but if we just // grab the first long, we'll get the seconds out of it - CopyOut(tc, &data, task_struct + offset, sizeof(data)); - - return data; + return tc->getVirtProxy().read(task_struct + offset); } int64_t @@ -172,8 +158,8 @@ class ThreadInfo std::string curTaskNameFromTaskStruct(Addr task_struct) { - int32_t offset; - int32_t size; + int32_t offset = 0; + int32_t size = 0; if (!get_data("task_struct_comm", offset)) return "FailureIn_curTaskName"; @@ -182,7 +168,7 @@ class ThreadInfo return "FailureIn_curTaskName"; char buffer[size + 1]; - CopyStringOut(tc, buffer, task_struct + offset, size); + tc->getVirtProxy().readString(buffer, task_struct + offset, size); return buffer; } @@ -200,10 +186,7 @@ class ThreadInfo if (!get_data("task_struct_mm", offset)) return -1; - int32_t mm_ptr; - CopyOut(tc, &mm_ptr, task_struct + offset, sizeof(mm_ptr)); - - return mm_ptr; + return tc->getVirtProxy().read(task_struct + offset); } int32_t -- cgit v1.2.3