Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/usermode implement /proc/cpuinfo



details:   https://anonhg.NetBSD.org/src/rev/6b122dc5e946
branches:  trunk
changeset: 772036:6b122dc5e946
user:      jmcneill <jmcneill%NetBSD.org@localhost>
date:      Thu Dec 15 01:30:04 2011 +0000

description:
implement /proc/cpuinfo

diffstat:

 sys/arch/usermode/include/thunk.h           |   4 +++-
 sys/arch/usermode/usermode/procfs_machdep.c |   9 +++++----
 sys/arch/usermode/usermode/thunk.c          |  23 +++++++++++++++++++++--
 3 files changed, 29 insertions(+), 7 deletions(-)

diffs (90 lines):

diff -r ebd2c10d9fe5 -r 6b122dc5e946 sys/arch/usermode/include/thunk.h
--- a/sys/arch/usermode/include/thunk.h Thu Dec 15 01:25:41 2011 +0000
+++ b/sys/arch/usermode/include/thunk.h Thu Dec 15 01:30:04 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: thunk.h,v 1.39 2011/12/15 01:04:15 jmcneill Exp $ */
+/* $NetBSD: thunk.h,v 1.40 2011/12/15 01:30:04 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2011 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -136,6 +136,8 @@
 char * thunk_getenv(const char *);
 vaddr_t        thunk_get_vm_min_address(void);
 
+int    thunk_getcpuinfo(char *, int *);
+
 int    thunk_sdl_init(unsigned int, unsigned int, unsigned short);
 void * thunk_sdl_getfb(size_t);
 int    thunk_sdl_getchar(void);
diff -r ebd2c10d9fe5 -r 6b122dc5e946 sys/arch/usermode/usermode/procfs_machdep.c
--- a/sys/arch/usermode/usermode/procfs_machdep.c       Thu Dec 15 01:25:41 2011 +0000
+++ b/sys/arch/usermode/usermode/procfs_machdep.c       Thu Dec 15 01:30:04 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: procfs_machdep.c,v 1.2 2011/08/28 18:48:46 jmcneill Exp $ */
+/* $NetBSD: procfs_machdep.c,v 1.3 2011/12/15 01:30:04 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2011 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: procfs_machdep.c,v 1.2 2011/08/28 18:48:46 jmcneill Exp $");
+__RCSID("$NetBSD: procfs_machdep.c,v 1.3 2011/12/15 01:30:04 jmcneill Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -35,9 +35,10 @@
 
 #include <miscfs/procfs/procfs.h>
 
+#include <machine/thunk.h>
+
 int
 procfs_getcpuinfstr(char *bf, int *len)
 {
-       *len = 0;
-       return 0;
+       return thunk_getcpuinfo(bf, len);
 }
diff -r ebd2c10d9fe5 -r 6b122dc5e946 sys/arch/usermode/usermode/thunk.c
--- a/sys/arch/usermode/usermode/thunk.c        Thu Dec 15 01:25:41 2011 +0000
+++ b/sys/arch/usermode/usermode/thunk.c        Thu Dec 15 01:30:04 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: thunk.c,v 1.45 2011/12/15 01:04:14 jmcneill Exp $ */
+/* $NetBSD: thunk.c,v 1.46 2011/12/15 01:30:04 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2011 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -28,7 +28,7 @@
 
 #include <sys/cdefs.h>
 #ifdef __NetBSD__
-__RCSID("$NetBSD: thunk.c,v 1.45 2011/12/15 01:04:14 jmcneill Exp $");
+__RCSID("$NetBSD: thunk.c,v 1.46 2011/12/15 01:30:04 jmcneill Exp $");
 #endif
 
 #include <sys/types.h>
@@ -602,3 +602,22 @@
 
        return sigsuspend(&sigmask);
 }
+
+int
+thunk_getcpuinfo(char *cp, int *len)
+{
+       ssize_t rlen;
+       int fd;
+
+       fd = open("/proc/cpuinfo", O_RDONLY);
+       if (fd == -1)
+               return -1;
+       rlen = read(fd, cp, *len - 1);
+       close(fd);
+
+       if (rlen == -1)
+               return -1;
+
+       *len = rlen;
+       return 0;
+}



Home | Main Index | Thread Index | Old Index