This is os-alliant.c in view mode; [Download] [Up]
/* * 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-alliant.c,v 1.10 1992/11/24 04:05:57 mcooper Exp mcooper $"; #endif /* * $Log: os-alliant.c,v $ * Revision 1.10 1992/11/24 04:05:57 mcooper * New/cleaner KVM/nlist interface. * * Revision 1.9 1992/04/26 23:32:06 mcooper * Add Copyright notice * * Revision 1.8 1992/04/17 23:27:51 mcooper * Add support for ROM Version information (Sun only for now). * * Revision 1.7 1992/04/17 01:07:59 mcooper * More de-linting * * Revision 1.6 1992/04/15 02:04:16 mcooper * Change GetMemoryStr() to GetMemory(). * * Revision 1.5 1992/03/31 19:00:15 mcooper * A working version. * * Revision 1.4 1992/03/31 02:22:03 mcooper * Fix failed return value from CheckNlist(). * * Revision 1.3 1992/03/31 01:55:17 mcooper * Use new CheckNlist to check nlist success. * * Revision 1.2 1992/03/31 00:15:09 mcooper * Add error check for nlist.n_type. * * Revision 1.1 1992/03/01 23:28:16 mcooper * Initial revision * */ /* * Alliant specific functions */ #include <stdio.h> #include "system.h" #include "defs.h" #include <fcntl.h> #include <nlist.h> /* * All the wonderful global extern declarations */ #if defined(HAVE_USERETC) struct bpb *useretc = (struct bpb *)USERETC; #endif /* HAVE_USERETC */ #if defined(HAVE_MODELNUM) extern int modelnum; #endif /* HAVE_MODELNUM */ #if defined(HAVE_MEMORYSIZE) extern int memorysize; #endif /* HAVE_MEMORYSIZE */ #if defined(HAVE_SERIALNUM) extern int serialnum; #endif /* HAVE_SERIALNUM */ /* * Lookup a model value (val) and returns it's name. */ extern char *GetModelName() { register int i; register int Num = -1; extern NAMETAB ModelTab[]; #if defined(HAVE_MODELNUM) /* * Alliant 2800's have an external variable * called "modelnum". */ Num = modelnum; #endif /* HAVE_MODELNUM */ #if defined(HAVE_USERETC) /* * Alliant FX/80's have an external variable * called "useretc". */ Num = useretc->bp_model; #endif /* HAVE_USERETC */ for (i = 0; ModelTab[i].name; ++i) { if (ModelTab[i].value == Num) return(ModelTab[i].name); } return((char *) NULL); } /* * Get amount of memory. */ extern char *GetMemory() { static char Buf[BUFSIZ]; int Amount = -1; #if defined(HAVE_LIB_SYSCFG) int mem, ip, ce, det, att; lib_syscfg(&mem, &ip, &ce, &det, &att); Amount = mem; #endif /* HAVE_LIB_SYSCFG */ #if defined(HAVE_MEMORYSIZE) Amount = memorysize; #endif /* HAVE_MEMORYSIZE */ if (Amount > 0) { (void) sprintf(Buf, "%d MB", Amount); return(Buf); } else return((char *) NULL); } /* * Get kernel version string from kernel. */ extern char *GetKernelVersionStr() { struct nlist *nlptr; extern char VersionNameSYM[]; extern char VersionDateSYM[]; static char Version[BUFSIZ]; static char VerName[BUFSIZ], VerDate[BUFSIZ]; register char *p; kvm_t *kd; u_long nameaddr, dateaddr; Version[0] = C_NULL; if (!(kd = KVMopen())) return((char *) NULL); if (nlptr = KVMnlist(kd, VersionNameSYM, (struct nlist *)NULL)) { if (CheckNlist(nlptr)) return((char *) NULL); if (KVMread(kd, nlptr->n_value, (char *) VerName, sizeof(VerName))) { if (Debug) Error("GetKernelVersionStr() read versionname failed."); return((char *) NULL); } } if (nlptr = KVMnlist(kd, VersionDateSYM, (struct nlist *)NULL)) { if (CheckNlist(nlptr)) return((char *) NULL); if (KVMread(kd, nlptr->n_value, (char *) VerDate, sizeof(VerDate))) { if (Debug) Error("GetKernelVersionStr() read versiondate failed."); return((char *) NULL); } } if (kd) KVMclose(kd); /* * Zap trailing white space */ p = VerName; p = p + strlen(VerName) - 1; while (*p == ' ') { *p = C_NULL; *--p; } (void) sprintf(Version, "%s: %s", VerName, VerDate); return(Version); } /* * Get system serial number. */ extern char *GetSerialNoStr() { #if defined(HAVE_SERIALNUM) /* * Use global variable "serialnum" */ return(itoa(serialnum)); #endif /* HAVE_SERIALNUM */ #if defined(HAVE_USERETC) /* * Use global variable "useretc" */ return(itoa(useretc->bp_serialnum)); #endif /* HAVE_USERETC */ } /* * Get OS Version string */ extern char *GetOSVersionStr() { return(GetOSVersionFromKernVer()); } /* * Get ROM Version */ extern char *GetRomVer() { /* No support */ return((char *) NULL); }
These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.