NPA_Register_For_Event_Notification

Registers a procedure to be called prior to specific system events.

Thread Context:Blocking
Requirements:Must be called only from a blocking process level.

Syntax

    LONG NPA_Register_For_Event_Notification (
       LONG   npaHandle,
       LONG  *eventHandle,
       LONG   eventType,
       LONG   priority,
       LONG   (*warnRoutine)(
          void   (*outputRoutine)(void *controlString, ...),
          LONG   warnParameter),
       void   (*reportRoutine)(
          LONG   reportParameter)
       );
    
    

Parameters

npaHandle
(IN) The CDM's or HAM's handle for using the NPA_ APIs, assigned during NPA_Register_CDM_Module or NPA_Register_HAM_Module, respectively.
eventType
(IN) Indicates the type of event for which the caller wants notification. The following table describes events for which notification may be received, the type of notification that can be made (Warn, Report, or both), the thread context of the notification call (blocking or non-blocking), and the defined use of the input parameter (warnParameter or reportParameter ) passed to the notification call (warnRoutine or reportRoutine).

Type Definition

Type (Decimal)

EVENT_VOL_SYS_MOUNT

  • reportParameter is undefined.
  • reportRoutine is called immediately after volume sys: is mounted.
  • reportRoutine might block the thread.

0

EVENT_VOL_SYS_DISMOUNT

  • warnParameter and reportParameter are undefined.
  • warnRoutine and reportRoutine are called before volume sys: is dismounted.
  • reportRoutine might block the thread.

    NOTE:Your driver must not call HAI_Deactivate_Bus during the context of this event.

1

EVENT_ANY_VOL_MOUNT

  • reportParameter is the volume number.
  • reportRoutine is called immediately after any volume is mounted.
  • reportRoutine might block the thread.

2

EVENT_ANY_VOL_DISMOUNT

  • reportParameter and warnParameter are the volume number.
  • warnRoutine and reportRoutine are called before any volume is dismounted.
  • reportRoutine might block the thread.

    NOTE:Your driver must not call HAI_Deactivate_Bus during the context of this event.

3

EVENT_DOWN_SERVER

  • warnParameter and reportParameter are undefined.
  • warnRoutine and reportRoutine are called before the server is brought down.
  • reportRoutine might block the thread.

    NOTE:Your driver must not call HAI_Deactivate_Bus during the context of this event.

4

EVENT_CHANGE_TO_REAL_MODE

  • reportParameter is a flags field defined as follows: 0x00000001 = Blocking context 0x00000002 = Interrupts are enabled
  • reportRoutine is called before the server changes to real mode.
  • reportRoutine might block the thread, depending upon the status of the bit in the flags field.

5

EVENT_RETURN_FROM_REAL_MODE

  • reportParameter is a flags field defined as follows: 0x00000001 = Blocking context 0x00000002 = Interrupts are enabled
  • reportRoutine is called before the server changes from real mode.
  • reportRoutine might block the thread, depending upon the status of the bit in the flags field.

6

EVENT_EXIT_TO_DOS

  • reportParameter is a flags field defined as follows: 0x00000001 = Blocking context 0x00000002 = Interrupts are enabled
  • reportRoutine is called before the server exits to DOS.
  • reportRoutine might block the thread, depending upon the status of the bit in the flags field.

7

EVENT_MODULE_UNLOAD

  • reportParameter is the module handle.
  • warnRoutine and reportRoutine are called before a module is unloaded using the console command line. Only reportRoutine is called when a module unloads itself.
  • reportRoutine might block the thread.

8

EVENT_ACTIVATE_SCREEN

  • reportParameter is the screen ID.
  • reportRoutine is called after the screen becomes the active screen.
  • reportRoutine might block the thread.

14

EVENT_UPDATE_SCREEN

  • reportParameter is the screen ID.
  • reportRoutine is called after a change is made to the screen image.
  • reportRoutine might block the thread.

15

EVENT_UPDATE_SCREEN

  • reportParameter is the screen ID.
  • reportRoutine is called after a change to the cursor position or state.
  • reportRoutine might not block the thread.

16

EVENT_KEY_WAS_PRESSED

  • reportParameter is undefined.
  • reportRoutine is called after any key on the keyboard is pressed (including Shift, Alt, or Control).
  • reportRoutine is called at interrupt time. It cannot block the thread.

17

EVENT_DEACTIVATE_SCREEN

  • reportParameter is the screen ID.
  • reportRoutine is called after the screen becomes inactive.
  • reportRoutine cannot block the thread.

18

EVENT_OPEN_SCREEN

  • reportParameter is the screen ID for the newly created screen.
  • reportRoutine is called after the screen is created.
  • reportRoutine might block the thread.

20

EVENT_CLOSE_SCREEN

  • reportParameter is the screen ID for the screen being closed.
  • reportRoutine is called after the screen is closed.
  • reportRoutine might block the thread.

21

EVENT_MODULE_LOAD

  • reportParameter is the module handle.
  • reportRoutine is called after the module has been loaded.
  • reportRoutine might block the thread.

27

EVENT_GENERIC

32

priority
(IN) The priority used to call this notification function. Priorities are defined as follows:

Priority (Decimal)

Priority Definition

0

EVENT_PRIORITY_OS

20

EVENT_PRIORITY_APPLICATION

40

EVENT_PRIORITY_DEVICE

warnRoutine
(IN) Points to a function that is called when an event occurs that the OS classifies as a warning. If the warn function determines the event should not occur, it must output a message and then return a nonzero value. Most event notification functions are called at process level, but some are made at interrupt level (meaning the thread cannot be blocked). The above table of event types specifies which events must be checked to determine if the event allows its thread to be blocked and describes which events are classified as warnings.
reportRoutine
(IN) Points to a function that is called when an event occurs that the OS classifies as a report. Most event notification functions are called at process level, but some are made at interrupt level (meaning the thread cannot be blocked). The above table of event types specifies which events must be checked to determine if the event allows its thread to be blocked and describes which events are classified as reports.
eventHandle
(OUT) Receives a 32-bit handle to the registered event. This event handle is passed as an input parameter to NPA_Unregister_Event_Notification.

Return Values

The following table lists return values and descriptions.

zero

Successful

nonzero

Unsuccessful

Remarks

On some occasions a driver is required to perform some action prior to the OS terminating, switching to real mode, exiting to DOS, etc. The driver should call NPA_Register_For_Event_Notification providing notification procedure pointers as indicated above.

Even though the calls to register and deregister the event notification are blocking, the actual call to the event notification procedure provided by the driver is not always made from blocking process level (the environment varies with the particular event being reported). The warnRoutine is provided with two parameters when called. The first is the outputRoutine, which must be used to output messages (the outputRoutine must be called with controlString and as many parameters as the control string indicates), and the second is the parameter described in each of the event types above. When the reportRoutine is called it is passed a single parameter. This is the same parameter described in each of the event types described above.