home *** CD-ROM | disk | FTP | other *** search
- /*
- * Copyright (c) 1992 Michael A. Cooper.
- * This software may be freely distributed provided it is not sold for
- * profit and the author is credited appropriately.
- */
-
- #ifndef lint
- static char *RCSid = "$Header: /src/common/usc/bin/sysinfo/RCS/os-mach.c,v 1.4 1992/04/26 23:32:06 mcooper Exp $";
- #endif
-
- /*
- * $Log: os-mach.c,v $
- * Revision 1.4 1992/04/26 23:32:06 mcooper
- * Add Copyright notice
- *
- * Revision 1.3 1992/04/17 01:07:59 mcooper
- * More de-linting
- *
- * Revision 1.2 1992/03/22 01:05:09 mcooper
- * Major cleanup and re-org.
- *
- * Revision 1.1 1992/03/01 23:28:16 mcooper
- * Initial revision
- *
- */
-
- /*
- * Mach specific functions
- */
-
- #include <stdio.h>
- #include "system.h"
- #include "defs.h"
-
- #if defined(HAVE_HOST_INFO)
- #include <sys/host_info.h>
-
- /*
- * Use the host_info() call to obtain type of CPU.
- */
- extern char *GetCpuTypeFromHostInfo()
- {
- extern NAMETAB CpuTypeTab[];
- struct host_basic_info basic_info;
- unsigned int count = HOST_BASIC_INFO_COUNT;
- register int i;
-
- if (host_info(host_self(), HOST_BASIC_INFO,
- (host_info_t) &basic_info, &count) != KERN_SUCCESS) {
- return((char *)NULL);
- }
-
- for (i = 0; CpuTypeTab[i].name; ++i) {
- if (CpuTypeTab[i].value == basic_info.cpu_type)
- return(CpuTypeTab[i].name);
- }
-
- return((char *) NULL);
- }
-
- /*
- * Use the host_info() call to obtain the model of CPU.
- */
- extern char *GetModelFromHostInfo()
- {
- extern NAMETAB ModelTabMach[];
- struct host_basic_info basic_info;
- unsigned int count = HOST_BASIC_INFO_COUNT;
- register int i;
-
- if (host_info(host_self(), HOST_BASIC_INFO,
- (host_info_t) &basic_info, &count) != KERN_SUCCESS) {
- return((char *)NULL);
- }
-
- for (i = 0; ModelTabMach[i].name; ++i) {
- if (ModelTabMach[i].value == basic_info.cpu_subtype)
- return(ModelTabMach[i].name);
- }
-
- return((char *) NULL);
- }
-
- /*
- * Get our application architecture name.
- */
- extern char *GetAppArchFromHostInfo()
- {
- return(GetCpuTypeFromHostInfo());
- }
-
- /*
- * Get our kernel architecture name.
- */
- extern char *GetKernArchFromHostInfo()
- {
- return(GetCpuTypeFromHostInfo());
- }
-
- /*
- * Get amount of memory.
- */
- extern char *GetMemoryFromHostInfo()
- {
- struct host_basic_info BasicInfo;
- unsigned int count = HOST_BASIC_INFO_COUNT;
- static char Buf[BUFSIZ];
- int Amount = -1;
-
- if (host_info(host_self(), HOST_BASIC_INFO,
- (host_info_t) &BasicInfo, &count) == KERN_SUCCESS) {
- Amount = BasicInfo.memory_size / MBYTES;
- (void) sprintf(Buf, "%d MB", Amount);
- return(Buf);
- } else
- return((char *) NULL);
- }
-
- /*
- * Get kernel version string.
- */
- extern char *GetKernelVersionFromHostInfo()
- {
- static char Version[BUFSIZ];
- register char *p;
-
- Version[0] = C_NULL;
- if (host_kernel_version(host_self(), Version) != KERN_SUCCESS) {
- if (Debug) Error("host_kernel_version() failed: %s.\n", SYSERR);
- }
-
- #if defined(KERNSTR_END)
- if (Version[0])
- if ((p = index(Version, KERNSTR_END)) != NULL)
- *p = C_NULL;
- #endif /* KERNSTR_END */
-
- return((Version[0]) ? Version : (char *) NULL);
- }
-
- /*
- * Get OS version
- */
- extern char *GetOSVersionFromHostInfo()
- {
- static char Buf[BUFSIZ];
- struct machine_info Info;
-
- if (xxx_host_info(host_self(), (machine_info_t) &Info) == KERN_SUCCESS) {
- (void) sprintf(Buf, "%d.%d", Info.major_version, Info.minor_version);
- return(Buf);
- }
-
- return((char *) NULL);
- }
-
- #endif /* HAVE_HOST_INFO */
-