www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2001/12/03/13:43:49

X-Authentication-Warning: delorie.com: mailnull set sender to djgpp-bounces using -f
Message-ID: <271DBBEEA095D511B80D009027DE7D670DD129@mcoexc01.mlm.maxtor.com>
From: "Dykstra, Sean" <Sean_Dykstra AT maxtor DOT com>
To: "'djgpp AT delorie DOT com'" <djgpp AT delorie DOT com>
Subject: Critical Error Interrupt Help
Date: Mon, 3 Dec 2001 11:38:36 -0700
MIME-Version: 1.0
X-Mailer: Internet Mail Service (5.5.2653.19)
Reply-To: djgpp AT delorie DOT com

Hello!

We are porting an existing DOS/Windows app that traps the critical error
interrupt so that we can display a controlled message in our own message
window.  We would like to reproduce the error in the DJGPP version to look
and feel the same to the customer.

The app is completely locked into memory (we have to do physical DMA/UDMA
transfers, and we are only using CWSDPMI), so we are able to write the
handler in C/C++.  

The handler is called correctly, however, I do not seem to be able to pass
data in or out of the handler.  I have found a few references in the
archives to the hidden __dpmi_regs parameter, but it usually seems to
contain garbage...or it is more likely something I am doing wrong.

Thanks again, and the code snippet is below:

#define IRQ0       0x24

//XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXX
//XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXX
// Interrupt handlers
//XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXX
//XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXX
//Are the __dpmi_regs the correct way to get information in???
void SysInts::pm_new24h (__dpmi_regs *r)
   {
   InputHandler *pclInput;
   int  iError;
   char ch=0;
   uint16 _ax =  r->x.ax;
   iError = r->x.di;
   pclInput = InputHandler::pclInstantiate();

   pclMsgWin->iPrintf (M_WINDOW,"Error: di:%04X ax:%04X bx:%04X cx:%04X
dx:%04X",r->x.di,r->x.ax, r->x.bx, r->x.cx, r->x.dx);
   switch (iError) 
      {
      case WRITEPROTECT:
         pclMsgWin->iPrintf (M_WINDOW,"Write Protect Failure");
         break;
      case UNKNOWNUNIT:    
         pclMsgWin->iPrintf (M_WINDOW,"Unknown Unit");
         break;
      case DRIVENOTREADY:  
         pclMsgWin->iPrintf (M_WINDOW,"Drive Not Ready");
         break;
      case UNKNOWNCOMMAND:  
         pclMsgWin->iPrintf (M_WINDOW,"Unknown Command");
         break;
      case CRCERROR:       
         pclMsgWin->iPrintf (M_WINDOW,"CRC Data Error");
         break;
      case BADREQUEST:     
         pclMsgWin->iPrintf (M_WINDOW,"Bad Request Structure Length");
         break;
      case SEEKERROR:       
         pclMsgWin->iPrintf (M_WINDOW,"Seek Error");
         break;
      case UNKNOWNMEDIA:    
         pclMsgWin->iPrintf (M_WINDOW,"Unknown Media");
         break;
      case SECTORNOTFOUND: 
         pclMsgWin->iPrintf (M_WINDOW,"Sector Not Found");
         break;
      case OUTOFPAPER:     
         pclMsgWin->iPrintf (M_WINDOW,"Out of Paper");
         break;
      case WRITEFAULT:     
         pclMsgWin->iPrintf (M_WINDOW,"Write Fault");
         break;
      case READFAULT:       
         pclMsgWin->iPrintf (M_WINDOW,"Read Fault");
         break;
      case GENERALFAILURE:  
         pclMsgWin->iPrintf (M_WINDOW,"General Failure");
         break;
      case INVALIDCHANGE:  
         pclMsgWin->iPrintf (M_WINDOW,"Invalid Media Change");
         break;
      }
   while (0==ch)
      {
      pclMsgWin->iPrintf (M_WINDOW,"\nAbort, Retry, Ignore, Fail ?");
      ch=pclInput->uGetKey ();    
      ch|=0x20;
      pclMsgWin->iPrintf (M_WINDOW,"%c",ch);
      if ( (ch!='a') && (ch!='r') && (ch!='i') && (ch!='f') ) 
           {
           ch=0;
           }
      }     
   pclMsgWin->iPrintf (M_WINDOW,"\n");
   _ax &= 0xFF00;
   switch (ch) 
      {
      case 'a':
         _ax |= CRITFAIL;
         break;
      case 'r':
         _ax |= CRITRETRY;
         break;
      case 'f':
         _ax |= CRITFAIL;
         break;
      case 'i':
         _ax |= CRITIGNORE;
         break;
      }
   r->x.ax=_ax; //Is this the correct way to get information out???
   }

//==================================================================
// SysIntr32 - Protected Constructor                   
//                                                 
// Input:         none
// Implied input: none
// Output:        none
// Globals effected:
//==================================================================
SysInts::SysInts()
   {
   disable ();

   pclMsgWin = MsgWinClass::pclInstantiate();
   
   _go32_dpmi_get_protected_mode_interrupt_vector (IRQ0, &pm_old_handler);
   pm_new_handler.pm_offset = (int) pm_new24h;
   pm_new_handler.pm_selector = _go32_my_cs ();
   _go32_dpmi_allocate_iret_wrapper (&pm_new_handler);
   _go32_dpmi_set_protected_mode_interrupt_vector (IRQ0, &pm_new_handler);

   enable ();
   } // end of Protected constructor

//==================================================================
// ~SysIntr32 - Protected Destructor                   
//                                                 
// Input:         none
// Implied input: none
// Output:        none
// Globals effected:
//==================================================================
SysInts::~SysInts()
   {
   disable ();
   pclMsgWin->vRelease ();
   
   _go32_dpmi_free_iret_wrapper (&pm_new_handler);
   _go32_dpmi_set_protected_mode_interrupt_vector (IRQ0, &pm_old_handler);
   enable ();
   } // end of Protected destructor

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019