OSI Definition ToolAPI Syntax Definition

OSI Definition ToolAPI Syntax Definition

 

Each OSI (Operating System Implementation) contains a predefined list of API definitions. Each such API definition is intend to define the structure of the generated code that will result from use of that API. An API definition is often referred to as an OSI. OSIs are managed using the OSDT (Operating System Definition Tool) utility that is supplied with MicroC.

Each API definition might have predefined values that it would use, similar to the formal parameters of a function. To use predefined values in the API definition, you must use the predefined value name wrapped with the “$<” prefix and “>” postfix delimiters. Note that this notation is standard throughout the OSDT utility.

For example, consider the following API definition:

API Name Terminate Task(nameid),
API definition TerminateThread (t_$<nameid>.hndl, 0);

 

 

The resulting generated code, for a Task named “T1,” will be:

TerminateThread (t_T1.hndl, 0);
 

This is illustrated in the following figure.

Parameterizing an API Definition, Method 1

 

Another way to parameterize the API definition is to use the property value of the element itself, as defined in the Data Dictionary for it. For example, suppose the element has a design attribute named Create Mode that uses the attribute key word CK_createdMode, which then evaluates to:

CREATE_SUSPENDED
 

For the following API definition:

API Name Create Task(nameid)
 
API definition t_$<nameid>. hndl = CreateThread ( NULL ,
0 , ( LPTHREAD_START_ROUTINE )$<nameid> , NULL ,
$<CK_createdMode> , &t_$<nameid>.tid );
 
 

The resulting generated code, for a Task named “T1,” will be:

t_T1. hndl = CreateThread ( NULL , 0 ,

( LPTHREAD_START_ROUTINE ) T1, NULL ,

CREATE_SUSPENDED, &t_T1.tid );

T1*

 

Parameterizing an API Definition, Method 2

 

A third way to parameterize the API definition is to use the property value of the element itself (as defined in the DataDictionary for it) as the API definition itself. For example, suppose the element has a design attribute, possibly hidden, that uses the attribute key word:

CK_sendMessagesAPI

 

 

This evaluates to:

mySendMessage($<nameid>,...)
 

For the following API definition:

API Name Send Message(nameid)
API definition $<<CK_sendMessagesAPI>>
 

And design attribute definition:

mySendMessage($<nameid>, $<CK_MessagePriority>);
 

The resulting generated code, for a data item named DI1, will be:

mySendMessage(DI1, 1);

 

assuming that the CK_MessagePriority property evaluates to 1.

This third method is illustrated in the following figure.

Parameterizing an API Definition, Method 3

 

Note: A good use for this approach is to modify the API definition just for a local implementation requirement.
Note: Browsing of the defined key word, in the data dictionary, is supported in the tool. When in the definition field of the API, you can enter either of the following sequences, which will result in a list popping up with the predefined keys. The sequences are:

$<” and “$<<”. While in this list, pressing space, enter or “>” will close it.