Hardware Exceptions


  

 

While understand the hardware exception , one should have the thorough knowledge or segregation between Processor , RAM , Operating system and hardware. Majority of the times we understand the details of these components when we debug them. And understanding the Instruction set makes life easy for any debugger.

 

A hardware device / I/O devices usually sends an interrupt , this interrupt is followed by an vector. The vector determines what code needs to be exectuted to handle the interrupt. Most commonly used interrupt types are Non-Maskable Interrupt and Maskable Interrupt.

 

 

Non-Maskable Interrupts / NMI :

 

These are very critical and they should never be ignored. And NMI directly talk to the process and not via PIC (programmable interupt controller). Two major points to remember

 

a) NMI is hardware specific. NMI is generated by a specific hardware ( RAM ) and most common is parity error. 

 

b) when NMI is triggered no other interrupts are processed and cpu stops the instruction execution and starts processing NMI

 

 

 

Maskable Interrupts:

 

These interrupts are of low / normal priority , processor may execute or ignore the interrupts. These interrupts are categorized as device interrupts occuring from network adapters , disk etc..

 

 

Following are the important considerations for handling Interrupts.

 

a) The device driver should be capable of handling the interrupts both NMI and MI.

 

b) Decide on what action should be performed when interrupt occurs by your driver such as calling evtDeviceD0EntryPostinterruptsEnabled and

    EvtDeviceD0ExitPreInterruptsDisabled.

 

 

some of commonly known exceptions are listed below.

 

ACCESS VIOLATIONAccess violation exceptions are generated by modern processors when a memory access caused by an instruction or program execution does not satisfy certain conditions defined by the processor architecture or memory management unit structures.

 

This exception occurs in 3 main situations.

 

 1.when we try to read or write an inaccessible memory location .

 2.when a page which is belongs to a system component is used in usermode .i.e For example   using a page that the kernel is using .

 3.an inavlid read or write operation is done to a read only page .

 

BREAK POINT :

 By encountering a hardware defined breakpoint this exception occurs. This is usually referred to as Instruction address breakpoint and it is specific to the microprocessor.

 

DATA TYPE MISALIGNMENT :

 If u read or write data at an address that is not properly aligned .for example 16 bit entry must    be aligned to 2 boundaries and is not applicable to 32 bit processor INTEL 80X86

 

FLOAT DIVIDED BY ZERO, FLOAT OVERFLOW  , FLOAT  UNDERFLOW :

 By dividing an integer point variable with ‘0’ divided by aero exception occurs.

 By exeeding maximum positive  exponent  of floating type over flow exception occurs .

 By exeeding maximum negative  exponent  of floating point  type , floating underflow    exception occurs.

 

FLOATING RESERVED OPERAND:

 Usage of reserved floating point format is incorrct, so exception occurs .

 

ILLEGAL AND  PRIVILEGED  INSTRUCTION:

 Attempting to execute an instruction code which is not defined by processor causes to illegal  exception. Executing an instruction not allowed in current machine mode creates an exception.

 

INTEGER DIVIDED BY ZERO, INTEGER OVERFLOW :

 Dividing an integer type by zero causes   exception.

 

SINGLE STEP :

 If we execute an instruction in single step mode ,it causes to exception.

 

 

 The above mentioned exceptions are generally handled by Debuggers, the operating system

 or other low level code .

 

 

 

Sainath

Microsoft MVP

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s