home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-385-Vol-1of3.iso / d / ddx-mips.zip / MIPSOSBS.C < prev    next >
C/C++ Source or Header  |  1992-04-07  |  3KB  |  117 lines

  1.  
  2. /*
  3.  * $XConsortium$
  4.  *
  5.  * Copyright 1991 MIPS Computer Systems, Inc.
  6.  *
  7.  * Permission to use, copy, modify, distribute, and sell this software and its
  8.  * documentation for any purpose is hereby granted without fee, provided that
  9.  * the above copyright notice appear in all copies and that both that
  10.  * copyright notice and this permission notice appear in supporting
  11.  * documentation, and that the name of MIPS not be used in advertising or
  12.  * publicity pertaining to distribution of the software without specific,
  13.  * written prior permission.  MIPS makes no representations about the
  14.  * suitability of this software for any purpose.  It is provided "as is"
  15.  * without express or implied warranty.
  16.  *
  17.  * MIPS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
  18.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL MIPS
  19.  * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  20.  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
  21.  * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 
  22.  * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  23.  */
  24. #ident    "$Header: mipsOsBSD.c,v 1.5 92/04/06 21:04:19 dd Exp $"
  25.  
  26. /*
  27.  * OS support code which requires bsd43 include files
  28.  */
  29.  
  30. #include <bsd43/sys/types.h>
  31. #include <bsd43/syscall.h>
  32. #include <bsd43/sysmips.h>
  33. #include <bsd43/mips/cpu_board.h>
  34. #if !defined(BRDTYPE_R4XXX) && defined(BRDTYPE_XXXXXX)
  35. #define    BRDTYPE_R4XXX    BRDTYPE_XXXXXX
  36. #endif
  37. #undef FID
  38. #include <bsd43/mips/debug.h>
  39. #include <bsd43/mips/hwconf.h>
  40.  
  41. #include <bsd43/sys/file.h>
  42.  
  43. #include <bsd43/sys/time.h>
  44.  
  45. #include "mips.h"
  46.  
  47.  
  48. #ifdef SYSV
  49. #define    hwconf(option,conf) \
  50.     (syscall(BSD43_(SYS_sysmips), BSD43_(MIPS_HWCONF), \
  51.     BSD43_(option), (conf)))
  52.  
  53. #define    kopt(option,value,op) \
  54.     (syscall(BSD43_(SYS_sysmips), BSD43_(MIPS_KOPT), \
  55.     (option), (value), BSD43_(op), 0, 0))
  56. #endif /* SYSV */
  57.  
  58.  
  59. cpubd()
  60. {
  61.     struct bsd43_(hw_config) Conf;
  62.     int type = -1;
  63.  
  64.     if (hwconf(HWCONF_GET,&Conf) < 0)
  65.         return type;
  66.  
  67.     switch (Conf.cpubd_type) {
  68.     case BRDTYPE_I2000:
  69.     case BRDTYPE_I2000S:
  70.         type = RS2030;
  71.         break;
  72.     case BRDTYPE_R3030:
  73.         type = RS3230;
  74.         break;
  75. #ifdef BRDTYPE_R4XXX
  76.     case BRDTYPE_R4XXX:
  77.         type = RS4000;
  78.         break;
  79. #endif /* BRDTYPE_R4XXX */
  80.     }
  81.     return type;
  82. }
  83.  
  84. char *
  85. getkvar(name)
  86.     char *name;
  87. {
  88.     int addr;
  89.     int fd;
  90.     char *bp = 0;
  91.     static char buf[16];
  92.  
  93.     if ((addr = kopt(name, 0, KOPT_GET)) != -1 &&
  94.         addr != 0 &&
  95.         (fd = open("/dev/kmem", O_RDONLY)) >= 0) {
  96.         addr &= 0x7fffffff;
  97.         bzero(buf, sizeof buf);
  98.         if (lseek(fd, (off_t) addr, L_SET) != (off_t) -1 &&
  99.             read(fd, buf, sizeof buf - 1) >= 0) {
  100.             bp = buf;
  101.         }
  102.         (void) close(fd);
  103.     }
  104.  
  105.     return bp;
  106. }
  107.  
  108. mipsUsleep(usec)
  109.     int usec;
  110. {
  111.     struct timeval timeout;
  112.  
  113.     timeout.tv_sec = 0;
  114.     timeout.tv_usec = usec;
  115.     (void) select(1, (fd_set *) 0, (fd_set *) 0, (fd_set *) 0, &timeout);
  116. }
  117.