REJ10J1822-0101 Stub Generator V.1.00 User’s Manual Renesas Microcomputer Development Environment System Rev.1.01 Revision Date: Mar.
Notes regarding these materials 1. This document is provided for reference purposes only so that Renesas customers may select the appropriate Renesas products for their use. Renesas neither makes warranties or representations with respect to the accuracy or completeness of the information contained in this document nor grants any license to any intellectual property rights or any other rights of Renesas or any third party with respect to the information in this document. 2.
Preface This manual describes how to use the stub generator. Read this manual and understand it well before using the stub generator. Notes on Descriptions RPCGEN Abbreviation for the stub generator Prefix Prefix 0x indicates a hexadecimal number. Numbers with no prefix are decimal. \ ‘\’ is the directory delimiter. [Menu -> Menu item] ‘->’ leads to the menu item (e.g. File -> Save).
Trademarks All trademarks and registered trademarks belong to their respective owners. 1. TRON is an acronym formed from "The Real Time Operating system Nucleus". ITRON is short for "Industrial TRON" and µITRON is short for "Micro Industrial TRON". TRON, ITRON, and µITRON are the names of computer specifications and do not indicate specific products or groups of products. The µITRON4.0 specification is an open realtime-kernel specification defined by the TRON Association. The µITRON4.
Contents Section 1 Overview..................................................................................................1 1.1 1.2 Overview............................................................................................................................... 1 Operating Environment......................................................................................................... 2 Section 2 Installation......................................................................................
5.5 5.6 5.7 5.4.3 CLNT_INCFILE................................................................................................. 30 5.4.4 SVR_INCFILE ................................................................................................... 31 Server Information.............................................................................................................. 32 5.5.1 SVR_NAME....................................................................................................... 32 5.5.
6.7 Optional Keywords ............................................................................................................. 83 6.7.1 SVRSTUB (Server Stub) .................................................................................... 84 6.7.2 SVRFUNC (Server Function Name) .................................................................. 85 6.7.3 CLNTSTUB (Client Stub) .................................................................................. 86 6.7.4 UNACK (Asynchronous Call) ......
vi
Section 1 Overview Section 1 Overview 1.1 Overview The stub generator (hereafter referred to as RPCGEN) is a tool used to generate the source code of the client and server stubs that are required whenever the remote procedure call (RPC) facility of the HI7200/MP realtime operating system is to be used. A config file is created by using a text editor and then input to RPCGEN, which creates the source code of the client and server stubs.
Section 1 Overview 1.2 Operating Environment RPCGEN is provided as a Perl script file. Table 1.1 shows the operating environment. Table 1.1 Operating Environment Item Operating Environment Realtime OS HI7200/MP V.1.00 Release 00 or later Perl environment We have confirmed correct execution of RPCGEN by ActivePerl 5.8.8.820 (for Windows® (x86)) produced by ActiveState Software Inc. ActivePerl is available for free download from the following Web site: http://www.activestate.
Section 2 Installation Section 2 Installation 2.1 Downloading RPCGEN can be downloaded for free from the Renesas Web site at the following URL. http://www.renesas.com 2.2 Installing RPCGEN The file for downloading has been compressed in the zip format. Expanding the zip file generates the files listed in table 2.1. These files must be stored in a suitable folder. Table 2.1 Files Provided as RPCGEN Filename Description rpcgen.pl Main body of RPCGEN rpcgen_clnt.
Section 2 Installation Rev. 1.01 Mar.
Section 3 Functions and Files Generated by RPCGEN Section 3 Functions and Files Generated by RPCGEN 3.1 Functions Generated by RPCGEN Figure 3.1 shows the functions generated by RPCGEN. Client Server Clientinitialization function Serverinitialization function Client-stub functions Server-stub functions Clientshutdown function Servershutdown function Figure 3.1 Functions Generated by RPCGEN Rev. 1.01 Mar.
Section 3 Functions and Files Generated by RPCGEN 3.1.1 Client (1) Client-initialization function This function initiates the connection with the server. Specifying CLNT_NOINIT prevents the creation of the client-initialization function. (2) Client-shutdown function This function ends the connection with the server. Specifying CLNT_NOSHUTDOWN prevents the creation of the client-shutdown function.
Section 3 Functions and Files Generated by RPCGEN 3.2 Files Generated by RPCGEN RPCGEN generates the files listed in table 3.1 in accord with the name of the config file. Table 3.1 Files Generated by RPCGEN Filename Description Definition of the File Location _clnt.c Client-stub source file CLNTS option or CLNT_SOURCEPATH in the config file _clnt.h Client-stub header file _private.
Section 3 Functions and Files Generated by RPCGEN (3) _private.h (internal header file for the client stub) This is a header file included by _clnt.c only. (4) _svr.c (server-stub source file) This file contains the server-stub functions, server-initialization function, server-shutdown function, and server-stub function table. (5) _svr.
Section 4 Executing RPCGEN Section 4 Executing RPCGEN 4.1 Executing RPCGEN RPCGEN must be executed from the command prompt as follows. perlΔ-IΔ\rpcgen.plΔ [Δ
Section 4 Executing RPCGEN 4.2 Options 4.2.1 PUBI Format: PUBI="" Description: This option is used to specify the path for output of _public.h. If this option is used, a definition of PUB_INCPATH in the config file is ignored. 4.2.2 CLNTS Format: CLNTS="" Description: This option is used to specify the path for output of _clnt.c. If this option is used, a definition of CLNT_SOURCEPATH in the config file is ignored. 4.2.
Section 4 Executing RPCGEN 4.2.4 SVRS Format: SVRS="" Description: This option is used to specify the path for output of _svr.c. If this option is used, a definition of SVR_SOURCEPATH in the config file is ignored. 4.2.5 SVRI Format: SVRI="" Description: This option is used to specify the path for output of _svr.h. If this option is used, a definition of SVR_INCPATH in the config file is ignored. Rev. 1.01 Mar.
Section 4 Executing RPCGEN 4.3 Executing RPCGEN as a Build Phase in the High-performance Embedded Workshop After RPCGEN has been registered as a custom build phase in the workspace, it will be automatically executed at the time of building. (1) Defining Custom Placeholders The following two custom placeholders must be defined. • Path to RPCGEN [Placeholder]: RPCGEN_INST [Description]: RPCGEN Base directory [Directory]: Directory under which RPCGEN is stored • Path to Perl.
Section 4 Executing RPCGEN (2) Adding a File Extension To make execution as a custom build phase work, the filename extension “.x” for config files must be added as a filename extension to be used in custom build phases. Select [Project->File Extensions] from the menu bar of the High-performance Embedded Workshop. This opens the [File Extensions] dialog box shown in figure 4.2. Figure 4.2 [File Extensions] Dialog Box Clicking the [Add] button opens the [Add File Extension] dialog box shown in figure 4.3.
Section 4 Executing RPCGEN Figure 4.3 [Add File Extension] Dialog Box Rev. 1.01 Mar.
Section 4 Executing RPCGEN (3) Creating the RPCGEN Custom Build Phase Select [Build->Build Phases] from the menu bar of the High-performance Embedded Workshop. This opens the [Build Phases] dialog box shown in figure 4.4. Figure 4.4 [Build Phases] Dialog Box Clicking on the [Add] button invokes the [New Build Phase] wizard (figure 4.5). Rev. 1.01 Mar.
Section 4 Executing RPCGEN Figure 4.5 [New Build Phase - Step 1 of 4] Dialog Box Click on [Next] to go to step 2. Figure 4.6 [New Build Phase - Step 2 of 4] Dialog Box Rev. 1.01 Mar.
Section 4 Executing RPCGEN At step 2, select [Multiple phase]. Then select [RPCGEN config file] for [Select input file group]. Click on [Next] to go to step 3. Figure 4.7 [New Build Phase - Step 3 of 4] Dialog Box [Phase name]: Any name defined by the user (“rpcgen” in this example) [Command]: $(PERL_INST)\perl.exe [Default options]: -I $(RPCGEN_INST) $(RPCGEN_INST)\rpcgen.pl $(FULLFILE) [Initial directory]: $(FILEDIR) Click on [Next] to go to step 4. Rev. 1.01 Mar.
Section 4 Executing RPCGEN Figure 4.8 [New Build Phase - Step 4 of 4] Dialog Box Although no environment variables need to be added for RPCGEN, you can add environment variables for the Perl environment as required. Creation of the RPCGEN custom build phase is now complete. Next, the syntax for messages about RPCGEN must be defined. After the syntax has been defined, the corresponding config file (*.
Section 4 Executing RPCGEN Now settings must be made so that the files output by RPCGEN will be deleted by [Build->Clean Current Project] or [Build->Clean All Projects] from the High-performance Embedded Workshop. Select [Build->rpcgen] to open the [rpcgen Options] dialog box (figure 4.10). Select the [Output Files] tab, check that the “RPCGEN config file” folder icon is active, and click on the [Add] button.
Section 4 Executing RPCGEN (4) Settings in the [Build Phases] Dialog Box The created RPCGEN custom build phase is shown at the bottom of the [Build Phases] dialog box. Use the [Move Up] button to move “rpcgen” so that it is above “SH C/C++ Library Generator.” Figure 4.12 [Build Phases] Dialog Box - [Build Order] Tab Open the [Build File Order] tab. Select “RPCGEN config file” under [File group] and check the box for [rpcgen] under [Phase order]. Rev. 1.01 Mar.
Section 4 Executing RPCGEN Figure 4.13 [Build Phases] Dialog Box - [Build File Order] Tab Setting of the RPCGEN build phase is now complete. Rev. 1.01 Mar.
Section 4 Executing RPCGEN Rev. 1.01 Mar.
Section 5 Specifications of a Config File Section 5 Specifications of a Config File A config file contains definitions used for creation of the client and server stubs. Specifically, such definitions are made by appending keywords for passing to RPCGEN to the API of the server functions (as described in section 6, Definitions of Server Functions). Read this section carefully before creating your own config file. The extension for config files is “.x.
Section 5 Specifications of a Config File (3) Server information • SVR_NAME{…}; Server name • SVR_ID{…}; Server ID • SVR_VERSION{…}; Server version • SVR_NOINIT; The server-initialization function is not to be created. • SVR_NOSHUTDOWN; The server-shutdown function is not to be created. • SVR_NOSTUBTBL; The server-stub function table is not to be created.
Section 5 Specifications of a Config File 5.3 File Locations Use the statements listed below to define paths to the files generated by RPCGEN. If these definitions are omitted, RPCGEN will generate the source or header files in the current directory. If a definition is otherwise correct but the defined path does not exist or the directory already contains read-only files, RPCGEN displays an error message and terminates the processing. The following definitions of file locations are available.
Section 5 Specifications of a Config File 5.3.2 CLNT_SOURCEPATH Format: CLNT_SOURCEPATH{""}; Description: This statement defines the path under which _clnt.c will be generated. When the CLNTS option is used, a definition of CLNT_SOURCEPATH is ignored. Example: CLNT_SOURCEPATH{"clnt\source"}; _clnt.c will be generated in the clnt\source directory under the current directory. 5.3.
Section 5 Specifications of a Config File 5.3.4 SVR_SOURCEPATH Format: SVR_SOURCEPATH{""}; Description: This statement defines the path under which _svr.c will be generated. When the SVRS option is used, a definition of SVR_SOURCEPATH is ignored. Example: SVR_SOURCEPATH{"svr\source"}; _svr.c will be generated in the svr\source directory under the current directory. 5.3.
Section 5 Specifications of a Config File 5.4 Controlling the Output of #include Directives Use the statements listed below to output #include directives for user files to the files generated by RPCGEN. Note, however, that #include directives for the following include files will always be output. Table 5.1 Default Include Files Filename Description string.h Standard include file for the compiler types.
Section 5 Specifications of a Config File 5.4.1 Order of #Include Directives RPCGEN outputs #include directives to files in the following order. (1) _clnt.c 1. Default include files (in the order given in table 5.1) 2. File(s) defined with GLOBAL_INCFILE (in the order of file definition) 3. File(s) defined with CLNT_INCFILE (in the order of file definition) 4. _public.h generated by RPCGEN (only if SVR_AUTH has not been defined) 5. _clnt.h generated by RPCGEN 6.
Section 5 Specifications of a Config File 5.4.2 GLOBAL_INCFILE Format: GLOBAL_INCFILE{[Δ...]}; Description: This statement is for the output of #include directives for the specified files to _clnt.c and _svr.c. File(s) must be specified in the form "filename" or . The difference between these two formats is as defined in the specification of the #include directive. When two or more files are to be specified, they must be separated by a space.
Section 5 Specifications of a Config File 5.4.4 SVR_INCFILE Format: SVR_INCFILE{[Δ...]}; Description: This statement is for the output of #include directives for the specified files to _svr.c. File(s) must be specified in the form "filename" or . The difference between these two formats is as defined in the specification of the #include directive. When two or more files are to be specified, they must be separated by a space. Example: SVR_INCFILE{
Section 5 Specifications of a Config File 5.5 Server Information The following types of definitions are available for defining server information. • SVR_NAME{…}; Server name • SVR_ID{…}; Server ID • SVR_VERSION{…}; Server version • SVR_NOINIT; The server-initialization function is not to be created. • SVR_NOSHUTDOWN; The server-shutdown function is not to be created. • SVR_NOSTUBTBL; The server-stub function table is not to be created.
Section 5 Specifications of a Config File 5.5.2 SVR_ID Format: SVR_ID {}; Description: This statement defines the server ID. The ID number can only be specified as a 4-byte integer constant that can be represented as UINT32 or a C-language macro name to be replaced by such a 4-byte integer constant. If a C-language macro is used, this macro must have been defined in a file specified by GLOBAL_INCFILE.
Section 5 Specifications of a Config File 5.5.3 SVR_VERSION Format: SVR_VERSION {}; Description: This statement defines the server version. The server version can only be specified as a 4-byte integer constant that can be represented as UINT32 or a C-language macro name to be replaced by such a 4-byte integer constant. If a C-language macro is used, this macro must have been defined in a file specified by GLOBAL_INCFILE. The server version is output to _public.
Section 5 Specifications of a Config File 5.5.5 SVR_NOSTUBTBL Format: SVR_NOSTUBTBL; Description: The server-stub function table is rpc_server_info.ServerStubList, the table defined by rpc_start_server() or rpc_start_server_with_paramarea() called by the server-initialization function. If this statement is present, RPCGEN will not create the server-stub function table. Use SVR_NOSTUBTBL when the server-initialization function is provided as part of the application. Also refer to section 8.
Section 5 Specifications of a Config File 5.5.6 SVR_NOSHUTDOWN Format: SVR_NOSHUTDOWN; Description: If this statement is present, RPCGEN will not create the server-shutdown function. Use SVR_NOSHUTDOWN when the server-shutdown function is provided as part of the application. The server-shutdown function generated by RPCGEN calls rpc_stop_server() to stop the server.
Section 5 Specifications of a Config File 5.5.7 SVR_STATIC Format: SVR_STATIC{Δ}; Description: This statement defines the server as static. If this definition is omitted, the server will be dynamic. Note that SVR_STATIC cannot be used in conjunction with SVR_NOINIT. indicates the size of the server parameter area. Specify an integer constant that can be represented as UINT32. The specified value is rounded up to the nearest multiple of four.
Section 5 Specifications of a Config File 5.5.8 SVR_AUTH Format: SVR_AUTH; Description: There are two ways to assign the server ID and server version. (1) Model 1 Model 1 applies when SVR_AUTH has not been specified. In this model, the application does not recognize the server ID or server version. The server ID and server version are determined within the client and server stubs generated by RPCGEN. Each of the client-stub functions has the same API as the original server function.
Section 5 Specifications of a Config File Server application Client application Any server IDs and server versions in parameters are ignored func(...) (same API as the original server function) Any server IDs and server versions in parameters are ignored _public.
Section 5 Specifications of a Config File (2) Model 2 Model 2 applies when SVR_AUTH has been specified. In this model, the application assigns the server ID and server version. RPCGEN outputs definitions of the server ID and server version in _public.h so that the application is able to acquire this information. Each of the client-stub functions is in the form of rpcclnt__ and its first and second parameters are the server ID and server version, respectively.
Section 5 Specifications of a Config File _public.h Server ID Server version Client application Server ID and server version Clientinitialization function Clientshutdown function rpcclnt__func (server ID, server version, ...
Section 5 Specifications of a Config File 5.5.9 SVR_SECTION Format: SVR_SECTION{}; Description: This statement specifies the section to which the server stubs will be assigned. When this definition is omitted, one of the section names (alphabetical characters) listed below will automatically be assigned. If SVR_SECTION has been defined, the actual section name will be one of the letters listed below followed by
Section 5 Specifications of a Config File 5.6 Client Information The following definitions of client information are available. • CLNT_NOINIT; The client-initialization function is not to be created. • CLNT_NOSHUTDOWN; The client-shutdown function is not to be created. • CLNT_CALLCHK; Facilitates saving the return value in RPC calls • CLNT_SECTION{…}; Section name to be given to the client stub 5.6.
Section 5 Specifications of a Config File 5.6.2 CLNT_NOSHUTDOWN Format: CLNT_NOSHUTDOWN; Description: RPCGEN creates the following client-shutdown function in _clnt.c as the standard: INT32 rpcclnt__shutdown(UINT32 __ulRPCServerID, UINT32 __ulRPCServerVersion ); If the CLNT_NOSHUTDOWN statement is present, RPCGEN will not create the client-shutdown function. Use CLNT_NOSHUTDOWN when the client-shutdown function is provided as part of the application.
Section 5 Specifications of a Config File 5.6.3 CLNT_CALLCHK Format: CLNT_CALLCHK; Description: RPCGEN creates the following code in _clnt.c to facilitate saving of the return values of RPC calls (rpc_call() or rpc_call_copycbk()) and outputs the API of *rpc_retval_adr() in _clnt.h. *rpc_retval_adr() = rpc_call(...); rpc_retval_adr() must be implemented by the user.
Section 5 Specifications of a Config File 5.6.4 CLNT_SECTION Format: CLNT_SECTION{}; Description: This statement specifies the section to which the client stubs will be assigned. When this definition is omitted, one of the section names (alphabetical characters) listed below will automatically be assigned. If CLNT_SECTION has been defined, the actual section name will be one of the letters listed below followed by the
Section 5 Specifications of a Config File 5.7 Server Functions The following definition statement is available for defining server functions. • RPC_FUNC{…}; 5.7.1 Server functions RPC_FUNC Format: RPC_FUNC { ; ... }; Description: Enter definitions of server functions between the braces {} of RPC_FUNC. For information on definition statements for server functions, refer to section 6, Definitions of Server Functions.
Section 5 Specifications of a Config File Rev. 1.01 Mar.
Section 6 Definitions of Server Functions Section 6 Definitions of Server Functions 6.1 Format Server functions must be defined in one of the following formats. (1) = (, ...)[
Section 6 Definitions of Server Functions Example 2: Specification of a server function void func(struct ST *ptr); The function takes ptr, a pointer to a structure of type ST, as an input and does not return a value.
Section 6 Definitions of Server Functions Example 3: Specification of a server function double func(double inf); The input is inf and a value of type double will be returned.
Section 6 Definitions of Server Functions 6.2 Function-Type Directives 6.2.1 Function with a Return Value Format: Δ= Description: refers to a local variable used to store the return value in both client and server stubs. A parameter of the function may be specified as this variable.
Section 6 Definitions of Server Functions 6.2.2 Function without a Return Value Description: For a function that doesn’t have a return value, a return-value specification must not be made. Example: Specification of a server function void func(struct ST *ptr); The function has no input and returns a value in the ST structure indicated by *ptr. Definition of the server function func([OUT PTR]struct ST *ptr); Rev. 1.01 Mar.
Section 6 Definitions of Server Functions 6.2.3 When the Return Value is not Representable as a 4-Byte Integer Format: [RETEXT]ΔΔ = Description: By default, the return value is cast into UINT32 in the server stub and then transferred to the client. This value is cast back into the original type in the client stub and is then returned.
Section 6 Definitions of Server Functions 6.3 Function Names Description: Type the name of the function you wish to use. Example: Specification of a server function int func(int par); The function takes par as an input and returns a value of type int. Definition of the server function int ret = func([IN DFLT]int par); Rev. 1.01 Mar.
Section 6 Definitions of Server Functions 6.4 Parameters Parameters must be defined in the following format. [parameter directive] The parameter directive is a declaration of the following parameter specification and has the form given below. [Δ] : Specify one of the keywords given in section 6.5, Keywords for Input/Output. : Specify one of the keywords given in section 6.6, Keywords for Data Types.
Section 6 Definitions of Server Functions 6.5 Keywords for Input/Output The following three keywords are available for setting the input/output attributes of parameters. • IN: Input • OUT: Output • INOUT: Input and output The following optional keywords can also be attached to the keywords listed above (note, however, that REF and DESC cannot be used at the same time).
Section 6 Definitions of Server Functions 6.5.2 OUT (Output) Description: This keyword defines a parameter as an output from the server function. The data output by the server function to the area specified by the parameter are returned to the client. This keyword can only be used with the data-type keywords PTR and ARY. Example: Specification of a server function void func(struct ST *ptr); The function has no input and returns a value in the ST structure indicated by *ptr.
Section 6 Definitions of Server Functions 6.5.3 INOUT (Input and Output) Description: This keyword defines a parameter as an input to and output from the server function. The data in the area specified by the parameter are transferred from the client to the server and then passed to the server function. After that, the data output by the server function to the area specified by the parameter are returned to the client. This keyword can only be used with the data-type keywords PTR and ARY.
Section 6 Definitions of Server Functions 6.5.4 REF (Passing by Reference) Description: This keyword specifies that only the address of the parameter will be passed between the client and the server. REF is useful when the size of the parameter to be passed is large. This keyword can be used in conjunction with IN and with the data-type keywords PTR, STR, and ARY. Figure 6.1 illustrates the difference between cases with and without REF.
Section 6 Definitions of Server Functions Without the REF specification, the data indicated by the pointer variable specified with PTR, STR, or ARY are transferred. The transferred pointer points to a different area from that before the transfer. With the REF specification, the pointer variable is transferred. In this case, the pointer points to the same area even after the transfer.
Section 6 Definitions of Server Functions 6.5.5 DESC (Specified Parameter is not Passed from the Client to the Server) Description: This keyword specifies that the parameter will not be passed from the client to the server. This keyword can also be used with IN. Example: Specification of a server function int func(void); While the actual server function has no parameter, the client application calls an old API function, func, which does have a parameter (int par).
Section 6 Definitions of Server Functions 6.6 Keywords for Data Types Select one of the following four available keywords. • DFLT: Default • PTR: Pointer • STR: String • ARY: Array When ARY is selected, the parameter for COUNT must also be specified. 6.6.1 DFLT (Default) Input/Output Keywords Available for Use in Combination with DFLT: IN Description: The parameter itself is transferred between the client and server. DFLT is only specifiable when the parameter has any of the following types.
Section 6 Definitions of Server Functions 6.6.2 STR (String) Input/Output Keywords Available in Combination with STR: IN Description: The string specified as the parameter is transferred from the client to the server. STR is only specifiable when the parameter is of the character type. When STR is used with REF, the pointer to the string is transferred instead of the string itself. For details, refer to section 6.5.4, REF (Passing by Reference).
Section 6 Definitions of Server Functions 6.6.3 PTR (Pointer) Input/Output Keywords Available in Combination with PTR: All Description: The data pointed to by a specified pointer are transferred between the client and the server. PTR is only specifiable when the parameter is of the pointer type. When IN has been selected and REF is used with PTR, the pointer value is transferred instead of the data it indicates. For details, refer to section 6.5.4, REF (Passing by Reference).
Section 6 Definitions of Server Functions 6.6.4 ARY (Array) Input/Output Keywords Available in Combination with ARY: All Description: The data of a specified array are transferred between the client and the server. ARY is only specifiable when the parameter is of the array type. As the parameter specification that follows this keyword, define a parameter that expresses the first address of the array.
Section 6 Definitions of Server Functions 6.6.5 COUNT (Number of Elements in an Array) Description: When ARY is used, it must be followed by a definition of COUNT, which indicates the number of elements in the array to be passed between the client and the server. When the input/output keyword selected for ARY is IN (1) In this case, a parameter specification that includes ARY must be followed by a single definition of COUNT to indicate the number of elements in the array.
Section 6 Definitions of Server Functions UINT32 rpcsvr_SMPL_func( rpc_server_stub_info * __pInfo ) { ... inf = (struct INF *)( __pInfo->pucParamArea + __ulInputParamOffset); __ulInputParamOffset += ALIGNUP4(sizeof(*inf)); if (((UINT32)(inf->count)) > 0UL) { ptr = (struct ST *)( __pInfo->pucParamArea + __ulInputParamOffset); } ... ret = func( inf, ptr ); ... return ((UINT32)ret); } Figure 6.
Section 6 Definitions of Server Functions Example 2 Specification of a server function int func(struct ST *ptr, int count); Pointer ptr to an array of count elements of the structure type (ST) will be passed. Definition of the server function int ret = func([IN ARY]struct ST *ptr, [COUNT]count,[IN DFLT]int count); Example 3 Specification of a server function int func(int count , struct ST *ptr); Pointer ptr to an array of count elements of the structure type (ST) will be passed.
Section 6 Definitions of Server Functions Example 5 Specification of a server function int func(struct INF *inf, struct ST *ptr); ptr points to an array to be given to the server function and inf indicates other input information. It has a type-int member count, which indicates the number of elements in the array pointed to by ptr. Definition of the server function int ret = func([IN PTR]struct INF *inf, [IN ARY]struct ST *ptr, [COUNT]inf->count); Rev. 1.01 Mar.
Section 6 Definitions of Server Functions (2) When the input/output keyword selected for ARY is OUT In this case, a parameter specification that includes ARY must be followed by two definitions of COUNT to indicate the number of elements in the array. ,, The first COUNT is the COUNT keyword followed by an expression that specifies the number of elements in the array for storage of output by the client.
Section 6 Definitions of Server Functions int func (struct INF * inf, struct ST * ptr ) { IOVEC __input[1]; IOVEC __output[1]; ... __input[ __ulInputParamCount ].pBaseAddress = (UINT8 *)(inf); __input[ __ulInputParamCount++ ].ulSize = sizeof(*inf); if (((UINT32)(inf->count)) > 0UL) { __output[ __ulOutputParamCount ].pBaseAddress __output[ __ulOutputParamCount++ ].ulSize = (UINT8 *)(ptr); = sizeof(*ptr) * ((UINT32)(inf->count)); } ... rpc_call(...); } Figure 6.
Section 6 Definitions of Server Functions UINT32 rpcsvr_SMPL_func( rpc_server_stub_info * __pInfo ) { ... inf = (struct INF *)( __pInfo->pucParamArea + __ulInputParamOffset); __ulInputParamOffset += ALIGNUP4(sizeof(*inf)); if (((UINT32)(inf->count)) > 0UL) { ptr = (struct ST *)( __pInfo->pucParamArea + __ulInputParamOffset); } ret = func( inf, ptr ); __pInfo->pOutputIOVectorTable[ __ulOutputParamCount ].
Section 6 Definitions of Server Functions Examples: Example 1 Specification of a server function int func(struct ST *ptr); ptr points to an array for output that has 10 elements. func outputs all 10 elements. Definition of the server function int ret = func([OUT ARY]struct ST *ptr,[COUNT]10, [COUNT]10)); Example 2 Specification of a server function int func(struct ST *ptr, int *p_count); ptr points to an array for output that has 10 elements.
Section 6 Definitions of Server Functions Example 4 Specification of a server function int func(struct ST *ptr, int *p_count); ptr points to an array for output that has *p_count elements. func outputs the return parameter *p_count as the number of elements.
Section 6 Definitions of Server Functions Example 6 Specification of a server function int func(struct INF *inf, struct ST *ptr, int *p_count); ptr points to an array for output and inf indicates other input information. It has a type-int member count, which indicates the number of elements in the array pointed to by ptr. func outputs the return parameter *p_count as the number of elements.
Section 6 Definitions of Server Functions Example 8 Specification of a server function int func(struct INF *inf, struct ST *ptr); ptr points to an array for output and inf indicates other input information, including a type-int member count, which indicates the number of elements in the array pointed to by ptr. The return value indicates the number of elements to be output.
Section 6 Definitions of Server Functions int func (struct INF * inf, struct ST * ptr ) { IOVEC __input[2]; IOVEC __output[1]; ... __input[ __ulInputParamCount ].pBaseAddress = (UINT8 *)(inf); __input[ __ulInputParamCount++ ].ulSize = sizeof(*inf); if (((UINT32)(inf->count)) > 0UL) { __input[ __ulInputParamCount ].pBaseAddress = (UINT8 *)(ptr); __input[ __ulInputParamCount++ ].ulSize = sizeof(*ptr) * ((UINT32)(inf->count)); } if (((UINT32)(inf->count)) > 0UL) { __output[ __ulOutputParamCount ].
Section 6 Definitions of Server Functions UINT32 rpcsvr_SMPL_func( rpc_server_stub_info * __pInfo ) { ... inf = (struct INF *)( __pInfo->pucParamArea + __ulInputParamOffset); __ulInputParamOffset += ALIGNUP4(sizeof(*inf)); if (((UINT32)(inf->count)) > 0UL) { ptr = (struct ST *)( __pInfo->pucParamArea + __ulInputParamOffset); __ulInputParamOffset += ALIGNUP4(sizeof(*ptr) * ((UINT32)(inf->count))); } ... ret = func( inf, ptr ); __pInfo->pOutputIOVectorTable[ __ulOutputParamCount ].
Section 6 Definitions of Server Functions Examples: Example 1 Specification of a server function int func(struct ST *ptr); ptr points to an array for input and output that has 10 elements. func outputs all 10 elements. Definition of the server function int ret = func([INOUT ARY]struct ST *ptr,[COUNT]10, [COUNT]10); Example 2 Specification of a server function int func(struct ST *ptr, int *p_count); ptr points to an array for input and output that has 10 elements.
Section 6 Definitions of Server Functions Example 4 Specification of a server function int func(struct ST *ptr, int *p_count); ptr points to an array for input and output that has *p_count elements. func outputs the return parameter *p_count as the number of elements.
Section 6 Definitions of Server Functions Example 6 Specification of a server function int func(struct INF *inf, struct ST *ptr, int *p_count); ptr points to an array for input and output and inf indicates other input information, including a type-int member count, which indicates the number of elements in the array pointed to by ptr. func outputs the return parameter *p_count as the number of elements.
Section 6 Definitions of Server Functions Example 8 Specification of a server function int func(struct INF *inf, struct ST *ptr); ptr points to an array for input and output and inf indicates other input information, including a type-int member count, which indicates the number of elements in the array pointed to by ptr. The return value indicates the number of elements to be output.
Section 6 Definitions of Server Functions Table 6.2 shows the available combinations of optional keywords. Table 6.2 Combinations of Optional Keywords SVRSTUB SVRSTUB SVRFUNC SVRFUNC CLNTSTUB UNACK CLNTCOPYCBK ⎯ 9 9 9 9 9 9 ⎯ ⎯ CLNTSTUB 9 UNACK CLNTCOPYCBK 9: Available ⎯: Not available (RPCGEN reports an error and terminates processing) 6.7.
Section 6 Definitions of Server Functions 6.7.2 SVRFUNC (Server Function Name) Format: [SVRFUNC] Description: RPCGEN replaces the name of the server function to be called by the server stub with a specific name. Use SVRFUNC when the name of a function as called by the client does not match the name of the function as called by the server. SVRFUNC cannot be used with SVRSTUB.
Section 6 Definitions of Server Functions 6.7.3 CLNTSTUB (Client Stub) Format: [CLNTSTUB] Description: A client stub provided by the user is to be used, so RPCGEN does not create a client stub. Example: Specification of a server function int func(int par); The function takes par as an input and returns a value of type int. RPCGEN will not create a client stub for func because the user will provide this client stub. Definition of the server function int ret = func([IN DFLT]int par)[CLNTSTUB]; Rev. 1.
Section 6 Definitions of Server Functions 6.7.4 UNACK (Asynchronous Call) Format: [UNACK] Description: The client makes RPC calls in asynchronous mode. When UNACK is not used, RPC calls are made in synchronous mode. UNACK cannot be used with CLNTSTUB. Note: When UNACK is used, the return value of the server function must be of type void and the input/output keyword for parameters must be IN. Example: Specification of a server function void func(int par); The function takes par as an input.
Section 6 Definitions of Server Functions 6.7.5 CLNTCOPYCBK (RPC Call by rpc_call_copycbk()) Format: [CLNTCOPYCBK] Description: RPC calls are started by rpc_call_copycbk(). and are copy callback functions specified in rpc_call_copycbk(). Specification of the two callback functions is mandatory. The prototype for the callback functions must conform with the RPC specifications and has to be declared in a file included by the client stub.
Section 7 Server Functions Not Supported by RPCGEN Section 7 Server Functions Not Supported by RPCGEN This section gives the types of functions not supported by RPCGEN. If a server function you are using falls under the definitions in this section, use SVRSTUB or CLNTSTUB so that RPCGEN will not create a server or client stub for the server function. A substitute server or client stub must be implemented by the user. 7.
Section 7 Server Functions Not Supported by RPCGEN (2) Multiple-level pointers RPCGEN only recognizes the first level of multiple-level pointers. Example: Specification of a server function int func(int **ptr); The function takes ptr, a pointer to a pointer to int-type data, as an input. Definition of the server function int ret = func([IN PTR] int **ptr); In this case, RPCGEN creates code to transfer *ptr from the client to the server.
Section 7 Server Functions Not Supported by RPCGEN 7.2 Return Value (1) Pointer If a function returns a pointer-type value, this return value indicates an address in the server. RPCGEN does not create any code to transfer the data indicated by the pointer from the server to the client. Example: Specification of a server function int *func(int par); The return value is a pointer to int-type data.
Section 7 Server Functions Not Supported by RPCGEN Rev. 1.01 Mar.
Section 8 Application Interface Section 8 Application Interface 8.1 Client-Stub Functions Generated by RPCGEN The client-stub functions are called by the client application. This section gives the specifications for the client-stub functions generated by RPCGEN. The client-stub functions must be called in accord with the definitions in these specifications. If CLNTSTUB is used to prevent creation of client-stub functions, the user must implement clientstub functions in accord with the specifications.
Section 8 Application Interface (2) When SVR_AUTH has been specified Each of the client-stub functions has a different API from the corresponding actual server function and the server ID and server version information are added as parameters. RPCGEN outputs the client-stub functions themselves to _clnt.c and the prototype declarations to _clnt.h. The name of each client-stub function takes the form rpcclnt__.
Section 8 Application Interface 8.2 Server-Stub Functions Generated by RPCGEN RPCGEN outputs the server-stub functions themselves to _svr.c and the prototype declarations to _svr.h. The name of each server-stub function takes the form rpcsvr__. refers to the server name defined with SVR_NAME and refers to server function names defined between the braces {} of RPC_FUNC.
Section 8 Application Interface 8.3 Server-Initialization Function The server-initialization function is called by the server application and starts up the server by using rpc_start_server() or rpc_start_server_with_paramarea(). When SVR_NOINIT has not been specified, RPCGEN generates a server-initialization function rpcsvr__init. RPCGEN outputs the server-initialization function itself to _svr.c and the prototype declaration to _svr.h.
Section 8 Application Interface • Specification The server is started up by calling rpc_start_server() when SVR_STATIC has not been specified or rpc_start_server_with_paramarea() when SVR_STATIC has been specified. When SVR_AUTH has not been specified, however, the definitions of server ID and version in __config. UlRPCServerID and __config. UlRPCServerVersion are ignored. Instead, the macros RPCSVR_ID_ and RPCSVR_VERS_ output to _public.
Section 8 Application Interface (3) With SVR_NOSTUBTBL and without SVR_NOINIT RPCGEN does not generate the server-stub function table but does generate the serverinitialization function. RPCGEN assumes that the server-stub function table shown below is provided in the application and outputs the server-initialization function, which externally refers to the table, to _svr.c.
Section 8 Application Interface 8.5 Server-Shutdown Function The server-shutdown function is called by the server application and stops the server by using rpc_stop_server(). When SVR_NOSHUTDOWN has not been specified, RPCGEN generates a server-shutdown function rpcsvr__shutdown. RPCGEN outputs the server-shutdown function itself to _svr.c and the prototype declaration to _svr.h. refers to the server name defined with SVR_NAME.
Section 8 Application Interface 8.6 Client-Initialization Function The client-initialization function is called by the client application and initiates connection to the server by using rpc_connect(). When CLNT_NOINIT has not been specified, RPCGEN generates a client-initialization function rpcclnt__init. RPCGEN outputs the client-initialization function itself to _clnt.c and the prototype declaration to _clnt.h.
Section 8 Application Interface 8.7 Client-Shutdown Function The client-shutdown function is called by the client application and terminates the connection to the server by using rpc_disconnect(). When CLNT_NOSHUTDOWN has not been specified, RPCGEN generates a client-shutdown function rpcclnt__shutdown. RPCGEN outputs the client-shutdown function itself to _clnt.c and the prototype declaration to _clnt.h.
Section 8 Application Interface 8.8 rpc_retval_adr() rpc_retval_adr() is a client function to be provided by the user when CLNT_CALLCHK (refer to section 5.6.3, CLNT_CALLCHK) is specified. rpc_retval_adr() must be created according to the specification given below. • C-language API INT32 *rpc_retval_adr(void); • Specification The address to hold the return value that depends on the context (task or non-task) in which rpc_retval_adr() was called is returned. Rev. 1.01 Mar.
Section 8 Application Interface • Example of implementation (for the HI7200/MP) #define MAXTSKID 10 /* Maximum task ID */ static INT32 retval[MAXTSKID+1]; /* Array to hold the return */ /* value in the context */ /* [0]: Non-task context */ /* [1] to [MAXTSKID]: Task ID */ INT32 *rpc_retval_adr(void) { INT32 *retval_adr; ID myid; if(sns_ctx() == TRUE) { /* In a non-task context */ retval_adr = retval; } else { /* In a task context */ get_tid(%myid); retval_adr = &retval[GET_LOCALID(myid)]; } return
Section 8 Application Interface 8.9 _public.h The following macro definitions are output to _public.h. #define RPCSVR_ID_ #define RPCSVR_VERS_ , , and refer to the server name, server ID, and server version defined with SVR_NAME, SVR_ID, and SVR_VERSION, respectively. The position of _public.h depends on whether SVR_AUTH has been specified or not.
Section 9 Notes Section 9 Notes (1) Check that the source program generated by RPCGEN works as intended. We do not guarantee the operation of the program generated by RPCGEN. Be sure to check that the program works as you intended. RPCGEN does not report errors except in cases where a fatal error has been detected (i.e. when continuing with current processing is impossible). (2) Do not modify the contents of the files generated by RPCGEN.
Section 9 Notes Rev. 1.01 Mar.
Section 10 Error Messages Section 10 Error Messages RPCGEN shows an error message and terminates processing only when it has detected a fatal error (i.e. when continuing with the current processing is impossible). In other words, RPCGEN behaves as if it has successfully completed code generation in many cases where it has not in fact done so. Cases in which no errors will be detected: Note: “->” in the list below indicates a behavior in the current implementation.
Section 10 Error Messages 10.2 General Cannot open configuration file. RPCGEN cannot access the specified config file. No definition. must not be omitted. The directory doesn't exist. The directory was specified as a path by a definition such as PUB_INCPATH but does not exist. Cannot create file. File: RPCGEN cannot generate the file . Cannot create temporary file. RPCGEN cannot generate intermediate files in the current directory. 10.
Section 11 Samples Section 11 Samples This section introduces samples of the code in a config file and the corresponding output files. To create these samples, we have used the C standard library functions and the HI7200/MP service calls listed in table 11.1. This is simply because we have assumed that most users will understand these functions, not because the functions should necessarily be distributed by the RPC facility. Table 11.
Section 11 Samples 11.1 Config File (sample.x) /********************************************************************** File Header Comment : Sample Config File for RPCGEN **********************************************************************/ PUB_INCPATH {"include"}; // Output path for xxx_public.h SVR_SOURCEPATH {"server"}; // Output path xxx_svr.c SVR_INCPATH {"server"}; // Output path xxx_svr.h CLNT_SOURCEPATH {"client"}; // Output path xxx_clnt.c CLNT_INCPATH xxx_private.
Section 11 Samples { // stdlib.h [RETEXT] double ret = atof ([IN STR] const char *nptr); // nptr does not have to point to non-cached area int ret = atoi ([IN REF STR] const char *nptr); // nptr must point to non-cached area // HI7200/MP service calls (renamed from original service call name) ER ercd = ref_tsk2 ([IN DFLT] ID tskid, [OUT PTR] T_RTSK *pk_rtsk); ER ercd = ref_sem2 ([IN DFLT] ID semid, [OUT PTR] T_RSEM *pk_rsem); }; Rev. 1.01 Mar.
Section 11 Samples 11.2 sample_clnt.h /********************************************************************** File Header Comment : Sample Config File for RPCGEN **********************************************************************/ /********************************************************************** * Do not edit, unless you really know what you are doing, * this file was automatically generated by: * * rpcgen.
Section 11 Samples #endif #endif /* End of _RPC_SMPL_CLNT_H */ 11.3 sample_private.h /********************************************************************** File Header Comment : Sample Config File for RPCGEN **********************************************************************/ /********************************************************************** * Do not edit, unless you really know what you are doing, * this file was automatically generated by: * * rpcgen.
Section 11 Samples 11.4 sample_clnt.c /********************************************************************** File Header Comment : Sample Config File for RPCGEN **********************************************************************/ /********************************************************************** * Do not edit, unless you really know what you are doing, * this file was automatically generated by: * * rpcgen.
Section 11 Samples UINT32 __ulOutputParamCount = 0UL; IOVEC __output[1]; double ret; UINT32 __ulReturn; __info.ulMarshallingType = 0UL; __info.ulServerID = RPCSVR_ID_SMPL; __info.ulServerVersion = RPCSVR_VERS_SMPL; __info.ulServerProcedureID = RPC_SMPL_ATOF; __info.AckMode = RPC_ACK; __info.pInputIOVectorTable __info.ulInputIOVectorTableSize = __input; = sizeof(__input) / sizeof (IOVEC); __info.pOutputIOVectorTable = __output; __info.
Section 11 Samples UINT32 __ulInputParamCount = 0UL; IOVEC __input[1]; int ret; __info.ulMarshallingType = 0UL; __info.ulServerID = RPCSVR_ID_SMPL; __info.ulServerVersion = RPCSVR_VERS_SMPL; __info.ulServerProcedureID = RPC_SMPL_ATOI; __info.AckMode = RPC_ACK; __info.pInputIOVectorTable = __input; __info.ulInputIOVectorTableSize = sizeof(__input) / sizeof (IOVEC); __info.pOutputIOVectorTable = NULL; __info.ulOutputIOVectorTableSize = 0UL; __info.
Section 11 Samples __info.ulMarshallingType = 0UL; __info.ulServerID = RPCSVR_ID_SMPL; __info.ulServerVersion = RPCSVR_VERS_SMPL; __info.ulServerProcedureID = RPC_SMPL_REF_TSK2; __info.AckMode = RPC_ACK; __info.pInputIOVectorTable = __input; __info.ulInputIOVectorTableSize = sizeof(__input) / sizeof (IOVEC); __info.pOutputIOVectorTable __info.ulOutputIOVectorTableSize (IOVEC); = __output; = sizeof(__output) / sizeof __info.pulLastOutputIOVectorSize = &__ulLastOutputIOVectorSize; __info.
Section 11 Samples __info.ulMarshallingType = 0UL; __info.ulServerID = RPCSVR_ID_SMPL; __info.ulServerVersion = RPCSVR_VERS_SMPL; __info.ulServerProcedureID = RPC_SMPL_REF_SEM2; __info.AckMode = RPC_ACK; __info.pInputIOVectorTable = __input; __info.ulInputIOVectorTableSize __info.pOutputIOVectorTable __info.ulOutputIOVectorTableSize (IOVEC); = sizeof(__input) / sizeof (IOVEC); = __output; = sizeof(__output) / sizeof __info.pulLastOutputIOVectorSize = &__ulLastOutputIOVectorSize; __info.
Section 11 Samples } Rev. 1.01 Mar.
Section 11 Samples 11.5 sample_svr.h /********************************************************************** File Header Comment : Sample Config File for RPCGEN **********************************************************************/ /********************************************************************** * Do not edit, unless you really know what you are doing, * this file was automatically generated by: * * rpcgen.
Section 11 Samples UINT32 rpcsvr_SMPL_ref_sem2( rpc_server_stub_info * __pInfo ); INT32 rpcsvr_SMPL_init ( rpc_svr_config * __config ); INT32 rpcsvr_SMPL_shutdown ( UINT32 __ulServerID, UINT32 __ulServerVersion ); #ifdef __cplusplus } #endif #endif /* End of _RPC_SMPL_SVR_H */ Rev. 1.01 Mar.
Section 11 Samples 11.6 sample_svr.c /********************************************************************** File Header Comment : Sample Config File for RPCGEN **********************************************************************/ /********************************************************************** * Do not edit, unless you really know what you are doing, * this file was automatically generated by: * * rpcgen.
Section 11 Samples nptr = ( const char *)( __pInfo->pucParamArea + __ulInputParamOffset); ret = atof( nptr ); *((double *)(__pInfo->pOutputIOVectorTable[ __ulOutputParamCount ].pBaseAddress)) = ret; __pInfo->pOutputIOVectorTable[ __ulOutputParamCount ].
Section 11 Samples T_RTSK * pk_rtsk; UINT32 __ulInputParamOffset = 0UL; UINT32 __ulOutputParamCount = 0UL; ER ercd; tskid = *(ID *)( __pInfo->pucParamArea + __ulInputParamOffset); __ulInputParamOffset += ALIGNUP4(sizeof(ID)); pk_rtsk = ( T_RTSK *)( __pInfo->pucParamArea + __ulInputParamOffset); ercd = ref_tsk2( tskid, pk_rtsk ); __pInfo->pOutputIOVectorTable[ __ulOutputParamCount ].pBaseAddress = pk_rtsk; __pInfo->pOutputIOVectorTable[ __ulOutputParamCount++ ].
Section 11 Samples pk_rsem = ( T_RSEM *)( __pInfo->pucParamArea + __ulInputParamOffset); ercd = ref_sem2( semid, pk_rsem ); __pInfo->pOutputIOVectorTable[ __ulOutputParamCount ].pBaseAddress = pk_rsem; __pInfo->pOutputIOVectorTable[ __ulOutputParamCount++ ].
Section 11 Samples __server_info.ulRPCServerVersion __server_info.ServerStubTaskPriority >ServerStubTaskPriority; = RPCSVR_VERS_SMPL; = __config- __server_info.ServerStubList = __rpcsvr_SMPL_StubTable; __server_info.ulNumFunctions = 4UL; __server_info.ulStubStackSize >ulStubStackSize; = __config- __server_info.pUserDefinedData >pUserDefinedData; = __config- __server_info.
Section 11 Samples 11.7 sample_public.h /********************************************************************** File Header Comment : Sample Config File for RPCGEN **********************************************************************/ /********************************************************************** * Do not edit, unless you really know what you are doing, * this file was automatically generated by: * * rpcgen.
Section 11 Samples Rev. 1.01 Mar.
Renesas Microcomputer Development Environment System User's Manual Stub Generator V.1.00 Publication Date: Rev.1.01, March 17, 2008 Published by: Sales Strategic Planning Div. Renesas Technology Corp. Edited by: Customer Support Department Global Strategic Communication Div. Renesas Solutions Corp. © 2008. Renesas Technology Corp., All rights reserved. Printed in Japan.
Sales Strategic Planning Div. Nippon Bldg., 2-6-2, Ohte-machi, Chiyoda-ku, Tokyo 100-0004, Japan RENESAS SALES OFFICES http://www.renesas.com Refer to "http://www.renesas.com/en/network" for the latest and detailed information. Renesas Technology America, Inc. 450 Holger Way, San Jose, CA 95134-1368, U.S.A Tel: <1> (408) 382-7500, Fax: <1> (408) 382-7501 Renesas Technology Europe Limited Dukes Meadow, Millboard Road, Bourne End, Buckinghamshire, SL8 5FH, U.K.
Stub Generator V.1.