⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 irqinfo.c

📁 Dos6.0
💻 C
📖 第 1 页 / 共 2 页
字号:
/*********************************************************************
 * Microsoft Diagnostics Version 2.0
 *
 * A diagnostic utility to detect as much useful information about a
 *   customer's computer system as is possible.
 *
 * Microsoft Diagnostics:  We detect the World.
 *
 * IRQINFO.C - Source file for serial port detection code.
 ********************************************************************/


/* Include Files */

#include "msd.h"


/* Stores the interrupt vector table at program startup */

DWORD *padwIntTable = NULL;


/*********************************************************************
 * GetIrqInfo - Gets the hardware interrupt (IRQ) information.
 *
 * pIrq         - IRQ structure for storing data
 *
 * Returns:  TRUE if an error occured.
 *********************************************************************/

BOOL GetIrqInfo (IRQ_STRUCT *pIrq, BOOL fMinimumInfo)
{
  /* Structure pointers for holding data related to IRQs */

  COMPUTER_STRUCT       *pComputer = NULL;
  MOUSE_STRUCT          *pMouse    = NULL;
  DISK_STRUCT           *pDisk     = NULL;
  LPT_STRUCT            *pLpt      = NULL;
  COM_STRUCT            *pCom      = NULL;
  TSR_PROGRAMS_STRUCT   *pTsr      = NULL;
  DEVICE_DRIVER_STRUCT  *pDevice   = NULL;

  BOOL fReturnValue = FALSE;    /* Return value from various GetInfo calls */
  WORD wSize;                   /* Size, in bytes, to store the data       */
  WORD i;                       /* Looping variable                        */
  VOID *pStructForInfo = NULL;  /* Pointer to a generic struct             */
  BYTE FAR *fpBunchOfBytes = NULL;


  /* There is no minimum info from this routine */
  if (fMinimumInfo)
    return (FALSE);

#if HEAP_DEBUG
  HeapCheck ("Beginning of GetIrqInfo");
#endif

  /* See if any low memory locations change */
  fpBunchOfBytes = _fmalloc (256 * 4);
  _fmemcpy (fpBunchOfBytes, (BYTE FAR *) 0x00000000, 256*4);

#if HEAP_DEBUG
  HeapCheck ("After copy of BunchOfBytes");
#endif

  /* Fill the structures with the information related to IRQs */

  for (i = 0; fReturnValue == FALSE && rwIrqRecordTypes[i] != 0; ++i)
    {
      wSize = GetInfoSize (rwIrqRecordTypes[i], FALSE);

      if (wSize == 0)
        {
          fReturnValue = TRUE;
          break;
        }

      pStructForInfo = malloc (wSize);

      if (pStructForInfo == NULL)
        {
          OutOfMemory();
          fReturnValue = TRUE;
          break;
        }


      /* Zero out the structure before passing it on */
      memset (pStructForInfo, '\0', wSize);

      {
#if HEAP_DEBUG
        CHAR chBuffer[80];
        sprintf (chBuffer, "After malloc for IDI_ %d", rwIrqRecordTypes[i]);
        HeapCheck (chBuffer);
#endif
      }

      switch (rwIrqRecordTypes[i])
        {
          case IDI_COMPUTER_RECORD:
            fReturnValue = GetComputerIrqInfo (pStructForInfo);
            if (!fReturnValue)
              pComputer = (COMPUTER_STRUCT *) pStructForInfo;
            break;

          case IDI_MOUSE_RECORD:
            fReturnValue = GetInfo (rwIrqRecordTypes[i],
                                    pStructForInfo,
                                    FALSE,
                                    FALSE,
                                    FALSE);
            if (!fReturnValue)
              pMouse = (MOUSE_STRUCT *) pStructForInfo;
            break;

          case IDI_DISK_DRIVE_RECORD:
            fReturnValue = GetInfo (rwIrqRecordTypes[i],
                                    pStructForInfo,
                                    TRUE,   /* Minimum Info */
                                    FALSE,
                                    FALSE);
            if (!fReturnValue)
              pDisk = (DISK_STRUCT *) pStructForInfo;
            break;

          case IDI_LPT_RECORD:
            fReturnValue = GetInfo (rwIrqRecordTypes[i],
                                    pStructForInfo,
                                    FALSE,
                                    FALSE,
                                    FALSE);
            if (!fReturnValue)
              pLpt = (LPT_STRUCT *) pStructForInfo;
            break;

          case IDI_COM_RECORD:
            fReturnValue = GetInfo (rwIrqRecordTypes[i],
                                    pStructForInfo,
                                    FALSE,
                                    FALSE,
                                    FALSE);
            if (!fReturnValue)
              pCom = (COM_STRUCT *) pStructForInfo;
            break;
        }
    }

  if (fReturnValue)
    {
      free (pCom);
      free (pLpt);
      free (pDisk);
      free (pMouse);
      free (pComputer);

      return (fReturnValue);
    }


  /* Determine how many IRQs the computer has:  A Cascaded IRQ2 */
  /*   means that there are 16 IRQs, without means 8 (IRQs are  */
  /*   numbered starting at zero).                              */

  if (pComputer->fCascadeIntLvl2)
    pIrq->wNmbrIrqs = 15;
  else
    pIrq->wNmbrIrqs = 7;


  /* Set the serial strings for PS/2 or non-PS/2 computers */
  if (pComputer->wComputerClass == COMPUTER_CLASS_PS2)
    {
      paszAtIrqDescriptions[3][5]  = '\0';
      paszAtIrqDescriptions[4][11] = ' ';
    }


  /* Set the "detected" strings */
  SetIrqDetectedStrings (pIrq,
                         pComputer,
                         pMouse,
                         pDisk,
                         pLpt,
                         pCom);
  _memmax();
  free (pComputer);
  free (pMouse);
  free (pDisk);
  free (pLpt);
  free (pCom);
  _memmax();


  /* Get TSR info */
  wSize = GetInfoSize (IDI_TSR_PROGRAMS_RECORD, FALSE);
  if (wSize == 0)
    return (TRUE);

  pTsr = malloc (wSize);
  if (pTsr == NULL)
    {
      OutOfMemory();
      return (TRUE);
    }

  /* Zero out the structure before passing it on */
  memset (pTsr, '\0', wSize);
  fReturnValue = GetInfo (IDI_TSR_PROGRAMS_RECORD, pTsr,
                          FALSE, FALSE, FALSE);


  /* Get Device Driver info */
  wSize = GetInfoSize (IDI_DEVICE_DRIVERS_RECORD, FALSE);
  if (wSize == 0)
    return (TRUE);

  pDevice = malloc (wSize);
  if (pDevice == NULL)
    {
      OutOfMemory();
      return (TRUE);
    }

  /* Zero out the structure before passing it on */
  memset (pDevice, '\0', wSize);
  fReturnValue = GetInfo (IDI_DEVICE_DRIVERS_RECORD, pDevice,
                          FALSE, FALSE, FALSE);

  _memmax();
  /* Set the Interrupt vector address and the "Handled By" string */
  SetIrqHandledByStrings (pIrq,
                          pTsr,
                          pDevice);


  /* Free up the structure data */

  free (pDevice);
  free (pTsr);

#if HEAP_DEBUG
  HeapCheck ("After GetIrqInfo's set of free()s");
#endif

  return (FALSE);
}


/*********************************************************************
 * SetIrqDetectedStrings - Sets the szDetected[][] strings in the IRQ
 *                         data structure.
 *
 * pIrq      - IRQ information structure
 * pComptuer - Computer information structure
 * pMouse    - Mouse information structure
 * pLpt      - LPT Port information structure
 * pCom      - COM Port information structure
 *
 * Returns:  TRUE if an error occured.
 *********************************************************************/

BOOL SetIrqDetectedStrings (IRQ_STRUCT       *pIrq,
                            COMPUTER_STRUCT  *pComputer,
                            MOUSE_STRUCT     *pMouse,
                            DISK_STRUCT      *pDisk,
                            LPT_STRUCT       *pLpt,
                            COM_STRUCT       *pCom)
{
  union REGS inregs, outregs;   /* Register structures for int86 call */
  WORD i, u, x;                 /* Looping variables                  */

  for (i = 0; i <= pIrq->wNmbrIrqs; ++i)
    {
      for (u = 0; u < MAX_IRQ_DETECTED_STRINGS; ++u)
        pIrq->IrqxInfo[i].szDetected[u][0] = '\0';

      /* Zero out the index to pIrq->IrqxInfo[i].szDetected[] */
      u = 0;

      /* PC IRQ 5 == AT IRQ 14 */
      if (i == 5 && pComputer->wComputerClass == COMPUTER_CLASS_XT)
        i = 14;

      switch (i)
        {
          /* Timer Click, always assumed to be there */
          case  0:
            {
              pIrq->IrqxInfo[i].fDetected = TRUE;
              strcpy (pIrq->IrqxInfo[i].szDetected[0], pszYes);
              break;
            }

          /* Keyboard, always assumed to be there */
          case  1:
            {
              pIrq->IrqxInfo[i].fDetected = TRUE;
              strcpy (pIrq->IrqxInfo[i].szDetected[0], pszYes);
              break;
            }

          /* Cascade IRQ2 (AT) or I/O Channel (PC, always */
          /*   assumed to be there)                       */
          case  2:
            {
              if (pComputer->wComputerClass == COMPUTER_CLASS_XT)
                {
                  pIrq->IrqxInfo[i].fDetected = TRUE;
                  strcpy (pIrq->IrqxInfo[i].szDetected[u++], pszYes);
                }
              else if (pComputer->fCascadeIntLvl2)
                {
                  pIrq->IrqxInfo[i].fDetected = TRUE;
                  strcpy (pIrq->IrqxInfo[i].szDetected[u++], pszYes);
                }
              else
                {
                  pIrq->IrqxInfo[i].fDetected = FALSE;
                  strcpy (pIrq->IrqxInfo[i].szDetected[u++], pszNo);
                }

              /* Check for a mouse */
              if (pMouse->wIrq == i)
                {
                  pIrq->IrqxInfo[i].fDetected = TRUE;
                  strcpy (pIrq->IrqxInfo[i].szDetected[u++],
                          pMouse->szMouseHardwareType);
                }
              break;
            }

          /* COM2: (all), COM4: (non PS/2) */
          case  3:
            {
              /* COM2: index == 1 */
              if (pCom->ComxInfo[1].fComPortDetected)
                {
                  pIrq->IrqxInfo[i].fDetected = TRUE;
                  strcpy (pIrq->IrqxInfo[i].szDetected[u++], pszCom[2]);
                }

              /* COM4: index == 3 */
              if (pCom->ComxInfo[3].fComPortDetected &&
                  pComputer->wComputerClass != COMPUTER_CLASS_PS2)
                {
                  pIrq->IrqxInfo[i].fDetected = TRUE;
                  strcpy (pIrq->IrqxInfo[i].szDetected[u++], pszCom[4]);
                }

              /* Check for a mouse */
              if (pMouse->wIrq == i)
                {
                  pIrq->IrqxInfo[i].fDetected = TRUE;
                  strcpy (pIrq->IrqxInfo[i].szDetected[u++],
                          pMouse->szMouseHardwareType);
                }

              /* If nothing was detected for IRQ 3, set it to "No" */
              if (u == 0)
                {
                  pIrq->IrqxInfo[i].fDetected = FALSE;
                  strcpy (pIrq->IrqxInfo[i].szDetected[0], pszNo);
                }

              break;
            }

          /* COM1:/COM3: (all), COM4: (PS/2) */
          case  4:
            {
              /* COM1: index == 0 */
              if (pCom->ComxInfo[0].fComPortDetected)
                {
                  pIrq->IrqxInfo[i].fDetected = TRUE;
                  strcpy (pIrq->IrqxInfo[i].szDetected[u++], pszCom[1]);
                }

              /* COM3: index == 2 */
              if (pCom->ComxInfo[2].fComPortDetected)
                {
                  pIrq->IrqxInfo[i].fDetected = TRUE;
                  strcpy (pIrq->IrqxInfo[i].szDetected[u++], pszCom[3]);
                }

              /* COM4: index == 3 */
              if (pCom->ComxInfo[3].fComPortDetected &&
                  pComputer->wComputerClass == COMPUTER_CLASS_PS2)
                {
                  pIrq->IrqxInfo[i].fDetected = TRUE;
                  strcpy (pIrq->IrqxInfo[i].szDetected[u++], pszCom[4]);
                }

              /* Check for a mouse */
              if (pMouse->wIrq == i)
                {
                  pIrq->IrqxInfo[i].fDetected = TRUE;
                  strcpy (pIrq->IrqxInfo[i].szDetected[u++],
                          pMouse->szMouseHardwareType);
                }

              /* If nothing was detected for IRQ 4, set it to "No" */
              if (u == 0)
                {
                  pIrq->IrqxInfo[i].fDetected = FALSE;
                  strcpy (pIrq->IrqxInfo[i].szDetected[0], pszNo);
                }

              break;
            }

          /* LPT2: */
          case  5:
            {
              /* LPT2: index = 1 */
              if (pLpt->LptxInfo[1].fLptPortDetected)
                {
                  pIrq->IrqxInfo[i].fDetected = TRUE;
                  strcpy (pIrq->IrqxInfo[i].szDetected[u++], pszYes);
                }

              /* Check for a mouse */
              if (pMouse->wIrq == i)
                {
                  pIrq->IrqxInfo[i].fDetected = TRUE;
                  strcpy (pIrq->IrqxInfo[i].szDetected[u++],
                          pMouse->szMouseHardwareType);
                }

              /* If nothing was detected for IRQ 5, set it to "No" */
              if (u == 0)
                {
                  pIrq->IrqxInfo[i].fDetected = FALSE;
                  strcpy (pIrq->IrqxInfo[i].szDetected[0], pszNo);
                }

              break;
            }

          /* Floppy Controller */
          case  6:
            {
              int86 (0x11, &inregs, &outregs);

              /* Bit zero is set if floppies are present */
              if (outregs.x.ax & 1)
                {
                  pIrq->IrqxInfo[i].fDetected = TRUE;
                  strcpy (pIrq->IrqxInfo[i].szDetected[u++], pszYes);
                }

              /* Check for a mouse */
              if (pMouse->wIrq == i)
                {
                  pIrq->IrqxInfo[i].fDetected = TRUE;
                  strcpy (pIrq->IrqxInfo[i].szDetected[u++],
                          pMouse->szMouseHardwareType);
                }

              /* If nothing was detected for IRQ 6, set it to "No" */
              if (u == 0)
                {
                  pIrq->IrqxInfo[i].fDetected = FALSE;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -