www.beck-ipc.com

@CHIP-RTOS C Library - Helper Functions


helper_load_library

Load and link a dynamic link library (DLL).

int helper_load_library( const char far * libName,
                         void far * pFpl,
                         int * pFplSize,
                         int maxFplSize);

Parameters

libName

File name of the DLL (with extension!)

pFpl

Output Parameter:   Pointer to the vector list where on success the addresses of the DLL's exported functions will be written.

pFplSize

Output Parameter:   The number of bytes written to the vector table at pFpl will be reported here.   This will be at most maxFplSize bytes.

maxFplSize

Maximal size of vector table at pFpl , in bytes.

Return Value

error code
    CHIPDLL_ERR_OK:   Success, DLL was loaded and functions were exported
    CHIPDLL_ERR_COULDNTLD:    DLL could not be loaded
    CHIPDLL_ERR_NOTFOUND:    The dll was not found
    DLL specifix error code, defined by the DLL developer.

Comments

If the DLL is not yet loaded, this function loads and starts the DLL.

This API uses the software interrupt 0x67 (dedicated for use by @Chip DLL's) to request the linking information from the DLL with the specified name.

Re-entrancy note:
    If two calls to this API are made simultaneously by two different tasks for the same libName DLL, there is some chance that two instances of that DLL could be loaded.   Whether or not that would cause any problems other than the extra system memory being expended would depend on the functionality intended by your particular DLL that was being loaded.

The order of the exported functions in the function pointer list is equal to the order in the DLL,s project export function declaration.

Example:

            

struct MYDLL
{
  int  (*myFirstDllFunction)(int k);
  long (*mySecondDllFunction)(char *s);
};

int result;
int fplSize;
struct MYDLL myDll;

// Sign in to the DLL. When the DLL is not loaded yet it will be loaded automatically.
result = helper_load_library( "myLibrary.dll", &myDll, &fplSize, sizeof(myDll) );
if (result != CHIPDLL_ERR_OK)
{
  // Error while load DLL!
  return -1;
}

if ( fplSize < sizeof(myDll) )
{
  // Not all functions linked! Maybe it is an older
  // version of the DLL ?
  helper_unload_library( "myLibrary.dll" );
  return -2;
}

// Now the DLL's function can be called
myDll.myFirstDllFunction(5);
myDll.mySecondDllFunction("hello");

// When the DLL is no longer required, the application should sign off.
// When no more applications are signed in, the DLL will be removed from memory.
helper_unload_library( "myLibrary.dll" );

See Also

Supported since or modified in @CHIP-RTOS version

    SC12SC13SC11SC1x3SC2x
    V1.20V1.20V1.20V1.10V1.00

Supported by @CHIP-RTOS C Library since version

    CLIB
    V2.13

This API List
List of C Libraries
@CHIP-RTOS Main Index


End of document