Module Name: src Committed By: jmcneill Date: Thu Dec 15 01:30:04 UTC 2011
Modified Files: src/sys/arch/usermode/include: thunk.h src/sys/arch/usermode/usermode: procfs_machdep.c thunk.c Log Message: implement /proc/cpuinfo To generate a diff of this commit: cvs rdiff -u -r1.39 -r1.40 src/sys/arch/usermode/include/thunk.h cvs rdiff -u -r1.2 -r1.3 src/sys/arch/usermode/usermode/procfs_machdep.c cvs rdiff -u -r1.45 -r1.46 src/sys/arch/usermode/usermode/thunk.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/arch/usermode/include/thunk.h diff -u src/sys/arch/usermode/include/thunk.h:1.39 src/sys/arch/usermode/include/thunk.h:1.40 --- src/sys/arch/usermode/include/thunk.h:1.39 Thu Dec 15 01:04:15 2011 +++ src/sys/arch/usermode/include/thunk.h Thu Dec 15 01:30:04 2011 @@ -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 <jmcne...@invisible.ca> @@ -136,6 +136,8 @@ int thunk_idle(void); 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); Index: src/sys/arch/usermode/usermode/procfs_machdep.c diff -u src/sys/arch/usermode/usermode/procfs_machdep.c:1.2 src/sys/arch/usermode/usermode/procfs_machdep.c:1.3 --- src/sys/arch/usermode/usermode/procfs_machdep.c:1.2 Sun Aug 28 18:48:46 2011 +++ src/sys/arch/usermode/usermode/procfs_machdep.c Thu Dec 15 01:30:04 2011 @@ -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 <jmcne...@invisible.ca> @@ -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 @@ __RCSID("$NetBSD: procfs_machdep.c,v 1.2 #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); } Index: src/sys/arch/usermode/usermode/thunk.c diff -u src/sys/arch/usermode/usermode/thunk.c:1.45 src/sys/arch/usermode/usermode/thunk.c:1.46 --- src/sys/arch/usermode/usermode/thunk.c:1.45 Thu Dec 15 01:04:14 2011 +++ src/sys/arch/usermode/usermode/thunk.c Thu Dec 15 01:30:04 2011 @@ -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 <jmcne...@invisible.ca> @@ -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 @@ thunk_idle(void) 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; +}