DevHelp_RegisterKrnlExit

From EDM2
Jump to: navigation, search

DevHlp_RegisterKrnlExit allows an OS/2 device driver to handle NMIs (Non-Masked Interrupts), Trap 2 Parity Errors, and System Fatal Faults (fatal errors at Ring 0).

This DevHlp provides a notification to the device driver that a serious error occurred in the operating system and gives the device driver limited access to system resources. This DevHlp is valid at initialization time and in kernel mode.

Syntax

C

None available.

Assembler

         MOV       ax,0x1000           ; Kernel Exit Flags
                                       ;   Add     0x1000
                                       ;   Delete  0x0000
                                       ;
         MOV       cx,0x0001           ; Kernel Exit Type
                                       ;   NMI     0x0000
                                       ;   SFF     0x0001
                                       ;
         MOV       bx,SEL Sel          ; 16-bit Selector to User Exit
         MOV       si,OFF Off          ; 16-bit Offset   to User Exit
         MOV       dl,DevHlp_RegisterKrnlExit

         CALL      Device_Help

Parameters

C

None available.

Assembler

         MOV       ax,0x1000           ; Kernel Exit Flags
                                       ;   Add     0x1000
                                       ;   Delete  0x0000
                                       ;
         MOV       cx,0x0001           ; Kernel Exit Type
                                       ;   NMI     0x0000
                                       ;   SFF     0x0001
                                       ;
         MOV       bx,SEL Sel          ; 16-bit Selector to User Exit
         MOV       si,OFF Off          ; 16-bit Offset   to User Exit

Return Code

C

None available.

Assembler

         EAX is any system return code
              0  = success
        non-zero = Error

Remarks

When DevHlp_RegisterKrnlExit is initialized, it is the only active thread in the system. Therefore, this exit must return control to the operating system.

NMI's 
The DevHlp_RegisterKrnlExit will stop enumerating through the NMI device driver chain when an NMI condition is handled.

Note: If the exit routine handled the NMI, it must return with EAX - set to 0xffffffff.

System Fatal Faults 
System Fatal Faults are notifications to the device driver that the operating system encountered a non-recoverable error. At this point, you can attempt device-specific shutdown or cleanup.

If the device driver does not handle the error condition correctly, the result can be a hung system. The device driver must perform a Return Far to return control to OS/2.

NMI Handling

Entry:

EAX         = Kernel Exit Routine's DS

Exit:

EAX         = Return Code Kernel Exit Routine
              0xffffffff (is the only valid one)

The following are restored registers the exit routine can use:

              EAX, EBX, ECX, EDX, EBP, ESI, EDI,
              ESP, DS,  ES,  FS,  GS,  Flags

The exit routine can handle the the NMI or allow OS/2 to handle the NMI. If the exit routine handled the NMI, it must return with EAX - set to 0xffffffff.

The DevHlp_RegisterKrnlExit will stop enumerating through the NMI device driver chain when an NMI condition is handled.

SFF (System Fatal Fault) Handling
SFF is only a notification to the device driver.

Entry:

EAX         = Kernel Exit Routine's DS

Exit:

No Return Codes from this function

The following are restored registers the exit routine could have used:

EAX, EBX, ECX, EDX, EBP, ESI, EDI,
ESP, DS,  ES,  FS,  GS,  Flags

IF EBX =  -9L
  this is a debug kernel
  and the debugger will display
  the registers.
ELSE (this is a Retail Kernel)
  IF EBX =  -1
    this is a TSF or VSF  stack frame
    and ESI is the Trap Number
  ELSE
    this is a KSF stack frame
    and ESI is the Trap Number
  ENDIF
ENDIF