/*
 * $RCSfile: modeldep.c,v $
 *
 * x-kernel v3.3 - IRIX port
 *
 * Copyright (c) 1993 Massachusetts Board of Regents
 *
 * $Log: modeldep.c,v $
 * Revision 1.2  1996/01/30 20:52:53  slm
 * Updated copyright and version.
 *
 * Revision 1.1  1995/07/29  02:42:45  slm
 * Initial revision
 *
 * Revision 1.1.2.1  1994/11/12  19:13:38  hkaram
 * New branch
 *
 * Revision 1.1  1994/03/14  22:36:09  umass
 * Initial revision
 *
 * SGI Machine dependent code:   Platform ID, OS type & rev level, etc
 */

#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h> 
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/mman.h>
#include <sys/syssgi.h>
#include <sys/utsname.h>
#include "platform.h"
#include "x_stdio.h"
#include "modeldep.h"

const char *IrixSupportedHardware[7] =
           {
             POWER_SERIES200_MACHINE_NAME, POWER_SERIES300_MACHINE_NAME,
             POWER_SERIES400_MACHINE_NAME, CHALLENGE_MACHINE_NAME,
             INDIGO_MACHINE_NAME, INDIGO4000_MACHINE_NAME,
             NULL
           };

int   traceirixmodeldepp;


VOID
GetSGIMachineInfo (Machine)
     IRIX_Machine_Info *Machine;
{
  struct utsname info;
  int i = 0,
      j = 1;
  
  uname(&info);
  while (IrixSupportedHardware[i] &&
	 (j = strcmp(IrixSupportedHardware[i], info.machine))) i++;
  
  if (j)
    {
      Kabort("GetSGIMachineInfo:  I dont know your hardware identifier");
    }

  Machine->hardware_type = atoi((char *)(info. machine+2));
  strncpy(Machine->os_rev_level, info.release, sizeof(info.release));
  
  /* IP5 and IP6 (4D/200 and 4D/300 series) must be accounted for too */

  if ( (Machine->hardware_type == 5) || (Machine->hardware_type == 6) )
    Machine->hardware_type = SGI_POWER4D;

  switch (Machine->hardware_type)
    {
      case SGI_INDIGO_R3000:
      case SGI_INDIGO_R4000:
        xTrace0(irixmodeldepp,TR_MAJOR_EVENTS,
		"GetSGIMachineInfo: Machine type R3000/R4000 Indigo");
	strcpy(Machine->ethernet_if_name, SGI_IEEE8023_ECLIPSE);
	strcpy(Machine->fddi_if_name, SGI_FDDI_GIO32);
	break;

      case SGI_POWER4D:
      case SGI_CHALLENGE:
	xTrace0(irixmodeldepp,TR_MAJOR_EVENTS,
		"GetSGIMachineInfo: Machine type 4D/xxx / Challenge / Onyx");
        strcpy(Machine->ethernet_if_name, SGI_IEEE8023_POWER4D);
        strcpy(Machine->fddi_if_name, SGI_FDDI_VME);
        break;
    }

  xTrace2(irixmodeldepp, TR_MAJOR_EVENTS,
	  "Network interfaces ethernet = %s  FDDI = %s",
	  Machine->ethernet_if_name, Machine->fddi_if_name);
}
