Jump to content

PDDREF:Linking Resource Manager Services

From EDM2

This section discusses the programming considerations of adding Resource Management services to your driver.

The OS/2 Resource Manager consists of three components: RESOURCE.SYS, RMCALLS.LIB, and RMINFO.DLL.

RESOURCE.SYS

RESOURCE.SYS is a base device driver. In OS/2 Warp and subsequent versions, this driver is provided as part of the product and is loaded automatically without an explicit CONFIG.SYS BASEDEV= statement.

RMCALLS.LIB

The RMCALLS library code linked to a driver will provide rudimentary support for cases in which RESOURCE.SYS is not loaded on a system. Typically, a handle value of -1L and a return code of RMRC_SUCCESS will occur. In this manner, the driver code might not need to know about the presence of RESOURCE.SYS on a system, and can assume that all resources are available. This was the behavior previous to implementing Resource Manager.

RMADDToHDevice           ³RMAdjToHandleList        ³RMAllocResource                ³
RMConvertID              ³RMCreateAdapter          ³RMCreateDetected               ³
RMCreateDevice           ³RMCreateDriver           ³RMCreateLDev                   ³
RMCreateSysName          ³RMDeAllocResource        ³RMDestroyAdapter               ³
RMDestroyDetected        ³RMDestroyDevice          ³RMDestroyDriver                ³
RMDestroyLDev            ³RMDestroySysName         ³RMDevIDToHandleList            ³
RMGetCommandLine         ³RMGetDriverName          ³RMGetNodeInfo                  ³
RMGetVersion             ³RMHandleToParent         ³RMHandleToResourceHandleList   ³
RMHandleToType           ³RMHDevToHLDev            ³RMKeyToHandleList              ³
RMModifyNodeFlags        ³RMModifyResources        ³RMParseSCSIInquiry             ³
RMResToHandleList        ³RMUpdateAdjunct

RMCALLS Library Data

The RMCALLS library references the following four variables:
   PFN Device_Help;
   ULONG RMFlags = NULL;
   PFNRM RM_Help0 = NULL;
   PFNRM RM_Help3 = NULL; 

The PFN Device_Help variable must be initialized by your driver prior to calling any Resource Manager services. It is expected to contain the Device Help entry point provided in the OS/2 Init Request Packet your driver receives.

Prior to calling any Resource Manager services, the remaining data variables must be initialized to zero. Specify C-initializers when declaring the variables.

These variables must be allocated by your driver. If you plan to use Resource Manager services after your driver has completed initialization, you must ensure that these variables are not discarded.

Note: If you do not declare these variables, a linker error message will occur, indicating that they are missing.

RMCALLS Library Code

The code portion of the RMCALLS library is included in a segment named RMCode. There are three alternatives in handling the code in this segment:

  • Combine RMCode with your driver's default code segment if your driver does not intend to use Resource Manager services after initialization. Because the library code is linked after OBJ text, it would be discarded as your driver discards its initialization code.
  • Combine RMCode with your driver's swappable code segment. If your driver intends to use Resource Manager services after its initialization and has a swappable code segment, then combine RMCode with this segment.
  • Place RMCode in its own swappable segment. If your driver does not have a swappable code segment, then the RMCode will reside in its own swappable segment by default.

RMINFO.DLL

The RMINFO.DLL is dynamically linked with ring 3 applications to provide an interface with RESOURCE.SYS. The interfaces listed in the following table can be called from 16- and 32-bit applications.

RMAllocResource                ³RMConvertID              ³RMCreateAdapter          ³
RMCreateDetected               ³RMCreateDriver           ³RMDeAllocResource        ³
RMDeleteDetectedData           ³RMDestroyDetected        ³RMDestroyDriver          ³
RMDevIDToHandleList            ³RMGetNodeInfo            ³RMGetSnoopLevel          ³
RMHandleToResourceHandleList   ³RMSaveDetectedData       ³RMSetSnoopLevel 

Resource Manager Services

This section lists and describes the Resource Manager services and their return codes.

The following Resource Manager services are grouped functionally and are provided by a library. The information in this library can be found in Linking Resource Manager Services.

Auto Detection Services

The following services create or destroy a detected device node:

  • RMCreateDetected (see page RMCreateDetected)
  • RMDestroyDetected (see page RMDestroyDetected)

The following rminfo.dll services manage the detection (or snoop) levels and the detected data used for future boots:

  • RMGetSnoopLevel (see page RMGetSnoopLevel)
  • RMSetSnoopLevel (see page RMSetSnoopLevel)
  • RMSaveDetectedData (see page RMSaveDetectedData)
  • RMDeleteDetectedDate (see page RMDeleteDetectedData)

The following services are used to search the detected devices and convert plug-and-play device IDs.

  • RMDevIDToHandleList (see page RMDevIDToHandleList)
  • RMConvertID (see page RMConvertID)

Physical Node Management

The following services create driver, adapter, and device nodes:

  • RMCreateDriver (see RMCreateDriver)
  • RMCreateAdapter (see RMCreateAdapter)
  • RMCreateDevice (see RMCreateDevice)

The following services delete driver, adapter, and device nodes:

  • RMDestroyDriver (see RMDestroyDriver)
  • RMDestroyAdapter (see RMDestroyAdapter)
  • RMDestroyDevice (see RMDestroyDevice)

Resource Management

The following services allocate or deallocate resources:

  • RMAllocResource (see RMAllocResource)
  • RMDeallocResource (see RMDeAllocResource)

The following service edits existing device or adapter resource sets by adding or removing resources:

  • RMModifyResources (see RMModifyResources)

Node Searches

The following service searches for nodes matching a particular key:

  • RMKeyToHandleList (see RMKeyToHandleList)

The following service searches for nodes using a particular resource:

  • RMResToHandleList (see RMResToHandleList)

The following service searches for nodes containing matching adjunct data:

  • RMAdjToHandleList (see RMAdjToHandleList)

The following service returns the LDEV associated with a physical device node:

  • RMHDevtoHLDev (see RMHDevToHLDev)

Node Information

The following service provides the type of node with which the handle is associated:

  • RMHandleToType (see RMHandleToType)

The following service returns the handle of the node's parent:

  • RMHandleToParent (see RMHandleToParent)

The following service returns the contents of the Resource Manager node indicated by the handle:

  • RMGetNodeInfo (see RMGetNodeInfo)

Logical Node Management

The following services create or destroy a logical device node:

  • RMCreateLDev (see RMCreateLDev)
  • RMDestroyLDev (see RMDestroyLDev)

The following services create or destroy a system name node:

  • RMCreateSysName (see RMCreateSysName)
  • RMDestroySysName (see RMDestroySysName)

Miscellaneous

The following calls represent miscellaneous services.

  • RMADDtoHDevice (see RMADDToHDevice)
  • RMGetDriverName (see RMGetDriverName)
  • RMGetVersion (see RMGetVersion)
  • RMParseSCSIInquiry (see RMParseSCSIInquiry)
  • RMUpdateAdjunct (see RMUpdateAdjunct)

Return Codes