RTEMS CPU Kit with SuperCore  4.11.3
Data Structures | Macros | Typedefs | Functions
rap.c File Reference

RTEMS Application Loader. More...

#include <stdarg.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <rtems/libio_.h>
#include <dlfcn.h>
#include <rtems/rtl/rap.h>
#include <rtems/rtl/rtl.h>
#include "rtl-find-file.h"
Include dependency graph for rap.c:

Data Structures

struct  rtems_rap_data_s
 The global RAP data. More...
 
struct  rtems_rap_app_s
 The RAP file data. More...
 

Macros

#define RTEMS_MUTEX_ATTRIBS
 Semaphore configuration to create a mutex. More...
 
#define RTL_ENTRY_POINT   "_rtems"
 RTL entry.
 

Typedefs

typedef struct rtems_rap_data_s rtems_rap_data_t
 The global RAP data. More...
 
typedef struct rtems_rap_app_s rtems_rap_app_t
 The RAP file data. More...
 
typedef int(* rtems_rap_entry_t) (int argc, const char *argv[])
 RAP entry call signature.
 

Functions

bool rtems_rap_load (const char *name, int mode, int argc, const char *argv[])
 Load an application. More...
 
bool rtems_rap_unload (const char *name)
 Unload an application. More...
 
void * rtems_rap_find (const char *name)
 Find the application handle given a file name. More...
 
bool rtems_rap_iterate (rtems_rap_iterator_t iterator)
 Run an iterator over the modules calling the iterator function. More...
 
const char * rtems_rap_name (void *handle)
 Return the name of the module given a handle. More...
 
void * rtems_rap_dl_handle (void *handle)
 Return the DL handle used to load the module given the RAP handle. More...
 
int rtems_rap_get_error (char *message, size_t max_message)
 Get the last error message clearing it. More...
 

Detailed Description

RTEMS Application Loader.

This is the RAP implementation.

Macro Definition Documentation

◆ RTEMS_MUTEX_ATTRIBS

#define RTEMS_MUTEX_ATTRIBS
Value:
RTEMS_INHERIT_PRIORITY | RTEMS_NO_PRIORITY_CEILING | RTEMS_LOCAL)
#define RTEMS_BINARY_SEMAPHORE
This attribute constant indicates that the Classic API Semaphore instance created will be a proper bi...
Definition: attr.h:106
#define RTEMS_PRIORITY
This is the attribute constant which reflects that blocking tasks will be managed using task priority...
Definition: attr.h:70
#define RTEMS_NO_PRIORITY_CEILING
This attribute constant indicates that the Classic API Semaphore instance created will NOT use the Pr...
Definition: attr.h:132
#define RTEMS_LOCAL
This is the attribute constant to indicate local resource.
Definition: attr.h:53

Semaphore configuration to create a mutex.

Typedef Documentation

◆ rtems_rap_app_t

The RAP file data.

This structure is allocated on the heap when a file is loaded.

◆ rtems_rap_data_t

The global RAP data.

This structure is allocated on the heap when the first call to location an application and is never released.

Function Documentation

◆ rtems_rap_dl_handle()

void* rtems_rap_dl_handle ( void *  handle)

Return the DL handle used to load the module given the RAP handle.

Parameters
handleThe module handle.
Returns
void* The DL handle returned by the dlopen call.

◆ rtems_rap_find()

void* rtems_rap_find ( const char *  name)

Find the application handle given a file name.

Parameters
nameThe name of the application file. It can be absolute or relative. Relative names can the basename with an extension.
Return values
NULLNo application file with that name found.
Returns
void* The application descriptor.

◆ rtems_rap_get_error()

int rtems_rap_get_error ( char *  message,
size_t  max_message 
)

Get the last error message clearing it.

This call is not thread safe is multiple threads are loading object files at the same time. This call follows the model provided by the dlopen family of calls.

Parameters
messagePointer to a buffer to copy the message into.
max_messageThe maximum message that can be copied.
Returns
int The last error number.

◆ rtems_rap_iterate()

bool rtems_rap_iterate ( rtems_rap_iterator_t  iterator)

Run an iterator over the modules calling the iterator function.

Parameters
iteratorThe iterator function.
Return values
trueThe iterator function returned did not return false.
falseThe iterator function returned false..

◆ rtems_rap_load()

bool rtems_rap_load ( const char *  name,
int  mode,
int  argc,
const char *  argv[] 
)

Load an application.

Parameters
nameThe name of the application file.
Returns
bool True if the module loads else an error.

◆ rtems_rap_name()

const char* rtems_rap_name ( void *  handle)

Return the name of the module given a handle.

Parameters
handleThe module handle.
Returns
const char* The name of the module if the handle is valid else it is NULL.

◆ rtems_rap_unload()

bool rtems_rap_unload ( const char *  name)

Unload an application.

Parameters
objThe application descriptor.
Return values
trueThe application file has been unloaded.
falseThe application could not be unloaded.