@CHIP-RTOS C Library - Helper Functions


Load and link a dynamic link library (DLL).

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



File name of the DLL (with extension!)


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


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


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.


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.



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

// 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


Supported by @CHIP-RTOS C Library since version


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

End of document