home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume26 / sysinfo-1.0 / part01 / os-bsd43.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-04-10  |  2.4 KB  |  120 lines

  1. /*
  2.  * Copyright (c) 1992 Michael A. Cooper.
  3.  * This software may be freely distributed provided it is not sold for 
  4.  * profit and the author is credited appropriately.
  5.  */
  6.  
  7. #ifndef lint
  8. static char *RCSid = "$Header: /src/common/usc/bin/sysinfo/RCS/os-bsd43.c,v 1.6 1992/04/26 23:32:06 mcooper Exp $";
  9. #endif
  10.  
  11. /*
  12.  * $Log: os-bsd43.c,v $
  13.  * Revision 1.6  1992/04/26  23:32:06  mcooper
  14.  * Add Copyright notice
  15.  *
  16.  * Revision 1.5  1992/04/17  23:27:51  mcooper
  17.  * Add support for ROM Version information (Sun only for now).
  18.  *
  19.  * Revision 1.4  1992/04/17  01:07:59  mcooper
  20.  * More de-linting
  21.  *
  22.  * Revision 1.3  1992/04/16  19:58:12  mcooper
  23.  * De-linting stuff.
  24.  *
  25.  * Revision 1.2  1992/04/15  02:04:16  mcooper
  26.  * Change GetMemoryStr() to GetMemory().
  27.  *
  28.  * Revision 1.1  1992/03/31  02:39:03  mcooper
  29.  * Initial revision
  30.  *
  31.  */
  32.  
  33.  
  34. /*
  35.  * 4.3BSD specific functions
  36.  */
  37.  
  38. #include <stdio.h>
  39. #include "system.h"
  40. #include "defs.h"
  41.  
  42. #include <sys/types.h>
  43. #include <nlist.h>
  44.  
  45. /*
  46.  * Get the system model name.  
  47.  * 4.3BSD (MtXinu) keeps a kernel variable "machineid" which
  48.  * is the type of machine as defined in <machine/cpu.h>.
  49.  */
  50. extern char *GetModelName()
  51. {
  52.     extern NAMETAB        ModelTab[];
  53.     extern struct nlist        MachineIDNL[];
  54.     static int            machineid;
  55.     register int        i;
  56.     kvm_t               *kd;
  57.  
  58.     if (!(kd = KVM_open(MachineIDNL))) {
  59.     if (Debug) Error("Cannot find MachineID symbol in kernel.");
  60.     return((char *) NULL);
  61.     }
  62.  
  63.     /*
  64.      * See if we got a valid entry
  65.      */
  66.     if (CheckNlist(&MachineIDNL[0]))
  67.     return((char *) NULL);
  68.  
  69.     if (KVM_read(kd, (u_long) MachineIDNL[0].n_value, (char *) &machineid,
  70.          sizeof(machineid))) {
  71.     if (Debug) Error("Cannot read machineid from kernel.");
  72.     return((char *) NULL);
  73.     }
  74.  
  75.     KVM_close(kd);
  76.  
  77.     for (i = 0; ModelTab[i].name; ++i)
  78.     if (ModelTab[i].value == machineid)
  79.         return(ModelTab[i].name);
  80.  
  81.     if (Debug)
  82.     printf("system model/type %d is unknown.\n", machineid);
  83.  
  84.     return((char *) NULL);
  85. }
  86.  
  87. /*
  88.  * Get kernel version string from kernel symbol "version".
  89.  */
  90. extern char *GetKernelVersionStr()
  91. {
  92.     return(GetKernelVersionFromVersion());
  93. }
  94.  
  95. /*
  96.  * Get amount of physical memory using kernel symbol "physmem".
  97.  */
  98. extern char *GetMemory()
  99. {
  100.     return(GetMemoryFromPhysmem());
  101. }
  102.  
  103. /*
  104.  * Get system serial number
  105.  */
  106. extern char *GetSerialNoStr()
  107. {
  108.     /* No support */
  109.     return((char *) NULL);
  110. }
  111.  
  112. /*
  113.  * Get ROM Version
  114.  */
  115. extern char *GetRomVer()
  116. {
  117.     /* No support */
  118.     return((char *) NULL);
  119. }
  120.