qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] RFC: Read the cache information from /proc/self/auxv on PPC Linux
@ 2009-06-23 14:54 Filip Navara
  2009-06-23 15:47 ` malc
  0 siblings, 1 reply; 2+ messages in thread
From: Filip Navara @ 2009-06-23 14:54 UTC (permalink / raw)
  To: qemu-devel

[-- Attachment #1: Type: text/plain, Size: 485 bytes --]

Hello,

I'd really like to cleanup the code for SDL_main, but a prerequisite
is to change reading of cache information on PPC Linux. This patch is
based on suggestion by Hollis Blanchard. If ppc_init_cacheline_sizes
gets fixed on PPC Linux we will no longer need to pass the "env"
variable around and the code will be cleaner. Unfortunately I don't
have access to PPC Linux, so I can't really test if the patch works or
even compiles, so any help is appreciated.

Thanks,
Filip Navara

[-- Attachment #2: 0001-Read-the-cache-information-from-proc-self-auxv-on-PP.patch.txt --]
[-- Type: text/plain, Size: 1640 bytes --]

From ac63e41830ec555a36e05bd37c9718945b3c8e3b Mon Sep 17 00:00:00 2001
From: Filip Navara <filip.navara@gmail.com>
Date: Tue, 23 Jun 2009 16:47:24 +0200
Subject: [PATCH] Read the cache information from /proc/self/auxv on PPC Linux

---
 cache-utils.c |   24 +++++++++++++++---------
 1 files changed, 15 insertions(+), 9 deletions(-)

diff --git a/cache-utils.c b/cache-utils.c
index 45d62c9..1675905 100644
--- a/cache-utils.c
+++ b/cache-utils.c
@@ -16,6 +16,8 @@ static void ppc_init_cacheline_sizes(void)
 }
 
 #elif defined __linux__
+#include <unistd.h>
+#include <fcntl.h>
 
 #define QEMU_AT_NULL        0
 #define QEMU_AT_DCACHEBSIZE 19
@@ -23,16 +25,20 @@ static void ppc_init_cacheline_sizes(void)
 
 static void ppc_init_cacheline_sizes(char **envp)
 {
-    unsigned long *auxv;
-
-    while (*envp++);
-
-    for (auxv = (unsigned long *) envp; *auxv != QEMU_AT_NULL; auxv += 2) {
-        switch (*auxv) {
-        case QEMU_AT_DCACHEBSIZE: qemu_cache_conf.dcache_bsize = auxv[1]; break;
-        case QEMU_AT_ICACHEBSIZE: qemu_cache_conf.icache_bsize = auxv[1]; break;
-        default: break;
+    int fd;
+    unsigned long auxv[2];
+    
+    fd = open("/proc/self/auxv", O_RDONLY);
+    if (fd != -1) {
+        while (read(fd, auxv, sizeof(auxv)) == sizeof(auxv) &&
+               auxv[0] != QEMU_AT_NULL) {
+            switch (auxv[0]) {
+            case QEMU_AT_DCACHEBSIZE: qemu_cache_conf.dcache_bsize = auxv[1]; break;
+            case QEMU_AT_ICACHEBSIZE: qemu_cache_conf.icache_bsize = auxv[1]; break;
+            default: break;
+            }
         }
+        close(fd);
     }
 }
 
-- 
1.6.3.msysgit.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2009-06-23 15:47 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-06-23 14:54 [Qemu-devel] [PATCH] RFC: Read the cache information from /proc/self/auxv on PPC Linux Filip Navara
2009-06-23 15:47 ` malc

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).