Add new port sysutils/cpuid: tool to dump x86 CPUID information.

WWW: http://www.etallen.com/cpuid.html

The package and the binary have been renamed to cpuid-etallen in order to
avoid conflict with misc/cpuid.

PR:		194826
Submitted by:	Uffe Jakobsen
This commit is contained in:
Max Brazhnikov 2014-12-09 22:07:14 +00:00
parent adae686ff4
commit b3893e6f33
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=374435
5 changed files with 118 additions and 0 deletions

View File

@ -149,6 +149,7 @@
SUBDIR += cpdup
SUBDIR += cpu
SUBDIR += cpuburn
SUBDIR += cpuid
SUBDIR += cpulimit
SUBDIR += cramfs
SUBDIR += crashme

34
sysutils/cpuid/Makefile Normal file
View File

@ -0,0 +1,34 @@
# Created by: uffe@uffe.org
# $FreeBSD$
PORTNAME= cpuid
PORTVERSION= 20140123
CATEGORIES= sysutils
MASTER_SITES= http://www.etallen.com/cpuid/
PKGNAMESUFFIX= ${CPUID_SUFFIX}
DISTNAME= ${PORTNAME}-${PORTVERSION}.src
MAINTAINER= uffe@uffe.org
COMMENT= Tool to dump x86 CPUID information about the CPU(s)
LICENSE= GPLv2
LICENSE_FILE= ${WRKSRC}/LICENSE
USES= gmake
ALL_TARGET= default
WRKSRC= ${WRKDIR}/${PORTNAME}-${PORTVERSION}
# Renamed to avoid conflict with misc/cpuid
CPUID_SUFFIX= -etallen
PLIST_FILES= bin/cpuid${CPUID_SUFFIX} \
man/man1/cpuid${CPUID_SUFFIX}.1.gz
post-patch:
${REINPLACE_CMD} 's,CFL=.*,& -pthread,' ${WRKSRC}/Makefile
do-install:
${INSTALL_PROGRAM} ${WRKSRC}/cpuid ${STAGEDIR}${PREFIX}/bin/cpuid${CPUID_SUFFIX}
${INSTALL_MAN} ${WRKSRC}/cpuid.man.gz ${STAGEDIR}${PREFIX}/man/man1/cpuid${CPUID_SUFFIX}.1.gz
.include <bsd.port.mk>

2
sysutils/cpuid/distinfo Normal file
View File

@ -0,0 +1,2 @@
SHA256 (cpuid-20140123.src.tar.gz) = b85aba5696d382f0dba8dc246bd42d09767089d6181a9cd0633d626f079d79ff
SIZE (cpuid-20140123.src.tar.gz) = 67882

View File

@ -0,0 +1,75 @@
--- cpuid.c.orig 2014-01-24 01:26:27 UTC
+++ cpuid.c
@@ -17,6 +17,8 @@
** 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
+#define CPUID_MAJOR 0
+
#define _GNU_SOURCE
#include <stdio.h>
#include <sys/types.h>
@@ -26,11 +28,14 @@
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
-#include <linux/major.h>
+//#include <linux/major.h>
#include <regex.h>
#include <getopt.h>
#include <sys/syscall.h>
+#include <pthread.h>
+#include <pthread_np.h>
+
typedef int boolean;
#define TRUE 1
#define FALSE 0
@@ -5877,7 +5882,8 @@ real_setup(unsigned int cpu,
= (1 << cpu % (sizeof(unsigned int)*8));
int status;
- status = syscall(__NR_sched_setaffinity, 0, sizeof(mask), &mask);
+ //status = syscall(__NR_sched_setaffinity, 0, sizeof(mask), &mask);
+ status = pthread_setaffinity_np(0, sizeof(mask), &mask);
if (status == -1) {
if (cpu > 0) {
if (errno == EINVAL) return -1;
@@ -5987,11 +5993,14 @@ static int real_get (int cpuid
: "a" (reg),
"c" (ecx));
} else {
- off64_t result;
- off64_t offset = ((off64_t)ecx << 32) + reg;
+ //off64_t result;
+ //off64_t offset = ((uint64_t)ecx << 32) + reg;
+ uint64_t result;
+ uint64_t offset = ((uint64_t)ecx << 32) + reg;
int status;
- result = lseek64(cpuid_fd, offset, SEEK_SET);
+ //result = lseek64(cpuid_fd, offset, SEEK_SET);
+ result = lseek(cpuid_fd, offset, SEEK_SET);
if (result == -1) {
if (quiet) {
return FALSE;
@@ -6432,7 +6441,8 @@ main(int argc,
};
boolean opt_one_cpu = FALSE;
- boolean opt_inst = FALSE;
+ //boolean opt_inst = FALSE;
+ boolean opt_inst = TRUE;
boolean opt_kernel = FALSE;
boolean opt_raw = FALSE;
boolean opt_debug = FALSE;
@@ -6508,7 +6518,8 @@ main(int argc,
}
// Default to -i. So use inst unless -k is specified.
- boolean inst = !opt_kernel;
+ //boolean inst = !opt_kernel;
+ boolean inst = TRUE;
if (opt_version) {
printf("cpuid version %s\n", XSTR(VERSION));

6
sysutils/cpuid/pkg-descr Normal file
View File

@ -0,0 +1,6 @@
Cpuid dumps detailed information about the CPU(s) gathered from the
CPUID instruction, and also determines the exact model of CPU(s).
It supports Intel, AMD, and VIA CPUs, as well as older Transmeta,
Cyrix, UMC, NexGen, Rise, and SiS CPUs.
WWW: http://www.etallen.com/cpuid.html