1.1.3.4.4 DRV_MEMORY_Open Function

C

DRV_HANDLE DRV_MEMORY_Open
(
    const SYS_MODULE_INDEX drvIndex,
    const DRV_IO_INTENT ioIntent
);

Summary

Opens the specified Memory driver instance and returns a handle to it

Description

This routine opens the specified Memory driver instance and provides a handle.

When Open is called for the first time for specified Memory driver instance it opens the attached media device and reads the geomerty details.

This handle returned must be provided to all other client-level operations to identify the caller and the instance of the driver.

Preconditions

Function DRV_MEMORY_Initialize must have been called before calling this function.

Parameters

ParamDescription
drvIndexIdentifier for the instance to be opened
ioIntentZero or more of the values from the enumeration DRV_IO_INTENT "ORed" together to indicate the intended use of the driver

Returns

  • If successful, the routine returns a valid open-instance handle (a number identifying both the caller and the module instance).

  • If an error occurs, DRV_HANDLE_INVALID is returned. Errors can occur under the following circumstances:

    • if the attached media device is not ready or the geometry get fails.

    • if the number of client objects allocated via DRV_MEMORY_CLIENTS_NUMBER is insufficient

    • if the client is trying to open the driver but driver has been opened exclusively by another client

    • if the client is trying to open the driver exclusively, but has already been opened in a non exclusive mode by another client.

    • if the driver hardware instance being opened is not initialized or is invalid - if the attached memory device open or geometry read fails for first time.

Example

DRV_HANDLE handle;

handle = DRV_MEMORY_Open(DRV_MEMORY_INDEX_0);

if (DRV_HANDLE_INVALID == handle)
{
    // Unable to open the driver
}

Remarks

The handle returned is valid until the DRV_MEMORY_Close routine is called. If the driver innstance has already been opened, it cannot be opened again.