tru64-unix-managers (formerly alpha-osf-managers) (1994-2012)
 help / color / mirror / Atom feed
* [SUMMARY] pinfo/psrinfo from within C
@ 1999-01-13  4:00 Paul Tyler
  0 siblings, 0 replies; only message in thread
From: Paul Tyler @ 1999-01-13  4:00 UTC (permalink / raw)
  To: tru64-unix-managers

Thanks to the quick reply from someone who didn't want to be named.

I was simply looking for the wrong thing.  I wanted the GSI_PROC_TYPE
option to getsysinfo.  The final code is:


#include <stdio.h>
#include <unistd.h>
#include <sys/sysinfo.h>
#include <machine/hal_sysinfo.h>
#include <machine/cpuconf.h>

int main(int argc,char *argv[])
{
	
	int	status=0;
	long	buf;
	int	st=0;
	char	*str;

	status = getsysinfo(GSI_PROC_TYPE, &buf, sizeof(buf), st, NULL,NULL);

	buf = buf & 0xffff;
	CPU_TYPE_TO_TEXT(buf,str);
	printf("status = 0, start = %d\n",st);
	printf("\tcpu type = %d (%s)\n",buf,str);
}

The original mail follows.

Paul Tyler

>   Sorry about this.  I know it isn't directly about system admin but hopefully
>   someone can help.
>   
>   I've been trying to write some C code to determine the CPU version.
>   (As pinfo -v does.)  Using a getsysinfo system call I can get a number
>   which seems to be different for different CPU types but which doesn't
>   relate to the values in /usr/include/machine/hal/cpuconf.h.  Does
>   anyone know what the return codes should be?  I get a type of 56 for an
>   EV5.6 (21164A) and 37 for a EV4 (21064).  The include file indicates
>   these should be 7 and 2 respectively.  Any insight would be appreciated.
>   
>   The C code follows:
>   
>   #include <stdio.h>
>   #include <unistd.h>
>   #include <sys/sysinfo.h>
>   #include <machine/hal_sysinfo.h>
>   #include <machine/hal/cpuconf.h>
>   
>   int main(int argc,char *argv[])
>   {
>   	
>   	int	status=0;
>   	struct cpu_info	buf;
>   	int	st=0;
>   
>   	status = getsysinfo(GSI_CPU_INFO, &buf, sizeof(buf), st, NULL,NULL);
>   
>   	printf("status = 0, start = %d\n",st);
>   	printf("\tcpu type = %d\n",buf.cpu_type);
>   	printf("\tno cpus = %d\n",buf.ncpus);
>   }
>   
>   
>   Thanks
>   
>   Paul Tyler
>   

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~1999-01-13  4:00 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1999-01-13  4:00 [SUMMARY] pinfo/psrinfo from within C Paul Tyler

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox