Home

RI850V4 V2 Real-Time Operating System User`s Manual: Coding

image

Contents

1. h Task A Task B Task C Semaphore Priority 10 Priority 11 Priority 12 chg_pri Task B T h Task B Task A Task C Semaphore Priority 9 Priority 10 Priority 12 R20UT2889EJ0101 Rev 1 01 2tENESAS Page 31 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 3 TASK MANAGEMENT FUNCTIONS 3 8 Reference Task Priority A task priority is referenced by issuing the following service call from the processing program get_pri iget_pri Stores current priority of the task specified by parameter tskid in the area specified by parameter p_tskpri The following describes an example for coding this service call include lt kernel h gt include lt kernel_id h gt void task VP_INT exinf ID tskid 8 PRI p_tskpri get_pri tskid amp p_tskpri j Standard header file definition System information header file definition Declares and initializes variable Declares variable Reference task priority R20UT2889EJ0101 Rev 1 01 Sep 30 2015 2tENESAS Page 32 of 366 RI850V4 V2 CHAPTER 3 TASK MANAGEMENT FUNCTIONS 3 9 Reference Task State 3 9 1 Reference task state A task status is referenced by issuing the following service call from the processing program ref_tsk iref_tsk Stores task state packet current state current priority etc of the task specified by parameter tskid in the area specified by param
2. Keywords Meaning CRE_TSK_num The number of the definition of the Task information CRE_SEM_num The number of the definition of the Semaphore information CRE_FLG_num The number of the definition of the Eventflag information CRE_DTQ_num The number of the definition of the Data queue information CRE_MBX_num The number of the definition of the Mailbox information CRE_MTX_num The number of the definition of the Mutex information CRE_MPF_num The number of the definition of the Fixed sized memory pool information CRE_MPL_num The number of the definition of the Variable sized memory pool information CRE_CYC_num The number of the definition of the Cyclic handler information maxtpri The value of the definition in the Maximum priority maxtpri R20UT2889EJ0101 Rev 1 01 ztENESAS Page 356 of 366 Sep 30 2015 RI850V4 V2 APPENDIX B SIZE OF MEMORY B 1 4 kernel_data_init The size of kernel_data_init section is 4 bytes B 1 5 kernel_const_trace const The size of kernel_const_trace const section depends on the trace mode that is the mode selected in the Property panel gt Task Analyzer tab gt Trace category gt Selection of trace mode In the following table align4 x means the result of aligning the value x to a 4 byte boundary Type of Trace Mode Size of the Memory Area Not tracing align4 5 Bytes Taking in trace chart by
3. RI850V4 V2 FUNCTIONS include lt kernel h gt Standard header file definition include lt kernel_id h gt System information header file definition void task VP_INT exinf ER ercd Declares variable ID flgid ID_FLG1 Declares and initializes variable FLGPTN waiptn 14 Declares and initializes variable ODE wfmode TWF_ANDW Declares and initializes variable FLGPTN p_flgptn Declares variable TMO tmout 3600 Declares and initializes variable Wait for eventflag with timeout ercd twai_flg flgid waiptn wfmode amp p_flgptn tmout if ercd E_OK ETE Normal termination processing else if ercd E_RLWAI aaa igo eae ks Forced termination processing else if ercd E_TMOUT asa ai Timeout processing Note 1 With the RI850V4 whether to enable queuing of multiple tasks to the event flag wait queue is defined during Note 2 Note 3 Note 4 Note 5 R20UT2889EJ0101 Rev 1 01 Sep 30 2015 configuration If this service call is issued for the event flag TW_WSGL attribute to which a wait task is queued therefore E_ILUSE is returned regardless of whether the required condition is immediately satisfied TA_WSGL TA_WMUL Only one task is allowed to be in the WAITING state for the eventflag Multiple tasks are allowed to be in the WAITING state for the eventflag Invoking tasks are queued to the target event flag
4. A Macro of return value B Value of return value C Description of return value R20UT2889EJ0101 Rev 1 01 ztENESAS Page 176 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 16 SERVICE CALLS can_act ican_act Outline Cancel task activation requests C format ER_UINT can_act ID tskid ER_UINT ican_act ID tskid Parameter s V O Parameter Description ID number of the task for cancelling activation requests ID tskid TSK_SELF Invoking task Value ID number of the task for cancelling activation requests Explanation This service call cancels all of the activation requests queued to the task specified by parameter tskid sets the activation request counter to 0x0 When this service call is terminated normally the number of cancelled activation requests is returned Note This service call does not perform status manipulation processing but performs the setting of activation request counter Therefore the task does not move from a state such as the READY state to the DORMANT state Return value Macro Value Description Invalid ID number tskid lt 0x0 E_ID 18 tskid gt Maximum ID number When this service call was issued from a non task TSK_SELF was specified tskid Context error E_CTX 25 This service call was issued in the CPU locked state Non existent object E_NOEXS 42 Specified task is not registered posili
5. R20UT2889EJ0101 Rev 1 01 Sep 30 2015 2tENESAS Page 30 of 366 RI850V4 V2 CHAPTER 3 TASK MANAGEMENT FUNCTIONS 3 7 Change Task Priority The priority is changed by issuing the following service call from the processing program chg_pri ichg_pri These service calls change the priority of the task specified by parameter tskid current priority to a value specified by parameter tskpri If the target task is in the RUNNING or READY state after this service call is issued this service call re queues the task at the end of the ready queue corresponding to the priority specified by parameter tskpri following priority change processing The following describes an example for coding this service call include lt kernel h gt include lt kernel_id h gt void task VP_INT exinf chg pri tskid tskpri Standard header file definition System information header file definition Declares and initializes variable Declares and initializes variable Change task priority Note When the target task is queued to a wait queue in the order of priority the wait order may change due to issue of this service call Example When three tasks task A priority level 10 task B priority level 11 task C priority level 12 are queued to the semaphore wait queue in the order of priority and the priority level of task B is changed from 11 to 9 the wait order will be changed as follows
6. Acquire variable sized memory block polling ercd pget_mpl mplid blksz amp p_blk if ercd E_OK ae rere Polling success processing rel_mpl mplid p_ blk Release variable sized memory block lse if ercd E_TMOUT niet tray eid de Polling failure processing Note 1 The RI850V4 acquires variable size memory blocks in the unit of integral multiple of 4 If a value other than Note 2 Note 3 Note 4 an integral multiple of 4 is specified for parameter blksz it is rounded up to be an integral multiple of 4 The RI850V4 needs a 4 byte area management block to manage the acquired variable sized memory blocks When this service call is issued an area of blksz 4 bytes is allocated in the target variable sized memory pool The RI850V4 does not perform memory clear processing when getting the acquired variable size memory block The contents of the got variable size memory block are therefore undefined If no variable size memory blocks could be acquired from the target variable size memory pool no successive areas equivalent to the requested size were available when this service call is issued the contents in the area specified by parameter p_blk become undefined R20UT2889EJ0101 Rev 1 01 7tENESAS Sep 30 2015 Page 102 of 366 RI850V4 V2 CHAPTER 7 MEMORY POOL MANAGEMENT FUNCTIONS tget_mpl This service call acquires a variable size memory block
7. 42 Non existent object Specified mutex is not registered R20UT2889EJ0101 Rev 1 01 Sep 30 2015 ztENESAS Page 257 of 366 RI850V4 V2 CHAPTER 16 SERVICE CALLS 16 2 8 Memory pool management functions fixed sized memory pools The following shows the service calls provided by the RI850V4 as the memory pool management functions fixed sized memory pools Table 16 8 Memory Pool Management Functions Fixed Sized Memory Pools Service Call Function Origin of Service Call get_mpf Acquire fixed sized memory block waiting forever Task pget_mpf Acquire fixed sized memory block polling ni eee Initialization rou ipget_mpf Acquire fixed sized memory block polling e Nontas SN Nelle uO nC OUr tget_mpf Acquire fixed sized memory block with timeout Task rel_mpf Release fixed sized memory block i POR teers alzato gu irel_mpf Release fixed sized memory block na Monster nitializatiom rou ref_mpf Reference fixed sized memory pool state heal Kon ster Na NZaNOni EU iref_mpf Reference fixed sized memory pool state nt RR eer IN IMee Aone R20UT2889EJ0101 Rev 1 01 ztENESAS Page 258 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 16 SERVICE CALLS Outline Acquire fixed sized memory block waiting forever C format ER get_mpf ID mpfid VP p_blk Parameter s 0 Parameter Description l ID number of the fixed sized memory pool f
8. Outline Reference fixed sized memory pool state C format ER ref_mpf ID mpfid T_RMPF pk_rmpf ER iref_mpf ID mpfid T_RMPF pk_rmpf Parameter s 0 Parameter Description ID mpfid ID number of the fixed sized memory pool to be referenced O T_RMPF pk_rmpf Pointer to the packet returning the fixed sized memory pool state Fixed sized memory pool state packet T_RMPF typedef struct t_rmpf ID wt skid Existence of waiting task UINT fblkcnt Number of free memory blocks ATR mpfatr Attribute ID memid Reserved for future use T_RMPF Explanation Stores fixed sized memory pool state packet ID number of the task at the head of the wait queue number of free mem ory blocks etc of the fixed sized memory pool specified by parameter mpfid in the area specified by parameter pk_rmprf Note For details about the fixed sized memory pool state packet refer to 15 2 9 Fixed sized memory pool state packet Return value Macro Value Description E OK 0 Normal completion Invalid ID number E ID 18 mpfid lt 0x0 mpfid gt Maximum ID number Context error E_CTX 25 This service call was issued in the CPU locked state R20UT2889EJ0101 Rev 1 01 2tENESAS Page 267 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 16 SERVICE CALLS Macro Value Description E_NOEXS 42 Non existent object
9. Select the operation after using up the trace buffer This item is displayed only when Taking in trace chart by software trace mode is selected in Selection of trace mode Default Continue to execution while the buffers overwriting How to change Select from the drop down list Operation after used up Continue to the Qufers OX e CULIO N Overwrites the oldest trace data written to the while the buffer _ buffers Restriction overwriting Stop the trace taking Stops writing to the trace buffer in Specify the size of the trace buffer bytes This item is displayed only when Taking in trace chart by software trace mode is selected in Selection of trace mode Buffer size Default 0x100 How to change Enter directly in the text box Restriction 0x10 Oxfffffffc R20UT2889EJ0101 Rev 1 01 Sep 30 2015 2tENESAS Page 346 of 366 RI850V4 V2 APPENDIX A WINDOW REFERENCE Select the location to store trace data This item is displayed only when Taking in trace chart by software trace mode is selected in Selection of trace mode Default Kernel buffer Select the buffer How to change Select from the drop down list Kernel Allocates the trace buffer in the prespecified buffer section kernel_data_trace bss Restriction Another Allocates the trace buffer at the address buffer specified in Buffer address Specify
10. Macro Value Description E_TMOUT 50 Polling failure There is no free memory block in the target fixed sized memory pool R20UT2889EJ0101 Rev 1 01 Sep 30 2015 ztENESAS Page 262 of 366 RI850V4 V2 CHAPTER 16 SERVICE CALLS Outline Acquire fixed sized memory block with timeout C format ER tget_mpf ID mpfid VP p_blk TMO tmout j Parameter s 1 0 Parameter Description l ID number of the fixed sized memory pool from which a memory block l ID mpfid is acquired O VP p_ blk Start address of the acquired memory block Specified timeout unit millisecond TMO tmout TMO_FEVR Waiting forever TMO_POL Polling Value Specified timeout Explanation This service call acquires the fixed sized memory block from the fixed sized memory pool specified by parameter mpfid and stores the start address in the area specified by parameter p_bik If no fixed size memory blocks could be acquired from the target fixed size memory pool no available fixed size memory blocks exist when this service call is issued this service call does not acquire the fixed size memory block but queues the invoking task to the target fixed size memory pool wait queue and moves it from the RUNNING state to the WAITING state with timeout fixed size memory block acquisition wait state The WAITING state for a fixed sized memory block is cancelled in the following cases and t
11. P decanters Polling failure processing Note 1 With the RI850V4 whether to enable queuing of multiple tasks to the event flag wait queue is defined during configuration If this service call is issued for the event flag TW_WSGL attribute to which a wait task is queued therefore E_ILUSE is returned regardless of whether the required condition is immediately satisfied TA_WSGL Only one task is allowed to be in the WAITING state for the eventtflag TA_WMUL Multiple tasks are allowed to be in the WAITING state for the eventflag Note 2 The RI850V4 performs bit pattern clear processing 0x0 setting when the required condition of the target eventflag TA_CLR attribute is satisfied Note 3 If the bit pattern of the target event flag does not satisfy the required condition when this service call is issued the contents in the area specified by parameter p_flgptn become undefined R20UT2889EJ0101 Rev 1 01 2tENESAS Page 58 of 366 Sep 30 2015 CHAPTER 5 SYNCHRONIZATION AND COMMUNICATION RI850V4 V2 FUNCTIONS twai_fig This service call checks whether the bit pattern specified by parameter waiptn and the bit pattern that satisfies the required condition specified by parameter wfmode are set to the eventflag specified by parameter flgid If a bit pattern that satisfies the required condition has been set for the target eventflag the bit pattern of the target eventtlag is stored in the area specified by parameter p_f
12. Reference number of free memory blocks Reference attribute Note For details about the fixed sized memory pool state packet refer to 15 2 9 Fixed sized memory pool state packet R20UT2889EJ0101 Rev 1 01 Sep 30 2015 7tENESAS Page 98 of 366 RI850V4 V2 CHAPTER 7 MEMORY POOL MANAGEMENT FUNCTIONS 7 4 Variable Sized Memory Pools When a dynamic memory manipulation request is issued from a processing program in the RI850V4 the variable sized memory pool is provided as a usable memory area Dynamic memory manipulation for variable size memory pools is performed in the units of the specified variable size memory block size 7 4 1 Create variable sized memory pool In the RI850V4 the method of creating a variable sized memory pool is limited to static creation Variable sized memory pools therefore cannot be created dynamically using a method such as issuing a service call from a processing program Static variable size memory pool creation means defining of variable size memory pools using static API CRE_MPL in the system configuration file For details about the static API CRE_MPL refer to 17 5 8 Variable sized memory pool information R20UT2889EJ0101 Rev 1 01 2tENESAS Page 99 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 7 MEMORY POOL MANAGEMENT FUNCTIONS 7 4 2 Acquire variable sized memory block A variable sized memory block is acquired waiting forever polling or with timeout by i
13. else if ercd E_RLWAI gigi ia E os ts Forced termination processing else if ercd E_TMOUT D etter tet ody os Timeout processing Note 1 Invoking tasks are queued to the target semaphore wait queue in the order defined during configuration Note 2 FIFO order or priority order TMO_FEVR is specified for wait time tmout processing equivalent to wai_sem will be executed When TMO_POL is specified processing equivalent to pol_sem ipol_sem will be executed R20UT2889EJ0101 Rev 1 01 Sep 30 2015 2tENESAS Page 50 of 366 RI850V4 V2 CHAPTER 5 SYNCHRONIZATION AND COMMUNICATION FUNCTIONS 5 2 3 Release semaphore resource A resource is returned by issuing the following service call from the processing program sig_sem isig sem These service calls return the resource to the semaphore specified by parameter semid adds 0x1 to the semaphore counter If a task is queued in the wait queue of the target semaphore when this service call is issued the counter manipulation processing is not performed but the resource is passed to the relevant task first task of wait queue As a result the relevant task is unlinked from the wait queue and is moved from the WAITING state WAITING state for a semaphore resource to the READY state or from the WAITING SUSPENDED state to the SUSPENDED state The following describes an example for coding this service call lt kernel h gt lt kernel_id h gt
14. include include void task VP_INT exinf ID_S ID semid EM1 Standard header file definition System information header file definition Declares and initializes variable Releas resource semaphor Note With the RI850V4 the maximum possible number of semaphore resources maximum resource count is defined during configuration If the number of resources exceeds the specified maximum resource count this service call therefore does not return the acquired resources addition to the semaphore counter value but returns E_QOVR R20UT2889EJ0101 Rev 1 01 Sep 30 2015 2tENESAS Page 51 of 366 CHAPTER 5 SYNCHRONIZATION AND COMMUNICATION RI850V4 V2 FUNCTIONS 5 2 4 Reference semaphore state A semaphore status is referenced by issuing the following service call from the processing program ref_sem iref_sem Stores semaphore state packet ID number of the task at the head of the wait queue current resource count etc of the semaphore specified by parameter semid in the area specified by parameter pk_rsem The following describes an example for coding this service call lt kernel h gt lt kernel_id h gt include include void task VP_INT exinf ID semid ID_SEM1 T_RSEM pk_rsem ID wtskid UINT semcnt ATR sematr UINT maxsem ref_sem semid amp pk_rsem wtskid pk_rsem wtskid semcnt pk_rsem semcnt sematr pk_r
15. R20UT2889EJ0101 Rev 1 01 Sep 30 2015 ztENESAS Page 195 of 366 RI850V4 V2 CHAPTER 16 SERVICE CALLS Outline Wakeup task C format ER wup_tsk ID tskid j ER iwup_tsk ID tskid Parameter s V O Parameter Description ID number of the task to be woken up ID tskid TSK_SELF Invoking task Value ID number of the task to be woken up Explanation These service calls cancel the WAITING state sleeping state of the task specified by parameter tskid As a result the target task is moved from the sleeping state to the READY state or from the WAITING SUSPENDED state to the SUSPENDED state If the target task is in a state other than the sleeping state when this service call is issued this service call does not move the state but increments the wakeup request counter by added 0x1 to the wakeup request counter Note Return value The wakeup request counter managed by the RI850V4 is configured in 7 bit widths If the number of wakeup requests exceeds the maximum count value 127 as a result of issuing this service call the counter manipulation processing is therefore not performed but E_QOVR is returned Macro Value Description E OK 0 Normal completion Invalid ID number tskid lt 0x0 E_ID 18 tskid gt Maximum ID number When this service call was issued from a non task TSK_SELF was specified Context error E_CTX 25 This service call was issue
16. Specifies whether to check the stack overflows before the RI850V4 starts processing The keyword that can be specified for flg is TA_ON or TA_OFF TA_ON Overflow is checked TA_OFF Overflow is not checked Note Overflow is not checked by default 6 Maximum priority maxtpri Specifies the maximum priority of the task A value from 0x1 to 0x20 can be specified for maxtpri If omitted 0x20 is specified as the maximum task priority 7 Maximum interrupt priority maxintori Specifies the maximum priority for El level maskable interrupts to be managed by the RI850V4 The following values can be specified for maxintpri When the CPU type of the target device is G3K A value from INTPRIO to INTPRI7 When the CPU type of the target device is G3M A value from INTPRIO to INTPRI15 Note 1 When INTPRIS is specified the RI850V4 manages interrupts within the range from priority INTPRI3 to the minimum interrupt priority The minimum interrupt priority is determined as follows When the CPU type of the target device is G3K IINTPRI7 is the minimum interrupt priority When the CPU type of the target device is G3M INTPRI15 is the minimum interrupt priority Note 2 When the interrupt handlers for the El level maskable interrupts are called in the reduced mode the RINT bit in the reset vector base address RBASE or the exception handler vector address EBASE is set to 1 the maximum interrupt priority should be set to INTPRIO If omitted The max
17. TA_HLNG A_ACT TA_ENAINT 0 taskl 1 0x100 NULL CRE_TSK ID_TASK2 TA_HLNG A_ENAINT 0 task2 3 0x50 NULL CRE_TSK ID_TASK3 TA_HLNG A_ENAINT 0 task3 3 0x50 NULL De CRE_TSK ID_TASK4 TA_HLNG A_ENAINT 0 task4 7 0x50 NULL CRE_TSK ID_TASK5 TA_HLNG A_ENAINT 0 task5 5 0x50 NULL CRE_SE ID_SEM1 TA_TFIFO 0x1 0x1 jg CRE_FLG ID_FLG1 TA_TFIFO TA_WMUL TA_CLR 0x0 CRE_DTQ ID_DTQ1 TA_TFIFO 0x40 NULL CRE_MBX ID_MBX1 TA_TFIFO TA_MFIFO 0x10 NULL CRE_MTX ID_MTX1 TA_TFIFO 0x10 CRE_MPF ID_MPF1 TA_TFIFO 0x4 0x10 NULL CRE_MPL ID_MPL1 TA_TFIFO 0x50 NULL CRE_CYC ID_CYC1 TA_HLNG TA_STA 0x0 cychdri 1000 5 DEF_INH 0x1000 TA_HLNG inthdrl DEF_INH 0x1001 TA_HLNG inthdr2 DEF_SVC 1 TA_HLNG svcrtnl ATT_INI TA_HLNG 0x0 inirtn VATT_IDL TA_HLNG idlrtn Note The RI850V4 provides sample source files for the system configuration file R20UT2889EJ0101 Rev 1 01 tENESAS Page 328 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 18 CONFIGURATOR CF850V4 CHAPTER 18 CONFIGURATOR CF850V4 This chapter explains configurator CF850V4 which is provided by the RI850V4 as a utility tool useful for system construction 18 1 Outline To build systems load module that use functions provided by the RI850V4 the information storing data to be provided for the RI850V4 is requi
18. The items constituting the task information are as follows 1 ID number tskid Specifies the ID number for a task A value from 0x1 to Oxff or a name can be specified for tskid Note When a name is specified the CF850V4 automatically assigns an ID number The CF850V4 outputs the relationship between a name and an ID number to the system information header file in the following format define tskid value 2 Attribute tskatr Specifies the attribute for a task The keyword that can be specified for tskatris TA_HLNG TA_ASM TA_ACT TA_DISPREEMPT TA_ENAINT and TA_DISINT Coding language TA_HLNG Start a task through a C language interface TA_ASM Start a task through an assembly language interface Initial activation state TA_ACT Task is activated after the creation Initial preemption state TA_DISPREEMPT Preemption is disabled at task activation Initial interrupt state TA_ENAINT Acceptance of El level maskable interrupts from the Maximum interrupt priority maxintpri to the minimum interrupt priority is enabled TA_DISINT Acceptance of El level maskable interrupts from the Maximum interrupt priority maxintpri to the minimum interrupt priority is disabled Note 1 If specification of TA_ACT is omitted the DORMANT state is specified as the initial activation state Note 2 If specification of TA_DISPREEMPT is omitted preempt acceptance is enabled Note 3 If specifications of TALENAINT and TA_DISINT a
19. Macro Value Description E OK 0 Normal completion Invalid ID number EID 18 cycid lt 0x0 cycid gt Maximum ID number Context error E_CTX 25 This service call was issued in the CPU locked state R20UT2889EJ0101 Rev 1 01 2tENESAS Page 286 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 16 SERVICE CALLS Macro Value Description E_NOEXS 42 Non existent object Specified cyclic handler is not registered R20UT2889EJ0101 Rev 1 01 Sep 30 2015 ztENESAS Page 287 of 366 RI850V4 V2 CHAPTER 16 SERVICE CALLS 16 2 11 System state management functions The following shows the service calls provided by the RI850V4 as the system state management functions Table 16 11 System State Management Functions Service Call Function Origin of Service Call rot_rdq Rotate task precedence Hae Non task Initialization rou irot_rdq Rotate task precedence Nomtask MitalizationTou vsta_sch Forced scheduler activation Task get_tid Reference task ID in the RUNNING state ti Nomiaet Initialization fou iget_tid Reference task ID in the RUNNING state i Nontas s Mitialization rou loc_cpu Lock the CPU Task Non task iloc_cpu Lock the CPU Task Non task unl_cpu Unlock the CPU Task Non task iunl_cpu Unlock the CPU Task Non task sns_loc Reference CPU state ne Non task Initialization rou dis_dsp
20. R20UT2889EJ0101 Rev 1 01 tENESAS Page 306 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 17 SYSTEM CONFIGURATION FILE 17 3 Declarative Information The following describes the format that must be observed when describing the declarative information in the system configuration file The GOTHIC FONT characters in following descriptions are the reserved words and italic face characters are the portion that the user must write the relevant numeric value symbol name or keyword 17 3 1 Header file declaration The header file declaration defines File name h_file The number of definable header file declaration items is not restricted The following shows the header file declaration format INCLUDE h_file The items constituting the header file declaration are as follows 1 File name h_file Reflects the header file declaration specified in h_file into the system information header file output by the CF850V4 As a result macro definitions in filename can be referenced from a file in which the system information header file output by the CF850V4 is included Note If lt sample h gt is specified in h_file the header file definition include processing is output as include lt sample h gt If sample h is specified in h_file the header file definition include processing is output as include sample h to the system information header file R20UT2889EJ0101 Rev 1 01 ztENESAS Page 307 of 366 Sep 30 2015
21. RI850V4 V2 CHAPTER 17 SYSTEM CONFIGURATION FILE 17 4 System Information The following describes the format that must be observed when describing the system information in the system configuration file The GOTHIC FONT characters in following descriptions are the reserved words and italic face characters are the portion that the user must write the relevant numeric value symbol name or keyword Items enclosed by square brackets can be omitted 17 4 1 Rl series information The RI series information defines Real time OS name rtos_name Version number rtos_ver Only one information item can be defined as RI series information The following shows the RI series information format RI_SERIES rtos_name rtos_ver j The items constituting the RI series information are as follows 1 Real time OS name rtos_name Specifies the real time OS name The keyword that can be specified for rlos_name is the RI850V4 2 Version number rtos_ver Specifies the version number for the RI850V4 In RI_SERIES values specifiable for rtos_veris the V2xy as version number Note If the version number of RI850V4 is V2 01 23 rtos_ver should be set to V201 R20UT2889EJ0101 Rev 1 01 ztENESAS Page 308 of 366 Sep 30 2015 RI850V4 V2 17 4 The 2 Basic information basic information defines CPU type cpu Base clock interval tim_base Base clock timer exception code tim_intno System stack
22. This service call moves an invoking task from the RUNNING state to the WAITING state sleeping state As a result the invoking task is unlinked from the ready queue and excluded from the RI850V4 scheduling subject If a wakeup request has been queued to the target task the wakeup request counter is not set to 0x0 when this service call is issued this service call does not move the state but decrements the wakeup request counter by subtracting 0x1 from the wakeup request counter The sleeping state is cancelled in the following cases and then moved to the READY state Sleeping State Cancel Operation Return Value A wakeup request was issued as a result of issuing wup_tsk E OK A wakeup request was issued as a result of issuing iwup_tsk E OK Forced release from waiting accept rel_wai while waiting E RLWAI Forced release from waiting accept irel_wai while waiting E RLWAI Polling failure or timeout E TMOUT The following describes an example for coding this service call include lt kernel h gt void task VP_INT exin include lt kernel_id h gt Standard header file definition ER ercd Declares variable TMO tmout 3600 Declares and initializes variable ercd tslp_tsk tmout Put task to sleep with timeout if ercd E_OK Normal termination processing E_RLWAI Forced termination processing E_TMOUT Timeout p
23. referred to as Realtime OS related files Trace information file trcinf c node This node and the file displayed under this node cannot be deleted R20UT2889EJ0101 Rev 1 01 tENESAS Page 340 of 366 Sep 30 2015 RI850V4 V2 APPENDIX A WINDOW REFERENCE Property panel Outline This panel is used to display information regarding the node selected on the Project Tree panel and change the settings of the information This panel can be opened as follows On the Project Tree panel select a component such as the Realtime OS node or the system configuration file and then select the View menu gt Property or select Property from the context menu Note When the Property panel is already open selecting a component such as the Realtime OS node or the system configuration file on the Project Tree panel displays the detailed information regarding the selected component Display image Property xj A RIB50V4 Property 4 le 4 Version Information CSTs V2 01 00 Install folder C Program Files Renesas Electronics CS5 CC RI850V4RH Register mode 32 register mode Kernel version This is the version of the RI850 4 to be used in this project RI850V4 Task Analyzer Explanation of each area 1 Selected node area Display the name of the selected node on the Project Tree panel When multiple nodes are selected this area is blank 2 Detailed information display change area In this a
24. 16 2 7 Option Settings for Build 20 CHAPTER 3 TASK MANAGEMENT FUNCTIONS 21 3 1 Outline 21 3 2 Tasks 21 3 2 1 Task state 21 3 2 2 Task priority 23 3 2 3 Basic form of tasks 24 3 2 4 Internal processing of task 25 3 3 Create Task 26 3 4 Activate Task 26 3 4 1 Queuing an activation request 26 3 4 2 Not queuing an activation request 27 3 5 Cancel Task Activation Requests 28 3 6 Terminate Task 29 3 6 1 Terminate invoking task 29 3 6 2 Terminate task 30 3 7 Change Task Priority 31 3 8 Reference Task Priority 32 3 9 Reference Task State 33 3 9 1 Reference task state 33 3 9 2 Reference task state simplified version 34 3 10 Memory Saving 35 3 10 1 Disable preempt 35 CHAPTER 4 TASK DEPENDENT SYNCHRONIZATION FUNCTIONS 36 4 1 Outline 36 4 2 Put Task to Sleep 36 4 2 1 Waiting forever 36 4 2 2 With timeout 38 4 3 Wakeup Task 39 4 4 Cancel Task Wakeup Requests 40 4 5 Release Task from Waiting 41 4 6 Suspend Task 42 4 7 Resume Suspended Task 43 4 7 1 Resume suspended task 43 4 7 2 Forcibly resume suspended task 44 4 8 Delay Task 45 4 9 Differences Between Wakeup Wait with Timeout and Time Elapse Wait 46 CHAPTER 5 SYNCHRONIZATION AND COMMUNICATION FUNCTIONS 47 5 1 Outline 47 5 2 Semaphores 47 5 2 1 Create semaphore 47 5 2 2 Acquire semaphore resource 48 5 2 3 Releas
25. ATR eycatr RELTIM cyctim RELTIM cycphs Standard header file definition System information header file definition Declares Declares Declares Declares Declares Declares Declares and initializes variable data structure variable variable variable variable variable ref_cyc eycestat lefttim cycphs eycactr cyctim cycid amp pk_rcyc pk_rcyc cycstat pk_rcyc lefttim pk_rcyc cycatr pk_rceyc cyctim pk_rcyc cycphs Reference cyclic handler state Reference current state Reference time left before th activation Reference attribute Reference activation cycle Reference activation phase next Note For details about the cyclic handler state packet refer to 15 2 12 Cyclic handler state packet R20UT2889EJ0101 Rev 1 01 Sep 30 2015 2tENESAS Page 131 of 366 RI850V4 V2 CHAPTER 10 INTERRUPT MANAGEMENT FUNCTIONS CHAPTER 10 INTERRUPT MANAGEMENT FUNCTIONS This chapter describes the interrupt management functions performed by the RI850V4 10 1 Outline The RI850V4 provides as interrupt management functions related to the interrupt handlers activated when an EIl level maskable interrupt is occurred 10 2 User Own Coding Module To support various execution environments the RI850V4 extracts from the interrupt management functions the hardware dependent processing In
26. CtENESAS C O D aes Cp lt 5 D RI850V4 V2 Real Time Operating System User s Manual Coding Target Device RH850 Family RH850G3k RH850 Family RH850G3M All information contained in these materials including products and product specifications represents information on the product at the time of publication and is subject to change by Renesas Electronics Corp without notice Please review the latest information published by Renesas Electronics Corp through various means including the Renesas Electronics Corp website http www renesas com Renesas Electronics Www renesas com Rev 1 01 Sep 2015 10 11 12 Notice Descriptions of circuits software and other related information in this document are provided only to illustrate the operation of semiconductor products and application examples You are fully responsible for the incorporation of these circuits software and information in the design of your equipment Renesas Electronics assumes no responsibility for any losses incurred by you or third parties arising from the use of these circuits software or information Renesas Electronics has used reasonable care in preparing the information included in this document but Renesas Electronics does not warrant that such information is error free Renesas Electronics assumes no liability whatsoever for any damages incurred by you resulting from errors in or omissions from the information
27. Forced send to data queue C format ER fsnd_dtq ID dtqid VP_INT data ER ifsnd_dtq ID dtqid VP_INT data Parameter s 0 Parameter Description l ID dtqid ID number of the data queue to which the data element is sent l VP_INT data Data element to be sent to the data queue Explanation These service calls write data specified by parameter data to the data queue area of the data queue specified by parameter dtqid If there is no available space for writing data in the data queue area of the target data queue when either of these service calls is issued the service call overwrites data to the area with the oldest data that was written If a task has been queued to the reception wait queue of the target data queue when this service call is issued this service call does not write data but transfers the data to the task As a result the task is unlinked from the reception wait queue and moves from the WAITING state data reception wait state to the READY state or from the WAITING SUSPENDED state to the SUSPENDED state Return value Macro Value Description E OK 0 Normal completion Invalid ID number E ID 18 dtqid lt 0x0 dtqid gt Maximum ID number Context error E CTX 25 This service call was issued in the CPU locked state Illegal service call use E_ILUSE 28 The capacity of the data queue area is 0 Non existent object E NOEXS 42
28. Forced termination processing Note Invoking tasks are queued to the target semaphore wait queue in the order defined during configuration FIFO order or priority order R20UT2889EJ0101 Rev 1 01 2tENESAS Page 48 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 5 SYNCHRONIZATION AND COMMUNICATION FUNCTIONS pol_sem ipol_sem This service call acquires a resource from the semaphore specified by parameter semid subtracts 0x1 from the semaphore counter If a resource could not be acquired from the target semaphore semaphore counter is set to 0x0 when this service call is issued the counter manipulation processing is not performed but E_TMOUT is returned The following describes an example for coding this service call include lt kernel h gt include ER ercd ID semid ID_ lt kernel_id h gt void task VP_INT exinf SEM1 E_TMOUT Standard header file definition System information header file definition Declares variable Declares and initializes variable Acquire semaphor resourc Polling success processing Polling failure processing polling R20UT2889EJ0101 Rev 1 01 Sep 30 2015 2tENESAS Page 49 of 366 RI850V4 V2 CHAPTER 5 SYNCHRONIZATION AND COMMUNICATION FUNCTIONS twai_sem This service call acquires a resource from the semaphore specified by parameter semid subtracts 0x1 f
29. iref_mpf Memory pool management functions variable sized memory pools get_mpl pget_mpl ipget_mpl tget_mpl rel_mpl irel_mpl ref_mpl iref_mpl Time management functions set_tim iset_tim get_tim iget_tim sta_cyc ista_cyc stp_cyc istp_cyc ref_cyc iref_cyc System state management functions rot_rdq irot_rdq vsta_sch get_tid iget_tid loc_cpu iloc_cpu unl_cpu iunl_cpu sns_loc dis_dsp ena_dsp sns_dsp sns_ctx sns_dpn Service call management functions cal_svc ical_svc R20UT2889EJ0101 Rev 1 01 2tENESAS Page 173 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 16 SERVICE CALLS 16 1 1 Call service call The method for calling service calls from processing programs coded either in C or assembly language is described below C language By calling using the same method as for normal C functions service call parameters are handed over to the RI850V4 as arguments and the relevant processing is executed Assembly language When issuing a service call from a processing program coded in assembly language set parameters and the return address according to the calling rules prescribed in the C compiler used as the development environment and call the function using the jarl instruction the service call parameters are then transferred to the RI850V4 as arguments and the relevant processing will be executed Note To call the service calls provided by the RI850V4 from a processing program the
30. non task module independent from tasks Therefore even if a task with the highest priority in the system is being executed the processing is suspended when a specified activation cycle has come and the control is passed to the cyclic handler The RI850V4 manages the states in which each cyclic handler may enter and cyclic handlers themselves by using management objects cyclic handler control blocks corresponding to cyclic handlers one to one Basic form of cyclic handlers When coding a cyclic handler use a void function with one VP_INT argument any function name is fine The extended information specified with Cyclic handler information is set for the exinf argument The following shows the basic form of cyclic handlers in C R20UT2889EJ0101 Rev 1 01 2tENESAS Page 124 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 9 TIME MANAGEMENT FUNCTIONS include lt kernel h gt Standard header file definition include lt kernel_id h gt System information header file definition void cychdr VP_INT exinf Terminate cyclic handler Coding method Code cyclic handlers using C or assembly language When coding in C they can be coded in the same manner as void type functions coded When coding in assembly language code them according to the calling rules prescribed in the compiler used Stack switching The RI850V4 switches to the system stack specified in the Basic information when passing control to a cyclic
31. user is not required to code the kernel initialization module R20UT2889EJ0101 Rev 1 01 ztENESAS Page 152 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 15 DATA TYPES AND MACROS CHAPTER 15 DATA TYPES AND MACROS This chapter describes the data types data structures and macros which are used when issuing service calls provided by the RI850V4 The definition of the macro and data structures is performed by each header file stored in lt ri_root gt include os Note lt ri_root gt indicates the installation folder of RI850V4 The default folder is C Program Files Renesas Electronics CS CC RI850V4RH 15 1 Data Types The Following lists the data types of parameters specified when issuing a service call Macro definition of the data type is performed by the header file lt ri_root gt include os types h which is called from the standard header file lt ri_root gt include kernel h and the ITRON general definition header file lt ri_root gt include os itron h Table 15 1 Data Types Macro Data Type Description signed char Signed 8 bit integer H signed short Signed 16 bit integer W signed long Signed 32 bit integer UB unsigned char Unsigned 8 bit integer UH unsigned short Unsigned 16 bit integer UW unsigned long Unsigned 32 bit integer VB signed char 8 bit value with unknown data type VH signed short 16 bit value with unknown data type VW s
32. 2 5 Data queue state packet The following shows data queue state packet T_RDTQ used when issuing ref _dtq or iref_dtq Definition of data queue state packet T_RDTQ is performed by the header file lt ri_root gt include os packet h which is called from the standard header file lt ri_root gt include kernel h typedef struct t_rdtq ID stskid Existence of tasks waiting for data transmission ID rtskid Existence of tasks waiting for data reception UINT sdtqcnt number of data elements in the data queue ATR dtgqatr Attribute UINT dtqent Data count ID memid Reserved for future use T_RDTQ The following shows details on data queue state packet T_RDTQ stskid Stores whether a task is queued to the transmission wait queue of the data queue TSK_NONE No applicable task Value ID number of the task at the head of the wait queue rtskid Stores whether a task is queued to the reception wait queue of the data queue TSK_NONE No applicable task Value ID number of the task at the head of the wait queue sdtqent Stores the number of data elements in data queue dtqatr Stores the attribute queuing method Task queuing method bit 0 TA_TFIFO Task wait queue is in FIFO order TA_TPRI Task wait queue is in task priority order Structure of diqatr 15 0 A TA_TFIFO 0 TA_TPRI 1 dtqent Stores the data count memid System reserved area R20UT2889
33. 2 Activation Method 18 2 1 Activating from command line The following is how to activate the CF850V4 from the command line Note that in the examples below C gt indicates the command prompt D indicates pressing of the space key and lt Enter gt indicates pressing of the enter key The activation options enclosed in can be omitted C gt cf850v4 exe A lt command file gt A peid lt id gt A cpu A lt name gt A devpath lt path gt A i A lt SIT file gt A e A lt Entry file gt A d A lt Header file gt A ni A ne A nd A t A lt TOOL names A T A lt Compiler path gt A A lt Include path gt A np A intbp lt nterrupt Base Address gt A ebase lt Exception Base Address gt A V A help A lt CF file gt Enter The details of each activation option are explained below lt command_file gt Specifies the command file name to be input If omitted The activation options specified on the command line is valid Note 1 Specify the command file name lt command file gt within 255 characters including the path name Note 2 When the command file name including the path includes a space surround lt command file gt by double quotation marks Note 3 For details about the command file refer to 18 2 3 Command file peid lt id gt Specifies the target PE number for which the application with RI850V4 is allocated If omitted The CF850V4 performs pr
34. 30 2015 CHAPTER 6 EXTENDED SYNCHRONIZATION AND RI850V4 V2 COMMUNICATION FUNCTIONS 6 2 4 Unlock mutex The mutex locked state can be cancelled by issuing the following service call from the processing program unl_mtx This service call unlocks the locked mutex specified by parameter mtxid If a task has been queued to the target mutex wait queue when this service call is issued mutex lock processing is performed by the task the first task in the wait queue immediately after mutex unlock processing As a result the task is unlinked from the wait queue and moves from the WAITING state mutex wait state to the READY state or from the WAITING SUSPENDED state to the SUSPENDED state The following describes an example for coding this service call include lt kernel h gt Standard header file definition include lt kernel_id h gt System information header file definition void task VP_INT exinf ER ercd Declares variable ID mtxid ID_MTX1 Declares and initializes variable ercd loc_mtx mtxid Lock mutex if ercd E_OK EE E Locked state unl_mtx mtxid Unlock mutex lse if ercd E_RLWAI Forced termination processing Note A locked mutex can be unlocked only by the task that locked the mutex If this service call is issued for a mutex that was not locked by an invoking task no processing is performed but E_ILUSE is returned R20UT2889EJ
35. 4 4 Reference variable sized memory pool state 106 CHAPTER 8 SYSTEM STATE MANAGEMENT FUNCTIONS 107 8 1 Outline 107 8 2 Rotate Task Precedence 107 8 3 Forced Scheduler Activation 109 8 4 Reference Task ID in the RUNNING State 110 8 5 Lock the CPU 111 8 6 Unlock the CPU 113 8 7 Reference CPU State 115 8 8 Disable Dispatching 116 8 9 Enable Dispatching 118 8 10 Reference Dispatching State 120 8 11 Reference Contexts 121 8 12 Reference Dispatch Pending State 122 CHAPTER 9 TIME MANAGEMENT FUNCTIONS 123 9 1 Outline 123 9 2 System Time 123 9 2 1 Base clock timer interrupt 123 9 2 2 Base clock interval 124 9 3 Timer Operations 124 9 3 1 Delayed task wakeup 124 9 3 2 Timeout 124 9 3 3 Cyclic handlers 124 9 3 4 Create cyclic handler 125 9 4 Set System Time 126 9 5 Reference System Time 127 9 6 Start Cyclic Handler Operation 128 9 7 Stop Cyclic Handler Operation 130 9 8 Reference Cyclic Handler State 131 CHAPTER 10 INTERRUPT MANAGEMENT FUNCTIONS 132 10 1 Outline 132 10 2 User Own Coding Module 132 10 2 1 Interrupt entry processing 132 10 3 Interrupt Handlers 134 10 3 1 Basic form of interrupt handlers 134 10 3 2 Internal processing of interrupt handler 134 10 3 3 Define interrupt handler 135 10 4 Base Clock Timer Interrupts 135 10 5 Multiple Interrupts 135 CHAPTER 11 S
36. Code extended service call routines using C or assembly language When coding in C they can be coded in the same manner as ordinary functions coded When coding in assembly language code them according to the calling rules prescribed in the compiler used Stack switching The RI850V4 positions extended service call routines as extensions of the processing program that called the extended service call routine When passing control to an extended service call routine stack switching processing is therefore not performed Service call issue The RI850V4 positions extended service call routines as extensions of the processing program that called the extended service call routine Service calls that can be issued in extended service call routines depend on the type task or non task of the processing program that called the extended service call routine Note For details on the valid issue range of each service call refer to Table 16 1 to Table 16 12 Acceptance of El level maskable interrupts The RI850V4 handles an extended service call routine as an extension of the processing program that called the extended service call routine Therefore when passing control to an extended service call routine manipulation related to acceptance of El level maskable interrupts manipulation of the PMn bits in the priority mask register PMR and the ID bit in the program status word PSW is not performed 11 3 Define Extended Service Call Routine Th
37. ER ichg_pri ID tskid PRI tskpri Parameter s V O Parameter Description ID number of the task whose priority is to be changed ID tskid TSK_SELF Invoking task Value ID number of the task whose priority is to be changed New base priority of the task PRI tskpri TPRI_INI Initial priority Value New base priority Explanation These service calls change the priority of the task specified by parameter tskid current priority to a value specified by parameter tskpri If the target task is in the RUNNING or READY state after this service call is issued this service call re queues the task at the end of the ready queue corresponding to the priority specified by parameter tskpri following priority change processing Note When the target task is queued to a wait queue in the order of priority the wait order may change due to issue of this service call Example When three tasks task A priority level 10 task B priority level 11 task C priority level 12 are queued to the semaphore wait queue in the order of priority and the priority level of task B is changed from 11 to 9 the wait order will be changed as follows h Task A Task B Task C Semaphore Priority 10 Priority 11 Priority 12 chg_pri Task B an h Task B Task A Task C Semaphore Priority 9 Priority 10 Priority 12 R20UT2889EJ0101 Rev 1 01 RENESAS Page 185 of 366 Sep 30 2015 RI
38. E_CTX 25 This service call was issued from a non task This service call was issued in the CPU locked state R20UT2889EJ0101 Rev 1 01 Sep 30 2015 7tENESAS Page 297 of 366 RI850V4 V2 CHAPTER 16 SERVICE CALLS Outline Reference dispatching state C format BOOL sns_dsp Parameter s None Explanation void This service call acquires the system status type when this service call is issued dispatch disabled state or dispatch enabled state When this service call is terminated normally the acquired system state type TRUE dispatch disabled state FALSE dispatch enabled state is returned Return value Macro Value Description TRUE 1 Normal completion dispatching disabled state FALSE 0 Normal completion dispatching enabled state R20UT2889EJ0101 Rev 1 01 Sep 30 2015 2tENESAS Page 298 of 366 RI850V4 V2 CHAPTER 16 SERVICE CALLS Outline Reference contexts C format BOOL sns_ctx void Parameter s None Explanation This service call acquires the context type of the processing program that issued this service call non task context or task context When this service call is terminated normally the acquired context type TRUE non task context FALSE task context is returned Return value Macro Value Description TRUE 1 Normal completion non task contexts FALSE 0 Normal completion task contexts
39. File Generate a file YestIt updates the file when the cfe file is chan Output folder BuildMode Name File name entry s Generate method Direct vector Specify an exception handler vector at No Configurator Start Setting User options System Information Table File File Information R20UT2889EJ0101 Rev 1 01 2tENESAS Page 348 of 366 Sep 30 2015 RI850V4 V2 APPENDIX A WINDOW REFERENCE Explanation of each area 1 System Information Table File The detailed information on the system information table file are displayed and the configuration can be changed Select whether to generate a system information table file and whether to update the file when the system configuration file is changed Default Yes It updates the file when the cfg file is changed i How to change Select from the drop down list Generates a new system information table file and displays it on the project tree If the system configuration file is changed when there is already a system information table file then the system information table file is Yes It updates the file when the cfg file is changed i Generate a file updated Does not update the system as Yes It does not information table file when the system Restriction Be eat update the file when configuration file is changed the cfg file is An error occurs during build if this changed ni item is selected when the system information table file doe
40. R20UT2889EJ0101 Rev 1 01 2tENESAS Page 299 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 16 SERVICE CALLS Outline Reference dispatch pending state C format BOOL sns_dpn void Parameter s None Explanation This service call acquires the system status type when this service call is issued whether in dispatch pending state or not When this service call is terminated normally the acquired system state type TRUE dispatch pending state FALSE dispatch not pending state is returned Return value Macro Value Description TRUE 1 Normal completion dispatch pending state FALSE 0 Normal completion any other states R20UT2889EJ0101 Rev 1 01 Sep 30 2015 2tENESAS Page 300 of 366 RI850V4 V2 CHAPTER 16 SERVICE CALLS 16 2 12 Service call management functions The following shows the service calls provided by the RI850V4 as the service call management functions Table 16 12 Service Call Management Functions Service Call Function Origin of Service Call Task Non task Initialization rou cal_svc Invoke extended service call routine ine A Task Non task Initialization rou ical_svc Invoke extended service call routine tine R20UT2889EJ0101 Rev 1 01 tENESAS Page 301 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 16 SERVICE CALLS cal_ svc ical_svc Outline Invoke extended service call routine C format ER_UINT cal_svce
41. READY state READY state tskpri 1 maxtpri R20UT2889EJ0101 Rev 1 01 7tENESAS Page 107 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 8 SYSTEM STATE MANAGEMENT FUNCTIONS The following describes an example for coding this service call include lt kernel h gt Standard header file definition include lt kernel_id h gt System information header file definition void cychdr VP_INT exinf PRI tskpri 8 Declares and initializes variable irot_rdq tskpri Rotate task precedence return Terminate cyclic handler Note 1 This service call does not perform queuing of rotation requests If no task is queued to the ready queue corresponding to the relevant priority therefore no processing is performed but it is not handled as an error Note 2 Round robin scheduling can be implemented by issuing this service call via a cyclic handler in a constant cycle Note 3 The ready queue is a hash table that uses priority as the key and tasks that have entered an executable state READY state or RUNNING state are queued in FIFO order Therefore the scheduler realizes the RI850V4 s scheduling system priority level method FCFS method by executing task detection processing from the highest priority level of the ready queue upon activation and upon detection of queued tasks giving the CPU use right to the first task of the proper priority level R20UT2889EJ0101 Rev 1 01 ztENESAS Page 108 of 366 Sep 30 2015 RI850V
42. TA_DISPREEMPT 1 LL TA_HLNG 0 TA_ENAINT 0 TA_ASM 1 TA_DISINT 1 TA_ACT 1 _itskpri Stores the initial priority memid System reserved area R20UT2889EJ0101 Rev 1 01 7tENESAS Page 156 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 15 DATA TYPES AND MACROS 15 2 2 Task state packet simplified version The following shows task state packet simplified version T_RTST used when issuing ref_tst or iref_tst Definition of task state packet simplified version T_RTST is performed by the header file lt ri_root gt include os packet h which is called from the standard header file lt ri_root gt include kernel h typedef struct t_rtst STA tskstat Current state STA tskwait Reason for waiting T_RIStT The following shows details on task state packet simplified version T_RTST tskstat Stores the current state TTS_RUN TTS_RDY TTS_WAI TTS_SUS TTS_WAS TTS_DMT tskwait RUNNING state READY state WAITING state SUSPENDED state WAITING SUSPENDED state DORMANT state Stores the reason for waiting TTW_SLP Sleeping state TTW_DLY Delayed state TTW_SEM WAITING state for a semaphore resource TTW_FLG WAITING state for an eventtflag TTW_SDTQ Sending WAITING state for a data queue TTW_RDTQ Receiving WAITING state for a data queue TTW_MBx Receiving WAITING state for a mailbox TTW_MTX WAITING state for a mutex TTW_MPF WAITING state for a fixed
43. acknowledgment of the relevant base clock timer interrupt is disabled by issuing this service call the TIME MANAGEMENT FUNCTIONS may no longer operate normally Note 6 If this service call or a service call other than sns_xxx is issued from when this service call is issued until unl_cpu or iunl_cpu is issued the RI850V4 returns E_CTX R20UT2889EJ0101 Rev 1 01 ztENESAS Page 112 of 366 Sep 30 2015 RI850V4 V2 8 6 Unlock the CPU CHAPTER 8 SYSTEM STATE MANAGEMENT FUNCTIONS The CPU locked state is cancelled by issuing the following service call from the processing program unl_cpu iunl_cpu These service calls change the system status to the CPU unlocked state As a result acknowledge processing of El level maskable interrupts prohibited through issue of either loc_cpu or iloc_cpu is enabled and the restriction on service call issue is released If an El level maskable interrupt is created during the interval from when either loc_cpu or iloc_cpu is issued until this service call is issued the RI850V4 delays transition to the relevant interrupt processing interrupt handler until this service call is issued The following shows a processing flow when using this service call Figure 8 3 Unlock the CPU n Suppressed period y Task Lock the CPU Interrupt handler Unlock the CPU The following describes an example for coding this service call return lt kernel h gt lt kernel_id h
44. an interrupt handler through an assembly language interface Start address inthdr Specifies the start address for an interrupt handler A value from 0x0 to Oxfffffffe aligned to a 2 byte boundary or a symbol name can be specified for inthdr Note When an interrupt handler is coded as follows the symbol name specified for inthdr should be func_int include lt kernel h gt include lt kernel_id h gt void func int void R20UT2889EJ0101 Rev 1 01 2tENESAS Page 324 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 17 SYSTEM CONFIGURATION FILE 17 5 11 Extended service call routine information The extended service call routine information defines Function code fned Attribute svcatr Start address svertn for an extended service call routine The number of items that can be defined as extended service call routine information is limited to one for each function code The following shows the extended service call routine information format DEF_SVC fnced svcatr svcrtn The items constituting the extended service call routine information are as follows 1 Function code fned Specifies the function code for an extended service call routine A value from 0x1 to Oxff can be specified for fncd 2 Attribute svcatr Specifies the language used to describe an extended service call routine The keyword that can be specified for svcatris TA_HLNG or TA_ASM TA_HLNG Start an extended service
45. call routine through a C language interface TA_ASM Start an extended service call routine through an assembly language interface 3 Start address svertn Specifies the start address for an extended service call routine A value from 0x0 to Oxfffffffe aligned to a 2 byte boundary or a symbol name can be specified for svcrtn Note When an extended service call routine handler is coded as follows the symbol name specified for svcrtn should be func_svc include lt kernel h gt include lt kernel_id h gt ER_UINT func_svc VP_INT parl VP_INT par2 VP_INT par3 ER_UINT ercd return ercd R20UT2889EJ0101 Rev 1 01 7tENESAS Page 325 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 17 SYSTEM CONFIGURATION FILE 17 5 12 Initialization routine information The initialization routine information defines Attribute iniatr Extended information exinf Start address inirtn for an initialization routine The number of initialization routine information items that can be specified is defined as being within the range of 0 to 254 The following shows the idle initialization routine information format ATT_INI initatr exinf inirtn The items constituting the initialization routine information are as follows 1 Attribute iniatr Specifies the language used to describe an initialization routine The keyword that can be specified for iniatr is TA_HLNG or TA_ASM TA_HLNG Start an initializ
46. call was issued in the dispatching disabled state Non existent object E_NOEXS 42 Specified semaphore is not registered Forced release from the WAITING state E_RLWAI 49 Accept rel_wai irel_wai while waiting Timeout E_TMOUT 50 Polling failure or timeout R20UT2889EJ0101 Rev 1 01 Sep 30 2015 ztENESAS Page 210 of 366 RI850V4 V2 CHAPTER 16 SERVICE CALLS sig_sem isig sem Outline Release semaphore resource C format ER sig_sem ID semid ER isig_sem ID semid Parameter s 1 0 Parameter Description l ID semid ID number of the semaphore to which resource is released Explanation These service calls return the resource to the semaphore specified by parameter semid adds 0x1 to the semaphore counter If a task is queued in the wait queue of the target semaphore when this service call is issued the counter manipulation processing is not performed but the resource is passed to the relevant task first task of wait queue As a result the relevant task is unlinked from the wait queue and is moved from the WAITING state WAITING state for a semaphore resource to the READY state or from the WAITING SUSPENDED state to the SUSPENDED state Note With the RI850V4 the maximum possible number of semaphore resources maximum resource count is defined during configuration If the number of resources exceeds the specified maximum resource count this service call the
47. can be opened as follows Select View menu gt Project Tree Display image Project Tree E gE US RH850 F1L RI850V4RH Project R7F701007xAFP Microcontroller A CC RH Build Tool 4 RI850V4 Realtime OS RH850 E1 LPD Debug Tool File fn Bem usr_stkovr s ER EEE SA i Realtime OS generated files Ar kernel_id h gt entry s i sit s g Realtime OS related file e trcinf c R20UT2889EJ0101 Rev 1 01 2tENESAS Page 339 of 366 Sep 30 2015 RI850V4 V2 APPENDIX A WINDOW REFERENCE Explanation of each area 1 Project tree area Project components are displayed in tree view with the following given node Node Description RI850V4 Realtime OS referred to as Realtime OS node Realtime OS to be used XXxx Cfg System configuration file The following information files appear directly below the node created when a system configuration file is added System information table file s Realtime OS generated files System information header file h referred to as Realtime OS generated files Entry file s node This node and files displayed under this node cannot be deleted directly This node and files displayed under this node will no longer appear if you remove the system configuration file from the project The following information file appears directly below the node Realtime OS related file
48. core devices Using the RI850V4 and libipcx together enables control of the processing between PEs R20UT2889EJ0101 Rev 1 01 2tENESAS Page 11 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 1 OVERVIEW 1 2 Execution Environment The RI850V4 supports the RH850 family G3K core and G3M core The following is a list of reserved OS resources that are exclusively used by the RI850V4 and cannot be modified from processing programs Reserved OS Resources General register r2 OS timer OSTM one channel Interrupt priority mask PMR UM bit in the program status word PSW Interrupt configurations INTCFG Exception handler vector address EBASE Base address of the interrupt handler table INTBP Note Whether the exception handler vector address EBASE or the base address of the interrupt handler table INTBP is reserved depends on the option settings for activation of the CONFIGURATOR CF850V4 When ebase lt Exception Base Address gt is specified the exception handler vector address EBASE is handled as a reserved resource when intbp lt nterrupt Base Address gt is specified the base address of the interrupt handler table INTBP is handled as a reserved resource R20UT2889EJ0101 Rev 1 01 ztENESAS Page 12 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 2 SYSTEM CONSTRUCTION CHAPTER 2 SYSTEM CONSTRUCTION This chapter describes how to build a system load module that uses the functio
49. details about the semaphore state packet refer to 15 2 3 Semaphore state packet Return value Macro Value Description E OK 0 Normal completion Invalid ID number E_ID 18 semid lt 0x0 semid gt Maximum ID number Context error E CIX 25 This service call was issued in the CPU locked state R20UT2889EJ0101 Rev 1 01 Sep 30 2015 ztENESAS Page 212 of 366 RI850V4 V2 CHAPTER 16 SERVICE CALLS Macro Value Description E_NOEXS 42 Non existent object Specified semaphore is not registered R20UT2889EJ0101 Rev 1 01 Sep 30 2015 ztENESAS Page 213 of 366 RI850V4 V2 16 2 4 Synchronization and communication functions eventflags The following shows the service calls provided by the RI850V4 as the synchronization and communication functions CHAPTER 16 SERVICE CALLS eventtflags Table 16 4 Synchronization and Communication Functions Eventflags Service Call Function Origin of Service Call set_flg Set eventtflag Task Non task Initialization rou tine iset_flg Set eventilag Task Non task Initialization rou tine Task Non task Initialization rou clr_flg Clear eventtflag tine Task Non task Initialization rou iclr_flg Clear eventtflag tine wai_flg Wait for eventflag waiting forever Task pol_fig Wait for eventflag polling a Non task Initialization rou ipol_flg Wait for ev
50. details about the variable sized memory pool state packet refer to 15 2 10 Variable sized memory pool state packet R20UT2889EJ0101 Sep 30 2015 Rev 1 01 2tENESAS Page 106 of 366 RI850V4 V2 CHAPTER 8 SYSTEM STATE MANAGEMENT FUNCTIONS CHAPTER 8 SYSTEM STATE MANAGEMENT FUNC TIONS This chapter describes the system management functions performed by the RI850V4 8 1 Outline The RI850V4 s system status management function provides functions for referencing the system status such as the context type and CPU lock status as well as functions for manipulating the system status such as ready queue rotation scheduler activation or the like 8 2 Rotate Task Precedence A ready queue is rotated by issuing the following service call from the processing program rot_rdq irot_rdq This service call re queues the first task of the ready queue corresponding to the priority specified by parameter tskpri to the end of the queue to change the task execution order explicitly The following shows the status transition when this service call is used Figure 8 1 Rotate Task Precedence Ready queue 1 tskpri 1 kori Task A Task B Task C tskpri RUNNING state READY state READY state tskpri 1 maxtpri Rotate task precedence Ready queue tskpri 1 kori Task B Task C Task A SKDN RUNNING state
51. does not perform memory clear processing when returning the acquired variable size memory block The contents of the returned variable size memory block are therefore undefined Note 2 When returning variable size memory blocks be sure to issue either of these service calls for the acquired variable size memory pools If the service call is issued for another variable size memory pool no error results but the operation is not guaranteed after that Return value Macro Value Description E OK 0 Normal completion Invalid ID number E ID 18 mplid lt 0x0 mplid gt Maximum ID number Context error E_CTX 25 This service call was issued in the CPU locked state R20UT2889EJ0101 Rev 1 01 2tENESAS Page 276 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 16 SERVICE CALLS Macro Value Description E_NOEXS 42 Non existent object Specified variable sized memory pool is not registered R20UT2889EJ0101 Rev 1 01 Sep 30 2015 ztENESAS Page 277 of 366 RI850V4 V2 CHAPTER 16 SERVICE CALLS ref_mpl iref_mpl Outline Reference variable sized memory pool state C format ER ref_mpl ID mplid T_RMPL pk_rmpl ER iref_mpl ID mplid T_RMPL pk_rmpl Parameter s 0 Parameter Description ID mplid ID number of the variable sized memory pool to be referenced O T_RMPL pk_rmpl Pointer to the packet returning the variable sized
52. error E CTX 25 This service call was issued in the CPU locked state Object state error E_OBJ 41 Specified task is neither in the WAITING state nor WAITING SUSPENDED state Non existent object E_NOEXS 42 Specified task is not registered R20UT2889EJ0101 Rev 1 01 tENESAS Page 199 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 16 SERVICE CALLS Outline Suspend task C format ER sus_tsk ID tskid ER isus_tsk ID tskid Parameter s V O Parameter Description ID number of the task to be suspended ID tskid TSK_SELF Invoking task Value ID number of the task to be suspended Explanation These service calls add 0x1 to the suspend request counter for the task specified by parameter tskid and then move the target task from the RUNNING state to the SUSPENDED state from the READY state to the SUSPENDED state or from the WAITING state to the WAITING SUSPENDED state If the target task has moved to the SUSPENDED or WAITING SUSPENDED state when this service call is issued the counter manipulation processing is not performed but only the suspend request counter increment processing is executed Note Return value The suspend request counter managed by the RI850V4 is configured in 7 bit widths If the number of suspend requests exceeds the maximum count value 127 as a result of issuing this service call the counter manipulation processing is therefore not pe
53. execution environment information required for a task s execution is called task context During task execution switching the task context of the task currently under execution by the RI850V4 is saved and the task context of the next task to be executed is loaded 3 2 1 Task state Tasks enter various states according to the acquisition status for the OS resources required for task execution and the occurrence non occurrence of various events In this process the current state of each task must be checked and managed by the RI850V4 The RI850V4 classifies task states into the following six types Figure 3 1 Task State e READY state RUNNING state A A i kq _____1 WAITING state I WAITING SUSPENDED state gt SUSPENDED state A DORMANT state ke R20UT2889EJ0101 Rev 1 01 2tENESAS Page 21 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 3 TASK MANAGEMENT FUNCTIONS 1 DORMANT state State of a task that is not active or the state entered by a task when processing has ended A task in the DORMANT state while being under management of the RI850V4 is not subject to RI850V4 scheduling 2 READY state State of a task for which the preparations required for processing execution have been completed but since another task with a higher priority level or a task with the same priority level
54. from the scheduling facility as a user own coding module This enhances portability to various execution environments and facilitates customization as well 13 2 1 Idle Routine The idle routine is a routine dedicated to idle processing that is extracted as a user own coding module to utilize the standby function provided by the CPU to achieve the low power consumption system and is called from the scheduler when there no longer remains a task subject to scheduling by the RI850V4 task in the RUNNING or READY state in the system The RI850V4 manages the states in which each idle routine may enter and idle routines themselves by using management objects idle routine control blocks corresponding to idle routines one to one Basic form of idle routine Code idle routines by using the void type function that has no arguments The following shows the basic form of idle routine in C include lt kernel h gt Standard header file definition void idlrtn void return Terminate idle routine Internal processing of idle routine The RI850V4 executes original pre processing when passing control to the idle routine as well as original post processing when regaining control from the idle routine Therefore note the following points when coding idle routines Coding method Code idle routines using C or assembly language When coding in C they can be coded in the same manner as ordinary functions coded Whe
55. hardware trace mode align4 61 Bytes Taking in trace chart by software trace mode align4 74 Bytes Taking in long statistics by software trace mode align4 70 Bytes R20UT2889EJ0101 Rev 1 01 RENESAS Page 357 of 366 Sep 30 2015 RI850V4 V2 APPENDIX B SIZE OF MEMORY B 1 6 kernel_data_trace bss The size of kernel_data_trace bss section depends on the trace mode The type of trace mode is selected in the Property panel gt Task Analyzer tab gt Trace category gt Selection of trace mode 1 2 Not tracing The size of kernel_data_trace bss section is 0 bytes Taking in trace chart by hardware trace mode The size of kernel_data_trace bss section is 4 bytes Taking in trace chart by software trace mode The size of kernel_data_trace bss section depends on the definition in the Property panel gt Task Analyzer tab gt Trace category gt Buffer size The following shows an expression required for estimating kernel_data_trace bss section size In the expression align4 x means the result of aligning the value x to a 4 byte boundary KERNEL DATA _TRACE BSS 24 align4 TRC_BUF_size Note The keyword in the expression means as follows Keywords Meaning The number of the definition of the Property panel gt Task Analyzer tab gt TRC BUR STZ Trace category gt Buffer size Taking in long stat
56. header files listed below must be coded include processing kernel h Standard header file kernel_id h System information header file R20UT2889EJ0101 Rev 1 01 ztENESAS Page 174 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 16 SERVICE CALLS 16 2 Explanation of Service Call The following explains the service calls supported by the RI850V4 in the format shown below 1 2 Outline 3 C format 4 Parameter s 1 0 Parameter Description 5 gt Explanation 6 Return value Macro Value Description R20UT2889EJ0101 Rev 1 01 RENESAS Sep 30 2015 Page 175 of 366 RI850V4 V2 CHAPTER 16 SERVICE CALLS 1 Name Indicates the name of the service call 2 Outline Outlines the functions of the service call 3 C format Indicates the format to be used when describing a service call to be issued in C language 4 Parameter s Service call parameters are explained in the following format 0 Parameter Description A B C A Parameter classification I Parameter input to RI850V4 O Parameter output from RI850V4 B Parameter data type C Description of parameter 5 Explanation Explains the function of a service call 6 Return value Indicates a service call s return value using a macro and value Macro Value Description A B C
57. in the Generate a file property is selected Default kernel_id h How to change Directly enter to the text box Restriction Up to 259 characters R20UT2889EJ0101 Rev 1 01 7tENESAS Page 350 of 366 Sep 30 2015 RI850V4 V2 APPENDIX A WINDOW REFERENCE 3 Entry File The detailed information on the entry file are displayed and the configuration can be changed Select whether to generate an entry file and whether to update the file when the system configuration file is changed Default Yes It updates the file when the cfg file is changed e How to change Select from the drop down list Generates an entry file and displays it on the project tree If the system configuration file is changed when there is already an entry file then the entry file is updated Yes It updates the file when the cfg file is changed e Generate a file Does not update the entry file when Yes It does not the system configuration file is Restriction update the file when changed the cfg file is An error occurs during build if this changed ne item is selected when the entry file does not exist Does not generate an entry file and No It does not does not display it on the project tree register the file to the If this item is selected when there is project ne already an entry file then the file itself is not deleted Specify the folder for outputting the entry fil
58. included herein Renesas Electronics does not assume any liability for infringement of patents copyrights or other intellectual property rights of third parties by or arising from the use of Renesas Electronics products or technical information described in this document No license express implied or otherwise is granted hereby under any patents copyrights or other intellectual property rights of Renesas Electronics or others You should not alter modify copy or otherwise misappropriate any Renesas Electronics product whether in whole or in part Renesas Electronics assumes no responsibility for any losses incurred by you or third parties arising from such alteration modification copy or otherwise misappropriation of Renesas Electronics product Renesas Electronics products are classified according to the following two quality grades Standard and High Quality The recommended applications for each Renesas Electronics product depends on the product s quality grade as indicated below Standard Computers office equipment communications equipment test and measurement equipment audio and visual equipment home electronic appliances machine tools personal electronic equipment and industrial robots etc High Quality Transportation equipment automobiles trains ships etc traffic control systems anti disaster systems anti crime systems and safety equipment etc Renesas Electronics products are neith
59. information specified in Task information during configuration and the value specified for the second parameter stacd when service call sta_tsk or ista_tsk is issued are called extended information 3 4 1 Queuing an activation request A task queuing an activation request is activated by issuing the following service call from the processing program act_tsk iact_tsk These service calls move a task specified by parameter tskid from the DORMANT state to the READY state As a result the target task is queued at the end on the ready queue corresponding to the initial priority and becomes subject to scheduling by the RI850V4 If the target task has been moved to a state other than the DORMANT state when this service call is issued this service call does not move the state but increments the activation request counter by added 0x1 to the wakeup request counter The following describes an example for coding this service call include lt kernel h gt Standard header file definition include lt kernel_id h gt System infromation header file definition void task VP_INT exinf ID tskid 8 Declares and initializes variable act_tsk tskid Activate task queues an activation request Note 1 The activation request counter managed by the RI850V4 is configured in 7 bit widths If the number of activation requests exceeds the maximum count value 127 as a result of issuing this service call the counter manipula
60. initialization processing which is required from the reset interrupt output until control is passed to the task The following shows a processing flow from when a reset interrupt occurs until the control is passed to the task Reset interrup Interrupt entry processing Boot processing Initialization routine Figure 14 1 Processing Flow System Initialization Kernel Initialization Module R20UT2889EJ0101 Rev 1 01 2tENESAS Page 147 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 14 SYSTEM INITIALIZATION ROUTINE 14 2 User Own Coding Module To support various execution environments the RI850V4 extracts from the system initialization processing the hardware dependent processing Boot processing that is required to execute processing as a user own coding module This enhances portability for various execution environments and facilitates customization as well 14 2 1 Boot processing This is a routine dedicated to initialization processing that is extracted as a user own coding module to initialize the minimum required hardware for the RI850V4 to perform processing and is called from Initialization routine Basic form of boot processing Code boot processing by using the void type function that has no arguments The following shows the basic form of boot processing in assembly public __boot text cseg text align 0x2 _ boot mov __kernel_start r11 Jump to Kernel Initialization Module j
61. is called from the scheduler when there no longer remains a task subject to scheduling by the RI850V4 task in the RUNNING or READY state in the system Boot processing A routine dedicated to initialization processing that is extracted as a user own coding module to initialize the minimum required hardware for the RI850V4 to perform processing and is called from Interrupt entry processing System dependent information The system dependent information is a header file file name userown h including various information required for the RI850V4 to execute processing which is extracted as a user own coding module Note For details about the user own coding module refer to CHAPTER 7 MEMORY POOL MANAGEMENT FUNCTIONS CHAPTER 10 INTERRUPT MANAGEMENT FUNCTIONS CHAPTER 12 SYSTEM CONFIGURATION MANAGEMENT FUNCTIONS CHAPTER 13 SCHEDULER CHAPTER 14 SYSTEM INITIALIZATION ROUTINE 2 5 Trace Information File The trace information file file name trcinf c includes descriptions of the processing necessary for the trace mode selected in the Property panel gt Task Analyzer tabbed page gt Trace category gt Selection of trace mode The user does not need to modify the contents of this file Note that this file should be incorporated into the load module even when the trace facility is not used Include this file as a target of build processing even when using the GHS version development environment R20UT2889EJ0101 Re
62. no successive areas equivalent to the requested size were available when this service call is issued the contents in the area specified by parameter p_blk become undefined Return value Macro Value Description E OK 0 Normal completion Parameter error E PAR 17 blksz 0x0 blksz gt Ox7fffffff Invalid ID number E ID 18 mplid lt 0x0 mplid gt Maximum ID number R20UT2889EJ0101 Rev 1 01 2tENESAS Page 272 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 16 SERVICE CALLS Macro Value Description Context error E CTX 25 This service call was issued in the CPU locked state Non existent object E NOEXS 42 Specified variable sized memory pool is not registered Polling failure E_TMOUT 50 No successive areas equivalent to the requested size were available in the target variable size memory pool R20UT2889EJ0101 Rev 1 01 Sep 30 2015 ztENESAS Page 273 of 366 RI850V4 V2 CHAPTER 16 SERVICE CALLS Outline Acquire variable sized memory block with timeout C format ER tget_mpl ID mplid UINT blksz VP p blk TMO tmout j Parameter s 1 0 Parameter Description ID number of the variable sized memory pool from which a memory ID mplid block is acquired l UINT blksz Memory block size to be acquired in bytes O VP p blk Start address of the acquired memory block Specified timeout
63. non task TSK_SELF was specified tskid Context error E_CTX 25 This service call was issued in the CPU locked state Object state error E_OBJ 41 Specified task is in the DORMANT state Non existent object E_NOEXS 42 Specified task is not registered R20UT2889EJ0101 Rev 1 01 tENESAS Page 187 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 16 SERVICE CALLS Outline Reference task state C format ER ref_tsk ID tskid T_RTSK pk_rtsk ER iref_tsk ID tskid T_RTSK pk_rtsk Parameter s V O Parameter Description ID number of the task to referenced ID tskid TSK_SELF Invoking task Value ID number of the task to referenced O T_RTSK pk_rtsk Pointer to the packet returning the task state Task state packet T_RTSK typedef struct t_rtsk STA PRI PRI Explanation tskstat tskpri tskbpri tskwait wobjid lefttmo actcnt wupcnt suscnt tskatr itskpri memid Current state Current priority Reserved for future use Reason for waiting Object ID number for which the task is waiting Remaining time until timeout Activation request count Wakeup request count Suspension count Attribute Initial priority Reserved for future use Stores task state packet current state current priority etc of the task specified by parameter tskid in the area specified by parameter pk_rtsk Note For detai
64. not queue an activation request R20UT2889EJ0101 Rev 1 01 2tENESAS Page 27 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 3 TASK MANAGEMENT FUNCTIONS 3 5 Cancel Task Activation Requests An activation request is cancelled by issuing the following service call from the processing program can_act ican_act This service call cancels all of the activation requests queued to the task specified by parameter tskid sets the activation request counter to 0x0 When this service call is terminated normally the number of cancelled activation requests is returned The following describes an example for coding this service call include lt kernel h gt Standard header file definition include lt kernel_id h gt System information header file definition void task VP_INT exinf ER_UINT ercd Declares variable ID tskid 8 Declares and initializes variable ercd can_act tskid Cancel task activation requests if ercd gt 0x0 Normal termination processing Note This service call does not perform status manipulation processing but performs the setting of activation request counter Therefore the task does not move from a state such as the READY state to the DORMANT state R20UT2889EJ0101 Rev 1 01 ztENESAS Page 28 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 3 TASK MANAGEMENT FUNCTIONS 3 6 Terminate Task 3 6 1 Terminate invoking task An invoking task is termina
65. of the base clock cycle defined in Basic information is specified for cycphs the CF850V4 assumes that an integral multiple is specified and performs processing R20UT2889EJ0101 Rev 1 01 ztENESAS Page 323 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 17 SYSTEM CONFIGURATION FILE 17 5 10 Interrupt handler information The interrupt handler information defines Exception code inhno Attribute inhatr Start address inthdr for an interrupt handler information The number of items that can be defined as interrupt handler information is limited to one for each exception code The following shows the interrupt handler information format iw EF_INH inhno inhatr inthdr The items constituting the interrupt handler information are as follows 1 Exception code inhno Specifies the exception code for an El level maskable interrupt for which an interrupt handler is to be registered The value that can be specified for inhno is an interrupt source name specified in the device file or a value from 0x1000 to the maximum exception code specified in the Basic information Note When an interrupt source name is specified for inhno cpu_name must be specified for the CF850V4 activation option Attribute inhatr Specifies the language used to describe an interrupt handler The keyword that can be specified for inhatris TA_HLNG or TA_ASM TA_HLNG Start an interrupt handler through a C language interface TA_ASM Start
66. of the size 4 byte specified by parameter biksz from the variable size memory pool specified by parameter mplid and stores its start address into the area specified by parameter p_bik If no variable size memory blocks could be acquired from the target variable size memory pool no successive areas equivalent to the requested size were available when this service call is issued this service call does not acquire variable size memory blocks but queues the invoking task to the target variable size memory pool wait queue and moves it from the RUNNING state to the WAITING state with timeout variable size memory block acquisition wait state The WAITING state for a variable sized memory block is cancelled in the following cases and then moved to the READY state WAITING State for a Variable sized Memory Block Cancel Operation Return Value The variable size memory block that satisfies the requested size was returned to the target E OK variable size memory pool as a result of issuing rel_mpl The variable size memory block that satisfies the requested size was returned to the target E OK variable size memory pool as a result of issuing irel_mpl Forced release from waiting accept rel_wai while waiting E_RLWAI Forced release from waiting accept irel_wai while waiting E_RLWAI Polling failure or timeout E_TMOUT The following describes an example for coding this service call R20UT2889EJ0101 Rev 1 01 tENESA
67. processing rel_mpf mpfid p blk Release fixed sized memory block else if ercd E_RLWAI abe plat aera arte Forced termination processing lse if ercd E_TMOUT Beco cece eae ans Timeout processing Note 1 The RI850V4 does not perform memory clear processing when getting the acquired fixed size memory block The contents of the got fixed size memory block are therefore undefined R20UT2889EJ0101 Rev 1 01 ztENESAS Sep 30 2015 Page 95 of 366 RI850V4 V2 CHAPTER 7 MEMORY POOL MANAGEMENT FUNCTIONS Note 2 Invoking tasks are queued to the target fixed size memory pool wait queue in the order defined during configuration FIFO order or priority order Note 3 If the fixed size memory block acquisition wait state is cancelled because rel_wai or irel_wai was issued or the wait time elapsed the contents in the area specified by parameter p_bik become undefined Note 4 TMO_FEVR is specified for wait time tmout processing equivalent to get_mpf will be executed When TMO_POL is specified processing equivalent to pget_mpf ipget_mpf will be executed R20UT2889EJ0101 Rev 1 01 2tENESAS Page 96 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 7 MEMORY POOL MANAGEMENT FUNCTIONS 7 3 3 Release fixed sized memory block A fixed sized memory block is returned by issuing the following service call from the processing program rel_mpf irel_mpf This service call returns the fixed sized memory block specified b
68. processing routine provided for initializing the minimum required software for the RI850V4 to perform processing and is called from Boot processing The following processing is executed in the kernel initialization module Initializing management objects Initializes the objects defined in the system configuration file such as tasks and semaphores Initializing the system time Initializes the system time to 0 which is updated in units of the Base clock interval tim_base when an El level maskable interrupt defined in the Base clock timer exception code tim_intno occurs Activating tasks Moves the tasks whose Attribute tskatr such as coding language and initial activation state is defined as TA_ACT from the DORMANT state to the READY state Starting cyclic handlers Moves the cyclic handlers whose Attribute cycatr such as coding language and initial activation state is defined as TA_STA from the non operational state STP state to the operational state STA state Calling initialization routines Calls the initialization routines defined in the Initialization routine information in the order of definitions in the system configuration file Returning control to the scheduler Selects the most suitable one of the tasks placed in the READY state and moves the task from the READY state to the RUNNING state Note The kernel initialization module is included in the system initialization processing provided by the RI850V4 The
69. programs to the areas reserved for future use in each data structure 15 2 1 Task state packet The following shows task state packet T_RTSK used when issuing ref_tsk or iref_tsk Definition of task state packet T_RTSK is performed by the header file lt ri_root gt include os packet h which is called from the standard header file lt ri_root gt include kernel h typedef struct t_rtsk STA tskstat Current state PRI tskpri Current priority PRI tskbpri Reserved for future use STA tskwait Reason for waiting ID wobjid Object ID number for which the task waiting TMO lefttmo Remaining time until timeout UINT actcnt Activation request count UINT wupcent Wakeup request count UINT suscnt Suspension count ATR tskatr Attribute PRI itskpri Initial priority ID memid Reserved for future use T_RTSK The following shows details on task state packet T_RTSK tskstat Stores the current state TTS_RUN RUNNING state TTS_RDY READY state TTS_WAI WAITING state TTS_SUS SUSPENDED state TTS_WAS WAITING SUSPENDED state TTS_DMT DORMANT state tskpri Stores the current priority tskbpri System reserved area tskwait Stores the reason for waiting TTW_SLP Sleeping state TTW_DLY Delayed state TTW_SEM WAITING state for a semaphore resource TTW_FLG WAITING state for an eventflag TTW_SDTQ Sending WAITING state for a data queue TTW_RDTQ Receiving WAIT
70. realizes the RI850V4 s scheduling system by executing task detection processing from the highest priority level of the ready queue upon activation and upon detection of queued tasks giving the CPU use right to the first task of the proper priority level Return value Macro Value Description E OK 0 Normal completion Parameter error tskpri lt 0x0 E_PAR 17 tskpri gt Maximum priority When this service call was issued from a non task TPRI_SELF was specified tskpri Context error E_CTX 25 This service call was issued in the CPU locked state R20UT2889EJ0101 Rev 1 01 Sep 30 2015 2tENESAS Page 289 of 366 RI850V4 V2 CHAPTER 16 SERVICE CALLS Outline Forced scheduler activation C format ER vsta_sch void Parameter s None Explanation This service call explicitly forces the RI850V4 scheduler to activate If a scheduling request has been kept pending task switching may therefore occur Note The RI850V4 provides this service call as a function to activate a scheduler from a task for which preempt acknowledge status disable is defined during configuration Return value Macro Value Description E OK 0 Normal completion Context error This service call was issued from a non task E CTX 25 This service call was issued in the CPU locked state This service call was issued in the dispatching disabled state R2
71. served FCFS basis and the task for which the longest interval of time has elapsed since it entered an executable state READY state is selected as the task to which the CPU use right is granted R20UT2889EJ0101 Rev 1 01 2tENESAS Page 142 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 13 SCHEDULER 13 1 3 Ready queue The RI850V4 uses a ready queue to implement task scheduling The ready queue is a hash table that uses priority as the key and tasks that have entered an executable state READY state or RUNNING state are queued in FIFO order Therefore the scheduler realizes the RI850V4 s scheduling method priority level or FCFS by executing task detection processing from the highest priority level of the ready queue upon activation and upon detection of queued tasks giving the CPU use right to the first task of the proper priority level The following shows the case where multiple tasks are queued to a ready queue Figure 13 1 Implementation of Scheduling Method Priority Level Method or FCFS Method Ready queue 1 Priority High l tskpri 1 f Task A Task B tskpri RUNNING state READY state tskpri 1 tskpri n 1 tskpri n e ee READY state tskpri n 1 Priority Low maxtpri Create ready queue In the RI850V4 the method of creating a ready queue is limited to static creation Ready queues therefore cannot be created dynami
72. size sys_stksz Whether to check stack stkchk Maximum priority maxtpri Maximum interrupt priority maxintpri Maximum number of interrupt handlers maxint Maximum value of exception code maxintno Only one information item can be defined as basic information The following shows the basic information format C CL SY PU_TYPE chip_type D STK_CHK stkchk MAX_PRI maxtpri MAX_INTPRI maxintpri j MAX_INT maxint maxintno EF TIM tim_base K_ININO tim_intno S_STK sys_stksz The 1 5 items constituting the basic information are as follows CPU type cou Specifies the type for a CPU If you are using the CS don t need to specify this specified item The keyword that can be specified for chip_type is G3K or G3M G3K G3K core G3M G3M core If omitted The CPU type should be the device type specified in the cpu option When the PE number is specified in the peid option the CPU type corresponding to the PE number should be specified When the cpu option setting is omitted the CPU type should be G3K Base clock interval tim_base Specifies the base clock interval unit millisecond of the timer to be used A value from 0x1 to Oxffff can be specified for tim_base If omitted Oxims is specified as the base clock cycle of the RI850V4 Note The base clock cycle means the occurrence interval of base clock timer interrupt tim_intno which is
73. specified for mprihd are limited to NULL characters R20UT2889EJ0101 Rev 1 01 7tENESAS Page 318 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 17 SYSTEM CONFIGURATION FILE 17 5 6 Mutex information The mutex information defines ID number mtxid Attribute mtxatr Reserved for future use ceilpri for a mutex The number of items that can be defined as mutex information is limited to one for each ID number The following shows the mutex information format CRE_MTX mtxid mtxatr ceilpri The items constituting the mutex information are as follows 1 ID number mtxid Specifies the ID number for a mutex A value from 0x1 to Oxff or a name can be specified for mtxid Note When a name is specified the CF850V4 automatically assigns an ID number The CF850V4 outputs the relationship between a name and an ID number to the system information header file in the following format define mtxid value 2 Attribute mtxatr Specifies the task queuing method for a mutex The keyword that can be specified for mtxatris TA_TFIFO or TA_TPRI TA_TFIFO Task wait queue is in FIFO order TA_TPRI Task wait queue is in task priority order 3 Reserved for future use ceilpri System reserved area Only values from 0x1 to maximum task priority maxtpri defined in Basic information can be specified for ceilpri R20UT2889EJ0101 Rev 1 01 ztENESAS Page 319 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 17 SYSTEM CONFIGURATION FIL
74. state or from the WAITING SUSPENDED state to the SUSPENDED state R20UT2889EJ0101 Rev 1 01 2tENESAS Page 229 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 16 SERVICE CALLS Note 1 Data is written to the data queue area of the target data queue in the order of the data transmission request Note 2 Invoking tasks are queued to the transmission wait queue of the target data queue in the order defined during configuration FIFO order or priority order Note 3 TMO_FEVR is specified for wait time tmout processing equivalent to snd_dtq will be executed When TMO_POL is specified processing equivalent to psnd_dtq ipsnd_dtq will be executed Return value Macro Value Description E OK 0 Normal completion Parameter error tmout lt TMO_FEVR E_PAR 17 Invalid ID number E_ID 18 dtqid lt 0x0 dtgid gt Maximum ID number Context error This service call was issued from a non task E CTX 25 This service call was issued in the CPU locked state This service call was issued in the dispatching disabled state Non existent object E NOEXS 42 Specified data queue is not registered Forced release from the WAITING state E RLWAI 49 Accept rel_wai irel_wai while waiting Timeout E TMOUT 50 Polling failure or timeout R20UT2889EJ0101 Rev 1 01 tENESAS Page 230 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 16 SERVICE CALLS fsnd_dtq ifsnd_dtq Outline
75. task Initialization rou iprev_mbx Receive from mailbox polling i Non task initalization rou trev _mbx Receive from mailbox with timeout Task ref_mbx Reference mailbox state nah Yonas ial eal MOTT TOU iref_mbx Reference mailbox state an Non task Initialization rou R20UT2889EJ0101 Rev 1 01 tENESAS Page 239 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 16 SERVICE CALLS snd_mbx isnd_mbx Outline Send to mailbox C format ER snd_mbx ID mbxid T_MSG pk_msqg ER isnd_mbx ID mbxid T_MSG pk_msqg Parameter s 0 Parameter Description l ID mbxid ID number of the mailbox to which the message is sent l T_MSG pk_msg Start address of the message packet to be sent to the mailbox Message packet T_MSG typedef struct t_msg struct t_msg msgnext Reserved for future use T_MSG Message packet T_ MSG_PRI typedef struct t_msg_pri struct t_msg msgque Reserved for future use PRI msgpri Message priority T_MSG_PRI Explanation This service call transmits the message specified by parameter pk_msg to the mailbox specified by parameter mbxid queues the message in the wait queue If a task is queued to the target mailbox wait queue when this service call is issued the message is not queued but handed over to the relevant task first task of the wait queue As a result the relevant task is unlinked from the wait queue and is moved from the WAITING state receivi
76. task that acquired the memory is unlinked from the queue and moved from the WAITING state variable size memory block acquisition wait state to the READY state or from the WAITING SUSPENDED state to the SUSPENDED state The following describes an example for coding this service call include include void task lt kernel h gt lt kernel_id h gt VP_INT exinf Standard header file definition System information header file definition ER ercd ID mplid ID_MPL1 UINT blksz 256 VP blk ercd get_mpl mplid blksz Declares variable Declares and initializes variable Declares and initializes variable Declares variable Acquire variable sized memory block amp b1lk if ercd E_OK ss andes sano Normal termination processing rel_mpl mplid bik Release variable sized memory block else if ercd E_RLWAI KAREE aguas Forced termination processing Note 1 The RI850V4 does not perform memory clear processing when returning the acquired variable size memory Note 2 block The contents of the returned variable size memory block are therefore undefined When returning variable size memory blocks be sure to issue either of these service calls for the acquired variable size memory pools If the service call is issued for another variable size memory pool no error results but the operation is not guaranteed after that R20UT28
77. the bit pattern set to the eventflag specified by parameter flgid and the bit pattern specified by parameter cirptn as the bit pattern of the target eventflag Note If the bit pattern set to the target eventtflag is B 1100 and the bit pattern specified by parameter cirptn is B 1010 when this service call is issued the bit pattern of the target eventtflag is set to B 1000 Return value Macro Value Description E OK 0 Normal completion Invalid ID number E ID 18 flgid lt 0x0 flgid gt Maximum ID number Context error E CTX 25 This service call was issued in the CPU locked state Non existent object E NOEXS 42 Specified eventflag is not registered R20UT2889EJ0101 Rev 1 01 7tENESAS Page 217 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 16 SERVICE CALLS Outline Wait for eventflag waiting forever C format ER wai_flg ID flgid FLGPTN waiptn MODE wfmode FLGPTN p_flgptn j Parameter s 0 Parameter Description l ID flgid ID number of the eventflag to wait for l FLGPTN waiptn Wait bit pattern Wait mode l MODE wfmode TWF_ANDW AND waiting condition TWF_ORW OR waiting condition O FLGPTN p_flgptn Bit pattern causing a task to be released from waiting Explanation This service call checks whether the bit pattern specified by parameter waiptn and the bit pattern that satisfies the required condition specified by parameter wf
78. the interrupt priority manipulation of EIC EIPn 8 Selection of the interrupt vector method manipulation of EIC EITB 9 Initialization of memory areas for uninitialized data such as the bss section 10 Initialization of Internal unit of CPU such as the OS timer and peripheral controllers For initialization of the OS timer see 9 2 1 Base clock timer interrupt 11 Setting of the priority for the floating point operation exception only for the device incorporating the FPU 12 Setting of the start address of the system information table in r6 13 Returning of control to the Kernel Initialization Module _kernel_start Note 1 When initializing the interrupt configuration register INTCFG clear the ISPC bit to 0 to automatically update the ISPR value Note 2 If global pointer GP is modified outside the boot processing correct operation is not guaranteed afterwards Note 3 When modifying element pointer EP in a processing program such as a task or a cyclic handler compiler option Xep callee must be specified Property panel gt Common Options tabbed page gt Register Mode category gt ep register treatment must be set to Treat as callee save Note 4 Setting of stack pointer sp is required only when the dedicated boot processing stack is used Note 5 The following shows sample codes for initializing kernel_data_init section CC RH compiler Use the RAM section area initialization func
79. the mutex specified by parameter mtxid If the target mutex could not be locked another task has been locked when this service call is issued this service call queues the invoking task to the target mutex wait queue and moves it from the RUNNING state to the WAITING state mutex wait state The WAITING state for a mutex is cancelled in the following cases and then moved to the READY state WAITING State for a Mutex Cancel Operation Return Value The locked state of the target mutex was cancelled as a result of issuing unl_mtx E OK The locked state of the target mutex was cancelled as a result of issuing ext_tsk E OK The locked state of the target mutex was cancelled as a result of issuing ter_tsk E OK Forced release from waiting accept rel_wai while waiting E RLWAI Forced release from waiting accept irel_ wai while waiting E RLWAI Note 1 Invoking tasks are queued to the target mutex wait queue in the order defined during configuration FIFO order or priority order Note 2 In the RI850V4 E_ILUSE is returned if this service call is re issued for the mutex that has been locked by the invoking task multiple locking of mutex Return value Macro Value Description E OK 0 Normal completion Invalid ID number E ID 18 mtxid lt 0x0 mtxid gt Maximum ID number R20UT2889EJ0101 Rev 1 01 2tENESAS Page 250 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 16 SERVICE CAL
80. the start address of the area to be allocated as the trace buffer This item is displayed only when Another buffer is selected in Select the buffer Buffer address Default 0x100 How to change Enter directly in the text box Restriction 0x10 OxfffffffO R20UT2889EJ0101 Rev 1 01 ztENESAS Page 347 of 366 Sep 30 2015 RI850V4 V2 APPENDIX A WINDOW REFERENCE System Configuration File Related Information tab Outline This tab shows the detailed information on the using system configuration file categorized by the following and the configuration can be changed System information table file System information header file Entry file This tab can be opened as follows On the Project Tree panel select a component such as the Realtime OS node or the system configuration file and then select the View menu gt Property or select Property from the context menu Note When the Property panel is already open selecting a component such as the Realtime OS node or the system configuration file on the Project Tree panel displays the detailed information regarding the selected component Display image _8 4 Ee Generate a file YestIt updates the file when the cfe file is chan Output folder BuildMode Name File name sits System Information Header File Generate a file Yes lt updates the file when the cfg file is chan Output folder BuildModeNa me File name kernel_idh Entry
81. user own coding module to execute post overflow processing and is called when a stack overflow occurs in the RI850V4 or a processing program Acceptance of interrupts is disabled the ID flag in the program status word PSW is set to 1 in the initial state after activation Interrupt entry processing A routine dedicated to entry processing that is extracted as a user own coding module to assign processing for branching to the relevant processing such as interrupt preprocessing to the handler address to which the CPU forcibly passes control when an interrupt occurs The interrupt entry processing for the El level maskable interrupts defined in the Interrupt handler information in the system configuration file is included in the entry file created by executing the configurator for the system configuration file Therefore coding of interrupt entry processing is necessary for other interrupts such as a reset that are not El level maskable interrupts Initialization routine A routine dedicated to initialization processing that is extracted as a user own coding module to initialize the hardware dependent on the user execution environment such as the peripheral controller and is called from the Kernel Initialization Module Idle Routine A routine dedicated to idle processing that is extracted from the SCHEDULER as a user own coding module to utilize the standby function provided by the CPU to achieve the low power consumption system and
82. using this service call Figure 8 2 Lock the CPU Task Interrupt handler Lock the CPU Suppressed period wv Unlock the CPU return R20UT2889EJ0101 Rev 1 01 2tENESAS Page 111 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 8 SYSTEM STATE MANAGEMENT FUNCTIONS The following describes an example for coding this service call include lt kernel h gt Standard header file definition include lt kernel_id h gt System information header file definition void task VP_INT exinf lge epu O Lock the CPU E ET E CPU locked state unl epu Unlock the CPU Note 1 The CPU locked state changed by issuing this service call must be cancelled before the processing program that issued this service call ends Note 2 This service call does not perform queuing of lock requests If the system is in the CPU locked state therefore no processing is performed but it is not handled as an error Note 3 This service call manipulates PMn bits in the priority mask register PMR to disable acceptance of El level maskable interrupts The PMn bits to be manipulated correspond to the interrupt priority range defined as the Maximum interrupt priority maxintpri during configuration Note 4 This service call does not manipulate the ID bit in the program status word PSW Note 5 The RI850V4 realizes the TIME MANAGEMENT FUNCTIONS by using base clock timer interrupts that occur at constant intervals If
83. variable FLGPTN clrptn 10 Declares and initializes variable clr_flg flgid clrptn Clear eventflag Note If the bit pattern set to the target eventflag is B 1100 and the bit pattern specified by parameter clrptn is B 1010 when this service call is issued the bit pattern of the target eventflag is set to B 1110 R20UT2889EJ0101 Rev 1 01 2tENESAS Page 55 of 366 Sep 30 2015 CHAPTER 5 SYNCHRONIZATION AND COMMUNICATION RI850V4 V2 FUNCTIONS 5 3 4 Wait for eventflag A bit pattern is checked waiting forever polling or with timeout by issuing the following service call from the processing program wai_flg This service call checks whether the bit pattern specified by parameter waiptn and the bit pattern that satisfies the required condition specified by parameter wfmode are set to the eventflag specified by parameter flgid If a bit pattern that satisfies the required condition has been set for the target eventflag the bit pattern of the target eventtflag is stored in the area specified by parameter p_flgptn If the bit pattern of the target eventflag does not satisfy the required condition when this service call is issued the invoking task is queued to the target eventflag wait queue As a result the invoking task is unlinked from the ready queue and is moved from the RUNNING state to the WAITING state WAITING state for an eventtflag The WAITING state for an eventflag is cancelled in the following cases and
84. void __ghseinfo_clear while b lt e void s n v s sint8 bt v bt n b memset s sint32 v uint32 n Note 6 Manipulate within the Initialization routine the RINT bit in the reset vector base address RBASE and the RINT bit in the exception handler vector address EBASE to specify whether operation should be done in the reduced mode which is necessary when using an entry file in the direct vector method Note 7 Manipulate within the Initialization routine the MKn bits or EIMKn bits in the El level interrupt mask register IMRm to enable acceptance of El level maskable interrupts Note 8 Set the priority of the floating point operation exception to a higher value than the maximum priority of interrupts managed by the kernel 14 2 2 System dependent information System dependent information is a header file file name userown h including various information that is required for the RI850V4 which is extracted as a user own coding module Basic form of system dependent information When coding system dependent information use a specified file name userown h and specified macro names KERNEL_USR_TMCNTREG and KERNEL_USR_BASETIME The following shows the basic form of system dependent information in the C language include lt kernel_id h gt System information header file definition define KERNEL _USR_TMCNTREG Oxffec0004 I O address define KERNE
85. will be executed Return value Macro Value Description E OK 0 Normal completion Parameter error tmout lt TMO_FEVR E_PAR 17 Invalid ID number E ID 18 mpfid lt 0x0 mpfid gt Maximum ID number Context error This service call was issued from a non task E CIX 25 This service call was issued in the CPU locked state This service call was issued in the dispatching disabled state Non existent object E NOEXS 42 Specified fixed sized memory pool is not registered Forced release from the WAITING state E RLWAI 49 Accept rel_wai irel_wai while waiting Timeout E TMOUT 50 Polling failure or timeout R20UT2889EJ0101 Rev 1 01 tENESAS Page 264 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 16 SERVICE CALLS rel_mpf irel_mpf Outline Release fixed sized memory block C format ER rel_mpf ID mpfid VP blk ER irel_mpf ID mpfid VP blk Parameter s 1 0 Parameter Description i ID number of the fixed sized memory pool to which the memory block is l ID mpfid released l VP blk Start address of the memory block to be released Explanation This service call returns the fixed sized memory block specified by parameter blk to the fixed sized memory pool specified by parameter mpfid If a task is queued to the target fixed sized memory pool wait queue when this service call is issued fixed sized memory block ret
86. 0 C Program Files Sample include R20UT2889EJ0101 Rev 1 01 7tENESAS Page 334 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 18 CONFIGURATOR CF850V4 18 2 4 Command input examples The following shows CF850V4 command input examples In these examples C gt indicates the command prompt A indicates the space key input and lt Enter gt indicates the ENTER key input 1 System configuration file sys cfg is loaded from the current folder the device file corresponding to the device specification name r7f701z03 is loaded from the C CS CC Device RH850 Devicefile folder as an input file and system information table file sit s entry file entry s for the direct vector method vector address 0x200 and system information header file kernel_id h are then output Command search processing for the preprocessor of the C compiler package from Renesas Electronics is done in the following order and the relevant preprocessor is activated when the CF850V4 has finished the analysis for the syntax of the system configuration file 1 CACS CC CC RH V1 00 00 bin 2 Folders defined by environment variables such as PATH File search processing for the header files specified in the header file information is performed in the following order 1 C tmp inc850 2 C Program Files Sample include C gt cf850v4 A cpu A rf701203 A devpath C CS CC Device RH850 Devicefile A i A sits A e A entry s A d A kernel_id h A t A REL A T A C
87. 01 Rev 1 01 2tENESAS Page 34 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 3 TASK MANAGEMENT FUNCTIONS 3 10 Memory Saving The RI850V4 provides the method Disable preempt for reducing the task stack size required by tasks to perform processing 3 10 1 Disable preempt In the RI850V4 preempt acknowledge status attribute TA_DISPREEMPT can be defined in Task information when creating a system configuration file The task for which this attribute is defined performs the operation that continues processing by ignoring the scheduling request issued from a non task so a management area of 24 to 44 bytes can be reduced per task R20UT2889EJ0101 Rev 1 01 2tENESAS Page 35 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 4 TASK DEPENDENT SYNCHRONIZATION FUNCTIONS CHAPTER 4 TASK DEPENDENT SYNCHRONIZATION FUNCTIONS This chapter describes the task dependent synchronization functions performed by the RI850V4 4 1 Outline The RI850V4 provides several task dependent synchronization functions 4 2 Put Task to Sleep 4 2 1 Waiting forever A task is moved to the sleeping state waiting forever by issuing the following service call from the processing program slp_tsk As a result the invoking task is unlinked from the ready queue and excluded from the RI850V4 scheduling subject If a wakeup request has been queued to the target task the wakeup request counter is not set to 0x0 when this service call is issued this service call does not move
88. 0101 Rev 1 01 2tENESAS Page 87 of 366 Sep 30 2015 CHAPTER 6 EXTENDED SYNCHRONIZATION AND RI850V4 V2 COMMUNICATION FUNCTIONS 6 2 5 Reference mutex state A mutex status is referenced by issuing the following service call from the processing program ref_mtx iref_mtx The service calls store the detailed information of the mutex specified by parameter mixid existence of locked mutexes waiting tasks etc into the area specified by parameter pk_rmtx The following describes an example for coding this service call include lt kernel h gt Standard header file definition include lt kernel_id h gt System information header file definition void task VP_INT exinf ID mtxid ID_MTX1 Declares and initializes variable T_RMTX pk_rmtx Declares data structure ID htskid Declares variable ID wt skid Declares variable ATR mtxatr Declares variable ref_mtx mbxid amp pk_rmtx Reference mutex state htskid pk_rmtx htskid Acquires existence of locked mutexes wtskid pk_rmtx wtskid Reference ID number of the task at the head of the wait queue mtxatr pk_rmtx mtxatr Reference attribute Note For details about the mutex state packet refer to 15 2 8 Mutex state packet R20UT2889EJ0101 Rev 1 01 ztENESAS Page 88 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 7 MEMORY POOL MANAGEMENT FUNCTIONS CHAPTER 7 MEMORY POOL MANAGEMENT FUNC TIONS This chapte
89. 0UT2889EJ0101 Rev 1 01 2tENESAS Page 75 of 366 Sep 30 2015 CHAPTER 5 SYNCHRONIZATION AND COMMUNICATION RI850V4 V2 FUNCTIONS When using a mailbox with the TA_MPRI attribute The contents and length past the first 8 bytes of a message system reserved area msgque priority level msgpri are not restricted in particular in the RI850V4 Therefore the contents and length past the first 8 bytes are prescribed among the processing programs that exchange data using the mailbox with the TA_MPRI attribute The following shows the basic form of coding TA_MPRI attribute messages in C Message packet for TA_MPRI attribute typedef struct t_msg_pri struct t_msg msgque Reserved for future use PRI msgpri Message priority T_MSG_PRI Note 1 In the RI850V4 a message having a smaller priority number is given a higher priority Note 2 Values that can be specified as the message priority level are limited to the range defined in Mailbox information Maximum message priority maxmpri when the system configuration file is created Note 3 For details about the message packet refer to 15 2 6 Message packet 5 5 2 Create mailbox In the RI850V4 the method of creating a mailbox is limited to static creation Mailboxes therefore cannot be created dynamically using a method such as issuing a service call from a processing program Static mailbox creation means defining of mailboxes using static API CRE_MBxX in the system confi
90. 0UT2889EJ0101 Rev 1 01 7tENESAS Page 290 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 16 SERVICE CALLS get_tid iget_tid Outline Reference task ID in the RUNNING state C format ER get_tid ID p_tskid ER iget_tid ID p_tskid Parameter s 0 Parameter Description O ID p_tskid ID number of the task in the RUNNING state Explanation These service calls store the ID of a task in the RUNNING state in the area specified by parameter p_tskid Note This service call stores TSK_NONE in the area specified by parameter p_tskid if no tasks that have entered the RUNNING state exist all tasks in the IDLE state Return value Macro Value Description E OK 0 Normal completion Context error E CTX 25 This service call was issued in the CPU locked state R20UT2889EJ0101 Rev 1 01 7tENESAS Page 291 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 16 SERVICE CALLS loc_cpu illoc_cpu Outline Lock the CPU C format ER loc_cpu void ER iloc_cpu void Parameter s None Explanation These service calls change the system status type to the CPU locked state As a result El level maskable interrupt acceptance and service call issue except for some service calls are prohibited during the interval from when this service call is issued until unl_cpu or iunl_cpu is issued Service Call Function loc_cpu iloc_cpu Lock the CPU unl_c
91. 15 RI850V4 V2 APPENDIX A WINDOW REFERENCE Generate method Select the branch method when a base clock timer interrupt defined in the Basic information or an El level maskable interrupt defined in the Interrupt handler information occurs Default Direct vector How to change Select from the drop down list Restriction TAD e Generates an entry file for the table reference reference 3 method intbp Generates an entry file for the direct P rect vector Vector method Base address of the interrupt handler address table Specifies the base address of the interrupt handler address table This item is not displayed when Direct vector is selected in Generate method Default 0x0 How to change Enter directly in the text box Restriction 0x0 Oxffffffff Specify the exception handler vector address Exception handler vector address Select whether to specify the exception handler vector address Default No How to change Select from the drop down list Restriction Specify the exception handler vector address This item is not displayed when No is selected in Specify the exception handler vector address Yes Specifies the exception handler vector ebase address No Does not specify the exception handler vector address Default 0x0 How to change Enter directly in the text box Restr
92. 193 Prince Edward Road West Mongkok Kowloon Hong Kong Tel 852 2265 6688 Fax 852 2886 9022 Renesas Electronics Taiwan Co Ltd 13F No 363 Fu Shing North Road Taipei 10543 Taiwan Tel 886 2 8175 9600 Fax 886 2 8175 9670 Renesas Electronics Singapore Pte Ltd 80 Bendemeer Road Unit 06 02 Hyflux Innovation Centre Singapore 339949 Tel 65 6213 0200 Fax 65 6213 0300 Renesas Electronics Malaysia Sdn Bhd Unit 1207 Block B Menara Amcorp Amcorp Trade Centre No 18 Jin Persiaran Barat 46050 Petaling Jaya Selangor Darul Ehsan Malaysia Tel 60 3 7955 9390 Fax 60 3 7955 9510 Renesas Electronics India Pvt Ltd No 777C 100 Feet Road HALII Stage Indiranagar Bangalore India Tel 91 80 67208700 Fax 91 80 67208777 Renesas Electronics Korea Co Ltd 12F 234 Teheran ro Gangnam Gu Seoul 135 080 Korea Tel 82 2 558 3737 Fax 82 2 558 5141 2015 Renesas Electronics Corporation All rights reserved Colophon 4 0 RI850V4 V2 tENESAS Renesas Electronics Corporation R20UT2889EJ0101
93. 4 1 align4 1 KERNEL_CONST 224 8 MEM AREA num 24 CRE_TSK_num 8 CRE_SEM_ num 8 CRE_FLG_num 8 CRE_DTQ_num 4 CRE_MBX_num DEF_INH_num DEF_SVC_num _INI_num _IDL_num VA align4 maxint TA_ACT_num TA_STA_num align4 2 CRE _MTX_num 12 CRE_MPF_num 12 CRE_MPL_num 20 CRE_CYC_num Note The keyword in the expression means as follows Keywords Meaning MEM _AREA_ num The number of the definition of the Memory area information CRE_TSK_num The number of the definition of the Task information CRE_SE num The number of the definition of the Semaphore information CRE_FLG_num The number of the definition of the Eventflag information CRE_DTQ_num The number of the definition of the Data queue information CRE_MBX_num The number of the definition of the Mailbox information CRE X_num The number of the definition of the Mutex information CRE_MPF_num The number of the definition of the Fixed sized memory pool information CRE_MPL_num The number of the definition of the Variable sized memory pool information CRE_CYC_num The number of the definition of the Cyclic handler information DEF_INH_num The number of the definition of the Interrupt handler information DEF_SVC_num The number o
94. 4 V2 CHAPTER 2 SYSTEM CONSTRUCTION When using the RI850V4 some options should always be specified For details see 15 4 Conditional Compile Macro Note See CS Integrated Development Environment User s Manual RH850 Build for details about setting build options 8 Runa build Run a build to create a load module Note See CS Integrated Development Environment User s Manual RH850 Build for details about running a build Figure 2 5 Project Tree Panel After Running Build Project Tree o 3 o RH850 Fil RI850V4RH Project R7F701007xAFP Microcontroller A CC RH Build Tool AI RI850V4 Realtime OS RH850 E1 LPD Debug Tool 6 0 File a g Build tool generated files peee aam usr_stkovr s ET sysco EE Realtime OS generated files h kernel_id h d Realtime OS related file ied trcinf c 9 Save the project Save the setting information of the project to the project file Note See CS Integrated Development Environment User s Manual Project Operation for details about saving the project R20UT2889EJ0101 Rev 1 01 Sep 30 2015 7tENESAS Page 19 of 366 RI850V4 V2 CHAPTER 2 SYSTEM CONSTRUCTION 2 7 Option Settings for Build When using the RI850V4 the following options should always be specified for user applications In addition the options listed in 15 4 Conditional Compile Macro should also be specified when using the hea
95. 4 V2 CHAPTER 8 SYSTEM STATE MANAGEMENT FUNCTIONS 8 3 Forced Scheduler Activation The scheduler can be forcibly activated by issuing the following service call from the processing program vsta_sch This service call explicitly forces the RI850V4 scheduler to activate If a scheduling request has been kept pending task switching may therefore occur The following describes an example for coding this service call include lt kernel h gt Standard header file definition include lt kernel_id h gt System information header file definition void task VP_INT exinf veta_sch Forced scheduler Note The RI850V4 provides this service call as a function to activate a scheduler from a task for which preempt acknowledge status TA_DISPREEMPT disable is defined during configuration R20UT2889EJ0101 Rev 1 01 ztENESAS Page 109 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 8 SYSTEM STATE MANAGEMENT FUNCTIONS 8 4 Reference Task ID in the RUNNING State A RUNNING state task is referenced by issuing the following service call from the processing program get_tid iget_tid These service calls store the ID of a task in the RUNNING state in the area specified by parameter p_tskid The following describes an example for coding this service call include lt kernel h gt Standard header file definition include lt kernel_id h gt System information header file definition void inthdr void ID p_tsk
96. 5 RI850V4 V2 CHAPTER 3 TASK MANAGEMENT FUNCTIONS 3 2 3 Basic form of tasks When coding a task use a void function with one VP_INT argument any function name is fine The extended information specified with Task information or the start code specified when sta_tsk or ista_tsk is issued is set for the exinf argument The following shows the basic form of tasks in C include lt kernel h gt include lt kernel_id h gt System information header file definition void task VP_INT exinf Standard header file definition Terminate invoking task Note 1 Note 2 Note 3 If a task moves from the DORMANT state to the READY state by issuing sta_tsk or ista_tsk the start code specified when issuing sta_tsk or ista_tsk is set to the exinf argument When the return instruction is issued in a task the same processing as ext_tsk is performed For details about the extended information refer to 3 4 Activate Task R20UT2889EJ0101 Rev 1 01 2tENESAS Page 24 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 3 TASK MANAGEMENT FUNCTIONS 3 2 4 Internal processing of task In the RI850V4 original dispatch processing task scheduling is executed during task switching Therefore note the following points when coding tasks Coding method Code tasks using C or assembly language When coding in C they can be coded in the same manner as ordinary functions coded When coding in assembly language code them a
97. 5 2 8 Mutex state packet 163 15 2 9 Fixed sized memory pool state packet 164 15 2 10 Variable sized memory pool state packet 165 15 2 11 System time packet 166 15 2 12 Cyclic handler state packet 167 15 3 Data Macros 168 15 3 1 Current state 168 15 3 2 Processing program attributes 169 15 3 3 Management object attributes 169 15 3 4 Service call operating modes 170 15 3 5 Return value 170 15 3 6 Kernel configuration constants 171 15 4 Conditional Compile Macro 172 CHAPTER 16 SERVICE CALLS 173 16 1 Outline 173 16 1 1 Call service call 174 16 2 Explanation of Service Call 175 16 2 1 Task management functions 178 16 2 2 Task dependent synchronization functions 192 16 2 3 Synchronization and communication functions semaphores 205 16 2 4 Synchronization and communication functions eventflags 214 16 2 5 Synchronization and communication functions data queues 225 16 2 6 Synchronization and communication functions mailboxes 239 16 2 7 Extended synchronization and communication functions mutexes 249 16 2 8 Memory pool management functions fixed sized memory pools 258 16 2 9 Memory pool management functions variable sized memory pools 269 16 2 10 Time management functions 280 16 2 11 System state management functions 288 16 2 12 Service call management functions 301 CHAPTER 17 SYSTEM CONFIGURATION FIL
98. 50V4 the method of creating a mutex is limited to static creation Mutexes therefore cannot be created dynamically using a method such as issuing a service call from a processing program Static mutex creation means defining of mutexes using static API CRE_MTX in the system configuration file For details about the static API CRE_MTX refer to 17 5 6 Mutex information R20UT2889EJ0101 Rev 1 01 2tENESAS Page 83 of 366 Sep 30 2015 CHAPTER 6 EXTENDED SYNCHRONIZATION AND RI850V4 V2 COMMUNICATION FUNCTIONS 6 2 3 Lock mutex Mutexes can be locked by issuing the following service call from the processing program loc_mtx This service call locks the mutex specified by parameter mtxid If the target mutex could not be locked another task has been locked when this service call is issued this service call queues the invoking task to the target mutex wait queue and moves it from the RUNNING state to the WAITING state mutex wait state The WAITING state for a mutex is cancelled in the following cases and then moved to the READY state WAITING State for a Mutex Cancel Operation Return Value The locked state of the target mutex was cancelled as a result of issuing unl_mtx E OK The locked state of the target mutex was cancelled as a result of issuing ext_tsk E OK The locked state of the target mutex was cancelled as a result of issuing ter_tsk E OK Forced release from waiting accept rel_wai while waiting E R
99. 850V4 V2 CHAPTER 16 SERVICE CALLS Return value Macro Value Description E OK 0 Normal completion Parameter error E_ PAR 17 tskpri lt 0x0 tskpri gt Maximum priority Invalid ID number tskid lt 0x0 E_ID 18 tskid gt Maximum ID number When this service call was issued from a non task TSK_SELF was specified tskid Context error E_CTX 25 This service call was issued int the CPU locked state Object state error E_OBJ 41 Specified task is in the DORMANT state Non existent object E_NOEXS 42 Specified task is not registered R20UT2889EJ0101 Rev 1 01 tENESAS Page 186 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 16 SERVICE CALLS get_pri iget_pri Outline Reference task priority C format ER get_pri ID tskid PRI p_tskpri ER iget_pri ID tskid PRI p_tskpri Parameter s V O Parameter Description ID number of the task to reference ID tskid TSK_SELF Invoking task Value ID number of the task to reference O PRI p_tskpri Current priority of specified task Explanation Stores current priority of the task specified by parameter tskid in the area specified by parameter p_tskpri Return value Macro Value Description E OK 0 Normal completion Invalid ID number tskid lt 0x0 E_ID 18 tskid gt Maximum ID number When this service call was issued from a
100. 89EJ0101 Rev 1 01 7tENESAS Page 105 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 7 MEMORY POOL MANAGEMENT FUNCTIONS 7 4 4 Reference variable sized memory pool state A variable sized memory pool status is referenced by issuing the following service call from the processing program ref_mpl iref_mpl These service calls store the detailed information ID number of the task at the head of the wait queue total size of free memory blocks etc of the variable size memory pool specified by parameter mplid into the area specified by parameter pk_rmpl The following describes an example for coding this service call include include T_RMPL ref_mpl wtskid fmplsz fblksz mplatr lt kernel h gt lt kernel_id h gt void task VP_INT exinf mplid ID_MPL1 pk_rmpl wt skid fmplsz fblksz mplatr mplid amp pk_rmpl pk_rmpl wtskid pk_rmpl fmplsz pk_rmpl fblksz pk_rmpl mplatr Standard header file definition System information header file definition Declares Declares Declares Declares Declares Declares Reference variable sized memory pool state Reference ID number of the task at the and initializes variable data structure variable variable variable variable head of the wait queue Reference total size of free memory blocks Reference maximum memory block size Reference attribute Note For
101. 9 2 System Time The system time is a time used by the RI850V4 for performing time management unit millisecond After initialization by the Kernel Initialization Module the system time is updated based on the Base clock interval tim_base when an El level maskable interrupt defined in the Base clock timer exception code tim_intno in the system configuration file occurs 9 2 1 Base clock timer interrupt To realize the time management function the RI850V4 uses interrupts that occur at constant intervals base clock timer interrupts When a base clock timer interrupt occurs processing related to the RI850V4 time system time update task timeout delay cyclic handler activation etc is executed A base clock timer interrupt is caused by an El level maskable interrupt defined in the Base clock timer exception code tim_intno in the system configuration file For details about the basic information CLK_INTNO refer to 17 4 2 Basic information The RI850V4 does not initialize hardware to generate base clock timer interrupts so it must be coded by the user Initialize the hardware used by Boot processing or Initialization routine and cancel the interrupt masking The following shows the necessary settings when using the OS timer as the base clock timer OS Timer Setting Registers Necessary Setting OSTMn control register OSTMnCTL OSTMnCTL OSTMnMD1 0 OSTMn compare register OSTMnCMP OSTMnCMP TIC_NUME 1000000 KERNEL_US
102. ACS CC CC RH V1 00 00 bin A I1 A C tmp inc850 A IA C Program Files Sample include A ebase 0x200 A sys cfg Enter 2 CF850V4 version information is output to the standard output C gt cf850v4 A V Enter 3 Information related to the CF850V4 activation option type usage or the like is output to the standard output C gt cf850v4 A help Enter R20UT2889EJ0101 Rev 1 01 7tENESAS Page 335 of 366 Sep 30 2015 RI850V4 V2 APPENDIX A WINDOW REFERENCE APPENDIX A WINDOW REFERENCE This appendix explains the window panels that are used when the activation option for the CF850V4 is specified from the integrated development environment platform CS A 1 Description The following shows the list of window panels Table A 1 List of Window Panels Window Panel Name Function Description This is the first window to be opened when CS is launched Main window This window is used to manipulate the CS components such as the build tool and resource information tool This panel is used to display the project components such as the Proj ct Tree panel microcontroller and build tool in tree view This panel is used to display information regarding the node selected on Property panel the Project Tree panel and change the settings of the information R20UT2889EJ0101 Rev 1 01 ztENESAS Page 336 of 366 Sep 30 2015 RI850V4 V2 APPENDIX A WINDOW REFERENCE Outl
103. AI Note Return value Invoking tasks are queued to the target semaphore wait queue in the order defined during configuration FIFO order or priority order Macro Value Description E OK 0 Normal completion Invalid ID number E ID 18 semid lt 0x0 semid gt Maximum ID number R20UT2889EJ0101 Rev 1 01 2tENESAS Page 206 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 16 SERVICE CALLS Macro Value Description Context error E CTX 25 This service call was issued from a non task This service call was issued in the CPU locked state This service call was issued in the dispatching disabled state Non existent object E NOEXS 42 Specified semaphore is not registered Forced release from the WAITING state E RLWAI 49 Accept rel_wai irel_wai while waiting R20UT2889EJ0101 Rev 1 01 Sep 30 2015 ztENESAS Page 207 of 366 RI850V4 V2 CHAPTER 16 SERVICE CALLS pol_sem ipol_sem Outline Acquire semaphore resource polling C format ER pol_sem ID semid ER isem_sem ID semid Parameter s 1 0 Parameter Description l ID semid ID number of the semaphore from which resource is acquired Explanation This service call acquires a resource from the semaphore specified by parameter semid subtracts 0x1 from the semaphore counter If a resource could not be acquired from the target semaphore semaphore c
104. AR 17 tmout lt TMO_FEVR Invalid ID number E_ ID 18 mbxid lt 0x0 mbxid gt Maximum ID number Context error E CTX 25 This service call was issued from a non task This service call was issued in the CPU locked state This service call was issued in the dispatching disabled state Non existent object E_NOEXS 42 Specified mailbox is not registered Forced release from the WAITING state E_RLWAI 49 Accept rel_wai irel_wai while waiting Timeout E_TMOUT 50 Polling failure or timeout R20UT2889EJ0101 Rev 1 01 Sep 30 2015 2tENESAS Page 247 of 366 RI850V4 V2 CHAPTER 16 SERVICE CALLS ref_mbx iref_mbx Outline Reference mailbox state C format ER ref_mbx ID mbxid T_RMBX pk_rmbx ER iref_mbx ID mbxid T_RMBX pk_rmbx Parameter s 0 Parameter Description l ID mbxid ID number of the mailbox to be referenced O T_RMBX pk_rmbx Pointer to the packet returning the mailbox state Mailbox state packet T_RMBX typedef struct t_rmbx ID wtskid Existence of waiting task T_MSG pk_msg Existence of waiting message ATR mbxatr Attribute T_RMBX Explanation Stores mailbox state packet ID number of the task at the head of the wait queue start address of the message packet at the head of the wait queue of the mailbox specified by parameter mbxid in the area specified by parameter pk_rmbx Note For details about the mailbox
105. Definition of mutex state packet T_RMTX is performed by the header file lt ri_root gt include os packet h which is called from the standard header file lt ri_root gt include kernel h typedef struct t_rmtx ID htskid Existence of locked mutex ID wtskid Existence of waiting task ATR mtxatr Attribute PRI ceilpri Reserved for future use T_RMTX The following shows details on mutex state packet T_RMTX htskid Stores whether a task that is locking a mutex exists TSK_NONE No applicable task Value ID number of the task locking the mutex wiskid Stores whether a task is queued to the mutex wait queue TSK_NONE No applicable task Value ID number of the task at the head of the wait queue mixatr Stores the attribute queuing method Task queuing method bit 0 to 1 TA_TFIFO Task wait queue is in FIFO order TA_TPRI Task wait queue is in task priority order Structure of mtxatr 15 0 t TA_TFIFO 0 TA_TPRI 1 ceilpri System reserved area R20UT2889EJ0101 Rev 1 01 7tENESAS Page 163 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 15 DATA TYPES AND MACROS 15 2 9 Fixed sized memory pool state packet The following shows fixed sized memory pool state packet T_RMPF used when issuing ref_mpf or iref_mpf Definition of fixed sized memory pool state packet T_RMPF is performed by the header file lt ri_root gt include os packet h which is called from the standard
106. Disable dispatching Task ena_dsp Enable dispatching Task sns_dsp Reference dispatching state leg PORE teor INI Eaton rou Task Non task Initialization rou sns_ctx Reference contexts tine sns_dpn Reference dispatching pending state bas NO tater Miiaizanon AU R20UT2889EJ0101 Rev 1 01 tENESAS Page 288 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 16 SERVICE CALLS Outline Rotate task precedence C format ER rot_rdq PRI tskpri ER irot_rdq PRI tskpri j Parameter s V O Parameter Description Priority of the tasks whose precedence is rotated PRI tskpri TPRI_SELF Current priority of the invoking task Value Priority of the tasks whose precedence is rotated Explanation This service call re queues the first task of the ready queue corresponding to the priority specified by parameter tskpri to the end of the queue to change the task execution order explicitly Note 1 This service call does not perform queuing of rotation requests If no task is queued to the ready queue corresponding to the relevant priority therefore no processing is performed but it is not handled as an error Note 2 Round robin scheduling can be implemented by issuing this service call via a cyclic handler in a constant cycle Note 3 The ready queue is a hash table that uses priority as the key and tasks that have entered an executable state READY state or RUNNING state are queued in FIFO order Therefore the scheduler
107. E 17 5 7 Fixed sized memory pool information The fixed sized memory pool information defines ID number mpfid Attribute mpfatr Block count blkcnt Basic block size blksz memory area name sec_nam Reserved for future use mpf for a fixed sized memory pool The The number of items that can be defined as fixed sized memory pool information is limited to one for each ID number following shows the fixed sized memory pool information format CRI BE MPF mpfid mpfatr blkcnt blksz sec_nam mpf The 1 items constituting the fixed sized memory pool information are as follows ID number mpfid Specifies the ID number for a fixed sized memory pool A value from 0x1 to Oxff or a name can be specified for mpfid Note When a name is specified the CF850V4 automatically assigns an ID number The CF850V4 outputs the relationship between a name and an ID number to the system information header file in the following format define mpfid value Attribute mpfatr Specifies the task queuing method for a fixed sized memory pool The keyword that can be specified for mpfatris TA_TFIFO or TA_TPRI TA_TFIFO Task wait queue is in FIFO order TA_TPRI Task wait queue is in task priority order Block count blkent Specifies the block count for a fixed sized memory pool A value from 0x1 to 0x7fff can be specified for b kent Basic block size b ksz memory area name sec_nam Specifies the size pe
108. E 303 17 1 17 2 17 3 17 4 Outline 303 Configuration Information 305 17 2 1 Cautions 306 Declarative Information 307 17 3 1 Header file declaration 307 System Information 308 17 4 1 Rl series information 308 17 4 2 Basic information 309 17 4 3 FPSR register information 311 17 4 4 Memory area information 312 17 5 Static API Information 313 17 5 1 Task information 313 17 5 2 Semaphore information 315 17 5 3 Eventflag information 316 17 5 4 Data queue information 317 17 5 5 Mailbox information 318 17 5 6 Mutex information 319 17 5 7 Fixed sized memory pool information 320 17 5 8 Variable sized memory pool information 321 17 5 9 Cyclic handler information 322 17 5 10 Interrupt handler information 324 17 5 11 Extended service call routine information 325 17 5 12 Initialization routine information 326 17 5 13 Idle routine information 327 17 6 Description Examples 328 CHAPTER 18 CONFIGURATOR CF850V4 329 18 1 Outline 329 18 2 Activation Method 330 18 2 1 Activating from command line 330 18 2 2 Activating from CS 333 18 2 3 Command file 334 18 2 4 Command input examples 335 APPENDIX A WINDOW REFERENCE 336 A 1 Description 336 APPENDIX B SIZE OF MEMORY 353 B 1 Description 353 B 1 1 kernel_system 353 B 1 2 kernel_const 355 B 1 3 kernel_data 356 B 1 4 kernel_
109. EJ0101 Rev 1 01 Sep 30 2015 state Receiving WAITING State for a Data Queue Cancel Operation Return Value Data was written to the data queue area of the target data queue as a result of issuing snd_dtq EOK Data was written to the data queue area of the target data queue as a result of issuing E OK psnd_dtq E Data was written to the data queue area of the target data queue as a result of issuing E OK ipsnd_dtq z Data was written to the data queue area of the target data queue as a result of issuing E OK tsnd_dtq _ Data was written to the data queue area of the target data queue as a result of issuing E OK fsnd_dtq Data was written to the data queue area of the target data queue as a result of issuing E OK ifsnd_dtq Forced release from waiting accept rel_wai while waiting E RLWAI Forced release from waiting accept irel_ wai while waiting E RLWAI The following describes an example for coding this service call include lt kernel h gt include lt kernel_id h gt void task VP_INT exinf Declares variable ER ercd ID dtqid ID_DTQ1 VP_INT p data Declares variable ercd rcv_dtq dtqid amp p data lse if ercd E_RLWAI Stance EEEE Normal termination processing E E Forced termination processing Standard header file definition System information header file definition Declares and initializes variabl
110. EJ0101 Rev 1 01 7tENESAS Page 160 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 15 DATA TYPES AND MACROS 15 2 6 Message packet The following shows message packet T_MSG T_MSG_PRI used when issuing snd_mbx isnd_mbx rcv_mbx prcv_mbx iprcv_mbx or trcv_mbx Definition of message packet T_ MSG T_MSG_PRI is performed by the header file lt ri_root gt include os types h which is called from the standard header file lt ri_root gt include kernel h and the ITRON general definition header file lt ri_root gt include itron h Message packet for TA_MFIFO attribute typedef struct t_msg struct t_msg msgnext Reserved for future use T_MSG Message packet for TA_MPRI attribute typedef struct t_msg_pri struct t_msg msgque Reserved for future use PRI msgpri Message priority T_MSG_PRI The following shows details on message packet T_RTSK T_MSG_PRI msgnext msgque System reserved area msgpri Stores the message priority Note 1 In the RI850V4 a message having a smaller priority number is given a higher priority Note 2 Values that can be specified as the message priority level are limited to the range defined in Mailbox information Maximum message priority maxmpri when the system configuration file is created R20UT2889EJ0101 Rev 1 01 ztENESAS Page 161 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 15 DATA TYPES AND MACROS 15 2 7 Mailbox state packet The following shows mailbox sta
111. ENDIX A WINDOW REFERENCE Task Analyzer tab Outline This page is used to display and change the settings of various information required when using the task analyzer tool which is a utility tool provided by the RI850V4 to analyze the history trace data of processing program execution This tab can be opened as follows On the Project Tree panel select a component such as the Realtime OS node or the system configuration file and then select the View menu gt Property or select Property from the context menu Note When the Property panel is already open selecting a component such as the Realtime OS node or the system configuration file on the Project Tree panel displays the detailed information regarding the selected component Display image Property X 4 RIB50W4 Property 4 Trace So ey soe Takes in trace chart by hardware trace mode Selection of trace mode Selects the buffer holding trace and information to acquire by trace Hardware trace mode Hold the trace to debugging tool with trace memory Software trace mode Hold the trace to target RAM If this mode is selected the monitor control taking trace is linked automatically Tee chart Take in the trace chart and the CPU usage rate The analyzable time is short Long statistics Take in the GPU usage rate Not take in the trace chart The analyzable time is long It can use only by software trace mode RI850V4 Task Analyzer Explan
112. ERVICE CALL MANAGEMENT FUNCTIONS 137 11 1 Outline 137 11 2 Extended Service Call Routines 137 11 2 1 Basic form extended service call routines 137 11 2 2 Internal processing of extended service call routine 138 11 3 Define Extended Service Call Routine 138 11 4 Invoke Extended Service Call Routine 139 CHAPTER 12 SYSTEM CONFIGURATION MANAGEMENT FUNCTIONS 140 12 1 Outline 140 12 2 User Own Coding Module 140 12 2 1 Initialization routine 140 12 2 2 Define initialization routine 141 CHAPTER 13 SCHEDULER 142 13 1 Outline 142 13 1 1 Drive Method 142 13 1 2 Scheduling Method 142 13 1 3 Ready queue 143 13 1 4 Scheduling Lock Function 143 13 2 User Own Coding Module 145 13 2 1 Idle Routine 145 13 2 2 Define Idle Routine 146 13 3 Scheduling in Non Tasks 146 CHAPTER 14 SYSTEM INITIALIZATION ROUTINE 147 14 1 Outline 147 14 2 User Own Coding Module 148 14 2 1 Boot processing 148 14 2 2 System dependent information 150 14 3 Kernel Initialization Module 152 CHAPTER 15 DATA TYPES AND MACROS 153 15 1 Data Types 153 15 2 Packet Formats 155 15 2 1 Task state packet 155 15 2 2 Task state packet simplified version 157 15 2 3 Semaphore state packet 158 15 2 4 Eventflag state packet 159 15 2 5 Data queue state packet 160 15 2 6 Message packet 161 15 2 7 Mailbox state packet 162 1
113. FN fncd VP_INT pari VP_INT par2 VP_INT par3 ER_UINT ical_sve FN fncd VP_INT pari VP_INT par2 VP_INT par3 Parameter s 0 Parameter Description l FN fncd Function code of the extended service call routine to be invoked VP_INT parl The first parameter of the extended service call routine l VP_INT par2 The second parameter of the extended service call routine l VP_INT par3 The third parameter of the extended service call routine Explanation These service calls call the extended service call routine specified by parameter fncd Note Extended service call routines that can be called using this service call are the routines whose transferred data total is less than four Return value Macro Value Description Invalid function code lt E_RSFN 10 i fncd gt Oxff Specified extended service call routine is not registered E Normal completion the extended service call routine s return value R20UT2889EJ0101 Rev 1 01 tENESAS Page 302 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 17 SYSTEM CONFIGURATION FILE CHAPTER 17 SYSTEM CONFIGURATION FILE This chapter explains the coding method of the system configuration file required to output information files system information table file system information header file and entry file that contain data to be provided for the RI850V4 17 1 Outline The following shows the notation method of syste
114. File category File name This property is not displayed when No lt does not register the file that is added to the project ni in the Generate a file property is selected Default sit s How to change Directly enter to the text box Restriction Up to 259 characters R20UT2889EJ0101 Rev 1 01 2tENESAS Page 349 of 366 Sep 30 2015 RI850V4 V2 APPENDIX A WINDOW REFERENCE 2 System Information Header File The detailed information on the system information header file are displayed and the configuration can be changed Select whether to generate a system information header file and whether to update the file when the system configuration file is changed Default Yes It updates the file when the cfg file is changed d How to change Select from the drop down list Generates a system information header file and displays it on the project tree If the system configuration file is changed when there is already a system information header file then the system information header file is Yes It updates the file when the cfg file is changed d Generate a file updated Does not update the system Restriction Yes It does not information header file when the update the file when system configuration file is changed the cfg file is An error occurs during build if this changed nd item is selected when the system information header file does not exist Does not gener
115. How to Use This Manual This manual is intended for users who design and develop application systems using RH850 family products This manual is intended for users to understand the functions of real time OS RI850V4 manufactured by Renesas Electronics described the organization listed below This manual can be broadly divided into the following units CHAPTER 1 CHAPTER 2 CHAPTER 3 CHAPTER 4 CHAPTER 5 CHAPTER 6 FUNCTIONS CHAPTER 7 CHAPTER 8 CHAPTER 9 CHAPTER 10 CHAPTER 11 CHAPTER 12 CHAPTER 13 CHAPTER 14 CHAPTER 15 CHAPTER 16 CHAPTER 17 CHAPTER 18 APPENDIX A APPENDIX B APPENDIX C OVERVIEW SYSTEM CONSTRUCTION TASK MANAGEMENT FUNCTIONS TASK DEPENDENT SYNCHRONIZATION FUNCTIONS SYNCHRONIZATION AND COMMUNICATION FUNCTIONS EXTENDED SYNCHRONIZATION AND COMMUNICATION MEMORY POOL MANAGEMENT FUNCTIONS SYSTEM STATE MANAGEMENT FUNCTIONS TIME MANAGEMENT FUNCTIONS INTERRUPT MANAGEMENT FUNCTIONS SERVICE CALL MANAGEMENT FUNCTIONS SYSTEM CONFIGURATION MANAGEMENT FUNCTIONS SCHEDULER SYSTEM INITIALIZATION ROUTINE DATA TYPES AND MACROS SERVICE CALLS SYSTEM CONFIGURATION FILE CONFIGURATOR CF850V4 WINDOW REFERENCE SIZE OF MEMORY SUPPORT FOR FLOATING POINT OPERATION COPROCESSOR It is assumed that the readers of this manual have general knowledge in the fields of electrical engineering logic circuits microcontrollers C language and assemblers To understand the hardware functions of the RH850 family gt Refer to
116. ING state for a data queue TTW_MBx Receiving WAITING state for a mailbox TTW_MTX WAITING state for a mutex TTW_MPF WAITING state for a fixed sized memory block TTW_MPL WAITING state for a variable sized memory block R20UT2889EJ0101 Rev 1 01 tENESAS Page 155 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 15 DATA TYPES AND MACROS wobjid Stores the object ID number for which the task waiting When the task is not in the WAITING state 0 is stored lefttmo Stores the remaining time until timeout unit millisecond actcnt Stores the activation request count wupcnt Stores the wakeup request count suscnt Stores the suspension count tskatr Stores the attribute coding language initial activation state etc Coding language bit 0 TA_HLNG Start a task through a C language interface TA_ASM Start a task through an assembly language interface Initial activation state bit 1 TA_ACT Task is activated after the creation Initial preemption state bit 14 TA_DISPREEMPT Preemption is disabled at task activation Initial interrupt state bit 15 TA_ENAINT Acceptance of El level maskable interrupts from the Maximum interrupt priority maxintpri to the minimum interrupt priority is enabled TA_DISINT Acceptance of El level maskable interrupts from the Maximum interrupt priority maxintpri to the minimum interrupt priority is disabled Structure of tskatr 15 14 1 0 t
117. INT exinf ercd mpfid 1 p blk Standard header file definition System information header file definition Declares variable Declares and initializes variable Declares variable Acquire fixed sized memory block polling ercd pget_mpf mpfid amp p_ blk if ercd E_OK ARTERE TE Polling success processing rel_mpf mpfid p blk Release fixed sized memory block lse if ercd E_TMOUT 3 soi Gordan Polling failure processing Note 1 The RI850V4 does not perform memory clear processing when getting the acquired fixed size memory block The contents of the got fixed size memory block are therefore undefined Note 2 If no fixed size memory blocks could be acquired from the target fixed size memory pool no available fixed size memory blocks exist when this service call is issued the contents in the area specified by parameter p_blk become undefined R20UT2889EJ0101 Rev 1 01 Sep 30 2015 2tENESAS Page 94 of 366 RI850V4 V2 CHAPTER 7 MEMORY POOL MANAGEMENT FUNCTIONS tget_mpf This service call acquires the fixed sized memory block from the fixed sized memory pool specified by parameter mpfid and stores the start address in the area specified by parameter p_bik If no fixed size memory blocks could be acquired from the target fixed size memory pool no available fixed size memory blocks exist when this service call is issued this servi
118. K_total DTQ total t MPF_total t MPL total Note The keyword in the expression means as follows Keywords Meaning SYSSTK The value calculated by System stack TSKSTK_total Total amount of the stack size that specified in Task stack for each task DTQ_total Total amount of the memory size that specified in Data queue for each data queue Total amount of the memory size that specified in Fixed sized memory pool for MPF_total each fixed sized memory pool MPL total Total amount of the memory size that specified in Variable sized memory pool for each variable sized memory pool 1 System stack The size of the system stack depends on the details of the Task information and the process of task The following shows an expression required for estimation the system stack size required by the RI850V4 In the following expression max a b c means the result of selecting the largest value from a b and c for example max 1 2 3 is 3 SYSSTK max align4 INT align4 CYC align4 INI align4 IDL Note The keyword in the expression means as follows Keywords Meaning The stack size of the interrupt handler using If the interrupt handler processes INT are nested considers the nest counts If the interrupt handler is undefined the stack size of the interrupt handler is nothing The stack size of the cyc
119. LS Macro Value Description Context error E CTX 25 This service call was issued from a non task This service call was issued in the CPU locked state This service call was issued in the dispatching disabled state Illegal service call use E_ILUSE 28 Multiple locking of a mutex Non existent object E_NOEXS 42 Specified mutex is not registered Forced release from the WAITING state E_RLWAI 49 Accept rel_wai irel_wai while waiting R20UT2889EJ0101 Rev 1 01 tENESAS Page 251 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 16 SERVICE CALLS Outline Lock mutex polling C format ER ploc_mtx ID mtxid j Parameter s 1 0 Parameter Description l ID mtxid ID number of the mutex to be locked Explanation This service call locks the mutex specified by parameter mtxid If the target mutex could not be locked another task has been locked when this service call is issued but E_TMOUT is returned Note In the RI850V4 E_ILUSE is returned if this service call is re issued for the mutex that has been locked by the invoking task multiple locking of mutex Return value Macro Value Description E OK 0 Normal completion Invalid ID number E ID 18 mtxid lt 0x0 mtxid gt Maximum ID number Context error E_CTX 25 This service call was issued from a non task This service call was issued in the CPU locked state Ille
120. LWAI Forced release from waiting accept irel_wai while waiting E RLWAI The following describes an example for coding this service call include lt kernel h gt Standard header file definition include lt kernel_id h gt System information header file definition void task VP_INT exinf ER ercd Declares variable ID mtxid ID_MTX1 Declares and initializes variable ercd loc_mtx mtxid j Lock mutex waiting forever if ercd E_OK EEE Locked state unl_mtx mtxid Unlock mutex else if ercd E_RLWAI SE TNE Forced termination processing Note 1 Invoking tasks are queued to the target mutex wait queue in the order defined during configuration FIFO order or priority order Note 2 In the RI850V4 E_ILUSE is returned if this service call is re issued for the mutex that has been locked by the invoking task multiple locking of mutex R20UT2889EJ0101 Rev 1 01 2tENESAS Page 84 of 366 Sep 30 2015 CHAPTER 6 EXTENDED SYNCHRONIZATION AND RI850V4 V2 COMMUNICATION FUNCTIONS ploc_mtx This service call locks the mutex specified by parameter mtxid If the target mutex could not be locked another task has been locked when this service call is issued but E_TMOUT is returned The following describes an example for coding this service call include lt kernel h gt Standard header file definition include lt kernel_id h gt Sy
121. L_USR_BASETIME 250 time for one count 4MHz gt 250ns The following is a list of information that should be defined as system dependent information Definition of the system information header file Include the system information header file output as a result of execution of the configurator for the system configu ration file Note This information is necessary only when Taking in long statistics by software trace mode is selected in the Property panel gt Task Analyzer tabbed page gt Trace category gt Selection of trace mode Basic clock timer information Define as macros the I O address register base address 0x4 for the counter register OSTMn and the time in nanoseconds for one count in the OS timer calculated according to the frequency of the OS timer operation R20UT2889EJ0101 Rev 1 01 7tENESAS Page 150 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 14 SYSTEM INITIALIZATION ROUTINE Note This information is necessary only when Taking in trace chart by software trace mode or Taking in long statistics by software trace mode is selected in the Property panel gt Task Analyzer tabbed page gt Trace category gt Selection of trace mode R20UT2889EJ0101 Rev 1 01 ztENESAS Page 151 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 14 SYSTEM INITIALIZATION ROUTINE 14 3 Kernel Initialization Module The kernel initialization module is a dedicated initialization
122. OK Forced release from waiting accept rel_wai while waiting E RLWAI Forced release from waiting accept irel_ wai while waiting E RLWAI Polling failure or timeout E TMOUT Note 1 Invoking tasks are queued to the target mutex wait queue in the order defined during configuration FIFO order or priority order Note 2 In the RI850V4 E_ILUSE is returned if this service call is re issued for the mutex that has been locked by the invoking task multiple locking of mutex Note 3 TMO_FEVR is specified for wait time tmout processing equivalent to loc_mtx will be executed When TMO_POL is specified processing equivalent to ploc_mtx will be executed R20UT2889EJ0101 Rev 1 01 2tENESAS Page 253 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 16 SERVICE CALLS Return value Macro Value Description E OK 0 Normal completion Parameter error E PAR 17 tmout lt TMO_FEVR Invalid ID number EID 18 mtxid lt 0x0 mtxid gt Maximum ID number Context error E CTX 25 This service call was issued from a non task This service call was issued in the CPU locked state This service call was issued in the dispatching disabled state lllegal service call use E_ILUSE 28 Multiple locking of a mutex Non existent object E_NOEXS 42 Specified mutex is not registered Forced release from the WAITING state E_RLWAI 49 Accept rel_wai irel_wai while waiting Timeout E_TMOU
123. ON APPENDIX C SUPPORT FOR FLOATING POINT OPERATION COPROCESSOR The RI850V4 supports the floating point operation coprocessor of the RH850 The RI850V4 manipulates the floating point configuration status register FPSR for floating point operation The user can change the floating point operation settings from processing programs as needed by changing this register value The value of FPSR is essentially specified independently for each processing program and is not inherited between processing programs However the RI850V4 does not manipulate FPSR when an extended service call routine starts or ends For this reason an extended service call routine inherits the FPSR value from the previous processing executed before the extended service call routine and the value changed in a processing program is retained after the program ends See table Table C 1 for the register value when each processing program is initially activated Table C 1 Register Values at Activation of Each Processing Program Processing Program Initial FPSR Value Task User setting Cyclic handler User setting Interrupt handler User setting Extended service call routine Inherits the value before activation Idle routine User setting Note 1 If a task is suspended and then resumed the FPSR is restored to the value before the suspension Note 2 User setting for FPSR in the above table is the value specified as the FPSR register informatio
124. OS A task is the minimum unit in which a program can be executed by an OS Multi task is the name given to the mode of operation in which a single processor processes multiple tasks concurrently Actually the processor can handle no more than one program instruction at a time But by switching the processor s attention to individual tasks on a regular basis at a certain timing it appears that the tasks are being processed simultaneously A multi task OS enables the parallel processing of tasks by switching the tasks to be executed as determined by the system One important purpose of a multi task OS is to improve the throughput of the overall system through the parallel processing of multiple tasks 1 1 3 Support for RH850 multi core devices The RI850V4 supports build processing for multi core devices The target processor element PE where the RI850V4 is to be used can be specified and the RI850V4 can be used in multiple PEs at the same time The RI850V4 is a real time OS for a single core which is intended to operate in a single PE and it does not provide facilities for controlling the processing between PEs As a measure for implementing the control of the processing between PEs a library specialized for multi core devices can be used Renesas Electronics offers the libipcx library for communication and exclusive control between processor elements hereafter called libipcx which is a sample library supporting the RH850 multi
125. P 0x00 Non operational state TCYC_STA 0x01 Operational state TTW_SLP 0x0001 Sleeping state TTW_DLY 0x0002 Delayed state TTW_SEM 0x0004 WAITING state for a semaphore resource TTW_FLG 0x0008 WAITING state for an eventtflag TTW_SDTQ 0x0010 Sending WAITING state for a data queue TTW_RDTQ 0x0020 Receiving WAITING state for a data queue TTW_MBX 0x0040 Receiving WAITING state for a mailbox TTW_MTX 0x0080 WAITING state for a mutex TTW_MPF 0x2000 WAITING state for a fixed sized memory pool TTW_MPL 0x4000 WAITING state for a variable sized memory pool TSK_NONE 0 No applicable task R20UT2889EJ0101 Rev 1 01 7tENESAS Page 168 of 366 Sep 30 2015 RI850V4 V2 15 3 2 Processing program attributes CHAPTER 15 DATA TYPES AND MACROS The following lists the processing program attributes acquired by issuing service calls ref_tsk ref_cyc or the like Macro definition of attributes is performed by the header file lt ri_root gt include os option h which is called from the stan dard header file lt ri_root gt include kernel h and the ITRON general definition header file lt ri_root gt include itron h Table 15 3 Processing Program Attributes 15 3 3 Management object attributes Macro Value Description TA_HLNG 0x0000 Start a processing unit through a C language interface TA_ASM 0x0001 Start a processing unit through an assembly language interface TA_ACT 0x0002 Task is activated after the creation TA
126. R 8 SYSTEM STATE MANAGEMENT FUNCTIONS 8 12 Reference Dispatch Pending State The dispatch pending state is referenced by issuing the following service call from the processing program sns_dpn This service call acquires the system status type when this service call is issued whether in dispatch pending state or not When this service call is terminated normally the acquired system state type TRUE dispatch pending state FALSE dispatch not pending state is returned The following describes an example for coding this service call include lt kernel h gt Standard header file definition include lt kernel_id h gt System information header file definition void task VP_INT exinf BOOL ercd Declares variable ercd sns_dpn Reference dispatch pending state if ercd TRUE oeann i Dispatch pending state oee ae aaia Other state R20UT2889EJ0101 Rev 1 01 ztENESAS Page 122 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 9 TIME MANAGEMENT FUNCTIONS CHAPTER 9 TIME MANAGEMENT FUNCTIONS This chapter describes the time management functions performed by the RI850V4 9 1 Outline The RI850V4 s time management function provides methods to implement time related processing Timer Operations Delayed task wakeup Timeout Cyclic handlers by using base clock timer interrupts that occur at constant intervals as well as a function to manipulate and reference the system time
127. R_BASETIME Timer interrupt priorit Maximum interrupt priority maxintpri or a lower value ptp y Note When passing control to the processing related to the base clock timer interrupt the RI850V4 enables acceptance of El level maskable interrupts by manipulating the PMn bits in the priority mask register PMR and the ID bit in the program status word PSW and issuing the eiret instruction clearing the in service priority register ISPR Therefore if an El level maskable interrupt occurs within the base clock timer interrupt processing the interrupt is accepted Note Use the OS timer in the interval timer mode R20UT2889EJ0101 Rev 1 01 2tENESAS Page 123 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 9 TIME MANAGEMENT FUNCTIONS 9 2 2 Base clock interval In the RI850V4 service call parameters for time specification are specified in milliseconds If is desirable to set 1 ms for the occurrence interval of base clock timer interrupts but it may be difficult depending on the target system performance processing capability required time resolution or the like The interval between occurrences of base clock timer interrupts can be defined as the Base clock interval tim_base in the system configuration file By specifying the base clock cycle processing regards that the time equivalent to the base clock cycle elapses during a base clock timer interrupt An integer value larger than 1 can be specified for the base cl
128. S prcv_mbx iprcv_mbx This service call receives a message from the mailbox specified by parameter mbxid and stores its start address in the area specified by parameter ppk_msg If the message could not be received from the target mailbox no messages were queued in the wait queue when this service call is issued message reception processing is not executed but E_TMOUT is returned The following describes an example for coding this service call include lt kernel h gt Standard header file definition include lt kernel_id h gt System information header file definition void task VP_INT exinf ER ercd Declares variable ID mbxid ID_MBX1 Declares and initializes variable T_MSG ppk_msg Declares data structure Receive from mailbox polling ercd prcv_mbx mbxid amp ppk_msq EPa Polling success processing lse if ercd E_TMOUT EEEE Polling failure processing Note 1 If no message could be received from the target mailbox no messages were queued to the wait queue when this service call is issued the contents in the area specified by parameter ppk_msg become undefined Note 2 For details about the message packet refer to 15 2 6 Message packet R20UT2889EJ0101 Rev 1 01 ztENESAS Page 79 of 366 Sep 30 2015 CHAPTER 5 SYNCHRONIZATION AND COMMUNICATION RI850V4 V2 FUNCTIONS trcv_mbx This service call receives a message from the mailbox s
129. S Outline Disable dispatching C format ER dis_dsp void Parameter s None Explanation This service call changes the system status to the dispatch disabled state As a result dispatch processing task scheduling is disabled from when this service call is issued until ena_dsp is issued If a service call chg_pri sig_sem etc accompanying dispatch processing is issued during the interval from when this service call is issued until ena_dsp is issued the RI850V4 executes only processing such as queue manipulation counter manipulation etc and the actual dispatch processing is delayed until ena_dsp is issued upon which the actual dispatch processing is performed in batch Note 1 The dispatch disabled state changed by issuing this service call must be cancelled before the task that issued this service call moves to the DORMANT state Note 2 This service call does not perform queuing of disable requests If the system is in the dispatch disabled state therefore no processing is performed but it is not handled as an error Note 3 If a service call such as wai_sem wai_flg that may move the status of an invoking task is issued from when this service call is issued until ena_dsp is issued the RI850V4 returns E_CTX regardless of whether the required condition is immediately satisfied Return value Macro Value Description E OK 0 Normal completion Context error E_CTX 25 This service
130. S Page 103 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 7 MEMORY POOL MANAGEMENT FUNCTIONS include lt kernel h gt Standard header file definition include lt kernel_id h gt System information header file definition void task VP_INT exinf ER ercd Declares variable ID mplid ID_MPL1 Declares and initializes variable UINT blksz 256 Declares and initializes variable VP p_blk Declares variable TMO tmout 3600 Declares and initializes variable Acquire variable sized memory block with timeout ercd tget_mpl mplid blksz amp p_blk tmout j if ercd E_OK ETEEN Normal termination processing rel_mpl mplid p_blk Release variable sized memory block else if ercd E_RLWAI yale ae tee or Forced termination processing lse if ercd E_TMOUT EEE Timeout processing Note 1 The RI850V4 acquires variable size memory blocks in the unit of integral multiple of 4 If a value other than an integral multiple of 4 is specified for parameter blksz it is rounded up to be an integral multiple of 4 Note 2 The RI850V4 needs a 4 byte area management block to manage the acquired variable sized memory blocks When this service call is issued an area of blksz 4 bytes is allocated in the target variable sized memory pool Note 3 The RI850V4 does not perform memory clear processing when getting the acquired variable size memory
131. S Page 29 of 366 Sep 30 2015 RI850V4 V2 3 6 2 Other tasks are forcibly terminated by issuing the following service call from the processing program Terminate task ter_tsk This service call forcibly moves a task specified by parameter tskid to the DORMANT state As a result the target task is excluded from the RI850V4 scheduling subject CHAPTER 3 TASK MANAGEMENT FUNCTIONS If an activation request has been queued to the target task the activation request counter is not set to 0x0 when this service call is issued this service call moves the task to the DORMANT state decrements the wakeup request counter by subtracting 0x1 from the wakeup request counter and then moves the task from the DORMANT state to the READY state The following describes an example for coding this service call lt kernel h gt lt kernel_id h gt include include void task VP_INT exinf ID tskid 8 ter_tsk tskid Standard header file definition System information header file definition Declares and initializes variable Terminate task Note When moving a task to the DORMANT state this service call initializes the following information to values that are set during task creation Priority current priority Wakeup request count Suspension count Interrupt status If the target task has locked a mutex the locked state is released at the same time processing equivalent to unl_mtx
132. Specified data queue is not registered R20UT2889EJ0101 Rev 1 01 tENESAS Page 231 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 16 SERVICE CALLS Outline Receive from data queue waiting forever C format ER rev_dtq ID dtqid VP_INT p data Parameter s O Parameter Description l ID dtqid ID number of the data queue from which a data element is received O VP_INT p data Data element received from the data queue Explanation This service call reads data in the data queue area of the data queue specified by parameter dtqid and stores it to the area specified by parameter p_data If no data could be read from the data queue area of the target data queue no data has been written to the data queue area when this service call is issued the service call does not read data but queues the invoking task to the reception wait queue of the target data queue and moves it from the RUNNING state to the WAITING state data reception wait state The receiving WAITING state for a data queue is cancelled in the following cases and then moved to the READY state Receiving WAITING State for a Data Queue Cancel Operation Return Value Data was written to the data queue area of the target data queue as a result of issuing snd_dtq E_OK Data was written to the data queue area of the target data queue as a result of issuing E OK psnd_diq Data was written to the data queue area o
133. Specified fixed sized memory pool is not registered R20UT2889EJ0101 Rev 1 01 Sep 30 2015 ztENESAS Page 268 of 366 RI850V4 V2 CHAPTER 16 SERVICE CALLS 16 2 9 Memory pool management functions variable sized memory pools The following shows the service calls provided by the RI850V4 as the memory pool management functions variable sized memory pools Table 16 9 Memory Pool Management Functions Variable Sized Memory Pools Service Call Function Origin of Service Call get_mpl Acquire variable sized memory block waiting forever Task pget_mpl Acquire variable sized memory block polling ni BOE Mees mitalizationrou ipget_mpl Acquire variable sized memory block polling hatte NOR tee Miele Aun ou tget_mpl Acquire variable sized memory block with timeout Task rel_mpl Release variable sized memory block a Ban eon Tnlpalle sien tou irel_mpl Release variable sized memory block na Monster nitializatiom rou F Task Non task Initialization rou ref_mpl Reference variable sized memory pool state iine Task Non task Initialization rou iref_mpl Reference variable sized memory pool state tine R20UT2889EJ0101 Rev 1 01 tENESAS Page 269 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 16 SERVICE CALLS Outline Acquire variable sized memory block waiting forever C format ER get_mpl ID mplid UINT blksz VP p blk P
134. T Normal termination processing rse if ercd E_RLWAI gisako kuaa Forced termination processing R20UT2889EJ0101 Rev 1 01 2tENESAS Page 56 of 366 Sep 30 2015 CHAPTER 5 SYNCHRONIZATION AND COMMUNICATION RI850V4 V2 FUNCTIONS Note 1 With the RI850V4 whether to enable queuing of multiple tasks to the event flag wait queue is defined during configuration If this service call is issued for the event flag TW_WSGL attribute to which a wait task is queued therefore E_ILUSE is returned regardless of whether the required condition is immediately satisfied TA_WSGL Only one task is allowed to be in the WAITING state for the eventtflag TA_WMUL Multiple tasks are allowed to be in the WAITING state for the eventflag Note 2 Invoking tasks are queued to the target event flag TA_WMUL attribute wait queue in the order defined during configuration FIFO order or priority order Note 3 The RI850V4 performs bit pattern clear processing 0x0 setting when the required condition of the target eventtflag TA_CLR attribute is satisfied Note 4 If the WAITING state for an eventflag is forcibly released by issuing rel_wai or irel_wai the contents of the area specified by parameter p_flgptn will be undefined R20UT2889EJ0101 Rev 1 01 2tENESAS Page 57 of 366 Sep 30 2015 CHAPTER 5 SYNCHRONIZATION AND COMMUNICATION RI850V4 V2 FUNCTIONS pol_flg ipol_flg This service call checks whether the bit pattern specified
135. T 50 Polling failure or timeout R20UT2889EJ0101 Rev 1 01 tENESAS Page 254 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 16 SERVICE CALLS Outline Unlock mutex C format ER unl_mtx ID mtxid Parameter s 1 0 Parameter Description l ID mtxid ID number of the mutex to be unlocked Explanation This service call unlocks the locked mutex specified by parameter mtxid If a task has been queued to the target mutex wait queue when this service call is issued mutex lock processing is performed by the task the first task in the wait queue immediately after mutex unlock processing As a result the task is unlinked from the wait queue and moves from the WAITING state mutex wait state to the READY state or from the WAITING SUSPENDED state to the SUSPENDED state Note A locked mutex can be unlocked only by the task that locked the mutex If this service call is issued for a mutex that was not locked by an invoking task no processing is performed but E_ILUSE is returned Return value Macro Value Description E OK 0 Normal completion Invalid ID number E ID 18 mtxid lt 0x0 mtxid gt Maximum ID number Context error E CTX 25 This service call was issued from a non task This service call was issued in the CPU locked state Illegal service call use E_ILUSE 28 Multiple unlocking of a mutex The invoking task does not have the specified mutex locked N
136. TA_HLNG TA_MFIFO TA_MPRI TA_OFF TA_ON TA_PHS TA_RSTR TA_STA TA_TFIFO TA_TPRI TA_WMUL TA_WSGL TBIT_FLGPTN TBIT_TEXPTN TIC_DENO TIC_NUME TKERNEL_MAKER TKERNEL_PRID TKERNEL_PRVER TKERNEL_SPVER TMAX_ACTCNT TMAX_MPRI TMAX_SEMCNT TMAX_SUSCNT TMAX_TPRI TMAX_WUPCNT TMIN_MPRI TMIN_TPRI TSZ_DTQ TSZ_MBF TSZ_MPF TSZ_MPL TSZ_MPRIHD VATT_IDL VDEF_RTN G3K G3M G3KH G3MH Note In addition to the above words service call names such as act_tsk or slp_tsk words starting with _kernel_ and the section names shown in Table B 1 to be used by the RI850V4 are reserved as keywords in the CF850V4 R20UT2889EJ0101 Rev 1 01 ztENESAS Page 304 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 17 SYSTEM CONFIGURATION FILE 17 2 Configuration Information The configuration information that is described in a system configuration file is divided into the following three main types Declarative Information Data related to a header file header file name in which data macro entities used in the system configuration file are defined Header file declaration System Information Data related to OS resources such as real time OS name processor type required for the RI850V4 to operate Rl series information Basic information FPSR register information Memory area information Static API Information Data related to management objects such as task and task exception handling routine used in the system Task informat
137. TA_WMUL attribute wait queue in the order defined during configuration FIFO order or priority order The RI850V4 performs bit pattern clear processing 0x0 setting when the required condition of the target eventflag TA_CLR attribute is satisfied If the event flag wait state is cancelled because rel_wai or irel_wai was issued or the wait time elapsed the contents in the area specified by parameter p_flgptn become undefined TMO_FEVR is specified for wait time tmout processing equivalent to wai_flg will be executed When TMO_POL is specified processing equivalent to pol_flg ipol_flg will be executed 2tENESAS Page 60 of 366 CHAPTER 5 SYNCHRONIZATION AND COMMUNICATION RI850V4 V2 FUNCTIONS 5 3 5 Reference eventflag state An eventflag status is referenced by issuing the following service call from the processing program ref_flg iref_flg Stores eventflag state packet ID number of the task at the head of the wait queue current bit pattern etc of the eventflag specified by parameter figid in the area specified by parameter pk_rfig The following describes an example for coding this service call include lt kernel h gt Standard header file definition include lt kernel_id h gt System information header file definition void task VP_INT exinf ID flgid ID_FLG1 Declares and initializes variable T_RFLG pk_rflg Declares data structure ID wt skid Declares variable FLGPTN flgp
138. TMOUT EEE E oes Timeout processing Note 1 Invoking tasks are queued to the reception wait queue of the target data queue in the order of the data Note 2 Note 3 reception request If the data reception wait state is cancelled because rel_wai or irel_wai was issued or the wait time elapsed the contents in the area specified by parameter p_ data become undefined TMO_FEVR is specified for wait time tmout processing equivalent to rcv_dtq will be executed When TMO_POL is specified processing equivalent to prcv_diq iprcv_dtq will be executed R20UT2889EJ0101 Rev 1 01 Sep 30 2015 2tENESAS Page 73 of 366 CHAPTER 5 SYNCHRONIZATION AND COMMUNICATION FUNCTIONS RI850V4 V2 5 4 5 Reference data queue state A data queue status is referenced by issuing the following service call from the processing program ref_dtq iref_dtq These service calls store the detailed information of the data queue existence of waiting tasks number of data elements in the data queue etc specified by parameter dtqid into the area specified by parameter pk_radtq The following describes an example for coding this service call include include lt kernel h gt lt kernel_id h gt void task VP_INT exinf ID dtqid ID_DTQ1 T_RDTQ pk_rdtq ID stskid ID rtskid UINT sdtqcnt ATR dtqatr UINT dtqcent ref_dtq dtqid amp pk_rdtq stskid pk_rdtq stskid rtskid pk_rdtq rtskid sdtqc
139. UNCTIONS 6 WAITING SUSPENDED state State in which the WAITING and SUSPENDED states are combined A task enters the SUSPENDED state when the WAITING state is cancelled or enters the WAITING state when the SUSPENDED state is cancelled 3 2 2 Task priority A priority level that determines the order in which that task will be processed in relation to the other tasks is assigned to each task As a result in the RI850V4 the task that has the highest priority level of all the tasks that have entered an executable state RUNNING state or READY state is selected and given the CPU use right In the RI850V4 the following two types of priorities are used for management purposes Initial priority Priority set when a task is created Therefore the priority level of a task priority level referenced by the scheduler immediately after it moves from the DORMANT state to the READY state is the initial priority Current priority Priority referenced by the RI850V4 when it performs a manipulation task scheduling queuing tasks to a wait queue in the order of priority or priority level inheritance when a task is activated Note 1 In the RI850V4 a task having a smaller priority number is given a higher priority Note 2 The priority range that can be specified in a system can be defined in Basic information Maximum priority maxtpri when creating a system configuration file R20UT2889EJ0101 Rev 1 01 2tENESAS Page 23 of 366 Sep 30 201
140. When a dynamic memory manipulation request is issued from a processing program in the RI850V4 the fixed sized memory pool is provided as a usable memory area Dynamic memory manipulation of the fixed size memory pool is executed in fixed size memory block units 7 3 1 Create fixed sized memory pool In the RI850V4 the method of creating a fixed sized memory pool is limited to static creation Fixed sized memory pools therefore cannot be created dynamically using a method such as issuing a service call from a processing program Static fixed size memory pool creation means defining of fixed size memory pools using static API CRE _MPF in the system configuration file For details about the static API CRE_MPF refer to 17 5 7 Fixed sized memory pool information R20UT2889EJ0101 Rev 1 01 2tENESAS Page 91 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 7 MEMORY POOL MANAGEMENT FUNCTIONS 7 3 2 Acquire fixed sized memory block A fixed sized memory block is acquired waiting forever polling or with timeout by issuing the following service call from the processing program get_mpf This service call acquires the fixed sized memory block from the fixed sized memory pool specified by parameter mpfid and stores the start address in the area specified by parameter p_bik If no fixed size memory blocks could be acquired from the target fixed size memory pool no available fixed size memory blocks exist when this service call is issued
141. _ data eee ea ee Polling success processing lse if ercd E_TMOUT eae ewe at Polling failure processing Note If no data could be read from the data queue area of the target data queue no data has been written to the data queue area when either of these service calls is issued the contents in the area specified by parameter p_data become undefined R20UT2889EJ0101 Rev 1 01 ztENESAS Page 71 of 366 Sep 30 2015 CHAPTER 5 SYNCHRONIZATION AND COMMUNICATION RI850V4 V2 FUNCTIONS trev_dtq This service call reads data in the data queue area of the data queue specified by parameter diqid and stores it to the area specified by parameter p_data If no data could be read from the data queue area of the target data queue no data has been written to the data queue area when this service call is issued the service call does not read data but queues the invoking task to the reception wait queue of the target data queue and moves it from the RUNNING state to the WAITING state with time out data reception wait state The receiving WAITING state for a data queue is cancelled in the following cases and then moved to the READY state Receiving WAITING State for a Data Queue Cancel Operation Return Value Data was written to the data queue area of the target data queue as a result of issuing E OK snd_dtiq _ Data was written to the data queue area of the target data
142. _DISPREEMPT 0x4000 Preemption is disabled at task activation TA_ENAINT 0x0000 All interrupts are enabled at task activation TA_DISINT 0x8000 All interrupts are disabled at task activation TA STA 0x0002 Cyclic handlers is in an operational state after the cre ation TA PHS 0x0004 es handler is activated preserving the activation The following lists the management object attributes acquired by issuing service calls ref_sem ref_flg or the like Macro definition of attributes is performed by the standard header file lt ri_root gt include kernel h which is called from the header file lt ri_root gt include os option h and the ITRON general definition header file lt ri_root gt include itron h Table 15 4 Management Object Attributes Macro Value Description TA_TFIFO 0x0000 Task wait queue is in FIFO order TA_TPRI 0x0001 Task wait queue is in task priority order TA_WSGL 0x0000 Only one task is allowed to be in the WAITING state for the eventflag TA WMUL 0x0002 Multiple tasks are allowed to be in the WAITING state for the eventflag Bit pattern is cleared when a task is released from the TASES 0x900 WAITING state for eventflag TA_MFIFO 0x0000 Message wait queue is in FIFO order TA_MPRI 0x0002 Message wait queue is in message priority order R20UT2889EJ0101 Rev 1 01 Sep 30 2015 7tENESAS Page 169 of 366 RI850V4 V2 CHAPTER 15 DATA TYPES AND MACROS 15 3 4 Service
143. a memory block l ID mpfid s is acquired O VP p_ blk Start address of the acquired memory block Explanation This service call acquires the fixed sized memory block from the fixed sized memory pool specified by parameter mpfid and stores the start address in the area specified by parameter p_bik If a fixed sized memory block could not be acquired from the target fixed sized memory pool no available fixed sized memory blocks exist when this service call is issued fixed sized memory block acquisition processing is not performed but E_TMOUT is returned Note 1 The RI850V4 does not perform memory clear processing when acquiring a fixed sized memory block The contents of the acquired fixed sized memory block are therefore undefined Note 2 If no fixed size memory blocks could be acquired from the target fixed size memory pool no available fixed size memory blocks exist when this service call is issued the contents in the area specified by parameter p_blk become undefined Return value Macro Value Description E OK 0 Normal completion Invalid ID number E ID 18 mpfid lt 0x0 mpfid gt Maximum ID number Context error E CTX 25 This service call was issued in the CPU locked state Non existent object E NOEXS 42 Specified fixed sized memory pool is not registered R20UT2889EJ0101 Rev 1 01 2tENESAS Page 261 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 16 SERVICE CALLS
144. a result of issuing ter_tsk E OK Forced release from waiting accept rel_wai while waiting E RLWAI Forced release from waiting accept irel_ wai while waiting E RLWAI Polling failure or timeout E TMOUT The following describes an example for coding this service call include lt kernel h gt Standard header file definition include lt kernel_id h gt System information header file definition void task VP_INT exinf ER ercd Declares variable ID mtxid ID_MTX1 Declares and initializes variable TMO tmout 3600 Declares and initializes variable ercd tloc_mtx mtxid tmout Lock mutex with timeout if ercd E_OK Say bade toe ar Locked state unl_mtx mtxid Unlock mutex else if ercd E_RLWAI Bahn eeu Oe Forced termination processing lse if ercd E_TMOUT ee eee Timeout processing Note 1 Invoking tasks are queued to the target mutex wait queue in the order defined during configuration FIFO Note 2 Note 3 order or priority order In the RI850V4 E_ILUSE is returned if this service call is re issued for the mutex that has been locked by the invoking task multiple locking of mutex TMO_FEVR is specified for wait time tmout processing equivalent to loc_mtx will be executed When TMO_POL is specified processing equivalent to ploc_mtx will be executed R20UT2889EJ0101 Rev 1 01 2tENESAS Page 86 of 366 Sep
145. acro Value Description E OK 0 Normal completion Parameter error E_PAR 17 waiptn 0x0 wmode is invalid Invalid ID number E_ ID 18 figid lt 0x0 flgid gt Maximum ID number Context error E CTX 25 This service call was issued in the CPU locked state Illegal service call use E ILUSE 28 There is already a task waiting for an eventflag with the TA_WSGL attribute Non existent object E NOEXS 42 Specified eventflag is not registered Polling failure E TMOUT 50 The bit pattern of the target eventflag does not satisfy the wait condition R20UT2889EJ0101 Rev 1 01 Sep 30 2015 ztENESAS Page 221 of 366 RI850V4 V2 CHAPTER 16 SERVICE CALLS Outline Wait for eventflag with timeout C format ER twai_flg ID flgid FLGPTN waiptn MODE wfmode FLGPTN p_flgptn TMO tmout Parameter s 1 0 Parameter Description ID flgid ID number of the eventflag to wait for l FLGPTN waiptn Wait bit pattern Wait mode MODE wfmode TWF_ANDW AND waiting condition TWF_ORW OR waiting condition O FLGPTN p_flgptn Bit pattern causing a task to be released from waiting Specified timeout unit millisecond TMO tmout TMO_FEVR Waiting forever TMO_POL Polling Value Specified timeout Explanation This service call checks whether the bit pattern specified by parameter waiptn and the bit pattern that satisfies the required condition specified by p
146. aiptn are set as the target eventflag wfmode TWF_ORW Checks which bit among bits to which 1 is set by parameter waiptn is set as the target eventflag Note 1 Note 2 Note 3 Note 4 Note 5 With the RI850V4 whether to enable queuing of multiple tasks to the event flag wait queue is defined during configuration If this service call is issued for the event flag TW_WSGL attribute to which a wait task is queued therefore E_ILUSE is returned regardless of whether the required condition is immediately satisfied TA_WSGL Only one task is allowed to be in the WAITING state for the eventtflag TA_WMUL Multiple tasks are allowed to be in the WAITING state for the eventflag Invoking tasks are queued to the target event flag TA_WMUL attribute wait queue in the order defined during configuration FIFO order or priority order The RI850V4 performs bit pattern clear processing 0x0 setting when the required condition of the target eventflag TA_CLR attribute is satisfied If the event flag wait state is cancelled because rel_wai or irel_wai was issued or the wait time elapsed the contents in the area specified by parameter p_flgptn become undefined TMO_FEVR is specified for wait time tmout processing equivalent to wai_flg will be executed When TMO_POL is specified processing equivalent to pol_flg ipol_flg will be executed Return value Macro Value Description E OK 0 Nor
147. alid ID number EID 18 digid lt 0x0 dtgid gt Maximum ID number Context error E CTX 25 This service call was issued from a non task This service call was issued in the CPU locked state This service call was issued in the dispatching disabled state Non existent object E_NOEXS 42 Specified data queue is not registered Forced release from the WAITING state E_RLWAI 49 Accept rel_wai irel_wai while waiting R20UT2889EJ0101 Rev 1 01 Sep 30 2015 ztENESAS Page 227 of 366 RI850V4 V2 CHAPTER 16 SERVICE CALLS psnd_dtq ipsnd_dtq Outline Send to data queue polling C format ER psnd_dtq ID dtqid VP_INT data ER ipsnd_dtq ID dtqid VP_INT data Parameter s 0 Parameter Description l ID dtqid ID number of the data queue to which the data element is sent l VP_INT data Data element to be sent to the data queue Explanation These service calls write data specified by parameter data to the data queue area of the data queue specified by parameter dtqid If there is no available space for writing data in the data queue area of the target data queue when either of these service calls is issued data is not written but E_TMOUT is returned If a task has been queued to the reception wait queue of the target data queue when this service call is issued this service call does not write data but transfers the data to the task As a result the task is unlinked from t
148. alizes variable Send to data queue polling ercd psnd_dtq dtqid data EOE Polling success processing lse if ercd E_TMOUT PTEE Polling failure processing Note Data is written to the data queue area of the target data queue in the order of the data transmission request R20UT2889EJ0101 Rev 1 01 ztENESAS Page 65 of 366 Sep 30 2015 CHAPTER 5 SYNCHRONIZATION AND COMMUNICATION RI850V4 V2 FUNCTIONS tsnd_dtq This service call writes data specified by parameter data to the data queue area of the data queue specified by parameter diqid If there is no available space for writing data in the data queue area of the target data queue when this service call is issued the service call does not write data but queues the invoking task to the transmission wait queue of the target data queue and moves it from the RUNNING state to the WAITING state with time data transmission wait state The sending WAITING state for a data queue is cancelled in the following cases and then moved to the READY state Sending WAITING State for a Data Queue Cancel Operation Return Value An available space was secured in the data queue area of the target data queue as a result E OK of issuing rcv_dtq An available space was secured in the data queue area of the target data queue as a result E OK of issuing prev_dtq An available space was secured in the data queue area of the target data
149. ans defining of event flags using static API CRE_FLG in the system configuration file For details about the static API CRE_FLG refer to 17 5 3 Eventflag information R20UT2889EJ0101 Rev 1 01 2tENESAS Page 53 of 366 Sep 30 2015 CHAPTER 5 SYNCHRONIZATION AND COMMUNICATION RI850V4 V2 FUNCTIONS 5 3 2 Set eventflag Bit pattern is set by issuing the following service call from the processing program set_flg iset_flg These service calls set the result of logical OR operating the bit pattern of the eventflag specified by parameter figid and the bit pattern specified by parameter setptn as the bit pattern of the target eventflag If the required condition of the task queued to the target eventflag wait queue is satisfied when this service call is issued the relevant task is unlinked from the wait queue at the same time as bit pattern setting processing As a result the relevant task is moved from the WAITING state WAITING state for an eventflag to the READY state or from the WAITING SUSPENDED state to the SUSPENDED state The following describes an example for coding this service call include lt kernel h gt Standard header file definition include lt kernel_id h gt System information header file definition void task VP_INT exinf ID flgid ID_FLG1 Declares and initializes variable FLGPTN setptn 10 Declares and initializes variable set_flg flgid setptn Set eventflag Note 1 I
150. arameter s 0 Parameter Description ID number of the variable sized memory pool from which a memory l ID mplid block is acquired l UINT blksz Memory block size to be acquired in bytes O VP p_ blk Start address of the acquired memory block Explanation This service call acquires a variable size memory block of the size specified by parameter blksz from the variable size memory pool specified by parameter mplid and stores its start address into the area specified by parameter p_bik If no variable size memory blocks could be acquired from the target variable size memory pool no successive areas equivalent to the requested size were available when this service call is issued this service call does not acquire variable size memory blocks but queues the invoking task to the target variable size memory pool wait queue and moves it from the RUNNING state to the WAITING state variable size memory block acquisition wait state The WAITING state for a variable sized memory block is cancelled in the following cases and then moved to the READY state WAITING State for a Variable sized Memory Block Cancel Operation Return Value The variable size memory block that satisfies the requested size was returned to the target E OK variable size memory pool as a result of issuing rel_mpl The variable size memory block that satisfies the requested size was returned to the target E OK variable size memory pool as a result of issuin
151. arameter wfmode are set to the eventflag specified by parameter flgid If a bit pattern that satisfies the required condition has been set for the target eventflag the bit pattern of the target eventtlag is stored in the area specified by parameter p_flgptn If the bit pattern of the target eventflag does not satisfy the required condition when this service call is issued the invoking task is queued to the target eventflag wait queue As a result the invoking task is unlinked from the ready queue and is moved from the RUNNING state to the WAITING state WAITING state for an eventflag The WAITING state for an eventflag is cancelled in the following cases and then moved to the READY state WAITING State for an Eventflag Cancel Operation Return Value A bit pattern that satisfies the required condition was set to the target eventflag as a result of E OK issuing set_flg m A bit pattern that satisfies the required condition was set to the target eventflag as a result of E OK issuing iset_flg Forced release from waiting accept rel_wai while waiting E RLWAI Forced release from waiting accept irel_wai while waiting E RLWAI Polling failure or timeout E TMOUT R20UT2889EJ0101 Rev 1 01 2tENESAS Page 222 of 366 Sep 30 2015 RI850V4 V2 The following shows the specification format of required condition wfmode wfmode TWF_ANDW Checks whether all of the bits to which 1 is set by parameter w
152. arget cyclic handler The following shows a cyclic handler activation timing image Figure 9 2 TA_PHS Attribute Not Specified m Start m Start m Start cyctim v cyctim v cyctim v cyctim cycphs cyctim i cyctim i cyctim i A A Start cyclic handler operation Start cyclic handler operation Generation processing completed The following describes an example for coding this service call include lt kernel h gt Standard header file definition include lt kernel_id h gt System information header file definition void task VP_INT exinf R20UT2889EJ0101 Rev 1 01 2tENESAS Page 128 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 9 TIME MANAGEMENT FUNCTIONS ID cycid ID_CYC1 Declares and initializes variable sta_cyc cycid Start cyclic handler operation Note The extended information specified in the Cyclic handler information is passed to the cyclic handler activated by issuing this service call R20UT2889EJ0101 Rev 1 01 ztENESAS Page 129 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 9 TIME MANAGEMENT FUNCTIONS 9 7 Stop Cyclic Handler Operation Moving to the non operational state STP state is implemented by issuing the following service call from the processing program stp_cyc istp_cyc This service call moves the cyclic handler specified by parameter cycid from the operational state STA state to non operational state STP sta
153. arl r11 lp Internal processing of boot processing Boot processing is a routine dedicated to initialization processing that is called from Initialization routine without RI850V4 intervention Therefore note the following points when coding boot processing Coding method Code boot processing using C or assembly language When coding in C they can be coded in the same manner as ordinary functions coded When coding in assembly language code them according to the calling rules prescribed in the compiler used Stack switching Setting of stack pointer SP is not executed at the point when control is passed to boot processing To use a boot processing dedicated stack setting of stack pointer SP must therefore be coded at the beginning of the boot processing Service call issue Execution of the Kernel Initialization Module is not performed when boot processing is started issue of service calls is therefore prohibited during boot processing The following lists processing that should be executed in boot processing Initializing the interrupt configuration register INTCFG 2 Setting of global pointer GP 3 Setting of element pointer EP 4 Setting stack pointer SP 5 Setting of text pointer TP only when using the CCV850 compiler 6 Initialization of kernel_data_init section R20UT2889EJ0101 Rev 1 01 2tENESAS Page 148 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 14 SYSTEM INITIALIZATION ROUTINE 7 Setting of
154. as the time management functions Table 16 10 Time Management Functions Service Call Function Origin of Service Call Task Non task Initialization rou set_tim Set system time tine i i Task Non task Initialization rou iset_tim Set system time tine Task Non task Initialization rou get_tim Reference system time iine F Task Non task Initialization rou iget_tim Reference system time tine k Non task Initializati sta_cyc Start cyclic handler operation he on task nitalization ou Task Non task Initialization rou ista_cyc Start cyclic handler operation a gn t sk nitalization r i Task Non task Initialization rou stp_cyc Stop cyclic handler operation tine Task Non task Initialization rou istp_cyc Stop cyclic handler operation tine Non task Initializati ref_cyc Reference cyclic handler state hi on task nitalzaton rou f Non task Initializati iref_cyc Reference cyclic handler state aed Oncor Nia Taton ToU R20UT2889EJ0101 Rev 1 01 tENESAS Page 280 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 16 SERVICE CALLS Outline Set system time C format ER set_tim SYSTIM p_systim ER iset_tim SYSTIM p_systim Parameter s 1 0 Parameter Description l SYSTIM p_systim Time to set as system time System time packet SYSTIM typedef struct t_systim UW ltime System time
155. ask state packet refer to 15 2 1 Task state packet R20UT2889EJ0101 Rev 1 01 2tENESAS Page 33 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 3 TASK MANAGEMENT FUNCTIONS 3 9 2 Reference task state simplified version A task status simplified version is referenced by issuing the following service call from the processing program ref_tst iref_tst Stores task state packet current state reason for waiting of the task specified by parameter tskid in the area specified by parameter pk_rtst Used for referencing only the current state and reason for wait among task information Response becomes faster than using ref_tsk or iref_tsk because only a few information items are acquired The following describes an example for coding this service call include lt kernel h gt Standard header file definition include lt kernel_id h gt System information header file definition void task VP_INT exinf ID tskid 8 Declares and initializes variable T_RTST pk_rtst Declares data structure STA tskstat Declares variable STA tskwait Declares variable ref_tst tskid amp pk_rtst Reference task state simplified version tskstat pk_rtst tskstat Reference current state tskwait pk_rtst tskwait Reference reason for waiting Note For details about the task state packet simplified version refer to 15 2 2 Task state packet simplified version R20UT2889EJ01
156. ate or from the WAITING state to the WAITING SUSPENDED state If the target task has moved to the SUSPENDED or WAITING SUSPENDED state when this service call is issued the counter manipulation processing is not performed but only the suspend request counter increment processing is executed The following describes an example for coding this service call lt kernel h gt lt kernel_id h gt include include void task VP_INT exinf ID tskid ID_TSK1 sus_tsk tskid Standard header file definition System information header file definition Declares and initializes variable Suspend task Note The suspend request counter managed by the RI850V4 is configured in 7 bit widths If the number of suspend requests exceeds the maximum count value 127 as a result of issuing this service call the counter manipulation processing is therefore not performed but E_QOVR is returned R20UT2889EJ0101 Rev 1 01 Sep 30 2015 2tENESAS Page 42 of 366 RI850V4 V2 CHAPTER 4 TASK DEPENDENT SYNCHRONIZATION FUNCTIONS 4 7 4 7 1 Resume Suspended Task Resume suspended task The SUSPENDED state is cancelled by issuing the following service call from the processing program rsm_tsk irsm_tsk This service call subtracts 0x1 from the suspend request counter for the task specified by parameter tskid and then cancels the SUSPENDED state of the target task As a result the target task is moved from th
157. ate decrements the wakeup request counter by subtracting 0x1 from the wakeup request counter and then moves the task from the DORMANT state to the READY state Note When moving a task to the DORMANT state this service call initializes the following information to values that are set during task creation Current priority Wakeup request count Suspension count Interrupt state If the target task has locked a mutex the locked state is released at the same time processing equivalent to unl_mtx Return value Macro Value Description E OK 0 Normal completion Invalid ID number E ID 18 tskid lt 0x0 tskid gt Maximum ID number Context error E CTX 25 This service call was issued from a non task This service call was issued in the CPU locked state R20UT2889EJ0101 Rev 1 01 2tENESAS Page 183 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 16 SERVICE CALLS Macro Value Description Illegal service call use E_ILUSE 28 Specified task is an invoking task Object state error E OBJ 41 Specified task is in the DORMANT state Non existent object E_NOEXS 42 Specified task is not registered R20UT2889EJ0101 Rev 1 01 Sep 30 2015 ztENESAS Page 184 of 366 RI850V4 V2 CHAPTER 16 SERVICE CALLS chg_pri ichg_pri Outline Change task priority C format ER chg_pri ID tskid PRI tskpri j
158. ate a system information header file and does not display it on the project tree If this item is selected when there is already a system information header file then the file itself is not deleted No It does not register the file to the project nd Specify the folder for outputting the system information header file If a relative path is specified the reference point of the path is the project folder If an absolute path is specified the reference point of the path is the project folder unless the drives are different The following macro name is available as an embedded macro BuildModeName Replaces with the build mode name If this field is left blank macro name BuildModeName will be displayed Output folder This property is not displayed when No It does not register the file that is added to the project nd in the Generate a file property is selected Default BuildModeName Directly enter to the text box or edit by the Browse For Folder KOW to change dialog box which appears when clicking the button Restriction Up to 247 characters Specify the system information header file name If the file name is changed the name of the file displayed on the project tree Use the extension h If the extension is different or omitted h is automatically added This property is not displayed when No It does not register the file that is added File name to the project nd
159. ation of each area 1 Trace category Displays and changes the settings of various information required when using the utility tool task analyzer tool to analyze the history trace data of processing program execution R20UT2889EJ0101 Rev 1 01 2tENESAS Page 345 of 366 Sep 30 2015 RI850V4 V2 APPENDIX A WINDOW REFERENCE Selection of trace mode Select the type of information to be acquired as trace data and the location where trace data is to be stored Default Not tracing How to change Select from the drop down list Restriction Not tracing Does not use the task analyzer tool Acquires information in a trace chart such as Taking i the execution transition state of the processing trace chart Program and the state of Realtime OS by hardware resource usage and CPU usage status as trace mode trace data The trace buffer is allocated in the trace memory prepared by the debug tool Acquires information in a trace chart such as Taking in the execution transition state of the processing trace chart Program and the state of Realtime OS by software resource usage and CPU usage status as race mode trace data l l The trace buffer is allocated in the area selected in Select the buffer Taking in l o n g Acquires the CPU usage status as trace data statistics by The trace buffer is allocated in the prespecified software section kernel_data_trace bss trace mode
160. ation of the data queue existence of waiting tasks number of data elements in the data queue etc specified by parameter dfqid into the area specified by parameter pk_rdtq Note For details about the data queue state packet refer to 15 2 5 Data queue state packet Return value Macro Value Description E OK 0 Normal completion Invalid ID number E_ ID 18 dtgid lt 0x0 dtgid gt Maximum ID number Context error E CIX 25 This service call was issued in the CPU locked state R20UT2889EJ0101 Rev 1 01 2tENESAS Page 237 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 16 SERVICE CALLS Macro Value Description E_NOEXS 42 Non existent object Specified data queue is not registered R20UT2889EJ0101 Rev 1 01 Sep 30 2015 ztENESAS Page 238 of 366 RI850V4 V2 CHAPTER 16 SERVICE CALLS 16 2 6 Synchronization and communication functions mailboxes The following shows the service calls provided by the RI850V4 as the synchronization and communication functions mailboxes Table 16 6 Synchronization and Communication Functions Mailboxes Service Call Function Origin of Service Call snd_mbx Sand io mailbox Non task Initialization rou isnd_mbx Send to mailbox o Non task Initialization rou rcv_mbx Receive from mailbox waiting forever Task prcv_mbx Receive from mailbox polling i Non
161. ation routine through a C language interface TA_ASM Start an initialization routine through an assembly language interface 2 Extended information exinf Specifies the extended information for an initialization routine A value from 0x0 to Oxffffffff or a symbol name can be specified for exinf Note The target initialization routine can be manipulated by handling the extended information as if it were a function parameter 3 Start address inirtn Specifies the start address for an initialization routine A value from 0x0 to Oxfffffffe aligned to a 2 byte boundary or a symbol name can be specified for inirtn Note When an initialization routine handler is coded as follows the symbol name specified for inirtn should be func_ini include lt kernel h gt void func_ini VP_INT exinf R20UT2889EJ0101 Rev 1 01 7tENESAS Page 326 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 17 SYSTEM CONFIGURATION FILE 17 5 13 Idle routine information The idle routine information defines Attribute idlatr Start address idlrtn for an idle routine The number of idle routine information items that can be specified is defined as being within the range of 0 to 1 The following shows the idle routine information format VATT_IDL idlatr idlrtn The items constituting the idle routine information are as follows 1 Attribute idlatr Specifies the language used to describe an idle routine The keyword that ca
162. be specified for memsz SIZE_AUTO Total size of management objects defined in Basic information Task information etc Note For expressions to calculate the memory area size refer to APPENDIX B SIZE OF MEMORY Note When information regarding kernel_work section has not been defined the CF850V4 assumes that the following information is specified MEM_AREA kernel_work SIZE_AUTO R20UT2889EJ0101 Rev 1 01 ztENESAS Page 312 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 17 SYSTEM CONFIGURATION FILE 17 5 Static API Information The following describes the format that must be observed when describing the static API information in the system configuration file The GOTHIC FONT characters in following descriptions are the reserved words and italic face characters are the portion that the user must write the relevant numeric value symbol name or keyword Items enclosed by square brackets can be omitted 17 5 1 Task information The task information defines ID number tskid Attribute tskatr Extended information exinf Start address task Initial priority itskpri Task stack size stksz memory area name sec_nam Reserved for future use stk for a task The number of items that can be defined as task information is limited to one for each ID number The following shows the task information format sec_nam CRE_TSK tskid tskatr exinf task itskpri stksz sec_nam stk
163. bject E NOEXS 42 Specified variable sized memory pool is not registered Forced release from the WAITING state E RLWAI 49 Accept rel_wai irel_wai while waiting Timeout E TMOUT 50 Polling failure or timeout R20UT2889EJ0101 Rev 1 01 tENESAS Page 275 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 16 SERVICE CALLS rel_mpl irel_mpl Outline Release variable sized memory block C format ER rel_mpl ID mplid VP blk ER irel_mpl ID mplid VP blk Parameter s 1 0 Parameter Description ID number of the variable sized memory pool to which the memory l ID mplid block is released l VP blk Start address of memory block to be released Explanation This service call returns the variable sized memory block specified by parameter blk to the variable sized memory pool specified by parameter mplid After returning the variable size memory blocks these service calls check the tasks queued to the target variable size memory pool wait queue from the top and assigns the memory if the size of memory requested by the wait queue is available This operation continues until no tasks queued to the wait queue remain or no memory space is available As a result the task that acquired the memory is unlinked from the queue and moved from the WAITING state variable size memory block acquisition wait state to the READY state or from the WAITING SUSPENDED state to the SUSPENDED state Note 1 The RI850V4
164. block The contents of the got variable size memory block are therefore undefined Note 4 Invoking tasks are queued to the target variable size memory pool wait queue in the order defined during configuration FIFO order or priority order Note 5 Ifthe variable size memory block acquisition wait state is cancelled because rel_wai or irel_wai was issued or the wait time elapsed the contents in the area specified by parameter p_blk become undefined Note 6 TMO_FEVR is specified for wait time tmout processing equivalent to get_mpl will be executed When TMO_POL is specified processing equivalent to pget_mpl ipget_mpl will be executed R20UT2889EJ0101 Rev 1 01 2tENESAS Page 104 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 7 MEMORY POOL MANAGEMENT FUNCTIONS 7 4 3 A variable sized memory block is returned by issuing the following service call from the processing program Release variable sized memory block rel_mopl irel_mpl This service call returns the variable sized memory block specified by parameter blk to the variable sized memory pool specified by parameter mplid After returning the variable size memory blocks these service calls check the tasks queued to the target variable size memory pool wait queue from the top and assigns the memory if the size of memory requested by the wait queue is available This operation continues until no tasks queued to the wait queue remain or no memory space is available As a result the
165. bout the static API VATT_IDL refer to 17 5 13 Idle routine information Note If Idle routine information is not defined the default idle routine function name _kernel_default_idirtn is registered during configuration The default idle routine issues the HALT instruction 13 3 Scheduling in Non Tasks If a service call isig_sem iset_flg etc accompanying dispatch processing task scheduling processing is issued in order to quickly complete the processing in the non task cyclic handler interrupt handler etc during the interval until the processing in the non task ends the RI850V4 executes only processing such as queue manipulation and the actual dispatch processing is delayed until a return instruction is issued upon which the actual dispatch processing is performed in batch The following shows a processing flow when a service call accompanying dispatch processing is issued in a non task Figure 13 3 Scheduling in Non Tasks Task A Task B Non task Priority High Priority Low Acquire semaphore resource _ n Delayed period return Release semaphore resource R20UT2889EJ0101 Rev 1 01 2tENESAS Page 146 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 14 SYSTEM INITIALIZATION ROUTINE CHAPTER 14 SYSTEM INITIALIZATION ROUTINE This chapter describes the system initialization routine performed by the RI850V4 14 1 Outline The system initialization routine of the RI850V4 provides system
166. by parameter dlytim has elapsed E OK Forced release from waiting accept rel_wai while waiting E RLWAI Forced release from waiting accept irel_wai while waiting E RLWAI Return value Macro Value Description E OK 0 Normal completion Context error E CTX 25 This service call was issued from a non task This service call was issued in the CPU locked state This service call was issued in the dispatching disabled state Forced release from the WAITING state E_RLWAI 49 Accept rel_wai irel_wai while waiting R20UT2889EJ0101 Rev 1 01 Sep 30 2015 2tENESAS Page 204 of 366 RI850V4 V2 CHAPTER 16 SERVICE CALLS 16 2 3 Synchronization and communication functions semaphores The following shows the service calls provided by the RI850V4 as the synchronization and communication functions semaphores Table 16 3 Synchronization and Communication Functions Semaphores Service Call Function Origin of Service Call wai_sem Acquire semaphore resource waiting forever Task Task Non task Initialization rou pol_sem Acquire semaphore resource polling tine Task Non task Initialization rou ipol_sem Acquire semaphore resource polling ine twai_sem Acquire semaphore resource with timeout Task i Task Non task Initialization rou sig_sem Release semaphore resource ine i Task Non task Initialization rou isig_sem Release semaphore resource fine Task N
167. by parameter waiptn and the bit pattern that satisfies the required condition specified by parameter wfmode are set to the eventflag specified by parameter flgid If the bit pattern that satisfies the required condition has been set to the target eventflag the bit pattern of the target eventtlag is stored in the area specified by parameter p_figptn If the bit pattern of the target eventflag does not satisfy the required condition when this service call is issued E_ TMOUT is returned The following shows the specification format of required condition wfmode wimode TWF_ANDW Checks whether all of the bits to which 1 is set by parameter waiptn are set as the target eventflag wfmode TWF_ORW Checks which bit among bits to which 1 is set by parameter waiptn is set as the target eventflag The following describes an example for coding this service call include lt kernel h gt Standard header file definition include lt kernel_id h gt System information header file definition void task VP_INT exinf ER ercd Declares variable ID flgid ID_FLG1 Declares and initializes variable FLGPTN waiptn 14 Declares and initializes variable ODE wfmode TWF_ANDW Declares and initializes variable FLGPTN p_flgptn Declares variable Wait for eventflag polling ercd pol_flg flgid waiptn wfmode amp p_flgptn PEER Polling success processing lse if ercd E_TMOUT
168. by tasks operating in parallel exclusive control function To resolve such problems the RI850V4 therefore provides mutexes The following shows a processing flow when using a mutex The mutexes provided in the RI850V4 do not support the priority inheritance protocol and priority ceiling protocol but only support the FIFO order and priority order Figure 6 1 Processing Flow Mutex Task T Lock mutex Exclusive control period 4 Unlock mutex 6 2 1 Differences from semaphores Since the mutexes of the RI850V4 do not support the priority inheritance protocol and priority ceiling protocol so it operates similarly to semaphores binary semaphore whose the maximum resource count is 1 but they differ in the following points A locked mutex can be unlocked equivalent to returning of resources only by the task that locked the mutex gt Semaphores can return resources via any task and handler Unlocking is automatically performed when a task that locked the mutex is terminated ext_tsk or ter_tsk gt Semaphores do not return resources automatically so they end with resources acquired Semaphores can manage multiple resources the maximum resource count can be assigned but the maximum number of resources assigned to a mutex is fixed to 1 R20UT2889EJ0101 Rev 1 01 2tENESAS Page 82 of 366 Sep 30 2015 CHAPTER 6 EXTENDED SYNCHRONIZATION AND RI850V4 V2 COMMUNICATION FUNCTIONS 6 2 2 Create mutex In the RI8
169. call operating modes The following lists the service call operating modes used when issuing service calls act_tsk wup_tsk or the like Macro definition of operating modes is performed by the header file lt ri_root gt include os option h which is called from the standard header file lt ri_root gt include kernel h and the ITRON general definition header file lt ri_root gt include itron h Table 15 5 Service Call Operating Modes Macro Value Description TSK_SELF 0 Invoking task TPRI_INI 0 Initial priority TMO_FEVR 1 Waiting forever TMO_POL 0 Polling TWF_ANDW 0x00 AND waiting condition TWF_ORW 0x01 OR waiting condition TPRI_SELF 0 Current priority of the Invoking task 15 3 5 Return value The following lists the values returned from service calls Macros for the return values are defined in the header file lt ri_root gt include os error h and option h which are called from the standard header file lt ri_root gt include kernel h and the common macro definition file for ITRON specifications lt ri_root gt include itron h Table 15 6 Return Value Macro Value Description E OK 0 Normal completion E_ NOSPT 9 Unsupported function E_RSFN 10 Invalid function code E_ RSATR 11 Invalid attribute E PAR 17 Parameter error EID 18 Invalid ID number E CTX 25 Context error E_ILUSE 28 Illegal service call use E NOMEM 33 Ins
170. call was issued from a non task This service call was issued in the CPU locked state R20UT2889EJ0101 Rev 1 01 Sep 30 2015 ztENESAS Page 296 of 366 RI850V4 V2 CHAPTER 16 SERVICE CALLS Outline Enable dispatching C format ER ena_dsp void Parameter s None Explanation This service call changes the system status to the dispatch enabled state As a result dispatch processing task scheduling that has been disabled by issuing dis_dsp is enabled If a service call chg_pri sig_sem etc accompanying dispatch processing is issued during the interval from when dis_dsp is issued until this service call is issued the RI850V4 executes only processing such as queue manipulation counter manipulation etc and the actual dispatch processing is delayed until this service call is issued upon which the actual dispatch processing is performed in batch Note 1 This service call does not perform queuing of enable requests If the system is in the dispatch enabled state therefore no processing is performed but it is not handled as an error Note 2 If a service call such as wai_sem wai_flg that may move the status of an invoking task is issued from when dis_dsp is issued until this service call is issued the RI850V4 returns E_CTX regardless of whether the required condition is immediately satisfied Return value Macro Value Description E OK 0 Normal completion Context error
171. cally using a method such as issuing a service call from a processing program Static ready queue creation means defining of maximum priority using static API MAX_PRI in the system configuration file For details about the basic information MAX_PRI refer to 17 4 2 Basic information 13 1 4 Scheduling Lock Function The RI850V4 provides the scheduling lock function for manipulating the scheduler status explicitly from the processing program and disabling enabling dispatch processing The following shows a processing flow when using the scheduling lock function R20UT2889EJ0101 Rev 1 01 2tENESAS Page 143 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 13 SCHEDULER Figure 13 2 Scheduling Lock Function Task A Task B Interrupt handler Priority High Priority Low Acquire semaphore resource Lock the CPU Delayed period a Unlock the CPU return Disable Dispatching zx Release semaphore resource Delayed period l Enable Dispatching The scheduling lock function can be implemented by issuing the following service call from the processing program loc_cpu iloc_cpu unl_cpu iunl_cpu dis_dsp ena_dsp R20UT2889EJ0101 Rev 1 01 ztENESAS Page 144 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 13 SCHEDULER 13 2 User Own Coding Module To support various execution environments the hardware dependent processing idle routine that is required for the RI850V4 to execute processing is extracted
172. ccording to the calling rules prescribed in the compiler used Stack switching When switching tasks the RI850V4 performs switching to the task specified in Task information Service call issue Service calls that can be issued in tasks are limited to the service calls that can be issued from tasks Note For details on the valid issue range of each service call refer to Table 16 1 to Table 16 12 Acceptance of El level maskable interrupts When a task is activated the RI850V4 sets the interrupt acceptance status according to the settings in the Attribute tskatr such as the description language and initial state after activation by manipulating the PMn bits in the priority mask register PMR and the ID bit in the program status word PSW R20UT2889EJ0101 Rev 1 01 2tENESAS Page 25 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 3 TASK MANAGEMENT FUNCTIONS 3 3 Create Task In the RI850V4 the method of creating a task is limited to static creation Tasks therefore cannot be created dynamically using a method such as issuing a service call from a processing program Static task creation means defining of tasks using static API CRE_TSK in the system configuration file For details about the static API CRE_TSK refer to 17 5 1 Task information 3 4 Activate Task The RI850V4 provides two types of interfaces for task activation queuing an activation request queuing and not queuing an activation request In the RI850V4 extended
173. ce call does not acquire the fixed size memory block but queues the invoking task to the target fixed size memory pool wait queue and moves it from the RUNNING state to the WAITING state with timeout fixed size memory block acquisition wait state The WAITING state for a fixed sized memory block is cancelled in the following cases and then moved to the READY state WAITING State for a Fixed sized Memory Block Cancel Operation Return Value A fixed sized memory block was returned to the target fixed sized memory pool as a result of E OK issuing rel_mpf A fixed sized memory block was returned to the target fixed sized memory pool as a result of E OK issuing irel_mpf z Forced release from waiting accept rel_wai while waiting E_RLWAI Forced release from waiting accept irel_wai while waiting E_RLWAI Polling failure or timeout E_TMOUT The following describes an example for coding this service call include lt kernel h gt Standard header file definition include lt kernel_id h gt System information header file definition void task VP_INT exinf ER ercd Declares variable ID mpfid 1 Declares and initializes variable VP p_blk Declares variable TMO tmout 3600 Declares and initializes variable Acquire fixed sized memory block with timeout ercd tget_mpf mpfid amp p_bik tmout if ercd E_OK EEEE Normal termination
174. cing only the current state and reason for wait among task information Response becomes faster than using ref_tsk or iref_tsk because only a few information items are acquired Note For details about the task state packet simplified version refer to 15 2 2 Task state packet simplified version Return value Macro Value Description E OK 0 Normal completion R20UT2889EJ0101 Rev 1 01 2tENESAS Page 190 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 16 SERVICE CALLS Macro Value Description 18 Invalid ID number tskid lt 0x0 tskid gt Maximum ID number When this service call was issued from a non task TSK_SELF was specified tskid E_ CTX Context error This service call was issued in the CPU locked state E_NOEXS Non existent object Specified task is not registered R20UT2889EJ0101 Rev 1 01 Sep 30 2015 ztENESAS Page 191 of 366 RI850V4 V2 16 2 2 Task dependent synchronization functions CHAPTER 16 SERVICE CALLS The following shows the service calls provided by the RI850V4 as the task dependent synchronization functions Table 16 2 Task Dependent Synchronization Functions Service Call Function Origin of Service Call slp_tsk Put task to sleep waiting forever Task tslp_tsk Put task to sleep with timeout Task wup_tsk Wakeup task na Non task Initiali
175. clude lt kernel_id h gt System information header file definition void task VP_INT exinf dis dsp Disable dispatching sea aee Dispatching disabled state ena_dsp Enable dispatching Note 1 This service call does not perform queuing of enable requests If the system is in the dispatch enabled state therefore no processing is performed but it is not handled as an error R20UT2889EJ0101 Rev 1 01 2tENESAS Page 118 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 8 SYSTEM STATE MANAGEMENT FUNCTIONS Note 2 If a service call such as wai_sem wai_flg that may move the status of an invoking task is issued from when dis_dsp is issued until this service call is issued the RI850V4 returns E_CTX regardless of whether the required condition is immediately satisfied R20UT2889EJ0101 Rev 1 01 ztENESAS Page 119 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 8 SYSTEM STATE MANAGEMENT FUNCTIONS 8 10 Reference Dispatching State The dispatch disabled state is referenced by issuing the following service call from the processing program sns_dsp This service call acquires the system status type when this service call is issued dispatch disabled state or dispatch enabled state When this service call is terminated normally the acquired system state type TRUE dispatch disabled state FALSE dispatch enabled state is returned The following describes an example for coding this service call include lt
176. d for sematr is TA_TFIFO or TA_TPRI TA_TFIFO Task wait queue is in FIFO order TA_TPRI Task wait queue is in task priority order 3 Initial resource count isemcnt Specifies the initial resource count for a semaphore A value from 0x0 to Maximum resource count maxsem can be specified for isemcnt 4 Maximum resource count maxsem Specifies the maximum resource count for a semaphore A value from 0x1 to Oxffff can be specified for maxsem R20UT2889EJ0101 Rev 1 01 ztENESAS Page 315 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 17 SYSTEM CONFIGURATION FILE 17 5 3 Eventflag information The eventflag information defines ID number flgid Attribute flgatr Initial bit pattern iflgotn for an eventtflag The number of items that can be defined as eventtflag information is limited to one for each ID number The following shows the eventtflag information format CRE_FLG flgid flgatr iflgptn The items constituting the eventflag information are as follows 1 ID number figid Specifies the ID number for an eventflag A value from 0x1 to Oxff or a name can be specified for figid Note When a name is specified the CF850V4 automatically assigns an ID number The CF850V4 outputs the relationship between a name and an ID number to the system information header file in the following format define flgid value Attribute flgatr Specifies the attribute for an eventtflag The keyword that can be sp
177. d in the CPU locked state Object state error E_OBJ 41 Specified task is in the DORMANT state R20UT2889EJ0101 Rev 1 01 Sep 30 2015 2tENESAS Page 196 of 366 RI850V4 V2 CHAPTER 16 SERVICE CALLS Macro Value Description Non existent object E NOEXS 42 Specified task is not registered Queue overflow E _QOVR 43 Wakeup request count exceeded 127 R20UT2889EJ0101 Rev 1 01 Sep 30 2015 ztENESAS Page 197 of 366 RI850V4 V2 CHAPTER 16 SERVICE CALLS can_wup ican_wup Outline Cancel task wakeup requests C format ER_UINT can_wup ID tskid ER_UINT ican_wup ID tskid j Parameter s V O Parameter Description ID number of the task for cancelling wakeup requests ID tskid TSK_SELF Invoking task Value ID number of the task for cancelling wakeup requests Explanation These service calls cancel all of the wakeup requests queued to the task specified by parameter tskid the wakeup request counter is set to 0x0 When this service call is terminated normally the number of cancelled wakeup requests is returned Return value Macro Value Description Invalid ID number tskid lt 0x0 E_ID 18 tskid gt Maximum ID number When this service call was issued from a non task TSK_SELF was specified tskid Context error E_CTX 25 This service call was issued in the CPU l
178. data structure Note 1 Messages are queued to the target mailbox wait queue in the order defined by queuing method during configuration FIFO order or priority order Note 2 With the RI850V4 mailbox only the start address of the message is handed over to the receiving processing program but the message contents are not copied to a separate area The message contents can therefore be rewritten even after this service call is issued Note 3 For details about the message packet refer to 15 2 6 Message packet R20UT2889EJ0101 Rev 1 01 RENESAS Sep 30 2015 Page 77 of 366 CHAPTER 5 SYNCHRONIZATION AND COMMUNICATION RI850V4 V2 FUNCTIONS 5 5 4 Receive from mailbox A message is received infinite wait polling or with timeout by issuing the following service call from the processing program rcv_mbx This service call receives a message from the mailbox specified by parameter mbxid and stores its start address in the area specified by parameter ppk_msg If no message could be received from the target mailbox no messages were queued to the wait queue when this service call is issued this service call does not receive messages but queues the invoking task to the target mailbox wait queue and moves it from the RUNNING state to the WAITING state message reception wait state The receiving WAITING state for a mailbox is cancelled in the following cases and then moved to the READY state Receivi
179. data_init 357 B 1 5 kernel_const_trace const 357 B 1 6 kernel_data_trace bss 358 B 1 7 kernel_work 359 B 1 8 sec_nam user definied area 361 APPENDIX C SUPPORT FOR FLOATING POINT OPERATION COPROCESSOR 362 RI850V4 V2 CHAPTER1 OVERVIEW CHAPTER 1 OVERVIEW 1 1 Outline The RI850V4 is a built in real time multi task OS that provides a highly efficient real time multi task environment to increases the application range of processor control units The RI850V4 is a high speed compact OS capable of being stored in and run from the ROM of a target system It can also be used in RH850 multi core devices 1 1 1 Real Time OS Control equipment demands systems that can rapidly respond to events occurring both internal and external to the equipment Conventional systems have utilized simple interrupt handling as a means of satisfying this demand As control equipment has become more powerful however it has proved difficult for systems to satisfy these requirements by means of simple interrupt handling alone In other words the task of managing the order in which internal and external events are processed has become increasingly difficult as systems have increased in complexity and programs have become larger Real time OS has been designed to overcome this problem The main purpose of a real time OS is to respond to internal and external events rapidly and execute programs in the optimum order 1 1 2 Multi task
180. de so that base clock timer interrupts occur according to the Base clock interval tim_base defined in the Basic information in the system configuration file Note 2 Manipulate within this routine the RINT bit in the reset vector base address RBASE and the RINT bit in the exception handler vector address EBASE to specify whether operation should be done in the reduced mode which is necessary when using an entry file in the direct vector method Note 3 Manipulate within this routine the MKn bits or EIMKn bits in the El level interrupt mask register IMRm to enable acceptance of El level maskable interrupts 12 2 2 Define initialization routine The RI850V4 supports the static registration of initialization routines only They cannot be registered dynamically by issuing a service call from the processing program Static initialization routine registration means defining of initialization routines using static API ATT_INI in the system configuration file For details about the static API ATT_INI refer to 17 5 12 Initialization routine information R20UT2889EJ0101 Rev 1 01 ztENESAS Page 141 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 13 SCHEDULER CHAPTER 13 SCHEDULER This chapter describes the scheduler of the RI850V4 13 1 Outline The scheduling functions provided by the RI850V4 consist of functions manage decide the order in which tasks are executed by monitoring the transition states of dynamically changing tasks so tha
181. der file provided by the RI850V4 CC RH version Perek Add two underscores before and after rel Xep callee Specifies the handling of the EP register CCV850 version Build Option Description reserve_r2 Reserves the r2 register D_ ghs Definition of the compiler from Green Hills Software Add two underscores before and after ghs Build Option Description Xreserve_r2 Reserves the r2 register Definition of the compiler from Renesas Electronics R20UT2889EJ0101 Rev 1 01 Sep 30 2015 2tENESAS Page 20 of 366 RI850V4 V2 CHAPTER 3 TASK MANAGEMENT FUNCTIONS CHAPTER 3 TASK MANAGEMENT FUNCTIONS This chapter describes the task management functions performed by the RI850V4 3 1 Outline The task management functions provided by the RI850V4 include a function to reference task statuses such as priorities and detailed task information in addition to a function to manipulate task statuses such as generation activation and termination of tasks 3 2 Tasks A task is processing program that is not executed unless it is explicitly manipulated via service calls provided by the RI850V4 unlike other processing programs cyclic handler and interrupt handler and is called from the scheduler The RI850V4 manages the states in which each task may enter and tasks themselves by using management objects task management blocks corresponding to tasks one to one Note The
182. ducts are not subject to radiation resistance design Please be sure to implement safety measures to guard them against the possibility of physical injury and injury or damage caused by fire in the event of the failure of a Renesas Electronics product such as safety design for hardware and software including but not limited to redundancy fire control and malfunction prevention appropriate treatment for aging degradation or any other appropriate measures Because the evaluation of microcomputer software alone is very difficult please evaluate the safety of the final products or systems manufactured by you Please contact a Renesas Electronics sales office for details as to environmental matters such as the environmental compatibility of each Renesas Electronics product Please use Renesas Electronics products in compliance with all applicable laws and regulations that regulate the inclusion or use of controlled substances including without limitation the EU RoHS Directive Renesas Electronics assumes no liability for damages or losses occurring as a result of your noncompliance with applicable laws and regulations Renesas Electronics products and technology may not be used for or incorporated into any products or systems whose manufacture use or sale is prohibited under any applicable domestic or foreign laws or regulations You should not use Renesas Electronics products or technology described in this document for any purpose relating to military a
183. e Receive from data queue waiting forever 2tENESAS Page 69 of 366 CHAPTER 5 SYNCHRONIZATION AND COMMUNICATION RI850V4 V2 FUNCTIONS Note 1 Invoking tasks are queued to the reception wait queue of the target data queue in the order of the data reception request Note 2 If the receiving WAITING state for a data queue is forcibly released by issuing rel_wai or irel_wai the contents of the area specified by parameter p_data will be undefined R20UT2889EJ0101 Rev 1 01 2tENESAS Page 70 of 366 Sep 30 2015 CHAPTER 5 SYNCHRONIZATION AND COMMUNICATION RI850V4 V2 FUNCTIONS prcv_diq iprcv_dtq These service calls read data in the data queue area of the data queue specified by parameter dtqid and stores it to the area specified by parameter p_data If no data could be read from the data queue area of the target data queue no data has been written to the data queue area when either of these service calls is issued the service call does not read data but E_TMOUT is returned The following describes an example for coding this service call include lt kernel h gt Standard header file definition include lt kernel_id h gt System information header file definition void task VP_INT exinf ER ercd Declares variable ID dtqid ID_DTQ1 Declares and initializes variable VP_INT p data Declares variable Receive from data queue polling ercd prcv_dtq dtqid amp p
184. e If a relative path is specified the reference point of the path is the project folder If an absolute path is specified the reference point of the path is the project folder unless the drives are different The following macro name is available as an embedded macro BuildModeName Replaces with the build mode name If this field is left blank macro name BuildModeName will be displayed Output folder This property is not displayed when No It does not register the file that is added to the project ne in the Generate a file property is selected Default BuildModeName Directly enter to the text box or edit by the Browse For Folder Howto change dialog box which appears when clicking the button Restriction Up to 247 characters Specify the entry file If the file name is changed the name of the file displayed on the project tree Use the extension s If the extension is different or omitted s is automatically added You cannot specify the same file name as the value of the File name property in the System Information Table File category File name This property is not displayed when No It does not register the file that is added to the project ne in the Generate a file property is selected Default entry s How to change Directly enter to the text box Restriction Up to 259 characters R20UT2889EJ0101 Rev 1 01 2tENESAS Page 351 of 366 Sep 30 20
185. e Forced termination processing Note 1 The RI850V4 does not perform memory clear processing when getting the acquired fixed size memory block The contents of the got fixed size memory block are therefore undefined R20UT2889EJ0101 Rev 1 01 2tENESAS Page 92 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 7 MEMORY POOL MANAGEMENT FUNCTIONS Note 2 Invoking tasks are queued to the target fixed size memory pool wait queue in the order defined during configuration FIFO order or priority order Note 3 If the fixed size memory block acquisition wait state is cancelled because rel_wai or irel_wai was issued the contents in the area specified by parameter p_blk become undefined R20UT2889EJ0101 Rev 1 01 2tENESAS Page 93 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 7 MEMORY POOL MANAGEMENT FUNCTIONS pget_mpf ipget_mpf This service call acquires the fixed sized memory block from the fixed sized memory pool specified by parameter mpfid and stores the start address in the area specified by parameter p_bik If a fixed sized memory block could not be acquired from the target fixed sized memory pool no available fixed sized memory blocks exist when this service call is issued fixed sized memory block acquisition processing is not performed but E_TMOUT is returned The following describes an example for coding this service call include include ER ID VP void task lt kernel h gt lt kernel_id h gt VP_
186. e Maximum interrupt priority maxintpri during configuration This service call does not manipulate the ID bit in the program status word PSW Note 3 This service call does not cancel the dispatch disabled state that was set by issuing dis_dsp If the system status before the CPU locked state is entered was the dispatch disabled state the system status becomes the dispatch disabled state after this service call is issued Note 4 If a service call other than loc_cpu iloc_cpu and sns_xxx is issued from when loc_cpu or iloc_cpu is issued until this service call is issued the RI850V4 returns E_CTX Return value Macro Value Description E OK 0 Normal completion R20UT2889EJ0101 Rev 1 01 2tENESAS Page 294 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 16 SERVICE CALLS Outline Reference CPU state C format BOOL sns_loc Parameter s None Explanation void This service call acquires the system status type when this service call is issued CPU locked state or CPU unlocked state When this service call is terminated normally the acquired system state type TRUE CPU locked state FALSE CPU unlocked state is returned Return value Macro Value Description TRUE 1 Normal completion CPU locked state FALSE 0 Normal completion CPU unlocked state R20UT2889EJ0101 Rev 1 01 Sep 30 2015 2tENESAS Page 295 of 366 RI850V4 V2 CHAPTER 16 SERVICE CALL
187. e RI850V4 supports the static registration of extended service call routines only They cannot be registered dynamically by issuing a service call from the processing program Static extended service call routine registration means defining of extended service call routines using static API CRE_SVC in the system configuration file For details about the static API DEF SVC refer to 17 5 11 Extended service call routine information R20UT2889EJ0101 Rev 1 01 2tENESAS Page 138 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 11 SERVICE CALL MANAGEMENT FUNCTIONS 11 4 Invoke Extended Service Call Routine Extended service call routines can be called by issuing the following service call from the processing program cal_sve ical_svc These service calls call the extended service call routine specified by parameter fncd The following describes an example for coding this service call include lt kernel h gt Standard header file definition include lt kernel_id h gt System information header file definition void task VP_INT exinf ER_UINT ercd Declares variable FN fncd 1 Declares and initializes variable VP_INT parl 123 Declares and initializes variable VP_INT par2 456 Declares and initializes variable VP_INT par3 789 Declares and initializes variable Invok xtended service call routine ercd cal_svc fncd parl par2 par3 if ercd E_RSFN ee eee Normal term
188. e Realtime OS node or the system configuration file on the Project Tree panel displays the detailed information regarding the selected component Display image Property x 4 RI850V4 Property 4 Version Information CEE V2 01 00 Install folder C Program Files Renesas Electronics C5 CC RI850V4RH Register mode 32 reeister mode Kernel version This is the version of the RI850V4 to be used in this project RI850V4 Task Analyzer Explanation of each area 1 Version Information The detailed information on the version of the RI850V4 are displayed Display the version of RI850V4 to be used Kernel version Default The latest version of the installed RI850V4 package How to change Changes not allowed Display the folder in which RI850V4 to be used is installed with the absolute path Install folder Default The folder in which RI850V4 to be used is installed How to change Changes not allowed R20UT2889EJ0101 Rev 1 01 2tENESAS Page 343 of 366 Sep 30 2015 RI850V4 V2 APPENDIX A WINDOW REFERENCE Register mode Display the register mode set in the project Display the same value as the value of the Select register mode property of the build tool Default The register mode selected in the property of the build tool How to change Changes not allowed R20UT2889EJ0101 Rev 1 01 Sep 30 2015 ztENESAS Page 344 of 366 RI850V4 V2 APP
189. e SUSPENDED state to the READY state or from the WAITING SUSPENDED state to the WAITING state If a suspend request is queued subtraction result is other than 0x0 when this service call is issued the counter manipulation processing is not performed but only the suspend request counter decrement processing is executed The following describes an example for coding this service call include lt kernel h gt Standard header file definition include lt kernel_id h gt System information header file definition void task VP_INT exinf ID tskid ID_TSK1 Declares and initializes variable rsm_tsk tskid Resume suspended task Note This service call does not perform queuing of cancellation requests If the target task is in a state other than the SUSPENDED or WAITING SUSPENDED state E_OBu is therefore returned R20UT2889EJ0101 Rev 1 01 tENESAS Page 43 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 4 TASK DEPENDENT SYNCHRONIZATION FUNCTIONS 4 7 2 _ Forcibly resume suspended task The SUSPENDED state is forcibly cancelled by issuing the following service calls from the processing program frsm_tsk ifrsm_tsk These service calls cancel all of the suspend requests issued for the task specified by parameter tskid by setting the suspend request counter to 0x0 As a result the target task moves from the SUSPENDED state to the READY state or from the WAITING SUSPENDED state to the WAITING state The
190. e call was issued in the CPU locked state R20UT2889EJ0101 Rev 1 01 2tENESAS Page 282 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 16 SERVICE CALLS sta_cyc ista_cyc Outline Start cyclic handler operation C format ER sta_cyc ID cycid ER ista_cyc ID cycid Parameter s 1 0 Parameter Description l ID cycid ID number of the cyclic handler operation to be started Explanation This service call moves the cyclic handler specified by parameter cycid from the non operational state STP state to operational state STA state As a result the target cyclic handler is handled as an activation target of the RI850V4 The relative interval from when either of this service call is issued until the first activation request is issued varies depending on whether the TA_PHS attribute is specified for the target cyclic handler during configuration Ifthe TA_PHS attribute is specified The target cyclic handler activation timing is set based on the activation phases initial activation phase cycphs and activation cycle cyctim defined during configuration If the target cyclic handler has already been started however no processing is performed even if this service call is issued but it is not handled as an error If the TA_PHS attribute is not specified The target cyclic handler activation timing is set based on the activation phase activation cycle cyctim when this service call is issued This setting is pe
191. e dedicated to entry processing that is called without RI850V4 intervention when an interrupt occurs Therefore note the following points when coding interrupt Coding method Code it in assembly language according to the calling convention in the compiler used Stack switching There is no stack that requires switching before executing interrupt entry processing Therefore coding regarding stack switching is not required in interrupt entry processing Service call issue To achieve faster response for processing such as an Interrupt Handlers corresponding to an interrupt that has occurred the issue of service calls is prohibited during interrupt entry processing The following is a list of processes that should be executed in interrupt entry processing External label declaration Setting of branch destination address Branch to interrupt processing R20UT2889EJ0101 Rev 1 01 ztENESAS Page 133 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 10 INTERRUPT MANAGEMENT FUNCTIONS 10 3 Interrupt Handlers The interrupt handler is a routine dedicated to interrupt servicing that is activated when an El level maskable interrupt occurs The RI850V4 handles the interrupt handler as a non task module independent from tasks Therefore even if a task with the highest priority in the system is being executed the processing is suspended when an interrupt occurs and the control is passed to the interrupt handler The RI850V4 manages the sta
192. e for a mailbox is cancelled in the following cases and then moved to the READY state Receiving WAITING State for a Mailbox Cancel Operation Return Value A message was transmitted to the target mailbox as a result of issuing snd_mbx E OK A message was transmitted to the target mailbox as a result of issuing isnd_mbx E OK Forced release from waiting accept rel_wai while waiting E RLWAI R20UT2889EJ0101 Rev 1 01 tENESAS Page 246 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 16 SERVICE CALLS Receiving WAITING State for a Mailbox Cancel Operation Return Value Forced release from waiting accept irel_wai while waiting Polling failure or timeout E RIWAI E_TMOUT Note 1 Invoking tasks are queued to the target mailbox wait queue in the order defined during configuration FIFO order or priority order Note 2 If the message reception wait state is cancelled because rel_wai or irel_wai was issued or the wait time elapsed the contents in the area specified by parameter pok_msg become undefined Note 3 TMO_FEVR is specified for wait time tmout processing equivalent to rcv_mbx will be executed When TMO_POL is specified processing equivalent to prcv_mbx iprcv_mbx will be executed Note 4 For details about the message packet refer to 15 2 6 Message packet Return value Macro Value Description E OK 0 Normal completion Parameter error E P
193. e semaphore resource 51 5 2 4 Reference semaphore state 52 5 3 Eventflags 53 5 3 1 Create eventflag 53 5 3 2 Set eventflag 54 5 3 3 Clear eventflag 55 5 3 4 Wait for eventflag 56 5 3 5 Reference eventflag state 61 5 4 Data Queues 62 5 4 1 Create data queue 62 5 4 2 Send to data queue 63 5 4 3 Forced send to data queue 68 5 4 4 Receive from data queue 69 5 4 5 Reference data queue state 74 5 5 Mailboxes 75 5 5 1 Messages 75 5 5 2 Create mailbox 76 5 5 3 Send to mailbox 77 5 5 4 Receive from mailbox 78 5 5 5 Reference mailbox state 81 CHAPTER 6 EXTENDED SYNCHRONIZATION AND COMMUNICATION FUNCTIONS 82 6 1 Outline 82 6 2 Mutexes 82 6 2 1 Differences from semaphores 82 6 2 2 Create mutex 83 6 2 3 Lock mutex 84 6 2 4 Unlock mutex 87 6 2 5 Reference mutex state 88 CHAPTER 7 MEMORY POOL MANAGEMENT FUNCTIONS 89 7 1 Outline 89 7 2 User Own Coding Module 89 7 2 1 Post overflow processing 90 7 3 Fixed Sized Memory Pools 91 7 3 1 Create fixed sized memory pool 91 7 3 2 Acquire fixed sized memory block 92 7 3 3 Release fixed sized memory block 97 7 3 4 Reference fixed sized memory pool state 98 7 4 Variable Sized Memory Pools 99 7 4 1 Create variable sized memory pool 99 7 4 2 Acquire variable sized memory block 100 7 4 3 Release variable sized memory block 105 7
194. e sleeping state is cancelled in the following cases and then moved to the READY state Sleeping State Cancel Operation Return Value A wakeup request was issued as a result of issuing wup_tsk E OK A wakeup request was issued as a result of issuing iwup_tsk E OK Forced release from waiting accept rel_wai while waiting E RLWAI Forced release from waiting accept irel_ wai while waiting E RLWAI Return value Macro Value Description E OK 0 Normal completion Context error E CTX 25 This service call was issued from a non task This service call was issued in the CPU locked state This service call was issued in the dispatching disabled state Forced release from the WAITING state E_RLWAI 49 Accept rel_wai irel_wai while waiting R20UT2889EJ0101 Rev 1 01 Sep 30 2015 2tENESAS Page 193 of 366 RI850V4 V2 CHAPTER 16 SERVICE CALLS Outline Put task to sleep with timeout C format ER tslp_tsk TMO tmout Parameter s 1 0 Parameter Description Specified timeout unit millisecond TMO tmout TMO_FEVR Waiting forever TMO_POL Polling Value Specified timeout Explanation This service call moves an invoking task from the RUNNING state to the WAITING state sleeping state As a result the invoking task is unlinked from the ready queue and excluded from the RI850V4 scheduling subject If a wakeup request has been queued to
195. ecified for flgatris TA_TFIFO TA_TPRI TA_LWSGL TA_WMUL and TA_CLR Task queuing method TA_TFIFO Task wait queue is in FIFO order TA_TPRI Task wait queue is in task priority order Queuing count TA_WSGL Only one task is allowed to be in the WAITING state for the eventflag TA_WMUL Multiple tasks are allowed to be in the WAITING state for the eventflag Bit pattern clear TA_CLR Bit pattern is cleared when a task is released from the WAITING state for eventflag Note 1 If specification of TA_TFIFO and TA_TPRI is omitted tasks are queued in the order of bit pattern checking Note 2 If specification of TA_CLR is omitted not clear bit patterns if the required condition is satisfied is set Initial bit pattern iflgptn Specifies the initial bit pattern for an eventflag A value from 0x0 to Oxffffffff can be specifies for iflgptn R20UT2889EJ0101 Rev 1 01 2tENESAS Page 316 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 17 SYSTEM CONFIGURATION FILE 17 5 4 Data queue information The data queue information defines ID number dtqid Attribute dtqatr Data count dtqcnt memory area name sec_nam Reserved for future use dtq for a data queue The number of items that can be defined as data queue information is limited to one for each ID number The following shows the data queue information format CRE_DTQ dtqid dtgatr dtqcnt sec_nam dtq The items constituting the data queue information are as f
196. en the cfe file is chang Output folder BuildModeNa me File name kernel_idh Entry File Generate a file Yes lt updates the file when the cfe file is chang Output folder BuildModeNameX File name entry s Generate method Direct vector Specify an exception handler vector ac No Configurator Start Setting User options File Information 6 Set trace function Use the task analyzer tool a utility tool provided by the RI850V4 on the Task Analyzer tabbed page in the Property panel to specify the information necessary to analyze the execution history trace data of the processing program Figure 2 4 Task Analyzer Tab zJ RISSOW4 Property 4 Trace SS SSS Takes in trace chart by hardware trace mode w Selection of trace mode Selects the buffer holding trace and information to acquire by trace Hardware trace mode Hold the trace to debugging tool with trace memory Software trace mode Hold the trace to target RAM If this mode is selected the monitor control taking trace is linked automatically ie chart Take in the trace chart and the GPU usage rate The analyzable time is short Long statistics Take in the CPU usage rate Not take in the trace chart The analyzable time is long It can use only by software trace mode 7 Set build options Set the options for the compiler assembler linker and the like R20UT2889EJ0101 Rev 1 01 2tENESAS Page 18 of 366 Sep 30 2015 RI850V
197. ent pk_rdtq sdtqcent dtgatr dtqent pk_rdtq dtgqatr pk_rdtq dtqent Standard header file definition System information header file definition Declares and initializes variable Declares data structure Declares variable Declares variable Declares variable Declares variable Declares variable Reference data queue state Acquires existence of tasks waiting for data transmission Acquires existence of tasks waiting for data reception Reference the number of data elements in data queue Reference attribute Reference data count Note For details about the data queue state packet refer to 15 2 5 Data queue state packet R20UT2889EJ0101 Rev 1 01 Sep 30 2015 2tENESAS Page 74 of 366 CHAPTER 5 SYNCHRONIZATION AND COMMUNICATION RI850V4 V2 FUNCTIONS 5 5 Mailboxes The RI850V4 provides a mailbox as a communication function between tasks that hands over the execution result of a given processing program to another processing program The following shows a processing flow when using a mailbox Figure 5 4 Processing Flow Mailbox Task A Task B Priority High Priority Low Receive from mailbox Reception wait period Send to mailbox 5 5 1 Messages The information exchanged among processing programs via the mailbox is called messages Messages can be transmitted to any processing pr
198. entflag polling baat Mente INNANZAtONTOU twai_flg Wait for eventflag with timeout Task ref_flg Reference eventflag state Ei PON IAS Initializatiom rou iref_flg Reference eventflag state bias Non task Initialization rou R20UT2889EJ0101 Rev 1 01 Sep 30 2015 ztENESAS Page 214 of 366 RI850V4 V2 CHAPTER 16 SERVICE CALLS set_fig iset_flg Outline Set eventtflag C format ER set_flg ID flgid FLGPTIN setptn ER iset_flg ID flgid FLGPTN setptn Parameter s 0 Parameter Description ID flgid ID number of the eventflag to be set l FLGPTN setptn Bit pattern to set Explanation These service calls set the result of logical OR operating the bit pattern of the eventflag specified by parameter flgid and the bit pattern specified by parameter setptn as the bit pattern of the target eventflag If the required condition of the task queued to the target eventflag wait queue is satisfied when this service call is issued the relevant task is unlinked from the wait queue at the same time as bit pattern setting processing As a result the relevant task is moved from the WAITING state WAITING state for an eventflag to the READY state or from the WAITING SUSPENDED state to the SUSPENDED state Note 1 If the bit pattern set to the target eventtflag is B 1100 and the bit pattern specified by parameter setptn is B 1010 when this service call is issued the bit pattern of the
199. er Task prev_dtq Receive from data queue polling Non ta k Initialization TOU iprev_dtq Receive from data queue polling i Nontask nitalzation rou trev_dtq Receive from data queue with timeout Task ref_dtq Reference data queue state i Nonitask Initalizatiom rour iref_dtq Reference data queue state Onis Ne ANOnsT OU R20UT2889EJ0101 Rev 1 01 tENESAS Page 225 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 16 SERVICE CALLS Outline Send to data queue waiting forever C format ER snd_dtq ID dtqid VP_INT data Parameter s 1 0 Parameter Description l ID dtqid ID number of the data queue to which the data element is sent VP_INT data Data element to be sent to the data queue Explanation This service call writes data specified by parameter data to the data queue area of the data queue specified by parameter dtqid If there is no available space for writing data in the data queue area of the target data queue when this service call is issued this service call does not write data but queues the invoking task to the transmission wait queue of the target data queue and moves it from the RUNNING state to the WAITING state data transmission wait state The sending WAITING state for a data queue is cancelled in the following cases and then moved to the READY state Sending WAITING State for a Data Queue Cancel Operation Return Value Available space was secured in t
200. er intended nor authorized for use in products or systems that may pose a direct threat to human life or bodily injury artificial life support devices or systems surgical implantations etc or may cause serious property damages nuclear reactor control systems military equipment etc You must check the quality grade of each Renesas Electronics product before using it in a particular application You may not use any Renesas Electronics product for any application for which it is not intended Renesas Electronics shall not be in any way liable for any damages or losses incurred by you or third parties arising from the use of any Renesas Electronics product for which the product is not intended by Renesas Electronics You should use the Renesas Electronics products described in this document within the range specified by Renesas Electronics especially with respect to the maximum rating operating supply voltage range movement power voltage range heat radiation characteristics installation and other product characteristics Renesas Electronics shall have no liability for malfunctions or damages arising out of the use of Renesas Electronics products beyond such specified ranges Although Renesas Electronics endeavors to improve the quality and reliability of its products semiconductor products have specific characteristics such as the occurrence of failure at a certain rate and malfunctions under certain use conditions Further Renesas Electronics pro
201. ervice call was issued in the CPU locked state This service call was issued in the dispatching disabled state Illegal service call use E ILUSE 28 There is already a task waiting for an eventflag with the TA_WSGL attribute Non existent object E NOEXS 42 Specified eventflag is not registered Forced release from the WAITING state E RLWAI 49 Accept rel_wai irel_wai while waiting R20UT2889EJ0101 Rev 1 01 tENESAS Page 219 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 16 SERVICE CALLS Outline Wait for eventflag polling C format ER pol_flg ID flgid FLGPIN waiptn MODE wfmode FLGPIN p_flgptn ER ipol_flg ID flgid FLGPTN waiptn MODE wfmode FLGPIN p_flgptn Parameter s V 0 Parameter Description ID flgid ID number of the eventflag to wait for l FLGPTN waiptn Wait bit pattern Wait mode l MODE wfmode TWF_ANDW AND waiting condition TWF_ORW OR waiting condition O FLGPTN p flgptn Bit pattern causing a task to be released from waiting Explanation This service call checks whether the bit pattern specified by parameter waiptn and the bit pattern that satisfies the required condition specified by parameter wfmode are set to the eventflag specified by parameter flgid If the bit pattern that satisfies the required condition has been set to the target eventtflag the bit pattern of the target eventtflag is stored in the area specified by parameter p_flgptn If the b
202. es provided for indirectly manipulating the resources tasks semaphores etc managed by the RI850V4 from a processing program The service calls provided by the RI850V4 are listed below by management module Task management functions act_tsk iact_tsk can_act ican_act sta_tsk ista_tsk ext_tsk ter_tsk chg_pri ichg_pri get_pri iget_pri ref_tsk iref_tsk ref_tst iref_tst Task dependent synchronization functions slp_tsk tslp_tsk wup_tsk iwup_tsk can_wup ican_wup rel_wai irel_wai sus_tsk isus_tsk rsm_tsk irsm_tsk frsm_tsk ifrsm_tsk dly_tsk Synchronization and communication functions semaphores wai_sem pol_sem ipol_sem twai_sem sig_sem isig_sem ref_sem iref_sem Synchronization and communication functions eventflags set_flg iset_flg clr_flg iclr_flg wai_flg pol_flg ipol_flg twai_flg ref_flg iref_flg Synchronization and communication functions data queues snd_dtq psnd_diq ipsnd_dtgq tsnd_dtg fsnd_dtg ifsnd_dtq rcv_dtg prcv_dtq iprcv_dtq trcv_dtq ref_dtq iref_dtq Synchronization and communication functions mailboxes snd_mbx isnd_mbx rcv_mbx prcv_mbx iprcv_mbx trcv_mbx ref_mbx iref_mbx Extended synchronization and communication functions mutexes loc_mtx ploc_mtx tloc_mtx unl_mtx ref_mtx iref_mtx Memory pool management functions fixed sized memory pools get_mpf pget_mpf ipget_mpf tget_mpf rel_mpf irel_mpf ref_mpf
203. et R20UT2889EJ0101 Rev 1 01 ztENESAS Page 126 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 9 TIME MANAGEMENT FUNCTIONS 9 5 The system time can be referenced by issuing the following service call from the processing program Reference System Time get_tim iget_tim These service calls store the RI850V4 system time unit millisecond into the area specified by parameter p_systim The following describes an example for coding this service call include include lt kernel h gt lt kernel_id h gt void task VP_INT exinf SYSTIM p_systim UW ltime UH utime get_tim amp p_systim ltime p_systim 1time utime p_systim utime Standard header file definition System information header file definition Declares Declares Declares data structure variable variable Referenc System Time Acquirer system time lower 32 bits Acquirer system time higher 16 bits Note 1 Note 2 For details about the system time packet refer to 15 2 11 System time packet The RI850V4 ignores the numeric values that cannot be expressed as the system time values overflowed from the 48 bit width R20UT288 Sep 30 20 9EJ0101 Rev 1 01 15 ztENESAS Page 127 of 366 RI850V4 V2 CHAPTER 9 TIME MANAGEMENT FUNCTIONS 9 6 Start Cyclic Handler Operation Moving to the operational state STA state is implemented by issuing the follo
204. eter pk_rtsk The following describes an example for coding this service call include lt kernel h gt Standard header file definition include lt kernel_id h gt System information header file definition void task VP_INT exinf ID tskid 8 Declares and initializes variable T_RTSK pk_rtsk Declares data structure STA tskstat Declares variable PRI tskpri Declares variable STA tskwait Declares variable ID wobjid Declares variable TMO lefttmo Declares variable UINT actcnt Declares variable UINT wupent Declares variable UINT suscnt Declares variable ATR tskatr Declares variable PRI itskpri Declares variable ref_tsk tskid amp pk_rtsk Reference task state tskstat pk_rtsk tskstat Reference current state tskpri pk_rtsk tskpri Reference current priority tskwait pk_rtsk tskwait Reference reason for waiting wobjid pk_rtsk wobjid Reference object ID number for which the task is waiting lefttmo pk_rtsk lefttmo Reference remaining time until timeout actcnt pk_rtsk actcnt Reference activation request count wupent pk_rtsk wupcent Reference wakeup request count suscnt pk_rtsk suscnt Reference suspension count tskatr pk_rtsk tskatr Reference attribute itskpri pk_rtsk itskpri Reference initial priority Note For details about the t
205. f the bit pattern set to the target eventflag is B 1100 and the bit pattern specified by parameter setptn is B 1010 when this service call is issued the bit pattern of the target eventflag is set to B 1110 Note 2 When the TA_WMUL attribute is specified for the target eventflag the range of tasks to be checked on whether issuing of this service call satisfies the required condition differs depending on whether the TA_CLR attribute is also specified When TA_CLR is specified Check begins from the task at the head of the wait queue and stops at the first task whose required condition is satisfied When TA_CLR is not specified All tasks placed in the wait queue are checked R20UT2889EJ0101 Rev 1 01 2tENESAS Page 54 of 366 Sep 30 2015 CHAPTER 5 SYNCHRONIZATION AND COMMUNICATION RI850V4 V2 FUNCTIONS 5 3 3 Clear eventflag A bit pattern is cleared by issuing the following service call from the processing program clr_fig iclr_flg This service call sets the result of logical AND operating the bit pattern set to the eventflag specified by parameter flgid and the bit pattern specified by parameter clrptn as the bit pattern of the target eventflag The following describes an example for coding this service call include lt kernel h gt Standard header file definition include lt kernel_id h gt System information header file definition void task VP_INT exinf ID flgid ID_FLG1 Declares and initializes
206. f the definition of the Extended service call routine information ATT_INI_num The number of the definition of the Initialization routine information VATT_IDL_num The number of the definition of the Idle routine information The value defined in the Maximum number of interrupt handlers maxint Maxent Maximum value of exception code maxintno 7 The number of the definition of TA_ACT to initial activation state of Attribute A_ACT_num tskatr The number of the definition of TA_STA to initial activation state of Attribute A_STA_num cycatr R20UT2889EJ0101 Rev 1 01 Sep 30 2015 2tENESAS Page 355 of 366 RI850V4 V2 APPENDIX B SIZE OF MEMORY B 1 3 kernel_data The size of kernel_data section depends on the number of information items defined such as Task information and Semaphore information and the details of the definitions The following shows an expression required for estimation kernel_data section size In the expression align4 x means the result of aligning the value x to a 4 byte boundary KERNEL_DATA 68 32 CRE_TSK_num 8 CRE_SEM_num 8 CRE_FLG_num 8 CRE_DTQ_num 12 CRE_MBX_num 8 CRE_MTX_num 8 CREJ 8 CRE_MPL_num 8 CRE align4 maxtpri Note The keyword in the expression means as follows
207. f the target data queue as a result of issuing E OK ipsnd_dtq Data was written to the data queue area of the target data queue as a result of issuing tsnd_dtq E_OK Data was written to the data queue area of the target data queue as a result of issuing fsnd_dtq E_OK Data was written to the data queue area of the target data queue as a result of issuing E OK ifsnd_dtq Forced release from waiting accept rel_wai while waiting E_RLWAI Forced release from waiting accept irel_wai while waiting E_RLWAI Note 1 Invoking tasks are queued to the reception wait queue of the target data queue in the order of the data reception request Note 2 If the receiving Note 3 for a data queue is forcibly released by issuing rel_wai or irel_wai the contents of the area specified by parameter p_data will be undefined R20UT2889EJ0101 Rev 1 01 Sep 30 2015 2tENESAS Page 232 of 366 RI850V4 V2 CHAPTER 16 SERVICE CALLS Return value Macro Value Description E OK 0 Normal completion Invalid ID number EID 18 digid lt 0x0 dtgid gt Maximum ID number Context error E CTX 25 This service call was issued from a non task This service call was issued in the CPU locked state This service call was issued in the dispatching disabled state Non existent object E_NOEXS 42 Specified data queue is not registered Forced release from the WAITING state E_RLWAI 49 Accept rel_wai
208. fied by parameter tskid from the DORMANT state to the READY state As a result the target task is queued at the end on the ready queue corresponding to the initial priority and becomes subject to scheduling by the RI850V4 This service call does not perform queuing of activation requests If the target task is in a state other than the DORMANT state the status manipulation processing for the target task is therefore not performed but E_OBu is returned Specify for parameter stacd the extended information transferred to the target task Return value Macro Value Description E OK 0 Normal completion Invalid ID number E ID 18 tskid lt 0x0 tskid gt Maximum ID number Context error E CTX 25 This service call was issued in the CPU locked state Object state error E OBJ 41 Specified task is not in the DORMANT state Non existent object E NOEXS 42 Specified task is not registered R20UT2889EJ0101 Rev 1 01 Sep 30 2015 7tENESAS Page 181 of 366 RI850V4 V2 CHAPTER 16 SERVICE CALLS Outline Terminate invoking task C format void ext_tsk void Parameter s None Explanation This service call moves an invoking task from the RUNNING state to the DORMANT state As a result the invoking task is unlinked from the ready queue and excluded from the RI850V4 scheduling subject If an activation request has been queued to the invoking task the activation request cou
209. following describes an example for coding this service call include lt kernel h gt Standard header file definition void task VP_INT exinf ID tskid ID_TSK1 Declares and initializes variable frsm_tsk tskid Forcibly resume suspended task include lt kernel_id h gt System information header file definition Note This service call does not perform queuing of cancellation requests If the target task is in a state other than the SUSPENDED or WAITING SUSPENDED state E_OBu is therefore returned R20UT2889EJ0101 Rev 1 01 2tENESAS Page 44 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 4 TASK DEPENDENT SYNCHRONIZATION FUNCTIONS 4 8 Delay Task A task is moved to the delayed state by issuing the following service call from the processing program dly_tsk This service call moves the invoking task from the RUNNING state to the WAITING state delayed state As a result the invoking task is unlinked from the ready queue and excluded from the RI850V4 scheduling subject The delayed state is cancelled in the following cases and then moved to the READY state Delayed State Cancel Operation Return Value Delay time specified by parameter dlytim has elapsed E OK Forced release from waiting accept rel_wai while waiting E RLWAI Forced release from waiting accept irel_wai while waiting E RLWAI The following describes an example for coding this service call
210. functions of the RI850V4 consist of Semaphores Eventflags Data Queues and Mailboxes that are provided as means for realizing exclusive control queuing and communication among tasks 5 2 Semaphores In the RI850V4 non negative number counting semaphores are provided as a means exclusive control function for preventing contention for limited resources hardware devices library function etc arising from the required conditions of simultaneously running tasks The following shows a processing flow when using a semaphore Figure 5 1 Processing Flow Semaphore Task Acquire semaphore resource Exclusive control period Release semaphore resource 5 2 1 Create semaphore In the RI850V4 the method of creating a semaphore is limited to static creation Semaphores therefore cannot be created dynamically using a method such as issuing a service call from a processing program Static semaphore creation means defining of semaphores using static API CRE_SEM in the system configuration file For details about the static API CRE_SEM refer to 17 5 2 Semaphore information R20UT2889EJ0101 Rev 1 01 2tENESAS Page 47 of 366 Sep 30 2015 CHAPTER 5 SYNCHRONIZATION AND COMMUNICATION RI850V4 V2 FUNCTIONS 5 2 2 Acquire semaphore resource A resource is acquired waiting forever polling or with timeout by issuing the following service call from the processing program wai_sem This service call acquire
211. g executed its processing is suspended when an El level maskable interrupt occurs and control is passed to the interrupt handler Extended Service Call Routines This is a routine to which user defined functions are registered in the RI850V4 and will never be executed unless it is called explicitly using service calls provided by the RI850V4 The RI850V4 positions extended service call routines as extensions of the processing program that called the extended service call routine Note For details about the processing programs refer to CHAPTER 3 TASK MANAGEMENT FUNCTIONS CHAPTER 9 TIME MANAGEMENT FUNCTIONS CHAPTER 10 INTERRUPT MANAGEMENT FUNCTIONS CHAPTER 11 SERVICE CALL MANAGEMENT FUNCTIONS R20UT2889EJ0101 Rev 1 01 2tENESAS Page 14 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 2 SYSTEM CONSTRUCTION 2 4 Coding User Own Coding Module To support various execution environments the hardware dependent processing and various information required for the RI850V4 to execute processing are extracted as user own coding modules This enhances portability for various execution environments and facilitates customization as well The user own coding modules for the RI850V4 are classified into the following six types depending on the type of hardware dependent processing to be executed and the usage of the module Post overflow processing A routine dedicated to post processing function name _kernel_stk_overflow that is extracted as a
212. g irel_mopl z Forced release from waiting accept rel_wai while waiting E_RLWAI Forced release from waiting accept irel_wai while waiting E_RLWAI Note 1 The RI850V4 acquires variable size memory blocks in the unit of integral multiple of 4 If a value other than an integral multiple of 4 is specified for parameter blksz it is rounded up to be an integral multiple of 4 Note 2 Invoking tasks are queued to the target variable size memory pool wait queue in the order defined during configuration FIFO order or priority order Note 3 If the variable size memory block acquisition wait state is cancelled because rel_wai or irel_wai was issued the contents in the area specified by parameter p_blk become undefined R20UT2889EJ0101 Rev 1 01 2tENESAS Page 270 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 16 SERVICE CALLS Return value Macro Value Description E OK 0 Normal completion Parameter error E PAR 17 blksz 0x0 blksz gt Ox7fffffff Invalid ID number E ID 18 mplid lt 0x0 mplid gt Maximum ID number Context error This service call was issued from a non task E CTX 25 This service call was issued in the CPU locked state This service call was issued in the dispatching disabled state Non existent object E NOEXS 42 Specified variable sized memory pool is not registered Forced release from the WAITING state E RLWAI 49 Accept re
213. g state packet T_RFLG used when issuing ref_flg or iref_flg Definition of eventflag state packet T_RFLG is performed by the header file lt ri_root gt include os packet h which is called the from the standard header file lt ri_root gt include kernel h typedef struct t_rflg ID wtskid Existence of waiting task FLGPTN flgptn Current bit pattern ATR flgatr Attribute T_RFLG The following shows details on eventflag state packet T_RFLG wtskid Stores whether a task is queued to the event flag wait queue TSK_NONE Value flgptn No applicable task ID number of the task at the head of the wait queue Stores the Current bit pattern flgatr Stores the attribute queuing method queuing count etc Task queuing method bit 0 TA_TFIFO TA_TPRI Task wait queue is in FIFO order Task wait queue is in task priority order Queuing count bit 1 TA_WSGL TA_WMUL Only one task is allowed to be in the WAITING state for the eveniflag Multiple tasks are allowed to be in the WAITING state for the eventflag Bit pattern clear bit 2 TA_CLR Structure of flgatr Bit pattern is cleared when a task is released from the WAITING state for eventflag 15 2 1 0 i TA_TFIFO 0 TA_TPRI 1 TA_WSGL 0 TA_WMUL 1 TA_CLR 1 R20UT2889EJ0101 Rev 1 01 7tENESAS Page 159 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 15 DATA TYPES AND MACROS 15
214. g such as queue manipulation counter manipulation etc and the actual dispatch processing is delayed until ena_dsp is issued upon which the actual dispatch processing is performed in batch The following shows a processing flow when using this service call Figure 8 4 Disable Dispatching Task A Task B Priority High Priority Low Acquire semaphore resource Disable Dispatching Release semaphore resource Suppressed period Enable Dispatching The following describes an example for coding this service call include lt kernel h gt Standard header file definition include lt kernel_id h gt System information header file definition pragma rtos_task task pragma directive definition void task VP_INT exinf dis dsp Disable dispatching EEEE Dispatching disabled state ena_dsp Enable dispatching R20UT2889EJ0101 Rev 1 01 ztENESAS Page 116 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 8 SYSTEM STATE MANAGEMENT FUNCTIONS Note 1 The dispatch disabled state changed by issuing this service call must be cancelled before the task that issued this service call moves to the DORMANT state Note 2 This service call does not perform queuing of disable requests If the system is in the dispatch disabled state therefore no processing is performed but it is not handled as an error Note 3 If a service call such as wai_sem wai_flg that may move the status of an
215. gal service call use E_ILUSE 28 Multiple locking of a mutex Non existent object E_ NOEXS 42 Specified mutex is not registered Polling failure E_ TMOUT 50 The target mutex has been locked by another task R20UT2889EJ0101 Rev 1 01 tENESAS Page 252 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 16 SERVICE CALLS Outline Lock mutex with timeout C format ER tloc_mtx ID mtxid TMO tmout Parameter s 0 Parameter Description l ID mtxid ID number of the mutex to be locked Specified timeout unit millisecond TMO tmout TMO_FEVR Waiting forever TMO_POL Polling Value Specified timeout Explanation This service call locks the mutex specified by parameter mtxid If the target mutex could not be locked another task has been locked when this service call is issued this service call queues the invoking task to the target mutex wait queue and moves it from the RUNNING state to the WAITING state with timeout mutex wait state The WAITING state for a mutex is cancelled in the following cases and then moved to the READY state WAITING State for a Mutex Cancel Operation Return Value The locked state of the target mutex was cancelled as a result of issuing unl_mtx E OK The locked state of the target mutex was cancelled as a result of issuing ext_tsk E OK The locked state of the target mutex was cancelled as a result of issuing ter_tsk E
216. get eventflag R20UT2889EJ0101 Rev 1 01 7tENESAS Page 218 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 16 SERVICE CALLS Note 1 With the RI850V4 whether to enable queuing of multiple tasks to the event flag wait queue is defined during configuration If this service call is issued for the event flag TW_WSGL attribute to which a wait task is queued therefore E_ILUSE is returned regardless of whether the required condition is immediately satisfied TA_WSGL Only one task is allowed to be in the WAITING state for the eventtflag TA_WMUL Multiple tasks are allowed to be in the WAITING state for the eventflag Note 2 Invoking tasks are queued to the target event flag TA_WMUL attribute wait queue in the order defined during configuration FIFO order or priority order Note 3 The RI850V4 performs bit pattern clear processing 0x0 setting when the required condition of the target eventflag TA_CLR attribute is satisfied Note 4 If the WAITING state for an eventtflag is forcibly released by issuing rel_wai or irel_wai the contents of the area specified by parameter p_figptn will be undefined Return value Macro Value Description E OK 0 Normal completion Parameter error E PAR 17 waiptn 0x0 wmode is invalid Invalid ID number E ID 18 flgid lt 0x0 flgid gt Maximum ID number Context error This service call was issued from a non task E_CTX 25 This s
217. gnate aaa c as a file name the file is named as aaa c cfg C assembly language source files created in 2 3 Coding Processing Programs Processing programs tasks cyclic handlers interrupt handlers extended service call routines C assembly language source files created in 2 4 Coding User Own Coding Module User own coding module post overflow processing interrupt entry processing initialization routine idle routine boot processing system dependent information Trace information files provided by the RI850V4 Library files provided by the RI850V4 Kernel library Library files provided by the C compiler package Standard library Math library etc Note 1 If the system configuration file is added to the Project Tree panel the Real Time OS generated files node is appeared The following information files are appeared under the Real Time OS generated files node However these files are not generated at this point in time System information table file System information header file Entry file R20UT2889EJ0101 Rev 1 01 2tENESAS Page 16 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 2 SYSTEM CONSTRUCTION Figure 2 2 Project Tree Panel After Adding sys cfg Project Tree 8 o RH850 FIL RI850V4RH Project Ay CC RH Build Tool 4 RI850V4 Realtime OS E RH850 E1 LPD Debug Tool a yp File Been aom usr_stkovr s AEA em Realtime OS generated files i ker
218. gt include include void task VP_INT exinf Standard header file definition System information header file definition Lock the CPU CPU locked state Unlock the CPU R20UT2889EJ0101 Rev 1 01 Sep 30 2015 2tENESAS Page 113 of 366 RI850V4 V2 CHAPTER 8 SYSTEM STATE MANAGEMENT FUNCTIONS Note 1 This service call does not perform queuing of cancellation requests If the system is in the CPU unlocked state therefore no processing is performed but it is not handled as an error Note 2 This service call manipulates PMn bits in the priority mask register PMR to disable acceptance of El level maskable interrupts The PMn bits to be manipulated correspond to the interrupt priority range defined as the Maximum interrupt priority maxintpri during configuration Note 3 This service call does not cancel the dispatch disabled state that was set by issuing dis_dsp If the system status before the CPU locked state is entered was the dispatch disabled state the system status becomes the dispatch disabled state after this service call is issued Note 4 If a service call other than loc_cpu iloc_cpu and sns_xxx is issued from when loc_cpu or iloc_cpu is issued until this service call is issued the RI850V4 returns E_CTX R20UT2889EJ0101 Rev 1 01 ztENESAS Page 114 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 8 SYSTEM STATE MANAGEMENT FUNCTIONS 8 7 Reference CPU State The CPU locked state
219. guration file For details about the static API CRE_MBxX refer to 17 5 5 Mailbox information R20UT2889EJ0101 Rev 1 01 2tENESAS Page 76 of 366 Sep 30 2015 CHAPTER 5 SYNCHRONIZATION AND COMMUNICATION RI850V4 V2 FUNCTIONS 5 5 3 Send to mailbox A message is transmitted by issuing the following service call from the processing program snd_mbx isnd_mbx This service call transmits the message specified by parameter pk_msg to the mailbox specified by parameter mbxid queues the message in the wait queue If a task is queued to the target mailbox wait queue when this service call is issued the message is not queued but handed over to the relevant task first task of the wait queue As a result the relevant task is unlinked from the wait queue and is moved from the WAITING state receiving WAITING state for a mailbox to the READY state or from the WAITING SUSPENDED state to the SUSPENDED state The following describes an example for coding this service call void task VP_INT exinf T_MSG_PRI pk_msgj Declares data structure Send to mailbox snd_mbx mbxid T_MSG pk_ msg include lt kernel h gt Standard header file definition include lt kernel_id h gt System information header file definition ID mbxid ID_MBX1 Declares and initializes variable Secures memory area for message Creates message contents pk_msg gt msgpri 8 Initializes
220. handler and switches to the relevant stack when returning control from the cyclic handler to the processing program in which a base clock timer interrupt occurred and caused activation of the cyclic handler Therefore coding regarding stack switching is not required in a cyclic handler Service call issue The RI850V4 handles the cyclic handler as a non task Service calls that can be issued in cyclic handlers are limited to the service calls that can be issued from non tasks Note 1 If a service call isig_sem iset_flg etc accompanying dispatch processing task scheduling processing is issued in order to quickly complete the processing in the cyclic handler during the interval until the processing in the cyclic handler ends the RI850V4 executes only processing such as queue manipulation counter manipulation etc and the actual dispatch processing is delayed until a return instruction is issued by the cyclic handler upon which the actual dispatch processing is performed in batch Note 2 For details on the valid issue range of each service call refer to Table 16 1 to Table 16 12 Acceptance of El level maskable interrupts When passing control to a cyclic handler the RI850V4 enables acceptance of El level maskable interrupts by manipulating the PMn bits in the priority mask register PMR and the ID bit in the program status word PSW and issuing the eiret instruction clearing the in service priority register ISPR Therefore if a
221. he data queue area of the target data queue as a result of E OK issuing rcv_diq Available space was secured in the data queue area of the target data queue as a result of E OK issuing prcv_diq Available space was secured in the data queue area of the target data queue as a result of E OK issuing iprcv_dtq a Available space was secured in the data queue area of the target data queue as a result of E OK issuing trcv_diq Forced release from waiting accept rel_wai while waiting E_RLWAI Forced release from waiting accept irel_wai while waiting E_RLWAI If a task has been queued to the reception wait queue of the target data queue when this service call is issued this service call does not write data but transfers the data to the task As a result the task is unlinked from the reception wait queue and moves from the WAITING state data reception wait state to the READY state or from the WAITING SUSPENDED state to the SUSPENDED state Note 1 Note 2 Data is written to the data queue area of the target data queue in the order of the data transmission request Invoking tasks are queued to the transmission wait queue of the target data queue in the order defined during configuration FIFO order or priority order R20UT2889EJ0101 Rev 1 01 Sep 30 2015 2tENESAS Page 226 of 366 RI850V4 V2 CHAPTER 16 SERVICE CALLS Return value Macro Value Description E OK 0 Normal completion Inv
222. he objectives that eliminate specified probable activation option character count restrictions in the command lines Description formats of the command file are described below 1 5 Character code Create a command file using ASCII code Note Shift JIS and EUC JP codes can be used only for comments Comment A line beginning with is handled as a comment Delimiter A space a tab or a new line character is handled as a delimiter Maximum number of lines Up to 50 lines can be coded in a command file Maximum number of characters Up to 16 384 characters per line can be coded in a command file An example of a command file is shown below In this example the following activation options are included Target processor name r7f701203 Device file search folder C CS CC Device RH850 Devicefile System information table file name sit s Entry file name entry s System information header file name kernel_id h C compiler package type REL Command search path for C compiler package C CS CC CC RH V1 00 00 bin Header file declaration search folder C tmp inc850 and C Program Files Sample include Vector address 0x200 System configuration file name sys cfg Figure 18 1 Example of Command File Description Command File cpu rf701z03 devpath C cS cc Device RH850 Devicefile i e d kernel_id h T C cs cc CC RH V1 00 00 bin I ebase 0x200 sys cfg sit s entry s REL C tmp inc85
223. he reception wait queue and moves from the WAITING state data reception wait state to the READY state or from the WAITING SUSPENDED state to the SUSPENDED state Note Data is written to the data queue area of the target data queue in the order of the data transmission request Return value Macro Value Description E OK 0 Normal completion Invalid ID number E_ID 18 dtqid lt 0x0 dtqid gt Maximum ID number Context error E CTX 25 This service call was issued in the CPU locked state Non existent object E_ NOEXS 42 Specified data queue is not registered Polling failure E_ TMOUT 50 There is no space in the target data queue R20UT2889EJ0101 Rev 1 01 tENESAS Page 228 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 16 SERVICE CALLS Outline Send to data queue with timeout C format ER tsnd_dtq ID dtgid VP_INT data TMO tmout Parameter s 0 Parameter Description l ID dtqid ID number of the data queue to which the data element is sent l VP_INT data Data element to be sent to the data queue Specified timeout unit millisecond TMO tmout TMO_FEVR Waiting forever TMO_POL Polling Value Specified timeout Explanation This service call writes data specified by parameter data to the data queue area of the data queue specified by parameter digid If there is no available space for writing data in the data queue area of
224. header file lt ri_root gt include kernel h typedef struct t_rmpf ID wtskid Existence of waiting task UINT fblkent Number of free memory blocks ATR mpfatr Attribute ID memid Reserved for future use T_RMPF The following shows details on fixed sized memory pool state packet T_RMPF wtskid Stores whether a task is queued to the fixed size memory pool TSK_NONE No applicable task Value ID number of the task at the head of the wait queue fblkent Stores the number of free memory blocks mpfatr Stores the attribute queuing method Task queuing method bit 0 TA_TFIFO Task wait queue is in FIFO order TA_TPRI Task wait queue is in task priority order Structure of mpfatr 15 0 L TA_TFIFO 0 TA_TPRI 1 memid System reserved area R20UT2889EJ0101 Rev 1 01 7tENESAS Page 164 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 15 DATA TYPES AND MACROS 15 2 10 Variable sized memory pool state packet The following shows variable sized memory pool state packet T_RMPL used when issuing ref_mpl or iref_mopl Definition of variable sized memory pool state packet T_RMPL is performed by the header file lt ri_root gt include os packet h which is called from the standard header file lt ri_root gt include kernel h typedef struct t_rmpl ID wt skid Existence of waiting task SIZE fmplsz Total size of free memory blocks UINT fblksz Maximum me
225. hen moved to the READY state WAITING State for a Fixed sized Memory Block Cancel Operation Return Value A fixed sized memory block was returned to the target fixed sized memory pool as a result of E OK issuing rel_mpf A fixed sized memory block was returned to the target fixed sized memory pool as a result of E OK issuing irel_mpf Forced release from waiting accept rel_wai while waiting E RLWAI Forced release from waiting accept irel_wai while waiting E RLWAI Polling failure or timeout E TMOUT Note 1 The RI850V4 does not perform memory clear processing when acquiring a fixed sized memory block The contents of the acquired fixed sized memory block are therefore undefined Note 2 If no fixed sized memory blocks can be acquired from the target fixed sized memory pool no available fixed sized memory blocks exist when this service call is issued the contents in the area specified by parameter p_blk become undefined R20UT2889EJ0101 Rev 1 01 2tENESAS Page 263 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 16 SERVICE CALLS Note 3 If the fixed size memory block acquisition wait state is cancelled because rel_wai or irel_wai was issued or the wait time elapsed the contents in the area specified by parameter p_blk become undefined Note 4 TMO_FEVR is specified for wait time tmout processing equivalent to get_mpf will be executed When TMO_POL is specified processing equivalent to pget_mpf ipget_mpf
226. iction 0x0 Oxffffffff 4 Configurator Start Setting category The activation option for the CF850V4 configurator can be specified User options Specify the desired user option to be passed to CF850V4 Default How to change Enter directly in the text box Restriction Specifies a PE number For details of value peid value setting see 18 2 1 Activating from command line Note Configurator Start Setting should be specified for each project that uses the RI850V4 and multiple PE numbers cannot be specified as the user option at the same time Therefore only a single PE should be handled in each project that uses the RI850V4 R20UT2889EJ0101 Rev 1 01 Sep 30 2015 2tENESAS Page 352 of 366 RI850V4 V2 APPENDIX B SIZE OF MEMORY APPENDIX B SIZE OF MEMORY This appendix explains the size of the memory area B 1 Description The memory areas used and managed by the RI850V4 are divided into eight sections by use Table B 1 Memory Area Section Name Outline kernel_system Area where executable code of RI850V4 is allocated kernel_const Area where static data of RI850V4 is allocated kernel_data Area where dynamic data of RI850V4 is allocated kernel_data_init Area where kernel initialization flag of RI850V4 is allocated kernel_const_trace const Area where static data of trace function is allocated kernel_data_trace bss Area
227. id Declares variable iget_tid amp p_tskid Reference task ID in the RUNNING state return Terminate interrupt handler Note This service call stores TSK_NONE in the area specified by parameter p_tskid if no tasks that have entered the RUNNING state exist all tasks in the IDLE state R20UT2889EJ0101 Rev 1 01 ztENESAS Page 110 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 8 SYSTEM STATE MANAGEMENT FUNCTIONS 8 5 Lock the CPU A task is moved to the CPU locked state by issuing the following service call from the processing program loc_cpu iloc_cpu These service calls change the system status type to the CPU locked state As a result El level maskable interrupt acknowledgment processing is prohibited during the interval from this service call is issued until unl_cpu or iunl_cpu is issued and service call issue is also restricted The service calls that can be issued in the CPU locked state are limited to the one listed below Service Call Function loc_cpu iloc_cpu Lock the CPU unl_cpu iunl_cpu Unlock the CPU sns_loc Reference CPU state sns_dsp Reference dispatching state sns_ctx Reference contexts sns_dpn Reference dispatch pending state If an El level maskable interrupt is created during this period the RI850V4 delays transition to the relevant interrupt processing interrupt handler until either unl_cpu or iunl_cpu is issued The following shows a processing flow when
228. ied by environment variable such as PATH Note 1 Specify the command search path name lt Compiler path gt within 255 characters Note 2 When the search path includes a space surround lt Compiler path gt by double quotation marks R20UT2889EJ0101 Rev 1 01 2tENESAS Page 331 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 18 CONFIGURATOR CF850V4 A lt nclude path gt Specifies the command search lt nclude path gt folder for lt Header file gt specified by Header file declaration If omitted The CF850V4 starts searching from a folder where the input file specified by lt CF file gt is stored the current folder default search target folder of the C compiler package specified by t A lt TOOL name gt in that order Note 1 Specify the command search path name lt nclude path gt within 255 characters Note 2 When the search path includes a space surround lt nclude path gt by double quotation marks np Disables C preprocessor activation when the CF850V4 finished the analysis for syntax included in the system configuration file If omitted The CF850V4 activates the C preprocessor of the C compiler package specified by t A lt TOOL name gt intop lt nterrupt Base Address gt Specifies the base address of the interrupt handler address table which is necessary when the entry file is output with the table reference method If omitted If both this activation option and ebase lt Exception Base Address gt a
229. ified data queue is not registered Polling failure E_ TMOUT 50 No data exists in the target data queue R20UT2889EJ0101 Rev 1 01 tENESAS Page 234 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 16 SERVICE CALLS Outline Receive from data queue with timeout C format ER trev_dtq ID dtqid VP_INT p data TMO tmout Parameter s 0 Parameter Description l ID dtqid ID number of the data queue from which a data element is received O VP_INT p data Data element received from the data queue Specified timeout unit millisecond TMO tmout TMO_FEVR Waiting forever TMO_POL Polling Value Specified timeout Explanation This service call reads data in the data queue area of the data queue specified by parameter dtqid and stores it to the area specified by parameter p_data If no data could be read from the data queue area of the target data queue no data has been written to the data queue area when this service call is issued the service call does not read data but queues the invoking task to the reception wait queue of the target data queue and moves it from the RUNNING state to the WAITING state with time out data reception wait state The receiving WAITING state for a data queue is cancelled in the following cases and then moved to the READY state Receiving WAITING State for a Data Queue Cancel Operation Return Value Data was written to the data queue area of the target data q
230. igned long 32 bit value with unknown data type VP void Pointer to unknown data type FP void Processing unit start address pointer to a function INT signed int Signed 32 bit integer UINT unsigned int Unsigned 32 bit integer BOOL signed long Boolean value TRUE or FALSE FN signed short Function code ER signed long Error code ID signed short Object ID number ATR unsigned short Object attribute STAT unsigned short Object state MODE unsigned short Service call operational mode PRI signed short Priority SIZE unsigned long Memory area size in bytes TMO signed long Timeout unit millisecond RELTIM unsigned long Relative time unit millisecond VP_INT signed int Pointer to unknown data type or signed 32 bit integer R20UT2889EJ0101 Rev 1 01 2tENESAS Page 153 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 15 DATA TYPES AND MACROS Macro Data Type Description ER_BOOL signed long Error code or boolean value TRUE or FALSE ER_ID signed long Error code or object ID number ER_UINT signed int Error code or signed 32 bit integer FLGPTN unsigned int Bit pattern INTNO unsigned short Exception code R20UT2889EJ0101 Rev 1 01 ztENESAS Page 154 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 15 DATA TYPES AND MACROS 15 2 Packet Formats This section explains the data structures task state packet semaphore state packet or the like used when issuing a service call provided by the RI850V4 Be sure not to refer from
231. igptn If the bit pattern of the target eventflag does not satisfy the required condition when this service call is issued the invoking task is queued to the target eventflag wait queue As a result the invoking task is unlinked from the ready queue and is moved from the RUNNING state to the WAITING state WAITING state for an eventtflag The WAITING state for an eventflag is cancelled in the following cases and then moved to the READY state WAITING State for an Eventflag Cancel Operation Return Value A bit pattern that satisfies the required condition was set to the target eventflag as a result of E OK issuing set_flg A bit pattern that satisfies the required condition was set to the target eventflag as a result of E OK issuing iset_flg Forced release from waiting accept rel_wai while waiting E_RLWAI Forced release from waiting accept irel_wai while waiting E_RLWAI Polling failure or timeout E_TMOUT The following shows the specification format of required condition wfmode wfmode TWF_ANDW Checks whether all of the bits to which 1 is set by parameter waiptn are set as the target eventflag wfmode TWF_ORW Checks which bit among bits to which 1 is set by parameter waiptn is set as the target eventflag The following describes an example for coding this service call R20UT2889EJ0101 Rev 1 01 2tENESAS Page 59 of 366 Sep 30 2015 CHAPTER 5 SYNCHRONIZATION AND COMMUNICATION
232. ilbox from which a message is received O T_MSG ppk_msg Start address of the message packet received from the mailbox Message packet T_MSG typedef struct t_msg struct t_msg msgnext Reserved for future use T_MSG Message packet T_ MSG_PRI typedef struct t_msg_pri struct t_msg msgque Reserved for future use PRI msgpri Message priority T_MSG_PRI Explanation This service call receives a message from the mailbox specified by parameter mbxid and stores its start address in the area specified by parameter ppk_msg If no message could be received from the target mailbox no messages were queued to the wait queue when this service call is issued this service call does not receive messages but queues the invoking task to the target mailbox wait queue and moves it from the RUNNING state to the WAITING state message reception wait state The receiving WAITING state for a mailbox is cancelled in the following cases and then moved to the READY state Receiving WAITING State for a Mailbox Cancel Operation Return Value A message was transmitted to the target mailbox as a result of issuing snd_mbx E OK A message was transmitted to the target mailbox as a result of issuing isnd_mbx E OK Forced release from waiting accept rel_wai while waiting E RLWAI Forced release from waiting accept irel_wai while waiting E RLWAI Note 1 Invoking tasks are queued to the targe
233. illegal 0x8000 func The start character is illegal BASE func Data macro BASE is handled as a symbol name func 0x8000 It is not the format of offset Note Up to 4 095 characters can be specified for symbol names including offset and spaces Name In a system configuration file words starting with an alphabetic character a to z A to Z or underscore _ are regarded as names The CF850V4 distinguishes between symbol names and other names based on the context in the system configuration file Note Up to 255 characters can be specified for names R20UT2889EJ0101 Rev 1 01 2tENESAS Page 303 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 17 SYSTEM CONFIGURATION FILE Preprocessing directives The following preprocessing directives can be coded in a system configuration file define elif Helse endif if ifdef ifndef include undef Keywords The words shown below are reserved by the CFV850V4 as keywords Using these words for any other purpose specified is therefore prohibited ATT_INI CLK_INTNO CPU_TYPE CRE_CYC CRE_DTQ CRE_FLG CRE_MBX CRE_MPF CRE_MPL CRE_MTX CRE_SEM CRE_TSK DEF EXC DEF_FPSR DEF INH DEF_SVC DEF_TEX DEF_TIM INCLUDE INT_STK MAX_CYC MAX_DTQ MAX_FLG MAX_INT MAX_INTPRI MAX MBX MAX_MPF MAX_MPL MAX_MTX MAX_PRI MAX_SEM MAX SVC MAX_TSK MEM_AREA NULL SERVICECALL RI_SERIES SIZE_AUTO STK_CHK SYS_STK TA_ACT TA_ASM TA_CLR TA_DISINT TA_DISPREEMPT TA_ENAINT
234. imum interrupt priority is set to INTPRIO 8 Maximum number of interrupt handlers maxint Maximum value of exception code maxintno A value from 0x0 to 0x200 can be specified for maxint and a value from 0x1000 to 0x11ff can be specified for maxintno Note 1 Specify for maxint the total number of interrupt handlers defined in the Interrupt handler information Note 2 When cpu_name is specified as the CF850V4 activation option the maxintno setting becomes invalid and the maximum exception code specified in the device file is used R20UT2889EJ0101 Rev 1 01 2tENESAS Page 310 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 17 SYSTEM CONFIGURATION FILE 17 4 3 FPSR register information The FPSR register information defines the following item 1 FPSR register information fosr The initial FPSR register value specified in this item is loaded in the FPSR register at the initial activation of a processing program such as a task a cyclic handler or an interrupt handler The following shows the FPSR register information format DEF_FPSR fpsr The item constituting the FPSR register information is shown below 1 Initial FPSR register value fosr Specifies the initial value to be loaded in the FPSR at initial activation of a processing program A value from 0x0 to Oxffffffff can be specified for fpsr Note that operation is not guaranteed if a value outside the range allowed by hardware is specified See the hard
235. ination processing Note Extended service call routines that can be called using this service call are the routines whose transferred data total is less than four R20UT2889EJ0101 Rev 1 01 2tENESAS Page 139 of 366 Sep 30 2015 CHAPTER 12 SYSTEM CONFIGURATION MANAGEMENT RI850V4 V2 FUNCTIONS CHAPTER 12 SYSTEM CONFIGURATION MANAGE MENT FUNCTIONS This chapter describes the system configuration management functions performed by the RI850V4 12 1 Outline The RI850V4 provides as system configuration management functions related to the initialization routine called from Kernel Initialization Module 12 2 User Own Coding Module To support various execution environments the RI850V4 extracts from the system management functions the hardware dependent processing Initialization routine that is required to execute processing as a user own coding module This enhances portability for various execution environments and facilitates customization as well 12 2 1 Initialization routine The initialization routine is a routine dedicated to initialization processing that is extracted as a user own coding module to initialize the hardware dependent on the user execution environment such as the peripheral controller and is called from the Kernel Initialization Module The RI850V4 manages the states in which each initialization routine may enter and initialization routines themselves by using management objects initialization rout
236. include lt kernel h gt Standard header file definition include lt kernel_id h gt System information header file definition void task VP_INT exinf ER ercd Declares variable RELTIM dlytim 3600 Declares and initializes variable ercd dly_tsk dlytim Delay task if ercd E_OK lse if ercd E_RLWAI dese E Normal termination processing EEE Forced termination processing R20UT2889EJ0101 Rev 1 01 RENESAS Sep 30 2015 Page 45 of 366 RI850V4 V2 CHAPTER 4 TASK DEPENDENT SYNCHRONIZATION FUNCTIONS 4 9 Differences Between Wakeup Wait with Timeout and Time Elapse Wait Wakeup waits with timeout and time elapse waits differ on the following points Table 4 1 Differences Between Wakeup Wait with Timeout and Time Elapse Wait Wakeup Wait with Timeout Time Elapse Wait Service call that causes status change tslp_tsk dly_tsk Return value when timed out E TMOUT E OK Operation when wup_tsk or iwup_tsk Queues the wakeup request time Sa Wakeup a is issued elapse wait is not cancelled R20UT2889EJ0101 Rev 1 01 2tENESAS Page 46 of 366 Sep 30 2015 CHAPTER 5 SYNCHRONIZATION AND COMMUNICATION RI850V4 V2 FUNCTIONS CHAPTER 5 SYNCHRONIZATION AND COMMUNICA TION FUNCTIONS This chapter describes the synchronization and communication functions performed by the RI850V4 5 1 Outline The synchronization and communication
237. ine This is the first window to be opened when CS is launched This window is used to manipulate the CS components such as the build tool and resource information tool This window can be opened as follows Select Windows start gt All programs gt Renesas Electronics CS gt CS for CC RL78 RX RH850 Display image RH850_F1L_RI850V4RH CS for CC Project Tree File Edit View Project Build Debug Tool Window Help GR Start yO ol a Gl GR TESI SS I ES 82 Project Tree l ukali 22 Property TE S L RH850 FIL RI850V4RH Project A RISO Property 4 Version Information F R7F701007xAFP Microcontrolle Kernel version 2 01 00 F Install folder GC Program Files Renesas Register mode 32 register mode A CC RH Build Tool Kernel version This is the version of the RIS50V 4 to be used in this project ba X DISCONNE R20UT2889EJ0101 Rev 1 01 2tENESAS Page 337 of 366 Sep 30 2015 RI850V4 V2 APPENDIX A WINDOW REFERENCE Explanation of each area 1 Menu bar This area contains the following group of menus View menu The View menu shows the cascading menu to start the tools of Real Realtime OS Time OS Opens the Realtime OS Resource Information panel Resource Mmiormatiogn Note that this menu is disabled when the debug tool is not connected Performance Analyzer This menu is always disabled O
238. ine control blocks corresponding to initialization routines one to one The following shows a processing flow from when a reset interrupt occurs until the control is passed to the task Interrupt entry processing Boot processing Initialization routine Figure 12 1 Processing Flow Initialization Routine Kernel Initialization Module yf Basic form of initialization routines Code initialization routines by using the void type function that has one VP_INT type argument R20UT2889EJ0101 Rev 1 01 ztENESAS Page 140 of 366 Sep 30 2015 CHAPTER 12 SYSTEM CONFIGURATION MANAGEMENT RI850V4 V2 FUNCTIONS Extended information specified in Initialization routine information is set to argument exinf The following shows the basic form of initialization routine in C include lt kernel h gt Standard header file definition void inirtn VP_INT exinf return Terminate initialization routine Internal processing of initialization routine The RI850V4 executes the original initialization routine pre processing when passing control from the Kernel Initialization Module to an initialization routine as well as the original initialization routine post processing when returning control from the initialization routine to the Kernel Initialization Module Therefore note the following points when coding initialization routines Coding method Code initialization routines
239. invoking task is issued from when this service call is issued until ena_dsp is issued the RI850V4 returns E_CTX regardless of whether the required condition is immediately satisfied R20UT2889EJ0101 Rev 1 01 ztENESAS Page 117 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 8 SYSTEM STATE MANAGEMENT FUNCTIONS 8 9 Enable Dispatching The dispatch disabled state is cancelled by issuing the following service call from the processing program ena_dsp This service call changes the system status to the dispatch enabled state As a result dispatch processing task scheduling that has been disabled by issuing dis_dsp is enabled If a service call chg_pri sig_sem etc accompanying dispatch processing is issued during the interval from when dis_dsp is issued until this service call is issued the RI850V4 executes only processing such as queue manipulation counter manipulation etc and the actual dispatch processing is delayed until this service call is issued upon which the actual dispatch processing is performed in batch The following shows a processing flow when using this service call Figure 8 5 Enable Dispatching Task A Task B Priority High Priority Low Acquire semaphore resource Disable Dispatching Release semaphore resource Suppressed period Enable Dispatching The following describes an example for coding this service call include lt kernel h gt Standard header file definition in
240. ion Semaphore information Eventflag information Data queue information Mailbox information Mutex information Fixed sized memory pool information Variable sized memory pool information Cyclic handler information Interrupt handler information Extended service call routine information Initialization routine information Idle routine information R20UT2889EJ0101 Rev 1 01 2tENESAS Page 305 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 17 SYSTEM CONFIGURATION FILE 17 2 1 Cautions In the system configuration file describe the system configuration information Declarative Information System Information Static API Information in the following order 1 Declarative Information description 2 System Information description 3 Static API Information description The information items in the System Information group such as RI series information or Basic information and those in the Static API Information group such as Task information or Semaphore information can be coded in any order within each respective group The following illustrates how the system configuration file is described Figure 17 1 System Configuration File Description Format Declarative Information Header file declaration description JE ee PR dds System Information RI series information etc description JE coat ese Static API Information Task information etc description ee eee a
241. ion of sec_nam is omitted the task stack is allocated to kernel_work section Note 2 The stack size that is actually secured is calculated as the specified stack size plus ctxsz size of context area of interrupt handler See 2 Task stack for details about ctxsz Reserved for future use stk System reserved area Values that can be specified for stk are limited to NULL characters R20UT2889EJ0101 Rev 1 01 ztENESAS Page 314 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 17 SYSTEM CONFIGURATION FILE 17 5 2 Semaphore information The semaphore information defines ID number semid Attribute sematr Initial resource count isemcnt Maximum resource count maxsem for a semaphore The number of items that can be defined as semaphore information is limited to one for each ID number The following shows the semaphore information format CRE_SEM semid sematr isemcnt maxsem The items constituting the semaphore information are as follows 1 ID number semid Specifies the ID number for a semaphore A value from 0x1 to Oxff or a name can be specified for semid Note When a name is specified the CF850V4 automatically assigns an ID number The CF850V4 outputs the relationship between a name and an ID number to the system information header file in the following format define semid value 2 Attribute sematr Specifies the task queuing method for a semaphore The keyword that can be specifie
242. irel_wai while waiting R20UT2889EJ0101 Rev 1 01 Sep 30 2015 ztENESAS Page 233 of 366 RI850V4 V2 CHAPTER 16 SERVICE CALLS Outline Receive from data queue polling C format ER prev_dtq ID dtqid VP_INT p_data ER iprcev_dtq ID dtqid VP_INT p_data Parameter s 0 Parameter Description ID dtqid ID number of the data queue from which a data element is received O VP_INT p data Data element received from the data queue Explanation s These service calls read data in the data queue area of the data queue specified by parameter dtqid and stores it to the area specified by parameter p_data If no data could be read from the data queue area of the target data queue no data has been written to the data queue area when either of these service calls is issued the service call does not read data but E_TMOUT is returned Note If no data could be read from the data queue area of the target data queue no data has been written to the data queue area when either of these service calls is issued the contents in the area specified by parameter p_data become undefined Return value Macro Value Description E OK 0 Normal completion Invalid ID number E ID 18 dtqid lt 0x0 dtgid gt Maximum ID number Context error E CTX 25 This service call was issued in the CPU locked state Non existent object E_ NOEXS 42 Spec
243. is currently being processed the task is waiting to be given the CPU s use right 3 RUNNING state State of a task that has acquired the CPU use right and is currently being processed Only one task can be in the running state at one time in the entire system 4 WAITING state State in which processing execution has been suspended because conditions required for execution are not satisfied Resumption of processing from the WAITING state starts from the point where the processing execution was suspended The value of information required for resumption such as task context immediately before suspension is therefore restored In the RI850V4 the WAITING state is classified into the following ten types according to their required conditions and managed Table 3 1 WAITING State WAITING State Description A task enters this state if the counter for the task registering the 5 Sleeping state Delayed state number of times the wakeup request has been issued indicates 0x0 upon the issue of slp_tsk or tslp_tsk A task enters this state upon the issue of a dly_tsk WAITING state for a semaphore resource A task enters this state if it cannot acquire a resource from the relevant semaphore upon the issue of wai_sem or twai_sem WAITING state for an eventflag A task enters this state if a relevant eventflag does not satisfy a predetermined condition upon the issue of wai_flg or twai_flg Sending WAITING sta
244. is referenced by issuing the following service call from the processing program sns_loc This service call acquires the system status type when this service call is issued CPU locked state or CPU unlocked state When this service call is terminated normally the acquired system state type TRUE CPU locked state FALSE CPU unlocked state is returned The following describes an example for coding this service call include lt kernel h gt Standard header file definition include lt kernel_id h gt System information header file definition void task VP_INT exinf BOOL ercd Declares variable ercd sns_loc Reference CPU state if ercd TRUE lpr dictates CPU locked state oee ae aaia CPU unlocked state R20UT2889EJ0101 Rev 1 01 ztENESAS Page 115 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 8 SYSTEM STATE MANAGEMENT FUNCTIONS 8 8 Disable Dispatching A task is moved to the dispatch disabled state by issuing the following service call from the processing program dis_dsp This service call changes the system status to the dispatch disabled state As a result dispatch processing task scheduling is disabled from when this service call is issued until ena_dsp is issued If a service call chg_pri sig_sem etc accompanying dispatch processing is issued during the interval from when this service call is issued until ena_dsp is issued the RI850V4 executes only processin
245. is used i A sit s Green Hills Compiler CCV850 is used i A sit 850 R20UT2889EJ0101 Rev 1 01 2tENESAS Page 330 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 18 CONFIGURATOR CF850V4 Note 1 Specify the output file name lt SI T file gt within 255 characters including the path name Note 2 When the output file name includes a space surround lt SIT file gt by double quotation marks Note 3 If this activation option is specified together with ni the CF850V4 handles ni as the valid option eA lt Entry file gt Specify the output file name entry file name while the CF850V4 is activated If omitted The CF850V4 assumes that the following activation option is specified and performs processing REL Compiler CC RH is used e A entry s Green Hills Compiler CCV850 is used e A entry 850 Note 1 Specify the output file name lt Entry file gt within 255 characters including the path name Note 2 When the output file name includes a space surround lt Entry file gt by double quotation marks Note 3 If this activation option is specified together with ne the CF850V4 handles ne as the valid option d A lt Header file gt Specify the output file name system information header file name while the CF850V4 is activated If omitted If omitted The CF850V4 assumes that d A kernel_id h is specified and performs processing Note 1 Specify the output file name lt Header file gt within 255 characters including the path name N
246. istics by software trace mode The size of kernel_data_trace bss section depends on the number of task information items defined and the details of the basic information definitions The following shows an expression required for estimation kernel_data_trace bss section size In the expression align4 x means the result of aligning the value x to a 4 byte boundary KERNEL_DATA_TRACE BSS 24 t 8 CRE_TSK_num t align4 10 intlvl maxintpri t 8 maxint Note The keyword in the expression means as follows Keywords Meaning CRE_TSK_num The number of the definition of the Task information intlvl The value of interrupt level provided in the target CPU maxintpri The value of the definition in the Maximum interrupt priority maxintpri The value of the definition in the Maximum number of interrupt handlers maxint maxint i Maximum value of exception code maxintno R20UT2889EJ0101 Rev 1 01 tENESAS Page 358 of 366 Sep 30 2015 RI850V4 V2 APPENDIX B SIZE OF MEMORY B 1 7 kernel_work The size of kernel_work section depends on the information such as Basic information and Task information and so on The following shows an expression required for estimating kernel_work section size In the expression align4 x means the result of aligning the value x to a 4 byte boundary KERNEL WORK 116 SYSSTK TSKST
247. it pattern of the target eventflag does not satisfy the required condition when this service call is issued E_TMOUT is returned The following shows the specification format of required condition wfmode wfmode TWF_ANDW Checks whether all of the bits to which 1 is set by parameter waiptn are set as the target eventflag wfmode TWF_ORW Checks which bit among bits to which 1 is set by parameter waiptn is set as the target eventflag Note 1 With the RI850V4 whether to enable queuing of multiple tasks to the event flag wait queue is defined during configuration If this service call is issued for the event flag TW_WSGL attribute to which a wait task is queued therefore E_ILUSE is returned regardless of whether the required condition is immediately satisfied TA_WSGL Only one task is allowed to be in the WAITING state for the eventtflag TA_WMUL Multiple tasks are allowed to be in the WAITING state for the eventflag Note 2 The RI850V4 performs bit pattern clear processing 0x0 setting when the required condition of the target eventflag TA_CLR attribute is satisfied Note 3 If the bit pattern of the target event flag does not satisfy the required condition when this service call is issued the contents in the area specified by parameter p_flgptn become undefined R20UT2889EJ0101 Rev 1 01 2tENESAS Page 220 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 16 SERVICE CALLS Return value M
248. kernel h gt Standard header file definition include lt kernel_id h gt System information header file definition void task VP_INT exinf BOOL ercd Declares variable ercd sns_dsp Reference dispatching state if ercd TRUE haha stearate Dispatching disabled state else if ercd FALSE oee ae aaia Dispatching enabled state R20UT2889EJ0101 Rev 1 01 ztENESAS Page 120 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 8 SYSTEM STATE MANAGEMENT FUNCTIONS 8 11 Reference Contexts The context type is referenced by issuing the following service call from the processing program sns_ctx This service call acquires the context type of the processing program that issued this service call non task context or task context When this service call is terminated normally the acquired context type TRUE non task context FALSE task context is returned The following describes an example for coding this service call include lt kernel h gt Standard header file definition include lt kernel_id h gt System information header file definition void task VP_INT exinf BOOL ercd Declares variable rcd sns_ctx Reference contexts if ercd TRUE Non task contexts lse if ercd FALSE oee ae aaia Task contexts R20UT2889EJ0101 Rev 1 01 ztENESAS Page 121 of 366 Sep 30 2015 RI850V4 V2 CHAPTE
249. l_wai irel_wai while waiting R20UT2889EJ0101 Rev 1 01 tENESAS Page 271 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 16 SERVICE CALLS pget_mpl ipget_mpl Outline Acquire variable sized memory block polling C format ER pget_mpl ID mplid UINT blksz VP p_blk ER ipget_mpl ID mplid UINT blksz VP p_blk Parameter s 1 0 Parameter Description ID number of the variable sized memory pool from which a memory l ID mplid block is acquired UINT blksz Memory block size to be acquired in bytes O VP p blk Start address of the acquired memory block Explanation This service call acquires a variable size memory block of the size specified by parameter blksz from the variable size memory pool specified by parameter mplid and stores its start address into the area specified by parameter p_bik If no variable size memory blocks could be acquired from the target variable size memory pool no successive areas equivalent to the requested size were available when this service call is issued this service call does not acquire variable size memory block but returns E_TMOUT Note 1 The RI850V4 acquires variable size memory blocks in the unit of integral multiple of 4 If a value other than an integral multiple of 4 is specified for parameter b ksz it is rounded up to be an integral multiple of 4 Note 2 If no variable size memory blocks could be acquired from the target variable size memory pool
250. lation processing is therefore not performed but E_QOVR is returned R20UT2889EJ0101 Rev 1 01 2tENESAS Page 39 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 4 TASK DEPENDENT SYNCHRONIZATION FUNCTIONS 4 4 Cancel Task Wakeup Requests A wakeup request is cancelled by issuing the following service call from the processing program can_wup ican_wup These service calls cancel all of the wakeup requests queued to the task specified by parameter tskid the wakeup request counter is set to 0x0 When this service call is terminated normally the number of cancelled wakeup requests is returned The following describes an example for coding this service call include lt kernel h gt Standard header file definition include lt kernel_id h gt System information header file definition void task VP_INT exinf ER_UINT ercd Declares variable ID tskid ID_TSK1 Declares and initializes variable ercd can_wup tskid Cancel task wakeup requests if ercd gt 0x0 Normal termination processing R20UT2889EJ0101 Rev 1 01 2tENESAS Page 40 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 4 TASK DEPENDENT SYNCHRONIZATION FUNCTIONS 4 5 Release Task from Waiting The WAITING state is forcibly cancelled by issuing the following service call from the processing program rel_wai irel_wai These service calls forcibly cancel the WAITING state of the task specified by parameter tskid As aresu
251. ler can be manipulated by handling the extended information as if it were a function parameter 4 Start address cychdr Specifies the start address for a cyclic handler A value from 0x0 to Oxfffffffe aligned to a 2 byte boundary or a symbol name can be specified for cychar Note When a cyclic handler is coded as follows the symbol name specified for cychdr should be func_cyc include lt kernel h gt include lt kernel_id h gt R20UT2889EJ0101 Rev 1 01 2tENESAS Page 322 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 17 SYSTEM CONFIGURATION FILE void func_cyc VP_INT exinf 5 Activation cycle cyctim Specifies the activation cycle unit millisecond for a cyclic handler A value from 0x1 to Ox7fffffff aligned to clkcyc multiple values can be specified for cyctim Note If a value other than an integral multiple of the base clock cycle defined in Basic information is specified for cyctim the CF850V4 assumes that an integral multiple is specified and performs processing 6 Activation phase cycphs Specifies the activation phase unit millisecond for a cyclic handler A value from 0x1 to Ox7fffffff aligned to clkcyc multiple values can be specified for cycphs Note 1 In the RI850V4 the initial activation phase means the relative interval from when generation of s cyclic handler is completed until the first activation request is issued Note 2 Ifa value other than an integral multiple
252. lic handler using If multiple cyclic handlers are existed CYC the maximum value among them If the cyclic handler is undefined the stack size of the cyclic handler is nothing The stack size of the initialization routine using If multiple initialization routines INI are existed the maximum value among them If the initialization routine is undefined the stack size of the initialization routine is nothing The stack size of the idle routine using If the idle routine is undefined the stack na size of the idle routine is nothing R20UT2889EJ0101 Rev 1 01 2tENESAS Page 359 of 366 Sep 30 2015 RI850V4 V2 APPENDIX B SIZE OF MEMORY 2 Task stack The size of the task stack depends on the details of Task information definitions and processing to be done in the tasks The following shows an expression required for estimating the task stack size required by each task defined in the Task information TSKSTK CUxXSZ stksz Note The keyword in the expression means as follows Keywords Meaning This value is determined as shown in Table B 2 according to the target C compiler type and device type specified in the activation options for the CONFIGURATOR clxsz CF850V4 see 18 2 1 Activating from command line for details of activation options and the preempt acceptance state specified in the Attribute tskatr such as coding language and initial activation state The value correspondi
253. ll is issued until unl_cpu or iunl_cpu is issued the RI850V4 returns E_CTX R20UT2889EJ0101 Rev 1 01 2tENESAS Page 292 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 16 SERVICE CALLS Return value Macro Value Description E OK 0 Normal completion R20UT2889EJ0101 Rev 1 01 ztENESAS Page 293 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 16 SERVICE CALLS Outline Unlock the CPU C format Parameter s None Explanation These service calls change the system status from the CPU locked state to the CPU unlocked state ER unl_cpu ER iunl_cpu void void As a result El level maskable interrupt acceptance and service call issue restricted prohibited through issue of loc_cpu or iloc_cpu are enabled If an El level maskable interrupt is created during the interval from when either loc_cpu or iloc_cpu is issued until this service call is issued the RI850V4 delays transition to the relevant interrupt processing interrupt handler until this service call is issued Note 1 This service call does not perform queuing of cancellation requests If the system is in the CPU unlocked state therefore no processing is performed but it is not handled as an error Note 2 This service call manipulates PMn bits in the priority mask register PMR to disable acceptance of El level maskable interrupts The PMn bits to be manipulated correspond to the interrupt priority range defined as th
254. llows Keywords Meaning bikes The value of the definition in the Basic block size blksz memory area name sec_nam blkent The value of the definition in the Block count blkcnt 5 Variable sized memory pool The size of the variable sized memory pools depends on the details of Variable sized memory pool information definitions The following shows an expression required for estimating the variable sized memory pool size required by each variable sized memory pool defined in the Variable sized memory pool information In the expression align4 x means the result of aligning the value x to a 4 byte boundary MPF align4 blksz blkcnt Note The keyword in the expression means as follows Keywords Meaning mplsz The value of the definition in the Pool size mplsz memory area name sec_nam B 1 8 sec_nam user definied area The size of sec_nam user defined area depends on the details of information definitions such as Task information and Data queue information Note This section is necessary when the task stack or data queue area is defined to be allocated outside kernel_work section in the Task information or Data queue information Estimate the memory size for this section with reference to the descriptions in B 1 7 kernel_work R20UT2889EJ0101 Rev 1 01 2tENESAS Page 361 of 366 Sep 30 2015 RI850V4 V2 APPENDIX C SUPPORT FOR FLOATING POINT OPERATI
255. lower 32 bits UH utime System time higher 16 bits SYSTIM Explanation These service calls change the RI850V4 system time unit millisecond to the time specified by parameter p_systim Note For details about the system time packet refer to 15 2 11 System time packet Return value Macro Value Description E OK 0 Normal completion Context error E CTX 25 This service call was issued in the CPU locked state R20UT2889EJ0101 Rev 1 01 2tENESAS Page 281 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 16 SERVICE CALLS get_tim iget_tim Outline Reference system time C format ER get_tim SYSTIM p_systim ER iget_tim SYSTIM p_systim Parameter s 0 Parameter Description O SYSTIM p_systim Current system time System time packet SYSTIM typedef struct t_systim UW ltime System time lower 32 bits UH utime System time higher 16 bits SYSTIM Explanation These service calls store the RI850V4 system time unit millisecond into the area specified by parameter p_systim Note 1 The RI850V4 ignores the numeric values that cannot be expressed as the system time values overflowed from the 48 bit width Note 2 For details about the system time packet refer to 15 2 11 System time packet Return value Macro Value Description E OK 0 Normal completion Context error E CTX 25 This servic
256. ls about the task state packet refer to 15 2 1 Task state packet R20UT2889EJ0101 Rev 1 01 Sep 30 2015 ztENESAS Page 188 of 366 RI850V4 V2 CHAPTER 16 SERVICE CALLS Return value Macro Value Description E OK 0 Normal completion Invalid ID number tskid lt 0x0 E_ID 18 tskid gt Maximum ID number When this service call was issued from a non task TSK_SELF was specified tskid Context error E_CTX 25 This service call was issued in the CPU locked state Non Existent object E_NOEXS 42 Specified task is not registered R20UT2889EJ0101 Rev 1 01 tENESAS Page 189 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 16 SERVICE CALLS Outline Reference task state simplified version C format ER ref_tst ID tskid T_RTST pk_rtst ER iref_tst ID tskid T_RTST pk_rtst Parameter s V O Parameter Description ID number of the task to be referenced ID tskidj TSK_SELF Invoking task Value ID number of the task to be referenced O T_RTST pk_rtst Pointer to the packet returning the task state Task state packet simplified version T_RTST typedef struct t_rtst STA tskstat Current state STA tskwait Reason for waiting EF RTST Explanation Stores task state packet current state reason for waiting of the task specified by parameter tskid in the area specified by parameter pk_rtst Used for referen
257. lt the target task unlinked from the wait queue and is moved from the WAITING state to the READY state or from the WAITING SUSPENDED state to the SUSPENDED state E_RLWAI is returned from the service call that triggered the move to the WAITING state slp_tsk wai_sem or the like to the task whose WAITING state is cancelled by this service call The following describes an example for coding this service call include lt kernel h gt Standard header file definition include lt kernel_id h gt System information header file definition void task VP_INT exinf ID tskid ID_TSK1 Declares and initializes variable rel_wai tskid Release task from waiting Note 1 This service call does not perform queuing of forced cancellation requests If the target task is in a state other than the WAITING or WAITING SUSPENDED state E_OBu is returned Note 2 The SUSPENDED state is not cancelled by these service calls R20UT2889EJ0101 Rev 1 01 RENESAS Sep 30 2015 Page 41 of 366 RI850V4 V2 CHAPTER 4 TASK DEPENDENT SYNCHRONIZATION FUNCTIONS 4 6 Suspend Task A task is moved to the SUSPENDED state by issuing the following service call from the processing program sus_tsk isus_tsk These service calls add 0x1 to the suspend request counter for the task specified by parameter tskid and then move the target task from the RUNNING state to the SUSPENDED state from the READY state to the SUSPENDED st
258. m configuration files Character code Create the system configuration file using ASCII code The CF850V4 distinguishes lower cases a to z and upper cases A to Z Note For Japanese language coding Shit JIS codes can be used only for comments Comment In a system configuration file parts between and and parts from two successive slashes to the line end are regarded as comments Numeric In a system configuration file words starting with a numeric value 0 to 9 are regarded as numeric values The CFV850V4 distinguishes numeric values as follows Octal Words starting with 0 Decimal Words starting with a value other than 0 Hexadecimal Words starting with Ox or OX Note Unless specified otherwise the range of values that can be specified as numeric values are limited from 0x0 to Oxffffffff Symbol name In a system configuration file words starting with an alphabetic character a to z A to Z or underscore _ are regarded as symbol names Describing a symbol name in the format symbol name offset is also possible but the offset must be a constant expression The following shows examples of describing symbol names The CF850V4 distinguishes between symbol names and other names based on the context in the system configuration file Correct func 0x80000 func name symbol 0x90 80 symbol name symbol BASE data macro Incorrect func 0x8000 The start character is
259. mal completion Parameter error E PAR 47 waiptn 0x0 wmode is invalid tmout lt TMO_FEVR Invalid ID number E ID 18 figid lt 0x0 flgid gt Maximum ID number Context error E CTX 25 This service call was issued from a non task This service call was issued in the CPU locked state This service call was issued in the dispatching disabled state Illegal service call use E ILUSE 28 There is already a task waiting for an eventflag with the TA_WSGL attribute Non existent object E NOEXS 42 Specified eventflag is not registered Forced release from the WAITING state E RLWAI 49 Accept rel_wai irel_wai while waiting Timeout E TMOUT 50 Polling failure or timeout R20UT2889EJ0101 Rev 1 01 tENESAS Page 223 of 366 Sep 30 2015 CHAPTER 16 SERVICE CALLS RI850V4 V2 CHAPTER 16 SERVICE CALLS ref_flg iref_flg Outline Reference eventtflag state C format ER ref_flg ID flgid T_RFLG pk_rflg ER iref_flg ID flgid T_RFLG pk_rflg Parameter s 0 Parameter Description l ID flgid ID number of the eventflag to be referenced O T_RFLG pk_rflg Pointer to the packet returning the eventflag state Eventflag state packet T_RFLG typedef struct t_rflg ID wtskid Existence of waiting task FLGPTN flgptn Current bit pattern ATR flgatr Attribute T_RFLG Explanation Stores eventflag state packet ID number of the task at the head of
260. memory pool state Variable sized memory pool state packet T_RMPL typedef struct t_rmpl ID wtskid Existence of waiting task SIZE fmplsz Total size of free memory blocks UINT fblksz Maximum memory block size available ATR mplatr Attribute ID memid Reserved for future use T_RMPL Explanation These service calls store the detailed information ID number of the task at the head of the wait queue total size of free memory blocks etc of the variable size memory pool specified by parameter mplid into the area specified by parameter pk_rmpl Note For details about the variable sized memory pool state packet refer to 15 2 10 Variable sized memory pool state packet Return value Macro Value Description E OK 0 Normal completion Invalid ID number EID 18 mplid lt 0x0 mplid gt Maximum ID number R20UT2889EJ0101 Rev 1 01 2tENESAS Page 278 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 16 SERVICE CALLS Macro Value Description Context error E CTX 25 This service call was issued in the CPU locked state Non existent object E NOEXS 42 Specified variable sized memory pool is not registered R20UT2889EJ0101 Rev 1 01 Sep 30 2015 ztENESAS Page 279 of 366 RI850V4 V2 CHAPTER 16 SERVICE CALLS 16 2 10 Time management functions The following shows the service calls provided by the RI850V4
261. mination processing Timeout processing Note 1 Data is written to the data queue area of the target data queue in the order of the data transmission request Note 2 Invoking tasks are queued to the transmission wait queue of the target data queue in the order defined during configuration FIFO order or priority order Note 3 TMO_FEVR is specified for wait time tmout processing equivalent to snd_dtq will be executed When TMO_POL is specified processing equivalent to psnd_dtq ipsnd_dtgq will be executed R20UT2889EJ0101 Rev 1 01 Sep 30 2015 2tENESAS Page 67 of 366 CHAPTER 5 SYNCHRONIZATION AND COMMUNICATION RI850V4 V2 FUNCTIONS 5 4 3 Forced send to data queue Data is forcibly transmitted by issuing the following service call from the processing program fsnd_dtq ifsnd_dtq These service calls write data specified by parameter data to the data queue area of the data queue specified by parameter digid If there is no available space for writing data in the data queue area of the target data queue when either of these service calls is issued the service call overwrites data to the area with the oldest data that was written If a task has been queued to the reception wait queue of the target data queue when this service call is issued this service call does not write data but transfers the data to the task As a result the task is unlinked from the reception wait queue and moves from the WAITING state data rece
262. mode 21 1K Bytes Taking in long statistics by software trace mode 20 9K Bytes 3 CCV850 version not supporting the FPU Type of the Trace Mode Size of the Memory Area Not tracing 20 0K Bytes Taking in trace chart by hardware trace mode 20 3K Bytes Taking in trace chart by software trace mode 20 8K Bytes Taking in long statistics by software trace mode 20 6K Bytes 4 CCV850 version supporting the FPU Type of the Trace Mode Size of the Memory Area Not tracing 20 2K Bytes Taking in trace chart by hardware trace mode 20 5K Bytes Taking in trace chart by software trace mode 21 0K Bytes Taking in long statistics by software trace mode 20 9K Bytes Note The above values are maximum when using all service calls provided by RI850V4 The value fluctuate corresponding to the type of service calls using R20UT2889EJ0101 Rev 1 01 RENESAS Sep 30 2015 Page 354 of 366 RI850V4 V2 APPENDIX B SIZE OF MEMORY B 1 2 kernel_const The size of kernel_const section depends on the number of information items defined such as Memory area information and Task information and the details of the definitions The following shows an expression required for estimation kernel_const section size In the expression align4 x means the result of aligning the value x to a 4 byte boundary 8 8 8 12 A align
263. mode are set to the eventflag specified by parameter flgid If a bit pattern that satisfies the required condition has been set for the target eventflag the bit pattern of the target eventtflag is stored in the area specified by parameter p_figptn If the bit pattern of the target eventflag does not satisfy the required condition when this service call is issued the invoking task is queued to the target eventflag wait queue As a result the invoking task is unlinked from the ready queue and is moved from the RUNNING state to the WAITING state WAITING state for an eventflag The WAITING state for an eventflag is cancelled in the following cases and then moved to the READY state WAITING State for an Eventflag Cancel Operation Return Value A bit pattern that satisfies the required condition was set to the target eventflag as a result of E OK issuing set_flg A bit pattern that satisfies the required condition was set to the target eventflag as a result of E OK issuing iset_flg Forced release from waiting accept rel_wai while waiting E RLWAI Forced release from waiting accept irel_wai while waiting E RLWAI The following shows the specification format of required condition wfmode wimode TWF_ANDW Checks whether all of the bits to which 1 is set by parameter waiptn are set as the target eventflag wfmode TWF_ORW Checks which bit among bits to which 1 is set by parameter waiptn is set as the tar
264. mory block size available ATR mplatr Attribute ID memid Reserved for future use T_RMPL The following shows details on variable sized memory pool state packet T_RMPL wtskid Stores whether a task is queued to the variable size memory pool wait queue TSK_NONE No applicable task Value ID number of the task at the head of the wait queue fmplsz Stores the total size of free memory blocks in bytes folksz Stores the maximum memory block size available in bytes moplatr Stores the attribute queuing method Task queuing method bit 0 TA_TFIFO Task wait queue is in FIFO order TA_TPRI Task wait queue is in task priority order Structure of mplatr 15 0 t TA_TFIFO 0 TA_TPRI 1 memid System reserved area R20UT2889EJ0101 Rev 1 01 7tENESAS Page 165 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 15 DATA TYPES AND MACROS 15 2 11 System time packet The following shows system time packet SYSTIM used when issuing set_tim iset_tim get_tim or iget_tim Definition of system time packet SYSTIM is performed by the header file lt ri_root gt include os packet h which is called from the standard header file lt ri_root gt include kernel h typedef struct t_systim UW ltime System time lower 32 bits UH utime System time higher 16 bits SYSTIM The following shows details on system time packet SYSTIM Itime Stores the
265. n El level maskable interrupt occurs within a cyclic handler the interrupt is accepted 9 3 4 Create cyclic handler In the RI850V4 the method of creating a cyclic handler is limited to static creation Cyclic handlers therefore cannot be created dynamically using a method such as issuing a service call from a processing program Static cyclic handler creation means defining of cyclic handlers using static API CRE_CYC in the system configuration file For details about the static API CRE_CYC refer to 17 5 9 Cyclic handler information R20UT2889EJ0101 Sep 30 2015 Rev 1 01 2tENESAS Page 125 of 366 RI850V4 V2 CHAPTER 9 TIME MANAGEMENT FUNCTIONS 9 4 Set System Time The system time can be set by issuing the following service call from the processing program set_tim iset_tim These service calls change the RI850V4 system time unit millisecond to the time specified by parameter p_systim The following describes an example for coding this service call include lt kernel h gt Standard header file definition include lt kernel_id h gt System information header file definition void task VP_INT exinf SYSTIM p_systim Declares data structure p_systim ltime 3600 Initializes data structure p_systim utime 0 Initializes data structure set_tim amp p_systim Set system time Note For details about the system time packet refer to 15 2 11 System time pack
266. n be specified for idlatr is TA_HLNG or TA_ASM TA_HLNG Start an idle routine through a C language interface TA_ASM Start an idle routine through an assembly language interface 2 Start address idirtn Specifies the start address for an idle routine A value from 0x0 to Oxfffffffe aligned to a 2 byte boundary or a symbol name can be specified for idirtn Note When an extended service call idle handler is coded as follows the symbol name specified for idirtn should be func_idl include lt kernel h gt void func_idl void return R20UT2889EJ0101 Rev 1 01 ztENESAS Page 327 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 17 SYSTEM CONFIGURATION FILE 17 6 Description Examples The following describes an example for coding the system configuration file Figure 17 2 Example of System Configuration File Declarative Information description INCLUDE kernel h System Information description RI_SERIES RI850V4 V201 CPU_TYPE G3M DEF_TI ivy CLK_INTNO 0x104c SYS_STK 0x800 STK_CHK TA_ON MAX_PRI 0x12 MAX_INTPRI INTPRI5 MAX_INT 10 0x1119 DEF_FPSR 0x00020000 MEM AREA kernel_work SIZE_AUTO Static API Information description CRE_TSK ID_TASK1
267. n coding in assembly language code them according to the calling rules prescribed in the compiler used Stack switching The RI850V4 switches to the system stack specified in Basic information when passing control to an idle routine Coding regarding stack switching is therefore not required in idle routines Service call issue The RI850V4 prohibits issue of service calls in idle routines Acceptance of El level maskable interrupts When passing control to the idle routine the RI850V4 enables acceptance of El level maskable interrupts by manipulating the PMn bits in the priority mask register PMR and the ID bit in the program status word PSW The PMn bits to be manipulated correspond to the interrupt priority range defined as the Maximum interrupt priority maxintpri during configuration Note In most cases control returns from the idle routine moves to another processing program if the wait time has passed or an El level maskable interrupt occurs do not issue the DI instruction in the idle routine R20UT2889EJ0101 Rev 1 01 2tENESAS Page 145 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 13 SCHEDULER 13 2 2 Define Idle Routine The RI850V4 supports the static registration of idle routines only They cannot be registered dynamically by issuing a service call from the processing program Static idle routine registration means defining of idle routines using static API VATT_IDL in the system configuration file For details a
268. n in the system configuration file R20UT2889EJ0101 Rev 1 01 ztENESAS Page 362 of 366 Sep 30 2015 Revision Record Description Rev Sep 30 2015 ia First Edition issued RI850V4 V2 User s Manual Coding Publication Date Rev 1 01 Sep 30 2015 Published by Renesas Electronics Corporation tENESAS SALES OFFICES Renesas Electronics Corporation http Avww renesas com Refer to http www renesas com for the latest and detailed information Renesas Electronics America Inc 2801 Scott Boulevard Santa Clara CA 95050 2549 U S A Tel 1 408 588 6000 Fax 1 408 588 6130 Renesas Electronics Canada Limited 9251 Yonge Street Suite 8309 Richmond Hill Ontario Canada L4C 9T3 Tel 1 905 237 2004 Renesas Electronics Europe Limited Dukes Meadow Millboard Road Bourne End Buckinghamshire SL8 5FH U K Tel 44 1628 585 100 Fax 44 1628 585 900 Renesas Electronics Europe GmbH Arcadiastrasse 10 40472 Dusseldorf Germany Tel 49 211 6503 0 Fax 49 211 6503 1327 Renesas Electronics China Co Ltd Room 1709 Quantum Plaza No 27 ZhiChunLu Haidian District Beijing 100191 P R China Tel 86 10 8235 1155 Fax 86 10 8235 7679 Renesas Electronics Shanghai Co Ltd Unit 301 Tower A Central Towers 555 Langao Road Putuo District Shanghai P R China 200333 Tel 86 21 2226 0888 Fax 86 21 2226 0999 Renesas Electronics Hong Kong Limited Unit 1601 1611 16 F Tower 2 Grand Century Place
269. nel_id h b Realtime OS related file J trcinf c Note 2 When replacing the system configuration file first remove the added system configuration file from the project then add another one again Note 3 Although it is possible to add more than one system configuration files to a project only the first file added is enabled Note that if you remove the enabled file from the project the remaining additional files will not be enabled you must therefore add them again 4 Specify the output of a load module file Specify the type of load module file to be generated Note For details of the load module output settings see CS Integrated Development Environment User s Manual CC RH Build Tool Operation 5 Set the output of information files Select the system configuration file on the project tree to open the Property panel On the System Configuration File Related Information tab set the output of information files system information table file system information header file and entry file R20UT2889EJ0101 Rev 1 01 Sep 30 2015 2tENESAS Page 17 of 366 RI850V4 V2 CHAPTER 2 SYSTEM CONSTRUCTION Figure 2 3 Property Panel System Configuration File Related Information Tab ES gf syscte Property e le Generate a file YestIt updates the file when the cfe file is chang Output folder BuildMode Name File name sits System Information Header File Generate a file Yes lt updates the file wh
270. ner as ordinary functions coded When coding in assembly language code them according to the calling rules prescribed in the compiler used Stack switching The RI850V4 switches to the system stack specified in Basic information when passing control to an interrupt handler and switches to the relevant stack when returning control to the processing program for which a base clock timer interrupt occurred Coding regarding stack switching is therefore not required in interrupt handler processing R20UT2889EJ0101 Rev 1 01 ztENESAS Page 134 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 10 INTERRUPT MANAGEMENT FUNCTIONS Service call issue The RI850V4 handles the interrupt handler as a non task Service calls that can be issued in interrupt handlers are limited to the service calls that can be issued from non tasks Note 1 If a service call isig_sem iset_flg etc accompanying dispatch processing task scheduling processing is issued in order to quickly complete the processing in the interrupt handler during the interval until the processing in the interrupt handler ends the RI850V4 executes only processing such as queue manipulation counter manipulation etc and the actual dispatch processing is delayed until a return instruction is issued by the interrupt handler upon which the actual dispatch processing is performed in batch Note 2 For details on the valid issue range of each service call refer to Table 16 1 to Table 16 12 Acce
271. ng WAITING state for a mailbox to the READY state or from the WAITING SUSPENDED state to the SUSPENDED state Note 1 Messages are queued to the target mailbox wait queue in the order defined by queuing method during configuration FIFO order or priority order Note 2 With the RI850V4 mailbox only the start address of the message is handed over to the receiving processing program but the message contents are not copied to a separate area The message contents can therefore be rewritten even after this service call is issued Note 3 For details about the message packet refer to 15 2 6 Message packet R20UT2889EJ0101 Rev 1 01 2tENESAS Page 240 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 16 SERVICE CALLS Return value Macro Value Description E OK 0 Normal completion Parameter error E PAR 17 msgpri lt 0x0 msgpri gt Maximum message priority Invalid ID number E ID 18 mbxid lt 0x0 mbxid gt Maximum ID number Context error E CTX 25 This service call was issued in the CPU locked state Non existent object E NOEXS 42 Specified mailbox is not registered R20UT2889EJ0101 Rev 1 01 Sep 30 2015 ztENESAS Page 241 of 366 RI850V4 V2 CHAPTER 16 SERVICE CALLS rcv_mbx Outline Receive from mailbox waiting forever C format ER rev_mbx ID mbxid T_MSG ppk_msqg Parameter s V O Parameter Description l ID mbxid ID number of the ma
272. ng WAITING State for a Mailbox Cancel Operation Return Value A message was transmitted to the target mailbox as a result of issuing snd_mbx E OK A message was transmitted to the target mailbox as a result of issuing isnd_mbx E OK Forced release from waiting accept rel_wai while waiting E RLWAI Forced release from waiting accept irel_ wai while waiting E RLWAI The following describes an example for coding this service call include lt kernel h gt Standard header file definition include lt kernel_id h gt System information header file definition void task VP_INT exinf ER ercd Declares variable ID mbxid ID_MBX1 Declares and initializes variable T_MSG ppk_msg Declares data structure Receive from mailbox ercd rcv_mbx mbxid amp ppk_msqg Normal termination processing lse if ercd E_RLWAI Forced termination processing Note 1 Invoking tasks are queued to the target mailbox wait queue in the order defined during configuration FIFO order or priority order Note 2 If the receiving WAITING state for a mailbox is forcibly released by issuing rel_wai or irel_wai the contents of the area specified by parameter ppk_msg will be undefined Note 3 For details about the message packet refer to 15 2 6 Message packet R20UT2889EJ0101 Rev 1 01 2tENESAS Page 78 of 366 Sep 30 2015 CHAPTER 5 SYNCHRONIZATION AND COMMUNICATION RI850V4 V2 FUNCTION
273. ng to task processing defined the value of the Task stack stksz rons 3 size stksz memory area name sec_nam Table B 2 Value of ctxsz Section Name FPU Enable Preempt Disable Preempt not supporting the FPU 132 88 CC RH version supporting the FPU 136 92 not supporting the FPU 128 84 CCV850 version supporting the FPU 132 88 3 Data queue The size of the data queues depends on the details of Data queue information definitions The following shows an expression required for estimating the data queue size by each data queue defined in the Data queue information DTQ 4 dtqent Note The keyword in the expression means as follows Keywords Meaning The value of the definition in the Data count dtqcnt memory area name atqent sec_nam Fixed sized memory pool The size of the fixed sized memory pools depends on the details of Fixed sized memory pool information definitions The following shows an expression required for estimating the fixed sized memory pool size required by each fixed sized memory pool defined in the Fixed sized memory pool information In the expression align4 x means the result of aligning the value x to a 4 byte boundary R20UT2889EJ0101 Rev 1 01 ztENESAS Page 360 of 366 Sep 30 2015 RI850V4 V2 APPENDIX B SIZE OF MEMORY MPF align4 blksz blkcnt Note The keyword in the expression means as fo
274. ns provided by the RI850V4 2 1 Outline System building consists in the creation of a load module using the files kernel library etc installed on the user development environment host machine from the RI850V4 s supply media The following shows the procedure for organizing the system Figure 2 1 Example of System Construction Programs Task Cyclic Handler Interrupt Handler Extended Service Call Routines System Configuration File y User own Coding C Configurator Post overflow processing Interrupt entry process Vv Initialize routine Information Files Idle routine Boot process System information table file i f System dependent information System information header file Entry file Trace information file RI850V4 Kernel Librar C C compiler Assembler C Compiler 4 Standard Library Math Library Object Files etc Linker l Load Module APN The RI850V4 provides a sample program with the files necessary for generating a load module For the location where the sample program is stored see RI Series Real Time Operating System User s Manual Start R20UT2889EJ0101 Rev 1 01 2tENESAS Page 13 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 2 SYSTEM CONSTRUCTION 2 2 Cording System Configuration File Code the SYSTEM CONFIGURATION FILE required for creating information files sy
275. nter is not set to 0x0 when this service call is issued this service call moves the task from the RUNNING state to the DORMANT state decrements the wakeup request counter by subtracting 0x1 from the wakeup request counter and then moves the task from the DORMANT state to the READY state Note 1 When moving a task from the RUNNING state to the DORMANT state this service call initializes the following information to values that are set during task creation Current priority Wakeup request count Suspension count interrupt state If an invoking task has locked a mutex the locked state is released at the same time processing equivalent to unl_mtx Note 2 When the return instruction is issued in a task the same processing as ext_tsk is performed Return value None R20UT2889EJ0101 Rev 1 01 2tENESAS Page 182 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 16 SERVICE CALLS Outline Terminate task C format ER ter_tsk ID tskid Parameter s 1 0 Parameter Description l ID tskid ID number of the task to be terminated Explanation This service call forcibly moves a task specified by parameter tskid to the DORMANT state As a result the target task is excluded from the RI850V4 scheduling subject If an activation request has been queued to the target task the activation request counter is not set to 0x0 when this service call is issued this service call moves the task to the DORMANT st
276. nterrupt disabled state the ID flag of the program status word PSW is set to 1 To generate multiple interrupts processing to cancel the interrupt disabled state such as issuing of El instruction must therefore be coded in the interrupt handler explicitly The following shows a processing flow when multiple interrupts occur R20UT2889EJ0101 Rev 1 01 2tENESAS Page 135 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 10 INTERRUPT MANAGEMENT FUNCTIONS Figure 10 2 Multiple Interrupts Task Interrupt handler A Interrupt handler B Mee Sr EI instruction l Saa eae return Calling DI instruction return R20UT2889EJ0101 Rev 1 01 ztENESAS Page 136 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 11 SERVICE CALL MANAGEMENT FUNCTIONS CHAPTER 11 SERVICE CALL MANAGEMENT FUNC TIONS This chapter describes the service call management functions performed by the RI850V4 11 1 Outline The RI850V4 s service call management function provides the function for manipulating the extended service call routine status such as registering and calling of extended service call routines 11 2 Extended Service Call Routines This is a routine to which user defined functions are registered in the RI850V4 and will never be executed unless it is called explicitly using service calls provided by the RI850V4 The RI850V4 positions extended service call routines as extensions of the processing program that called the extended service call ro
277. ocessing with the assumption that peid 1 is specified Note 1 When the cpu option is omitted the CF850V4 ignores this activation option setting and outputs an information file for a single core configuration Note 2 A value from 1 to the maximum PE number in the target device can be specified for lt a gt cpu A lt name gt Specifies the device specification name for the target device the character string of the device file name excluding the first character d and extension dvf If omitted When the CC RH compiler is used ne must be specified as the CF850V4 activation option Note 1 When the device file name is dr7f701007 dvf the character string specified for lt name gt should be r7 701007 Note 2 When peid lt d gt is specified information regarding the specified PE number is read from the device file devpath lt path gt Retrieves the device file corresponding to the target device specified with cou A lt name gt from the path folder If omitted The device file is retrieved for the current folder Note 1 Specify the search path lt path gt within 255 characters Note 2 When the search path includes a space surround lt path gt by double quotation marks iA lt SIT file gt Specify the output file name system information table file name while the CF850V4 is activated If omitted The CF850V4 assumes that the following activation option is specified and performs processing REL Compiler CC RH
278. ock cycle Floating point values such as 2 5 cannot be specified 9 3 Timer Operations The RI850V4 s timer operation function provides Delayed task wakeup Timeout and Cyclic handlers as the method for realizing time dependent processing 9 3 1 Delayed task wakeup Delayed wakeup the operation that makes the invoking task transit from the RUNNING state to the WAITING state during the interval until a given length of time has elapsed and makes that task move from the WAITING state to the READY state once the given length of time has elapsed Delayed wakeup is implemented by issuing the following service call from the processing program dly_tsk 9 3 2 Timeout Timeout is the operation that makes the target task move from the RUNNING state to the WAITING state during the interval until a given length of time has elapsed if the required condition issued from a task is not immediately satisfied and makes that task move from the WAITING state to the READY state regardless of whether the required condition is satisfied once the given length of time has elapsed A timeout is implemented by issuing the following service call from the processing program tslp_tsk twai_sem twai_flg tsnd_dtq trev_dtq trev_mbx tloc_mtx tget_mpf tget_mpl 9 3 3 Cyclic handlers The cyclic handler is a routine dedicated to cycle processing that is activated periodically at a constant interval activation cycle The RI850V4 handles the cyclic handler as a
279. ocked state Object state error E_OBJ 41 Specified task is in the DORMANT state Non existent object E_NOEXS 42 Specified task is not registered other Normal completion wakeup request count R20UT2889EJ0101 Rev 1 01 tENESAS Page 198 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 16 SERVICE CALLS rel_ wai irel_ wai Outline Release task from waiting C format ER rel_wai ID tskid ER irel_wai ID tskid Parameter s 1 0 Parameter Description l ID tskid ID number of the task to be released from waiting Explanation These service calls forcibly cancel the WAITING state of the task specified by parameter tskid As a result the target task unlinked from the wait queue and is moved from the WAITING state to the READY state or from the WAITING SUSPENDED state to the SUSPENDED state E_RLWA is returned from the service call that triggered the move to the WAITING state slp_tsk wai_sem or the like to the task whose WAITING state is cancelled by this service call Note 1 This service call does not perform queuing of forced cancellation requests If the target task is in a state other than the WAITING or WAITING SUSPENDED state E_OBu is returned Note 2 The SUSPENDED state is not cancelled by these service calls Return value Macro Value Description E OK 0 Normal completion Invalid ID number E ID 18 tskid lt 0x0 tskid gt Maximum ID number Context
280. of the target data queue in the order of the data transmission request Note 2 Invoking tasks are queued to the transmission wait queue of the target data queue in the order defined during configuration FIFO order or priority order R20UT2889EJ0101 Rev 1 01 2tENESAS Page 64 of 366 Sep 30 2015 CHAPTER 5 SYNCHRONIZATION AND COMMUNICATION RI850V4 V2 FUNCTIONS psnd_dtq ipsnd_dtq These service calls write data specified by parameter data to the data queue area of the data queue specified by parameter dtqid If there is no available space for writing data in the data queue area of the target data queue when either of these service calls is issued data is not written but E_TMOUT is returned If a task has been queued to the reception wait queue of the target data queue when this service call is issued this service call does not write data but transfers the data to the task As a result the task is unlinked from the reception wait queue and moves from the WAITING state data reception wait state to the READY state or from the WAITING SUSPENDED state to the SUSPENDED state The following describes an example for coding this service call include lt kernel h gt Standard header file definition include lt kernel_id h gt System information header file definition void task VP_INT exinf ER ercd Declares variable ID dtqid ID_DTQ1 Declares and initializes variable VP_INT data 123 Declares and initi
281. ogram via the mailbox but it should be noted that in the case of the synchronization and communication functions of the RI850V4 only the start address of the message is handed over to the receiving processing program but the message contents are not copied to a separate area Securement of memory area In the case of the RI850V4 it is recommended to use the memory area secured by issuing service calls such as get_mpf and get_mpl for messages Note The RI850V4 uses the message start area as a link area during queuing to the wait queue for mailbox messages Therefore if the memory area for messages is secured from other than the memory area controlled by the RI850V4 it must be secured from 4 byte aligned addresses Basic form of messages In the RI850V4 the message contents and length are prescribed as follows according to the attributes of the mailbox to be used When using a mailbox with the TA_MFIFO attribute The contents and length past the first 4 bytes of a message system reserved area msgnext are not restricted in particular in the RI850V4 Therefore the contents and length past the first 4 bytes are prescribed among the processing programs that exchange data using the mailbox with the TA_MFIFO attribute The following shows the basic form of coding TA_MFIFO attribute messages in C Message packet for TA_MFIFO attribute typedef struct t_msg struct t_msg msgnext Reserved for future use T_MSG R2
282. olling failure E TMOUT 50 No message exists in the target mailbox R20UT2889EJ0101 Rev 1 01 Sep 30 2015 ztENESAS Page 245 of 366 RI850V4 V2 CHAPTER 16 SERVICE CALLS Outline Receive from mailbox with timeout C format ER trev_mbx ID mbxid T_MSG ppk_msg TMO tmout Parameter s 0 Parameter Description l ID mbxid ID number of the mailbox from which a message is received O T_MSG ppk_msg Start address of the message packet received from the mailbox Specified timeout unit millisecond I TMO tmout TMO_FEVR Waiting forever TMO_POL Polling Value Specified timeout Message packet T_MSG typedef struct t_msg struct t_msg msgnext Reserved for future use T_MSG Message packet T_ MSG_PRI typedef struct t_msg_pri struct t_msg msgque Reserved for future use PRI msgpri Message priority T_MSG_PRI Explanation This service call receives a message from the mailbox specified by parameter mbxid and stores its start address in the area specified by parameter ppk_msg If no message could be received from the target mailbox no messages were queued to the wait queue when this service call is issued this service call does not receive messages but queues the invoking task to the target mailbox wait queue and moves it from the RUNNING state to the WAITING state with timeout message reception wait state The receiving WAITING stat
283. ollows 1 ID number dtgid Specifies the ID number for a data queue A value from 0x1 to Oxff or a name can be specified for dtgid Note When a name is specified the CF850V4 automatically assigns an ID number The CF850V4 outputs the relationship between a name and an ID number to the system information header file in the following format define dtqid value 2 Attribute dtgatr Specifies the task queuing method for a data queue The keyword that can be specified for dtqatr is TA_TFIFO or TA_TPRI TA_TFIFO Task wait queue is in FIFO order TA_TPRI Task wait queue is in task priority order 3 Data count dtqcent memory area name sec_nam Specifies the maximum number of data units that can be queued to the data queue area of a data queue and the name of the memory area secured for the data queue area Only values from 0x0 to Oxff can be specified for dtqgent and only memory area name sec_nam defined in Memory area information can be specified for sec_nam Note If specification of sec_nam is omitted the data queue is allocated to kernel_work section 4 Reserved for future use atq System reserved area Values that can be specified for dtq are limited to NULL characters R20UT2889EJ0101 Rev 1 01 2tENESAS Page 317 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 17 SYSTEM CONFIGURATION FILE 17 5 5 Mailbox information The mailbox information defines ID number mbxid Attribute mbxatr Maximum message priori
284. on existent object E_NOEXS 42 Specified mutex is not registered R20UT2889EJ0101 Rev 1 01 2tENESAS Page 255 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 16 SERVICE CALLS Outline Reference mutex state C format ER ref_mtx ID mtxid T_RMTX pk_rmtx ER iref_mtx ID mtxid T_RMTX pk_rmtx Parameter s 0 Parameter Description l ID mtxid ID number of the mutex to be referenced O T_RMTX pk_rmtx Pointer to the packet returning the mutex state Mutex state packet T_RMTX typedef struct t_rmtx ID T_RMTX Explanation htskid wtskid mtxatr ceilpri as Existence of locked mutex Existence of waiting task Attribute Reserved for future use The service calls store the detailed information of the mutex specified by parameter mtxid existence of locked mutexes waiting tasks etc into the area specified by parameter pk_rmtx Note For details about the mutex state packet refer to 15 2 8 Mutex state packet Return value Macro Value Description E OK 0 Normal completion Invalid ID number E_ID 18 mtxid lt 0x0 mtxid gt Maximum ID number Context error E CIX 25 This service call was issued in the CPU locked state R20UT2889EJ0101 Rev 1 01 Sep 30 2015 2tENESAS Page 256 of 366 RI850V4 V2 CHAPTER 16 SERVICE CALLS Macro Value Description E_NOEXS
285. on task Initialization rou ref_sem Reference semaphore state iine Task Non task Initialization rou iref_sem Reference semaphore state tine R20UT2889EJ0101 Rev 1 01 tENESAS Page 205 of 366 Sep 30 2015 RI850V 4V2 CHAPTER 16 SERVICE CALLS Outlin e Acquire semaphore resource waiting forever C format ER wai_sem ID semid Parameter s 1 0 Parameter Description l ID semid ID number of the semaphore from which resource is acquired Explanation This service call acquires a resource from the semaphore specified by parameter semid subtracts 0x1 from the semaphore counter If no resources are acquired from the target semaphore when this service call is issued no available resources exist this service call does not acquire resources but queues the invoking task to the target semaphore wait queue and moves it from the RUNNING state to the WAITING state resource acquisition wait state The WAITING state for a semaphore resource is cancelled in the following cases and then moved to the READY state WAITING State for a Semaphore Resource Cancel Operation Return Value The resource was returned to the target semaphore as a result of issuing sig_sem E OK The resource was returned to the target semaphore as a result of issuing isig_sem E OK Forced release from waiting accept rel_wai while waiting E RLWAI Forced release from waiting accept irel_wai while waiting E RLW
286. or from the WAITING SUSPENDED state to the WAITING state Note This service call does not perform queuing of cancellation requests If the target task is in a state other than the SUSPENDED or WAITING SUSPENDED state E_OBJ is therefore returned Return value Macro Value Description E_OK 0 Normal completion Invalid ID number E ID 18 tskid lt 0x0 tskid gt Maximum ID number Context error E CTX 25 This service call was issued in the CPU locked state Object state error E_OBJ 41 Specified task is neither in the SUSPENDED state nor WAITING SUSPENDED state Non existent object E_NOEXS 42 Specified task is not registered R20UT2889EJ0101 Rev 1 01 tENESAS Page 203 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 16 SERVICE CALLS dly_tsk Outline Delay task C format ER dly_tsk RELTIM dlytim Parameter s 1 0 Parameter Description l RELTIM dlytim Amount of time to delay the invoking task unit millisecond Explanation This service call moves the invoking task from the RUNNING state to the WAITING state delayed state As a result the invoking task is unlinked from the ready queue and excluded from the RI850V4 scheduling subject The delayed state is cancelled in the following cases and then moved to the READY state Delayed State Cancel Operation Return Value Delay time specified
287. ort various execution environments the hardware dependent processing Post overflow processing that is required for the RI850V4 to execute processing is extracted as a user own coding module This enhances portability to various execution environments and facilitates customization as well Note The RI850V4 checks stack overflows only when TA_ON Overflow is checked is defined as Whether to check stack stkchk in the system configuration file R20UT2889EJ0101 Rev 1 01 2tENESAS Page 89 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 7 MEMORY POOL MANAGEMENT FUNCTIONS 7 2 1 Post overflow processing This is a routine dedicated to post processing that is extracted as a user own coding module to execute post overflow processing and is called when a stack overflow occurs in a processing program Basic form of post overflow processing When coding the post overflow processing use a void function function name _kernel_stk_overflow with two INT type arguments The value of stack pointer sp when a stack overflow is detected is set for the r6 argument and the value of program counter pc when a stack overflow is detected is set for the r7 argument The following shows the basic form of the post overflow processing in assembly language include lt kernel h gt Standard header file definition text align 0x2 globl __kernel_stk_overflow __kernel_stk_overflow halt_loop jbr halt_loop Internal processing of pos
288. ote 2 When the output file name includes a space surround lt Header file gt by double quotation marks Note 3 If this activation option is specified together with nd the CF850V4 handles nd as the valid option ni Disables output of the system information table file If omitted The system information table file is output Note If this activation option is specified together with i A lt S T file gt the CF850V4 handles this activation option as the valid option ne Disables output of the entry file If omitted The entry file is output Note If this activation option is specified together with e A lt Entry file gt the CF850V4 handles this activation option as the valid option nd Disables output of the system information header file If omitted If omitted The CF850V4 assumes that d A kernel_id is specified and performs processing Note If this activation option is specified together with d A lt Header file gt the CF850V4 handles this activation option as the valid option t A lt TOOL name gt Specifies the type of the C compiler package used Only REL and GHS can be specified for too as the keyword If omitted The CF850V4 assumes that t A REL is specified and performs processing T A lt Compiler path gt Specifies the command search lt Compiler path gt folder for the C preprocessor of the C compiler package specified by t A lt TOOL name gt If omitted The CF850V4 searches commands from a folder specif
289. ounter is set to 0x0 when this service call is issued the counter manipulation processing is not performed but E_TMOUT is returned Return value Macro Value Description E OK 0 Normal completion Invalid ID number E ID 18 semid lt 0x0 semid gt Maximum ID number Context error E CTX 25 This service call was issued in the CPU locked state Non existent object E NOEXS 42 Specified semaphore is not registered Polling failure E TMOUT 50 The resource counter of the target semaphore is 0x0 R20UT2889EJ0101 Rev 1 01 tENESAS Page 208 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 16 SERVICE CALLS Outline Acquire semaphore resource with timeout C format ER twai_sem ID semid TMO tmout Parameter s 0 Parameter Description ID semid ID number of the semaphore from which resource is acquired Specified timeout unit millisecond TMO tmout TMO_FEVR Waiting forever TMO_POL Polling Value Specified timeout Explanation This service call acquires a resource from the semaphore specified by parameter semid subtracts 0x1 from the semaphore counter If no resources are acquired from the target semaphore when service call is issued this no available resources exist this service call does not acquire resources but queues the invoking task to the target semaphore wait queue and moves it from the RUNNING state to the WAITING s
290. packet received from the mailbox Message packet T_MSG typedef struct t_msg struct t_msg msgnext Reserved for future use T_MSG Message packet T_ MSG_PRI typedef struct t_msg_pri struct t_msg msgque Reserved for future use PRI msgpri Message priority T_MSG_PRI Explanation This service call receives a message from the mailbox specified by parameter mbxid and stores its start address in the area specified by parameter ppk_msg If the message could not be received from the target mailbox no messages were queued in the wait queue when this service call is issued message reception processing is not executed but E_TMOUT is returned Note 1 If no message could be received from the target mailbox no messages were queued to the wait queue when this service call is issued the contents in the area specified by parameter ppk_msg become undefined Note 2 For details about the message packet refer to 15 2 6 Message packet Return value Macro Value Description E OK 0 Normal completion R20UT2889EJ0101 Rev 1 01 2tENESAS Page 244 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 16 SERVICE CALLS Macro Value Description Invalid ID number EID 18 mbxid lt 0x0 mbxid gt Maximum ID number Context error E CTX 25 This service call was issued in the CPU locked state Non existent object E NOEXS 42 Specified mailbox is not registered P
291. pecified by parameter mbxid and stores its start address in the area specified by parameter ppk_msg If no message could be received from the target mailbox no messages were queued to the wait queue when this service call is issued this service call does not receive messages but queues the invoking task to the target mailbox wait queue and moves it from the RUNNING state to the WAITING state with timeout message reception wait state The receiving WAITING state for a mailbox is cancelled in the following cases and then moved to the READY state Receiving WAITING State for a Mailbox Cancel Operation Return Value A message was transmitted to the target mailbox as a result of issuing snd_mbx E OK A message was transmitted to the target mailbox as a result of issuing isnd_mbx E OK Forced release from waiting accept rel_wai while waiting E RLWAI Forced release from waiting accept irel_ wai while waiting E RLWAI Polling failure or timeout E_TMOUT The following describes an example for coding this service call include include void task lt kernel h gt lt kernel_id h gt Standard header file definition System information header file definition VP_INT exinf ER ercd Declares variable ID mbxid ID_MAX1 Declares and initializes variable T_MSG ppk_msg Declares data structure TMO tmout 3600 Declares and initializes variable Receive from mailbo
292. pens the Realtime OS Task Analyzer 1 panel Task Analyzer 1 Note that this menu is disabled when the debug tool is not connected Opens the Realtime OS Task Analyzer 2 panel Task Analyzer 2 Note that this menu is disabled when the debug tool is not connected 2 Toolbar Displays the buttons relate to Realtime OS Buttons on the toolbar can be customized in the User Setting dialog box You can also create a new toolbar in the same dialog box Realtime OS toolbar Opens the Realtime OS Resource Information panel ES Note that this button is disabled when the debug tool is not connected Opens the Realtime OS Task Analyzer 1 panel EJ Note that this menu is disabled when the debug tool is not connected Opens the Realtime OS Task Analyzer 2 panel Ed Note that this menu is disabled when the debug tool is not connected 3 Panel display area The following panels are displayed in this area Project Tree panel Property panel Output panel See the each panel section for details of the contents of the display Note See CS Integrated Development Environment User s Manual Build for details about the Output panel R20UT2889EJ0101 Rev 1 01 2tENESAS Page 338 of 366 Sep 30 2015 RI850V4 V2 APPENDIX A WINDOW REFERENCE Project Tree panel Outline This panel is used to display the project components such as the microcontroller and build tool in tree view This panel
293. pplications or use by the military including but not limited to the development of weapons of mass destruction When exporting the Renesas Electronics products or technology described in this document you should comply with the applicable export control laws and regulations and follow the procedures required by such laws and regulations It is the responsibility of the buyer or distributor of Renesas Electronics products who distributes disposes of or otherwise places the product with a third party to notify such third party in advance of the contents and conditions set forth in this document Renesas Electronics assumes no responsibility for any losses incurred by you or third parties as a result of unauthorized use of Renesas Electronics products This document may not be reproduced or duplicated in any form in whole or in part without prior written consent of Renesas Electronics Please contact a Renesas Electronics sales office if you have any questions regarding the information contained in this document or Renesas Electronics products or if you have any other inquiries Note 1 Renesas Electronics as used in this document means Renesas Electronics Corporation and also includes its majority owned subsidiaries Note 2 Renesas Electronics product s means any product developed or manufactured by or for Renesas Electronics 2012 4 Readers Purpose Organization How to Read This Manual Conventions
294. ptance of El level maskable interrupts When passing control to an interrupt handler the RI850V4 disables acceptance of El level maskable interrupts by manipulating the PMn bits set to enabled in the priority mask register PMR and the ID bit set to disabled in the program status word PSW 10 3 3 Define interrupt handler The RI850V4 supports the static registration of interrupt handlers only They cannot be registered dynamically by issuing a service call from the processing program Static interrupt handler registration means defining of interrupt handlers using static API DEF_INH in the system configuration file For details about the static API DEF_INH refer to 17 5 10 Interrupt handler information 10 4 Base Clock Timer Interrupts The RI850V4 realizes the TIME MANAGEMENT FUNCTIONS by using base clock timer interrupts that occur at constant intervals If a base clock timer interrupt occurs The RI850V4 s time management interrupt handler is activated and executes time related processing system time update delayed wakeup timeout of task cyclic handler activation etc Note If acknowledgment of the relevant base clock timer interrupt is disabled by issuing loc_cpu iloc_cpu or dis_int the TIME MANAGEMENT FUNCTIONS may no longer operate normally 10 5 Multiple Interrupts In the RI850V4 occurrence of an interrupt in an interrupt handler is called multiple interrupts Execution of interrupt handler is started in the i
295. ption wait state to the READY state or from the WAITING SUSPENDED state to the SUSPENDED state The following describes an example for coding this service call include lt kernel h gt Standard header file definition include lt kernel_id h gt System information header file definition void task VP_INT exinf ID dtqid ID_DTQ1 Declares and initializes variable VP_INT data 123 Declares and initializes variable fsnd_dtq dtqid data Forced send to data queue R20UT2889EJ0101 Rev 1 01 RENESAS Page 68 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 5 SYNCHRONIZATION AND COMMUNICATION FUNCTIONS 5 4 4 Receive from data queue A data is received waiting forever polling or with timeout by issuing the following service call from the processing program rcv_dtq This service call reads data in the data queue area of the data queue specified by parameter diqid and stores it to the area specified by parameter p_data If no data could be read from the data queue area of the target data queue no data has been written to the data queue area when this service call is issued the service call does not read data but queues the invoking task to the reception wait queue of the target data queue and moves it from the RUNNING state to the WAITING state data reception wait state The receiving WAITING state for a data queue is cancelled in the following cases and then moved to the READY R20UT2889
296. pu iunl_cpu Unlock the CPU sns_loc Reference CPU state sns_dsp Reference dispatching state sns_ctx Reference contexts sns_dpn Reference dispatch pending state If an El level maskable interrupt is created during this period the RI850V4 delays transition to the relevant interrupt processing interrupt handler until either unl_cpu or iunl_cpu is issued Note 1 The CPU locked state changed by issuing this service call must be cancelled before the processing program that issued this service call ends Note 2 This service call does not perform queuing of lock requests If the system is in the CPU locked state therefore no processing is performed but it is not handled as an error Note 3 This service call manipulates PMn bits in the priority mask register PMR to disable acceptance of El level maskable interrupts The PMn bits to be manipulated correspond to the interrupt priority range defined as the Maximum interrupt priority maxintpri during configuration This service call does not manipulate the ID bit in the program status word PSW Note 4 The RI850V4 realizes the TIME MANAGEMENT FUNCTIONS by using base clock timer interrupts that occur at constant intervals If acknowledgment of the relevant base clock timer interrupt is disabled by issuing this service call the TIME MANAGEMENT FUNCTIONS may no longer operate normally Note 5 If this service call or a service call other than sns_xxx is issued from when this service ca
297. queue as a result E OK of issuing iprcv_dtq An available space was secured in the data queue area of the target data queue as a result E OK of issuing trcv_dtq Forced release from waiting accept rel_wai while waiting E RLWAI Forced release from waiting accept irel_ wai while waiting E RLWAI Polling failure or timeout E TMOUT If a task has been queued to the reception wait queue of the target data queue when this service call is issued this service call does not write data but transfers the data to the task As a result the task is unlinked from the reception wait queue and moves from the WAITING state data reception wait state to the READY state or from the WAITING SUSPENDED state to the SUSPENDED state The following describes an example for coding this service call R20UT2889EJ0101 Rev 1 01 2tENESAS Page 66 of 366 Sep 30 2015 CHAPTER 5 SYNCHRONIZATION AND COMMUNICATION void task RI850V4 V2 FUNCTIONS include lt kernel h gt Standard header file definition include lt kernel_id h gt System information header file definition ercd tsnd_dtq VP_INT exinf ER ercd ID dtqid ID_DTQ1 VP_INT data TMO tmout dtqid data Declares variable Declares and initializes variable Declares and initializes variable Declares and initializes variable Send to data queue with timeout tmout Normal termination processing Forced ter
298. queue as a result of issuing E OK psnd_dtq Data was written to the data queue area of the target data queue as a result of issuing E OK ipsnd_dtq Data was written to the data queue area of the target data queue as a result of issuing E OK tsnd_dtq Data was written to the data queue area of the target data queue as a result of issuing E OK fsnd_dtq Data was written to the data queue area of the target data queue as a result of issuing E OK ifsnd_dtq Forced release from waiting accept rel_wai while waiting E RLWAI Forced release from waiting accept irel_ wai while waiting E RLWAI Polling failure or timeout E_ TMOUT The following describes an example for coding this service call R20UT2889EJ0101 Rev 1 01 tENESAS Page 72 of 366 Sep 30 2015 CHAPTER 5 SYNCHRONIZATION AND COMMUNICATION RI850V4 V2 FUNCTIONS include lt kernel h gt Standard header file definition include lt kernel_id h gt System information header file definition void task VP_INT exinf ER ercd Declares variable ID dtqid ID_DTQ1 Declares and initializes variable VP_INT p data Declares variable TMO tmout 3600 Declares and initializes variable Receive from data queue with timeout ercd trev_dtq dtgid amp p_data tmout if ercd E_OK aya ee Se Normal termination processing else if ercd E_RLWAI sje ease aie Forced termination processing lse if ercd E_
299. queue creation means defining of data queues using static API CRE_DTQ in the system configuration file For details about the static API CRE_DTQ refer to 17 5 4 Data queue information R20UT2889EJ0101 Rev 1 01 2tENESAS Page 62 of 366 Sep 30 2015 CHAPTER 5 SYNCHRONIZATION AND COMMUNICATION RI850V4 V2 FUNCTIONS 5 4 2 Send to data queue A data is transmitted by issuing the following service call from the processing program snd_diq This service call writes data specified by parameter data to the data queue area of the data queue specified by parameter diqid If there is no available space for writing data in the data queue area of the target data queue when this service call is issued this service call does not write data but queues the invoking task to the transmission wait queue of the target data queue and moves it from the RUNNING state to the WAITING state data transmission wait state The sending WAITING state for a data queue is cancelled in the following cases and then moved to the READY state Sending WAITING State for a Data Queue Cancel Operation Return Value Available space was secured in the data queue area of the target data queue as a result of E OK issuing rcv_dtq Available space was secured in the data queue area of the target data queue as a result of E OK issuing prcv_dtq E Available space was secured in the data queue area of the target data queue as a result of E OK issuing iprc
300. r The following shows the cyclic handler information format CRE_CYC cycid cycatr exinf cychdr cyctim cycphs j The items constituting the cyclic handler information are as follows 1 ID number cycid Specifies the ID number for a cyclic handler A value from 0x1 to Oxff or a name can be specified for cycid Note When a name is specified the CF850V4 automatically assigns an ID number The CF850V4 outputs the relationship between a name and an ID number to the system information header file in the following format define cycid value 2 Attribute cycatr Specifies the attribute for a cyclic handler The keywords that can be specified for cycatr are TA_LHLNG TA_ASM TA_STA and TA_PHS Coding language TA_HLNG Start a cyclic handler through a C language interface TA_ASM Start a cyclic handler through an assembly language interface Initial activation state TA_STA Cyclic handlers is in an operational state after the creation Activation phase TA_PHS Cyclic handler is activated preserving the activation phase Note 1 If specification of TA_STA is omitted the initial activation state is set to non operational state Note 2 If specification of TA_PHS is omitted no activation phase items are saved 3 Extended information exinf Specifies the extended information for a cyclic handler A value from 0x0 to Oxffffffff or a symbol name can be specified for exinf Note The target cyclic hand
301. r block unit bytes and the name of the memory area secured for the fixed size memory pool Only 4 byte boundary values from 0x1 to Ox7fffffic can be specified for blksz and only memory area name sec_area defined in Memory area information can be specified for sec_nam Note If specification of sec_nam is omitted the fixed sized memory pool is allocated to kernel_work section Reserved for future use mpf System reserved area Values that can be specified for mpl are limited to NULL characters R20UT2889EJ0101 Rev 1 01 2tENESAS Page 320 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 17 SYSTEM CONFIGURATION FILE 17 5 8 Variable sized memory pool information The variable sized memory pool information defines ID number mplid Attribute mplatr Pool size mplsz memory area name sec_nam Reserved for future use mpl for a variable sized memory pool The number of items that can be defined as variable sized memory pool information is limited to one for each ID number The following shows the variable sized memory pool information format CRE_MPL mplid mplatr mplsz sec_nam mpl The items constituting the variable sized memory pool information are as follows 1 ID number mplid Specifies the ID number for a variable sized memory pool A value from 0x1 to Oxff or a name can be specified for mplid Note When a name is specified the CF850V4 automatically assigns an ID number The CF850V4 outpu
302. r describes the memory pool management functions performed by the RI850V4 7 1 Outline The statically secured memory areas in the Kernel Initialization Module are subject to management by the memory pool management functions of the RI850V4 The RI850V4 provides a function to reference the memory area status including the detailed information of fixed variable size memory pools as well as a function to dynamically manipulate the memory area including acquisition release of fixed variable size memory blocks by releasing a part of the memory area statically secured initialized as Fixed Sized Memory Pools or Variable Sized Memory Pools Table 7 1 Memory Area tvang z kernel_system Area where executable code of RI850V4 is allocated kernel_const Area where static data of RI850V4 is allocated kernel_data Area where dynamic data of RI850V4 is allocated kernel_data_init Area where kernel initialization flag of RI850V4 is allocated kernel_const_trace const Area where static data of trace function is allocated kernel_data_trace bss Area where dynamic data of trace function is allocated Area where system stack task stack data queue fixed sized memory pool and kernel_work i variable sized memory pool is allocated defined Area where task stack data queue fixed sized memory pool and variable sized SEC NAN Sak eee eee memory pool is allocated 7 2 User Own Coding Module To supp
303. re omitted El level maskable interrupts from the Maxi mum interrupt priority maxintpri to the minimum interrupt priority are enabled in the initial state 3 Extended information exinf Specifies the extended information for a task A value from 0x0 to Oxffffffff or a symbol name can be specified for exinf Note The target task can be manipulated by handling the extended information as if it were a function parameter R20UT2889EJ0101 Rev 1 01 2tENESAS Page 313 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 17 SYSTEM CONFIGURATION FILE 4 Start address task Specifies the start address for a task A value from 0x0 to Oxfffffffe aligned to a 2 byte boundary or a symbol name can be specified for task Note When a task is coded as follows the symbol name specified for task should be func_task include lt kernel h gt include lt kernel_id h gt void func_task VP_INT exinf Initial priority itskpri Specifies the initial priority for a task A value from 0x1 to Maximum priority maxtpri defined in the Basic information can be specified for itskpri Task stack size stksz memory area name sec_nam Specifies the task stack size unit bytes and the name of the memory area secured for the task stack Only 4 byte boundary values from 0x0 to Ox7ffffffc can be specified for stksz and only memory area name sec_nam defined in Memory area information can be specified for sec_nam Note 1 If specificat
304. re omitted the CF850V4 performs processing with the assumption that the direct vector method based on the reset vector address is selected as Generate method for the entry file The reset vector address is set to the default value defined in the device file that is specified in cpu A lt name gt If the reset vector address value cannot be obtained from the device file an error will occur Note 1 A value from 0x200 to Oxfffff800 can be specified as the base address lt nterrupt Base Address gt Note 2 If this activation option is specified together with ebase lt Exception Base Address gt the CF850V4 handles this activation option as the valid option ebase lt Exception Base Address gt Specifies the exception handler vector address which is necessary when the entry file is output with the direct vector method If omitted If both this activation option and intbp lt nterrupt Base Address gt are omitted the CF850V4 performs processing with the assumption that the direct vector method based on the reset vector address is selected as Generate method for the entry file The reset vector address is set to the default value defined in the device file that is specified in cpu A lt name gt If the reset vector address value cannot be obtained from the device file an error will occur Note 1 A value from 0x200 to Oxfffffe00 can be specified as the vector address lt Exception Base Address gt Note 2 If this activation option is
305. re therefore undefined Note 4 Invoking tasks are queued to the target variable size memory pool wait queue in the order defined during configuration FIFO order or priority order Note 5 If the variable size memory block acquisition wait state is cancelled because rel_wai or irel_wai was issued the contents in the area specified by parameter p_blk become undefined R20UT2889EJ0101 Rev 1 01 ztENESAS Page 101 of 366 Sep 30 2015 RI850V4 V2 pget_mpl ipget_mpl CHAPTER 7 MEMORY POOL MANAGEMENT FUNCTIONS This service call acquires a variable size memory block of the size 4 byte specified by parameter biksz from the variable size memory pool specified by parameter mplid and stores its start address into the area specified by parameter p_bik If no variable size memory blocks could be acquired from the target variable size memory pool no successive areas equivalent to the requested size were available when this service call is issued this service call does not acquire variable size memory block but returns E_TMOUT The following describes an example for coding this service call include lt kernel h gt Standard header file definition include lt kernel_id h gt System information header file definition void task VP_INT exinf ER ercd Declares variable ID mplid ID_MTX1 Declares and initializes variable UINT blksz 256 Declares and initializes variable VP p_blk Declares variable
306. rea the detailed information on the Realtime OS node system configuration file or the like that is selected on the Project Tree panel is displayed by every category in the list And the settings of the information can be changed directly Mark E indicates that all the items in the category are expanded Mark H indicates that all the items are collapsed You can expand collapse the items by clicking these marks or double clicking the category name See the section on each tab for the details of the display setting in the category and its contents 3 Property description area Display the brief description of the categories and their contents selected in the detailed information display change area R20UT2889EJ0101 Rev 1 01 7tENESAS Page 341 of 366 Sep 30 2015 RI850V4 V2 APPENDIX A WINDOW REFERENCE 4 Tab selection area Categories for the display of the detailed information are changed by selecting a tab In this panel the following tabs are contained see the section on each tab for the details of the display setting on the tab When the Realtime OS node is selected on the Project Tree panel RI850V4 tab When the system configuration file is selected on the Project Tree panel System Configuration File Related Information tab File Information tab When the Realtime OS generated files node is selected on the Project Tree panel Category Information tab When the system information table file or entry file i
307. red Since information files are basically enumerations of data it is possible to describe them with various editors Information files however do not excel in descriptiveness and readability therefore substantial time and effort are required when they are described To solve this problem the RI850V4 provides a utility tool configurator CF850V4 that converts a system configuration file which excels in descriptiveness and readability into information files The CF850V4 reads the system configuration file as an input file and then outputs information files The information files output from the CF850V4 are explained below System information table file An information file that contains data related to OS resources base clock interval maximum priority management object or the like required by the RI850V4 to operate System information header file An information file that contains the correspondence between object names task names semaphore names or the like described in the system configuration file and IDs Entry file A routine Interrupt entry processing dedicated to entry processing that holds processing to branch to the relevant processing such as interrupt preprocessing _kernel_int_entry for the handler address to which the CPU forcibly passes control when an El level maskable interrupt occurs R20UT2889EJ0101 Rev 1 01 ztENESAS Page 329 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 18 CONFIGURATOR CF850V4 18
308. refore does not return the acquired resources addition to the semaphore counter value but returns E_QOVR Return value Macro Value Description E_OK 0 Normal completion Invalid ID number E ID 18 semid lt 0x0 semid gt Maximum ID number Context error E CIX 25 This service call was issued in the CPU locked state Non existent object E NOEXS 42 Specified semaphore is not registered Queue overflow E QOVR 43 Resource count exceeded maximum resource count R20UT2889EJ0101 Rev 1 01 tENESAS Page 211 of 366 Sep 30 2015 RI850V4 V2 ref_sem iref_sem Outline Reference semaphore state CHAPTER 16 SERVICE CALLS C format ER ref_sem ID semid T_RSEM pk_rsem ER iref_sem ID semid T_RSEM pk_rsem Parameter s 0 Parameter Description ID semid ID number of the semaphore to be referenced O T_RSEM pk_rsem Pointer to the packet returning the semaphore state Semaphore state packet T_RSEM typedef struct t_rsem ID wtskid Existence of waiting task UINT sement Current resource count ATR sematr Attribute UINT maxsem Maximum resource count T_RSEM Explanation Stores semaphore state packet ID number of the task at the head of the wait queue current resource count etc of the semaphore specified by parameter semid in the area specified by parameter pk_rsem Note For
309. required for implementing the TIME MANAGEMENT FUNCTIONS provided by the RI850V4 To initialize hardware used by the RI850V4 for time management such as timers and controllers the setting must therefore be made so as to generate base clock timer interrupts at the interval defined with tim_base Base clock timer exception code tim_intno Specifies the exception code for the base clock timer interrupt that is necessary to implement the time management facility provided by the RI850V4 The value that can be specified for tim_into is an interrupt source name specified in the device file or a value from 0x1000 to the maximum exception code maxintno Note When an interrupt source name is specified for tim_intno cpu A name must be specified for the CF850V4 activation option System stack size sys_stksz Specifies the system stack size in bytes A value from 0x0 to Ox ffffffc aligned to a 4 byte boundary can be specified for sys_stksz Note 1 For expressions to calculate the system stack size refer to 1 System stack Note 2 The memory area for system stack is secured from the kernel_work section Note 3 The stack size that is actually secured is calculated as the specified stack size plus 20 80 size of context area of interrupt handler Whether to check stack stkchk R20UT2889EJ0101 Rev 1 01 2tENESAS Page 309 of 366 Sep 30 2015 CHAPTER 17 SYSTEM CONFIGURATION FILE RI850V4 V2 CHAPTER 17 SYSTEM CONFIGURATION FILE
310. rformed but E_QOVR is returned Macro Value Description E OK 0 Normal completion Invalid ID number tskid lt 0x0 E_ID 18 tskid gt Maximum ID number When this service call was issued from a non task TSK_SELF was specified tskid Context error E_CTX 25 This service call was issued in the CPU locked state When this service call was issued in the dispatching disabled state invoking task was specified tskid R20UT2889EJ0101 Rev 1 01 Sep 30 2015 2tENESAS Page 200 of 366 RI850V4 V2 CHAPTER 16 SERVICE CALLS Macro Value Description Object state error E OBJ 41 Specified task is in the DORMANT state Non existent object E_NOEXS 42 Specified task is not registered Queue overflow E_QOVR 43 Suspension count exceeded 127 R20UT2889EJ0101 Rev 1 01 Sep 30 2015 ztENESAS Page 201 of 366 RI850V4 V2 CHAPTER 16 SERVICE CALLS Outline Resume suspended task C format ER rsm_tsk ID tskid ER irsm_tsk ID tskid Parameter s 0 Parameter Description l ID tskid ID number of the task to be resumed Explanation This service call subtracts 0x1 from the suspend request counter for the task specified by parameter tskid and then cancels the SUSPENDED state of the target task As a result the target task is moved from the SUSPENDED state to the READY state or from the WAITING SUSPENDED state
311. rformed regardless of the operating status of the target cyclic handler Return value Macro Value Description E OK 0 Normal completion Invalid ID number E ID 18 cycid lt 0x0 cycid gt Maximum ID number Context error E_CTX 25 This service call was issued in the CPU locked state R20UT2889EJ0101 Rev 1 01 2tENESAS Page 283 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 16 SERVICE CALLS Macro Value Description E_NOEXS 42 Non existent object Specified cyclic handler is not registered R20UT2889EJ0101 Rev 1 01 Sep 30 2015 ztENESAS Page 284 of 366 RI850V4 V2 CHAPTER 16 SERVICE CALLS stp_cyc istp_cyc Outline Stop cyclic handler operation C format ER stp_cyc ID cycid ER istp_cyc ID cycid Parameter s 1 0 Parameter Description l ID cycid ID number of the cyclic handler operation to be stopped Explanation This service call moves the cyclic handler specified by parameter cycid from the operational state STA state to non operational state STP state As a result the target cyclic handler is excluded from activation targets of the RI850V4 until issue of sta_cyc or ista_cyc Note This service call does not perform queuing of stop requests If the target cyclic handler has been moved to the non operational state STP state therefore no processing is performed but it is not handled a
312. ribes an example for coding this service call lt kernel h gt lt kernel_id h gt include include void task VP_INT exinf waiting forever ercd get_mpl mplid blksz amp p_ blk rel_mpl mplid p blk else if ercd E_RLWAI Normal termination processing Forced termination processing Standard header file definition System information header file definition ER ercd Declares variable ID mplid ID_MPL1 Declares and initializes variable UINT blksz 256 Declares and initializes variable VP p_blk Declares variable Acquire variable sized memory block Release variable sized memory block R20UT2889EJ0101 Rev 1 01 2tENESAS Sep 30 2015 Page 100 of 366 RI850V4 V2 CHAPTER 7 MEMORY POOL MANAGEMENT FUNCTIONS Note 1 The RI850V4 acquires variable size memory blocks in the unit of integral multiple of 4 If a value other than an integral multiple of 4 is specified for parameter blksz it is rounded up to be an integral multiple of 4 Note 2 The RI850V4 needs a 4 byte area management block to manage the acquired variable sized memory blocks When this service call is issued an area of biksz 4 bytes is allocated in the target variable sized memory pool Note 3 The RI850V4 does not perform memory clear processing when getting the acquired variable size memory block The contents of the got variable size memory block a
313. rity tine k Non task Initialization rou ref_tsk Reference task state be p NON ESS Inilaleation YOu Task Non task Initialization rou iref_tsk Reference task state kaa om tasknikalzatio s P Task Non task Initialization rou ref_tst Reference task state simplified version re onias ba 3 Task Non task Initialization rou iref_tst Reference task state simplified version Pan ontas tg R20UT2889EJ0101 Rev 1 01 Sep 30 2015 2tENESAS Page 178 of 366 RI850V4 V2 CHAPTER 16 SERVICE CALLS Outline Activate task queues an activation request C format ER act_tsk ID tskid ER iact_tsk ID tskid Parameter s V O Parameter Description ID number of the task to be activated ID tskid TSK_SELF Invoking task Value ID number of the task to be activated Explanation These service calls move a task specified by parameter tskid from the DORMANT state to the READY state As a result the target task is queued at the end on the ready queue corresponding to the initial priority and becomes subject to scheduling by the RI850V4 If the target task has been moved to a state other than the DORMANT state when this service call is issued this service call does not move the state but increments the activation request counter by added 0x1 to the wakeup request counter Note 1 Note 2 Return value The activation request counter managed by the RI850V4 is configured in 7 bit width
314. rmal completion Parameter error tmout lt TMO_FEVR E_ PAR 17 Invalid ID number EID 18 dtgid lt 0x0 dtgid gt Maximum ID number Context error This service call was issued from a non task E CTX 25 This service call was issued in the CPU locked state This service call was issued in the dispatching disabled state Non existent object E NOEXS 42 Specified data queue is not registered Forced release from the WAITING state E RLWAI 49 Accept rel_wai irel_wai while waiting Timeout E TMOUT 50 Polling failure or timeout R20UT2889EJ0101 Rev 1 01 tENESAS Page 236 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 16 SERVICE CALLS Outline Reference data queue state C format ER ref_dtq ID dtqid T_RDTQ pk_rdtq ER iref_dtq ID dtqid T_RDTQ pk_rdtq Parameter s 0 Parameter Description ID dtqid ID number of the data queue to be referenced O T_RDTQ pk_rdtq Pointer to the packet returning the data queue state Data queue state packet T_RDTQ typedef struct t_rdtq ID stskid Existence of tasks waiting for data transmission ID rtskid Existence of tasks waiting for data reception UINT sdtgqcnt Number of data elements in data queue ATR dtgqatr Attribute UINT dtqent Data count ID memid Reserved for future use T_RDTOQ Explanation These service calls store the detailed inform
315. rocessing System information header file definition Note When TMO_FEVR is specified for wait time tmout processing equivalent to slp_tsk will be executed R20UT2889EJ0101 Rev 1 01 Sep 30 2015 2tENESAS Page 38 of 366 RI850V4 V2 CHAPTER 4 TASK DEPENDENT SYNCHRONIZATION FUNCTIONS 4 3 Wakeup Task A task is woken up by issuing the following service call from the processing program wup_tsk iwup_tsk These service calls cancel the WAITING state sleeping state of the task specified by parameter tskid As a result the target task is moved from the sleeping state to the READY state or from the WAITING SUSPENDED state to the SUSPENDED state If the target task is in a state other than the sleeping state when this service call is issued this service call does not move the state but increments the wakeup request counter by added 0x1 to the wakeup request counter The following describes an example for coding this service call include lt kernel h gt Standard header file definition void task VP_INT exinf ID tskid ID_TSK1 Declares and initializes variable wup_tsk tskid Wakeup task include lt kernel_id h gt System information header file definition Note The wakeup request counter managed by the RI850V4 is configured in 7 bit widths If the number of wakeup requests exceeds the maximum count value 127 as a result of issuing this service call the counter manipu
316. rom the semaphore counter If no resources are acquired from the target semaphore when service call is issued this no available resources exist this service call does not acquire resources but queues the invoking task to the target semaphore wait queue and moves it from the RUNNING state to the WAITING state with timeout resource acquisition wait state The WAITING state for a semaphore resource is cancelled in the following cases and then moved to the READY state WAITING State for a Semaphore Resource Cancel Operation Return Value The resource was returned to the target semaphore as a result of issuing sig_sem E OK The resource was returned to the target semaphore as a result of issuing isig_sem E OK Forced release from waiting accept rel_wai while waiting E RLWAI Forced release from waiting accept irel_wai while waiting E RLWAI Polling failure or timeout E TMOUT The following describes an example for coding this service call include lt kernel h gt Standard header file definition include lt kernel_id h gt System information header file definition void task VP_INT exinf ER ercd Declares variable ID semid ID_SEM1 Declares and initializes variable TMO tmout 3600 Declares and initializes variable ercd twai_sem semid tmout Acquire semaphore resourc with timeout if ercd E_OK EEE E Normal termination processing
317. rom which a memory block l ID mpfid s is acquired O VP p_ blk Start address of the acquired memory block Explanation This service call acquires the fixed sized memory block from the fixed sized memory pool specified by parameter mpfid and stores the start address in the area specified by parameter p_bik If no fixed size memory blocks could be acquired from the target fixed size memory pool no available fixed size memory blocks exist when this service call is issued this service call does not acquire the fixed size memory block but queues the invoking task to the target fixed size memory pool wait queue and moves it from the RUNNING state to the WAITING state fixed size memory block acquisition wait state The WAITING state for a fixed sized memory block is cancelled in the following cases and then moved to the READY state WAITING State for a Fixed sized Memory Block Cancel Operation Return Value A fixed sized memory block was returned to the target fixed sized memory pool as a result of E OK issuing rel_mpf A fixed sized memory block was returned to the target fixed sized memory pool as a result of E OK issuing irel_mpf Forced release from waiting accept rel_wai while waiting E RLWAI Forced release from waiting accept irel_wai while waiting E RLWAI Note 1 The RI850V4 does not perform memory clear processing when acquiring a fixed sized memory block The contents of the acquired fixed si
318. rrupts defined in the Interrupt handler information in the system configuration file For interrupt types other than the El level maskable interrupt interrupt entry processing should always be coded in the direct vector method Direct vector method extern _inthdr External label declaration org base_adress offset Setting of branch destination address jr32 _inthdr Branch to interrupt processing Note Set base_address to the same value as that specified in the Property panel gt System Configuration File Related Information tabbed page _ Entry File category gt Specify an exception handler vector address Set offset to the offset value corresponding to the priority of the target interrupt R20UT2889EJ0101 Rev 1 01 2tENESAS Page 132 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 10 INTERRUPT MANAGEMENT FUNCTIONS Table reference method extern _inthdr External label declaration org base_adress offset Setting of branch destination address dw _inthdr Branch to interrupt processing Note Set base_adadress to the same value as that specified in the Property panel gt System Configuration File Related Information tabbed page _ Entry File category gt Base address of the interrupt handler address table Set offset to the offset value corresponding to the source of the target interrupt Internal processing of interrupt entry processing Interrupt entry processing is a routin
319. s If the number of activation requests exceeds the maximum count value 127 as a result of issuing this service call the counter manipulation processing is therefore not performed but E_QOVR is returned Extended information specified in Task information is passed to the task activated by issuing these service Calls Macro Value Description E OK 0 Normal completion Invalid ID number tskid lt 0x0 E_ID 18 tskid gt Maximum ID number When this service call was issued from a non task TSK_SELF was specified tskid Context error E_CTX 25 This service call was issued in the CPU locked state R20UT2889EJ0101 Rev 1 01 Sep 30 2015 2tENESAS Page 179 of 366 RI850V4 V2 CHAPTER 16 SERVICE CALLS Macro Value Description Non existent object E NOEXS 42 Specified task is not registered Queue overflow E _QOVR 43 Activation request count exceeded 127 R20UT2889EJ0101 Rev 1 01 Sep 30 2015 ztENESAS Page 180 of 366 RI850V4 V2 CHAPTER 16 SERVICE CALLS Outline Activate task does not queue an activation request C format ER sta_tsk ID tskid VP_INT stacd ER ista_tsk ID tskid VP_INT stacd Parameter s 0 Parameter Description l ID tskid ID number of the task to be activated l VP_INT stacd Start code extended information of the task Explanation These service calls move a task speci
320. s be sure to issue either of these service calls for the acquired fixed size memory pools If the service call is issued for another fixed size memory pool no error results but the operation is not guaranteed after that R20UT2889EJ0101 Rev 1 01 2tENESAS Page 97 of 366 Sep 30 2015 RI850V4 V2 7 3 4 Reference fixed sized memory pool state CHAPTER 7 MEMORY POOL MANAGEMENT FUNCTIONS A fixed sized memory pool status is referenced by issuing the following service call from the processing program ref_mpf iref_mpf Stores fixed sized memory pool state packet ID number of the task at the head of the wait queue number of free memory blocks etc of the fixed sized memory pool specified by parameter mpfid in the area specified by parameter pk_rmpt The following describes an example for coding this service call include lt kernel h gt include lt kernel_id h gt void task VP_INT exinf ID mpfid 1 T_RMPF pk_rmpf ID wtskid UINT fblkcnt ATR mpfatr ref_mpf mpfid amp pk_rmpf wtskid pk_rmpf wtskid fblkcnt pk_rmpf fblkcnt mpfatr pk_rmpf mpfatr Standard header file definition System information header file definition Declares and initializes variable Declares data structure Declares variable Declares variable Declares variable Reference fixed sized memory pool state Reference ID number of the task at the head of the wait queue
321. s a resource from the semaphore specified by parameter semid subtracts 0x1 from the semaphore counter If no resources are acquired from the target semaphore when this service call is issued no available resources exist this service call does not acquire resources but queues the invoking task to the target semaphore wait queue and moves it from the RUNNING state to the WAITING state resource acquisition wait state The WAITING state for a semaphore resource is cancelled in the following cases and then moved to the READY state WAITING State for a Semaphore Resource Cancel Operation Return Value The resource was returned to the target semaphore as a result of issuing sig_sem E OK The resource was returned to the target semaphore as a result of issuing isig_sem E OK Forced release from waiting accept rel_wai while waiting E RLWAI Forced release from waiting accept irel_wai while waiting E RLWAI The following describes an example for coding this service call include lt kernel h gt Standard header file definition include lt kernel_id h gt System information header file definition void task VP_INT exinf ER ercd Declares variable ID semid ID_SEM1 Declares and initializes variable ercd wai_sem semid Acquire semaphore resource waiting forever if ercd E_OK dete ENT Normal termination processing else if ercd E_RLWAI steer ae S
322. s an error Return value Macro Value Description E OK 0 Normal completion Invalid ID number E_ID 18 cycid lt 0x0 cycid gt Maximum ID number Context error E CTX 25 This service call was issued in the CPU locked state Non existent object E NOEXS 42 Specified cyclic handler is not registered R20UT2889EJ0101 Rev 1 01 7tENESAS Page 285 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 16 SERVICE CALLS ref_cyc iref_cyc Outline Reference cyclic handler state C format ER ref_cyc ID cycid T_RCYC pk_rcyc ER iref_cyc ID cycid T_RCYC pk_rcyc Parameter s 0 Parameter Description ID cycid ID number of the cyclic handler to be referenced O T_R YC pk_rcyc Pointer to the packet returning the cyclic handler state Cyclic handler state packet T_RCYC typedef struct t_rcyc STA cycstat Current state RELTIM lefttim Time left before the next activation ATR cycatr Attribute RELTIM cyctim Activation cycle RELTIM cycphs Activation phase k 7 _ RECYCs Explanation Stores cyclic handler state packet current state time left before the next activation etc of the cyclic handler specified by parameter cycid in the area specified by parameter pk_rcyc Note For details about the cyclic handler state packet refer to 15 2 12 Cyclic handler state packet Return value
323. s not exist Does not generate a system information table file and does not display it on the project tree If this item is selected when there is already a system information table file then the file itself is not deleted No It does not register the file to the project ni Specify the folder for outputting the system information table file If a relative path is specified the reference point of the path is the project folder If an absolute path is specified the reference point of the path is the project folder unless the drives are different The following macro name is available as an embedded macro BuildModeName Replaces with the build mode name If this field is left blank macro name BuildModeName will be displayed Output folder This property is not displayed when No It does not register the file that is added to the project ni in the Generate a file property is selected Default BuildModeName Directly enter to the text box or edit by the Browse For Folder OWO change dialog box which appears when clicking the button Restriction Up to 247 characters Specify the system information table file name If the file name is changed the name of the file displayed on the project tree Use the extension s If the extension is different or omitted s is automatically added You cannot specify the same file name as the value of the File name property in the Entry
324. s selected on the Project Tree panel Build Settings tab Individual Assemble Options tab File Information tab When the system information header file is selected on the Project Tree panel File Information tab When the trace information file is selected on the Project Tree panel Build Settings tab Individual Assemble Options tab File Information tab Note1 See CS Integrated Development Environment User s Manual CC RH Build Tool Operation for details about the File Information Category Information Build Settings Individual Assemble Options and Individual Compile Options tabbed pages Note2 When multiple components are selected on the Project Tree panel only the tab that is common to all the components is displayed If the value of the property is modified that is taken effect to the selected components all of which are common to all R20UT2889EJ0101 Rev 1 01 2tENESAS Page 342 of 366 Sep 30 2015 RI850V4 V2 APPENDIX A WINDOW REFERENCE RI850V4 tab Outline This tab shows the detailed information on RI850V4 to be used categorized by the following Version Information This tab can be opened as follows On the Project Tree panel select a component such as the Realtime OS node or the system configuration file and then select the View menu gt Property or select Property from the context menu Note When the Property panel is already open selecting a component such as th
325. sem sematr maxsem pk_rsem maxsem Note Standard header file definition System information header file definition Declares Declares Declares Declares Declares Declares and initializes variable data structure variable variable variable variable Referenc Reference ID number of the task at the head of the wait queue current resourc Referenc semaphor state count Reference attribute Reference maximum resource count For details about the semaphore state packet refer to 15 2 3 Semaphore state packet R20UT2889EJ0101 Rev 1 01 Sep 30 2015 2tENESAS Page 52 of 366 CHAPTER 5 SYNCHRONIZATION AND COMMUNICATION RI850V4 V2 FUNCTIONS 5 3 Eventflags The RI850V4 provides 32 bit eventflags as a queuing function for tasks such as keeping the tasks waiting for execution until the results of the execution of a given processing program are output The following shows a processing flow when using an eventflag Figure 5 2 Processing Flow Eventtflag Task A Task B Priority High Priority Low Wait for eventflag Queuing period Set eventtflag 5 3 1 Create eventflag In the RI850V4 the method of creating an eventflag is limited to static creation Eventflags therefore cannot be created dynamically using a method such as issuing a service call from a processing program Static event flag creation me
326. sized memory block TTW_MPL WAITING state for a variable sized memory block R20UT2889EJ0101 Rev 1 01 2tENESAS Page 157 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 15 DATA TYPES AND MACROS 15 2 3 Semaphore state packet The following shows semaphore state packet T_RSEM used when issuing ref_sem or iref_sem Definition of semaphore state packet T_RSEM is performed by the header file lt ri_root gt include os packet h which is called from the standard header file lt ri_root gt include kernel h typedef struct t_rsem ID wtskid Existence of waiting task UINT semcnt Current resource count ATR sematr Attribute UINT maxsem Maximum resource count T_RSEM The following shows details on semaphore state packet T_RSEM wtskid Stores whether a task is queued to the semaphore wait queue TSK_NONE No applicable task Value ID number of the task at the head of the wait queue semcnt Stores the current resource count sematr Stores the attribute queuing method Task queuing method bit 0 TA_TFIFO Task wait queue is in FIFO order TA_TPRI Task wait queue is in task priority order Structure of sematr 15 0 tL TA_TFIFO 0 TA_TPRI 1 maxsem Stores the maximum resource count R20UT2889EJ0101 Rev 1 01 7tENESAS Page 158 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 15 DATA TYPES AND MACROS 15 2 4 Eventflag state packet The following shows eventfla
327. sk T_RMBX wtskid pk_msg mbxatr ref_mbx lt kernel h gt lt kernel_id h gt VP_INT exinf mbxid ID_MBX1 pk_rmbx wt skid pk_msgj mbxatr mbxid amp pk_rmbx pk_rmbx wtskid pk_rmbx pk_msg pk_rmbx mbxatr Standard header file definition System information header file definition Declares Declares Declares Declares Declares Reference mailbox state Reference ID number of the task at the head of the wait queue Reference start address of the message packet at the head of the wait queue Reference attribute and initializes variable data structure variable data structure variable Note For details about the mailbox state packet refer to 15 2 7 Mailbox state packet R20UT2889EJ0101 Rev 1 01 Sep 30 2015 ztENESAS Page 81 of 366 CHAPTER 6 EXTENDED SYNCHRONIZATION AND RI850V4 V2 COMMUNICATION FUNCTIONS CHAPTER 6 EXTENDED SYNCHRONIZATION AND COMMUNICATION FUNCTIONS This chapter describes the extended synchronization and communication functions performed by the RI850V4 6 1 Outline The RI850V4 provides Mutexes as the extended synchronization and communication function for implementing exclusive control between tasks 6 2 Mutexes Multitask processing requires the function to prevent contentions on using the limited number of resources A D converter coprocessor files or the like simultaneously
328. specified together with intbp lt nterrupt Base Address gt the CF850V4 handles intop lt nterrupt Base Address gt as the valid option V Outputs version information for the CF850V4 to the standard output Note If this activation option is specified the CF850V4 handles other activation options as invalid options and suppresses outputting of information files help Outputs the usage of the activation options for the CF850V4 to the standard output Note If this activation option is specified the CF850V4 handles other activation options as invalid options and suppresses outputting of information files lt CF file gt Specifies the system configuration file name to be input Note 1 Specify the input file name lt CF file gt within 255 characters including the path name Note 2 When the input file name includes a space surround lt CF file gt by double quotation marks Note 3 This input file name can be omitted only when V or help is specified R20UT2889EJ0101 Rev 1 01 2tENESAS Page 332 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 18 CONFIGURATOR CF850V4 18 2 2 Activating from CS This is started when CS performs a build in accordance with the setting on the Property panel on the System Configuration File Related Information tab R20UT2889EJ0101 Rev 1 01 ztENESAS Page 333 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 18 CONFIGURATOR CF850V4 18 2 3 Command file The CF850V4 performs command file support from t
329. ssuing the following service call from the processing program get_mpl This service call acquires a variable size memory block of the size 4 byte specified by parameter biksz from the variable size memory pool specified by parameter mplid and stores its start address into the area specified by parameter p_bik If no variable size memory blocks could be acquired from the target variable size memory pool no successive areas equivalent to the requested size were available when this service call is issued this service call does not acquire variable size memory blocks but queues the invoking task to the target variable size memory pool wait queue and moves it from the RUNNING state to the WAITING state variable size memory block acquisition wait state The WAITING state for a variable sized memory block is cancelled in the following cases and then moved to the READY state WAITING State for a Variable sized Memory Block Cancel Operation Return Value The variable size memory block that satisfies the requested size was returned to the target E OK variable size memory pool as a result of issuing rel_mpl The variable size memory block that satisfies the requested size was returned to the target E OK variable size memory pool as a result of issuing irel_mpl Forced release from waiting accept rel_wai while waiting E RLWAI Forced release from waiting accept irel_wai while waiting E RLWAI The following desc
330. state packet refer to 15 2 7 Mailbox state packet Return value Macro Value Description E OK 0 Normal completion Invalid ID number E ID 18 mbxid lt 0x0 mbxid gt Maximum ID number Context error E CTX 25 This service call was issued in the CPU locked state Non existent object E_NOEXS 42 Specified mailbox is not registered R20UT2889EJ0101 Rev 1 01 2tENESAS Page 248 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 16 SERVICE CALLS 16 2 7 Extended synchronization and communication functions mutexes The following shows the service calls provided by the RI850V4 as the extended synchronization and communication functions mutexes Table 16 7 Extended Synchronization and Communication Functions Mutexes Service Call Function Origin of Service Call loc_mtx Lock mutex waiting forever Task ploc_mtx Lock mutex polling Task tloc_mtx Lock mutex with timeout Task unl_mtx Unlock mutex Task ref_mtx Reference mutex state ht Nonas sive aon U iref_mtx Reference mutex state hat Kon Task Nil alle WOntQUe R20UT2889EJ0101 Rev 1 01 ztENESAS Page 249 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 16 SERVICE CALLS Outline Lock mutex waiting forever C format ER loc_mtx ID mtxid Parameter s 1 0 Parameter Description l ID mtxid ID number of the mutex to be locked Explanation This service call locks
331. stem information header file definition void task VP_INT exinf ER ercd Declares variable ID mtxid ID_MTX1 Declares and initializes variable ercd ploc_mtx mtxid j Lock mutex polling if ercd E_OK a ener Polling success processing unl_mtx mtxid Unlock mutex lse if ercd E_TMOUT eee eee Polling failure processing Note In the RI850V4 E_ILUSE is returned if this service call is re issued for the mutex that has been locked by the invoking task multiple locking of mutex R20UT2889EJ0101 Rev 1 01 ztENESAS Page 85 of 366 Sep 30 2015 CHAPTER 6 EXTENDED SYNCHRONIZATION AND RI850V4 V2 COMMUNICATION FUNCTIONS tloc_mtx This service call locks the mutex specified by parameter mtxid If the target mutex could not be locked another task has been locked when this service call is issued this service call queues the invoking task to the target mutex wait queue and moves it from the RUNNING state to the WAITING state with timeout mutex wait state The WAITING state for a mutex is cancelled in the following cases and then moved to the READY state WAITING State for a Mutex Cancel Operation Return Value The locked state of the target mutex was cancelled as a result of issuing unl_mtx E OK The locked state of the target mutex was cancelled as a result of issuing ext_tsk E OK The locked state of the target mutex was cancelled as
332. stem information table file system information header file entry file that contain data to be provided for the RI850V4 Note For details about the system configuration file refer to CHAPTER 17 SYSTEM CONFIGURATION FILE 2 3 Coding Processing Programs Code the processing that should be implemented in the system In the RI850V4 the processing program is classified into the following seven types in accordance with the types and purposes of the processing that should be implemented Tasks A task is processing program that is not executed unless it is explicitly manipulated via service calls provided by the RI850V4 unlike other processing programs cyclic handler interrupt handler etc Cyclic handlers The cyclic handler is a routine dedicated to cycle processing that is activated periodically at a constant interval activation cycle The RI850V4 handles the cyclic handler as a non task module independent from tasks Therefore even if a task with the highest priority in the system is being executed the processing is suspended when a specified activation cycle has come and the control is passed to the cyclic handler Interrupt Handlers The interrupt handler is a routine dedicated to interrupt servicing that is activated when an El level maskable interrupt occurs The RI850V4 handles the interrupt handler as a non task module independent from tasks Therefore even if a task with the highest priority in the system is bein
333. system time lower 32 bits utime Stores the system time higher 16 bits R20UT2889EJ0101 Rev 1 01 ztENESAS Page 166 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 15 DATA TYPES AND MACROS 15 2 12 Cyclic handler state packet The following shows cyclic handler state packet T_RCYC used when issuing ref_cyc or iref_cyc Definition of cyclic handler state packet T_RCYC is performed by the header file lt ri_root gt include os packet h which is called from the standard header file lt ri_root gt include kernel h typedef struct t_rcyc STA cycstat Current state RELTIM lefttim Time left before the next activation ATR cycatr Attribute RELTIM cyctim Activation cycle RELTIM cycphs Activation phase T_RCYC The following shows details on cyclic handler state packet T_RCYC cycstat Store the current state TCYC_STP Non operational state TCYC_STA Operational state lefttim Stores the time left before the next activation unit millisecond cycatr Stores the attribute coding language initial activation state etc Coding language bit 0 TA_HLNG Start a cyclic handler through a C language interface TA_ASM Start a cyclic handler through an assembly language interface Initial activation state bit 1 TA_STA Cyclic handlers is in an operational state after the creation Existence of saved activation phases bit 2 TA_PHS Cyclic handler is ac
334. t mailbox wait queue in the order defined during configuration FIFO order or priority order R20UT2889EJ0101 Rev 1 01 7tENESAS Page 242 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 16 SERVICE CALLS Note 2 If the receiving WAITING state for a mailbox is forcibly released by issuing rel_wai or irel_wai the contents of the area specified by parameter ppk_msg will be undefined Note 3 For details about the message packet refer to 15 2 6 Message packet Return value Macro Value Description E OK 0 Normal completion Invalid ID number E_ID 18 mbxid lt 0x0 mbxid gt Maximum ID number Context error This service call was issued from a non task E CTX 25 This service call was issued in the CPU locked state This service call was issued in the dispatching disabled state Non existent object E NOEXS 42 Specified mailbox is not registered Forced release from the WAITING state E RLWAI 49 Accept rel_wai irel_wai while waiting R20UT2889EJ0101 Rev 1 01 tENESAS Page 243 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 16 SERVICE CALLS prcv_mbx iprcv_mbx Outline Receive from mailbox polling C format ER prev_mbx ID mbxid T_MSG ppk_msg ER iprcev_mbx ID mbxid T_MSG ppk_msg Parameter s 0 Parameter Description ID mbxid ID number of the mailbox from which a message is received O T_MSG ppk_msg Start address of the message
335. t overflow processing The overflow processing is a routine dedicated to post processing that is extracted as a user own coding module to execute post overflow processing and is called when a stack necessary for the RI850V4 and the processing program has overflowed Therefore note the following points when coding post overflow processing Coding method Code post overflow processing using the C or assembly language When coding in C it can be coded in the same manner as ordinary functions When coding in assembly language code it according to the calling convention in the compiler used Stack switching The RI850V4 does not perform the processing related to stack switching when passing control to post overflow processing Therefore when using the stack for post overflow processing the code for stack setting setting of the stack pointer SP should be written at the beginning of post overflow processing Service call issue Issue of service calls is prohibited in post overflow processing because correct operation cannot be guaranteed The following is a list of processes that should be executed in post overflow processing Post processing that handles stack overflows Note The processing such as reset that should be coded as post overflow processing depends on the user system R20UT2889EJ0101 Rev 1 01 2tENESAS Page 90 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 7 MEMORY POOL MANAGEMENT FUNCTIONS 7 3 Fixed Sized Memory Pools
336. t the CPU use right is given to the optimum task 13 1 1 Drive Method The RI850V4 employs the Event driven system in which the scheduler is activated when an event trigger occurs Event driven system Under the event driven system of the RI850V4 the scheduler is activated upon occurrence of the events listed below and dispatch processing task scheduling processing is executed Issue of service call that may cause task state transition Issue of instruction for returning from non task cyclic handler interrupt handler etc Occurrence of clock interrupt used when achieving TIME MANAGEMENT FUNCTIONS vsta_sch issue 13 1 2 Scheduling Method As task scheduling methods the RI850V4 employs the Priority level method which uses the priority level defined for each task and the FCFS method which uses the time elapsed from the point when a task becomes subject to RI850V4 scheduling Priority level method A task with the highest priority level is selected from among all the tasks that have entered an executable state RUNNING state or READY state and given the CPU use right FCFS method The same priority level can be defined for multiple tasks in the RI850V4 Therefore multiple tasks with the highest priority level which is used as the criterion for task selection under the Priority level method may exist simultaneously To remedy this dispatch processing task scheduling processing is executed on a first come first
337. target eventtflag is set to B 1110 Note 2 When the TA_WMUL attribute is specified for the target eventflag the range of tasks to be checked on whether issuing of this service call satisfies the required condition differs depending on whether the TA_CLR attribute is also specified When TA_CLR is specified Check begins from the task at the head of the wait queue and stops at the first task that meets the requirements When TA_CLR is not specified All tasks placed in the wait queue are checked Return value Macro Value Description E OK 0 Normal completion R20UT2889EJ0101 Rev 1 01 2tENESAS Page 215 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 16 SERVICE CALLS Macro Value Description Invalid ID number E ID 18 figid lt 0x0 flgid gt Maximum ID number Context error E CTX 25 This service call was issued in the CPU locked state Non existent object E NOEXS 42 Specified eventflag is not registered R20UT2889EJ0101 Rev 1 01 Sep 30 2015 ztENESAS Page 216 of 366 RI850V4 V2 CHAPTER 16 SERVICE CALLS Outline Clear eventflag C format ER clr flg ID flgid FLGPTN clrptn ER iclr_flg ID flgid FLGPTN clrptn Parameter s 0 Parameter Description ID flgid ID number of the eventflag to be cleared l FLGPTN clrptn Bit pattern to clear Explanation This service call sets the result of logical AND operating
338. tate with timeout resource acquisition wait state The WAITING state for a semaphore resource is cancelled in the following cases and then moved to the READY state WAITING State for a Semaphore Resource Cancel Operation Return Value The resource was returned to the target semaphore as a result of issuing sig_sem E OK The resource was returned to the target semaphore as a result of issuing isig_sem E OK Forced release from waiting accept rel_wai while waiting E RLWAI Forced release from waiting accept irel_ wai while waiting E RLWAI Polling failure or timeout E TMOUT Note 1 Invoking tasks are queued to the target semaphore wait queue in the order defined during configuration FIFO order or priority order Note 2 TMO_FEVR is specified for wait time tmout processing equivalent to wai_sem will be executed When TMO_POL is specified processing equivalent to pol_sem ipol_sem will be executed Return value Macro Value Description E OK 0 Normal completion R20UT2889EJ0101 Rev 1 01 2tENESAS Page 209 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 16 SERVICE CALLS Macro Value Description Parameter error E PAR 17 tmout lt TMO_FEVR Invalid ID number EID 18 semid lt 0x0 semid gt Maximum ID number Context error E CTX 25 This service call was issued from a non task This service call was issued in the CPU locked state This service
339. te As a result the target cyclic handler is excluded from activation targets of the RI850V4 until issue of sta_cyc or ista_cyc The following describes an example for coding this service call include lt kernel h gt Standard header file definition include lt kernel_id h gt System information header file definition void task VP_INT exinf ID cycid ID_CYC1 Declares and initializes variable stp_cyc cycid Stop cyclic handler operation Note This service call does not perform queuing of stop requests If this service call has already been issued and the target cyclic handler has been moved to the non operational state STP state no processing is performed but it is not handled as an error R20UT2889EJ0101 Rev 1 01 ztENESAS Page 130 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 9 TIME MANAGEMENT FUNCTIONS 9 8 Reference Cyclic Handler State A cyclic handler status by issuing the following service call from the processing program ref_cyc iref_cyc Stores cyclic handler state packet current state time left before the next activation etc of the cyclic handler specified by parameter cycid in the area specified by parameter pk_rcyc The following describes an example for coding this service call lt kernel h gt lt kernel_id h gt include include void task VP_INT exinf ID cycid ID_CYC1 T_RCYC pk_rcyc STA cycstat RELTIM Jlefttim
340. te for a data queue A task enters this state if cannot send a data to the relevant data queue upon the issue of snd_dtq or tsnd_dtq Receiving WAITING state for a data queue A task enters this state if cannot receive a data from the relevant data queue upon the issue of rcv_dtq or trev_dtq Receiving WAITING state for a mailbox A task enters this state if cannot receive a message from the relevant mailbox upon the issue of rcv_mbx or trcv_mbx WAITING state for a mutex A task enters this state if cannot lock the relevant mutex upon the issue of loc_mtx or tloc_mtx WAITING state for a fixed sized memory block A task enters this state if it cannot acquire a fixed sized memory block from the relevant fixed sized memory pool upon the issue of get_mpf or tget_mpf WAITING state for a variable sized memory block A task enters this state if it cannot acquire a variable sized memory block from the relevant variable sized memory pool upon the issue of get_mpl or tget_mpl SUSPENDED state State in which processing execution has been suspended forcibly Resumption of processing from the SUSPENDED state starts from the point where the processing execution was suspended The value of information required for resumption such as task context immediately before suspension is therefore restored R20UT2889EJ0101 Rev 1 01 Sep 30 2015 2tENESAS Page 22 of 366 RI850V4 V2 CHAPTER 3 TASK MANAGEMENT F
341. te packet T_RMBX used when issuing ref_mbx or iref_mbx Definition of mailbox state packet T_RMBxX is performed by the header file lt ri_root gt include os packet h which is called from the standard header file lt ri_root gt include kernel h typedef struct t_rmbx ID wtskid Existence of waiting task T_MSG pk_msg Existence of waiting message ATR mbxatr Attribute T_RMBX The following shows details on mailbox state packet T_RMBX wtskid Stores whether a task is queued to the mailbox wait queue TSK_NONE No applicable task Value ID number of the task at the head of the wait queue pk_msg Stores whether a message is queued to the mailbox wait queue NULL No applicable message Value Start address of the message packet at the head of the wait queue mbxatr Stores the attribute queuing method Task queuing method bit 0 TA_TFIFO Task wait queue is in FIFO order TA_TPRI Task wait queue is in task priority order Message queuing method bit 1 TA_MFIFO Message wait queue is in FIFO order TA_MPRI Message wait queue is in message priority order Structure of mbxatr 15 1 0 t TA_TFIFO 0 TA_TPRI 1 TA_MFIFO 0 TA_MPRI 1 R20UT2889EJ0101 Rev 1 01 7tENESAS Page 162 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 15 DATA TYPES AND MACROS 15 2 8 Mutex state packet The following shows mutex state packet T_RMTX used when issuing ref_mtx or iref_mtx
342. ted by issuing the following service call from the processing program ext_tsk This service call moves an invoking task from the RUNNING state to the DORMANT state As a result the invoking task is unlinked from the ready queue and excluded from the RI850V4 scheduling subject If an activation request has been queued to the invoking task the activation request counter is not set to 0x0 when this service call is issued this service call moves the task from the RUNNING state to the DORMANT state decrements the wakeup request counter by subtracting 0x1 from the wakeup request counter and then moves the task from the DORMANT state to the READY state The following describes an example for coding this service call include lt kernel h gt Standard header file definition include lt kernel_id h gt System information header file definition void task VP_INT exinf ext_tsk Terminate invoking task Note 1 When moving a task from the RUNNING state to the DORMANT state this service call initializes the following information to values that are set during task creation Priority current priority Wakeup request count Suspension count Interrupt status If an invoking task has locked a mutex the locked state is released at the same time processing equivalent to unl_mtx Note 2 When the return instruction is issued in a task the same processing as ext_tsk is performed R20UT2889EJ0101 Rev 1 01 2tENESA
343. terrupt entry processing that is required to execute processing as a user own coding module This enhances portability for various execution environments and facilitates customization as well 10 2 1 Interrupt entry processing Interrupt entry processing is a routine dedicated to entry processing that is extracted as a user own coding module to assign processing for branching to the relevant processing such as interrupt preprocessing to the handler address to which the CPU forcibly passes control when an interrupt occurs The interrupt entry processing for the El level maskable interrupts defined in the Interrupt handler information in the system configuration file is included in the entry file created by executing the configurator for the system configuration file Therefore coding of interrupt entry processing is necessary for other interrupts such as a reset that are not El level maskable interrupts Basic form of interrupt entry processing When coding an interrupt entry processing the code should match the branch method selected in the Property panel gt System Configuration File Related Information tabbed page gt Entry File category gt Generate method The following shows the basic form of interrupt entry processing in assembly language related to other interrupts such as El level maskable interrupts not defined in the Interrupt handler information reset or FE level maskable interrupts that are not El level maskable inte
344. tes in which each interrupt handler may enter and interrupt handlers themselves by using management objects interrupt handler control blocks corresponding to interrupt handlers one to one The following shows a processing flow from when an interrupt occurs until the control is passed to the interrupt handler ES Interrupt entry processing Interrupt preprocessing Interrupt Handlers Figure 10 1 Processing Flow Interrupt Handler 10 3 1 Basic form of interrupt handlers Code interrupt handlers by using the void type function that has no arguments The following shows the basic form of interrupt handlers in C include lt kernel h gt Standard header file definition include lt kernel_id h gt System information header file definition void inthdr void return Terminate interrupt handler 10 3 2 Internal processing of interrupt handler The RI850V4 executes original pre interrupt processing when passing control from the processing program where an El level maskable interrupt occurred to the interrupt handler as well as original post interrupt processing when restoring control from the interrupt handler to the processing program where the El level maskable interrupt occurred Therefore note the following points when coding interrupt handlers Coding method Code interrupt handlers using C or assembly language When coding in C they can be coded in the same man
345. the User s Manual of each product Data significance Higher digits on the left and lower digits on the right Note Footnote for item marked with Note in the text Caution Information requiring particular attention Remark Supplementary information Numeric representation Decimal XXXX Hexadecimal OxXXXX Prefixes indicating power of 2 address space and memory capacity K kilo 210 1024 M mega 2 1024 Related Documents The related documents indicated in this publication may include preliminary versions However preliminary versions are not marked as such Document Name Document No RI Series Start R20UT0751E Message R20UT0756E RI850V4 V2 Coding This manual Debug R20UT2890E Analysis R20UT2891E Caution The related documents listed above are subject to change without notice Be sure to use the latest edition of each document when designing All trademarks or registered trademarks in this document are the property of their respective owners TABLE OF CONTENTS CHAPTER 1 OVERVIEW 11 1 1 Outline 11 1 1 1 Real Time OS 11 1 1 2 Multi task OS 11 1 1 3 Support for RH850 multi core devices 11 1 2 Execution Environment 12 CHAPTER 2 SYSTEM CONSTRUCTION 13 2 1 Outline 13 2 2 Cording System Configuration File 14 2 3 Coding Processing Programs 14 2 4 Coding User Own Coding Module 15 2 5 Trace Information File 15 2 6 Creating Load Module
346. the state but decrements the wakeup request counter by subtracting 0x1 from the wakeup request counter The sleeping state is cancelled in the following cases and then moved to the READY state Sleeping State Cancel Operation Return Value A wakeup request was issued as a result of issuing wup_tsk E OK A wakeup request was issued as a result of issuing iwup_tsk E OK Forced release from waiting accept rel_wai while waiting E RLWAI Forced release from waiting accept irel_wai while waiting E RLWAI The following describes an example for coding this service call R20UT2889EJ0101 Rev 1 01 2tENESAS Page 36 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 4 TASK DEPENDENT SYNCHRONIZATION FUNCTIONS include lt kernel h gt Standard header file definition include lt kernel_id h gt System information header file definition void task VP_INT exinf ER ercd Declares variable ercd slp_tsk Put task to sleep waiting forever if ercd E_OK eee ae ee Normal termination processing else if ercd E_RLWAI tidal late ahead Forced termination processing R20UT2889EJ0101 Rev 1 01 2tENESAS Page 37 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 4 TASK DEPENDENT SYNCHRONIZATION FUNCTIONS 4 2 2 With timeout A task is moved to the sleeping state with timeout by issuing the following service call from the processing program tslp_tsk
347. the target data queue when this service call is issued the service call does not write data but queues the invoking task to the transmission wait queue of the target data queue and moves it from the RUNNING state to the WAITING state with time data transmission wait state The sending WAITING state for a data queue is cancelled in the following cases and then moved to the READY state Sending WAITING State for a Data Queue Cancel Operation Return Value An available space was secured in the data queue area of the target data queue as a result of E OK issuing rcv_dtq An available space was secured in the data queue area of the target data queue as a result of E OK issuing prcv_dtq An available space was secured in the data queue area of the target data queue as a result of E OK issuing iprcv_dtq An available space was secured in the data queue area of the target data queue as a result of E OK issuing trcv_diq gt Forced release from waiting accept rel_wai while waiting E RLWAI Forced release from waiting accept irel_wai while waiting E RLWAI Polling failure or timeout E TMOUT If a task has been queued to the reception wait queue of the target data queue when this service call is issued this service call does not write data but transfers the data to the task As a result the task is unlinked from the reception wait queue and moves from the WAITING state data reception wait state to the READY
348. the target task the wakeup request counter is not set to 0x0 when this service call is issued this service call does not move the state but decrements the wakeup request counter by subtracting 0x1 from the wakeup request counter The sleeping state is cancelled in the following cases and then moved to the READY state Sleeping State Cancel Operation Return Value A wakeup request was issued as a result of issuing wup_tsk E OK A wakeup request was issued as a result of issuing iwup_tsk E OK Forced release from waiting accept rel_wai while waiting E RLWAI Forced release from waiting accept irel_ wai while waiting E RLWAI Polling failure or timeout E TMOUT Note When TMO_FEVR is specified for wait time tmout processing equivalent to slp_tsk will be executed Return value Macro Value Description E OK 0 Normal completion Parameter error E_ PAR 17 tmout lt TMO_FEVR R20UT2889EJ0101 Rev 1 01 7tENESAS Page 194 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 16 SERVICE CALLS Macro Value Description Context error E CTX 25 This service call was issued from a non task This service call was issued in the CPU locked state This service call was issued in the dispatching disabled state Forced release from the WAITING state E_RLWAI 49 Accept rel_wai irel_wai while waiting Timeout E_TMOUT 50 Polling failure or timeout
349. the wait queue current bit pattern etc of the event flag specified by parameter figid in the area specified by parameter pk_rflg Note For details about the eventflag state packet refer to 15 2 4 Eventflag state packet Return value Macro Value Description E OK 0 Normal completion Invalid ID number EID 18 flgid lt 0x0 flgid gt Maximum ID number Context error E CTX 25 This service call was issued in the CPU locked state Non existent object E NOEXS 42 Specified eventflag is not registered R20UT2889EJ0101 Rev 1 01 2tENESAS Page 224 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 16 SERVICE CALLS 16 2 5 Synchronization and communication functions data queues The following shows the service calls provided by the RI850V4 as the synchronization and communication functions data queues Table 16 5 Synchronization and Communication Functions Data Queues Service Call Function Origin of Service Call snd_dtq Send to data queue waiting forever Task psnd_dtq Send to data queue polling raa Non task Initialization rou ipsnd_dtq Send to data queue polling eit No task nitalizatior rou tsnd_dtq Send to data queue with timeout Task fsnd_dtq Forced send to data queue Ha Nonitask Initalzation rour ifsnd_dtq Forced send to data queue Ta Nontas nitalization Tou rev_dtq Receive from data queue waiting forev
350. then moved to the READY state WAITING State for an Eventflag Cancel Operation Return Value A bit pattern that satisfies the required condition was set to the target eventflag as a result of E OK issuing set_flg A bit pattern that satisfies the required condition was set to the target eventflag as a result of E OK issuing iset_flg Forced release from waiting accept rel_wai while waiting E_RLWAI Forced release from waiting accept irel_wai while waiting E_RLWAI The following shows the specification format of required condition wfmode wfmode TWF_ANDW Checks whether all of the bits to which 1 is set by parameter waiptn are set as the target eventflag wfmode TWF_ORW Checks which bit among bits to which 1 is set by parameter waiptn is set as the target eventflag The following describes an example for coding this service call include lt kernel h gt Standard header file definition include lt kernel_id h gt System information header file definition void task VP_INT exinf ER ercd Declares variable ID flgid ID_FLG1 Declares and initializes variable FLGPTN waiptn 14 Declares and initializes variable ODE wfmode TWF_ANDW Declares and initializes variable FLGPIN p_flgptn Declares variable Wait for eventflag waiting forever ercd wai_flg flgid waiptn wfmode amp p_flgptn if ercd E_OK ATER
351. this service call does not acquire the fixed size memory block but queues the invoking task to the target fixed size memory pool wait queue and moves it from the RUNNING state to the WAITING state fixed size memory block acquisition wait state The WAITING state for a fixed sized memory block is cancelled in the following cases and then moved to the READY state WAITING State for a Fixed sized Memory Block Cancel Operation Return Value A fixed sized memory block was returned to the target fixed sized memory pool as a result of E OK issuing rel_mpf a A fixed sized memory block was returned to the target fixed sized memory pool as a result of E OK issuing irel_mpf E Forced release from waiting accept rel_wai while waiting E_RLWAI Forced release from waiting accept irel_wai while waiting E_RLWAI The following describes an example for coding this service call include lt kernel h gt Standard header file definition include lt kernel_id h gt System information header file definition void task VP_INT exinf ER ercd Declares variable ID mpfid 1 Declares and initializes variable VP p_blk Declares variable ercd get_mpf mpfid amp p_blk Acquire fixed sized memory block waiting forever if ercd E_OK EE Normal termination processing rel_mpf mpfid p_ blk Release fixed sized memory block lse if ercd E_RLWAI dae eileen o
352. tion _INITSCT_RH in the CC RH compiler to simplify the initialization code The following shows an example of assembly language code for initializing kernel_data_init section section T INIT _BSEC const const align 0x4 dw __ s kernel_data_init _e kernel_data_init mov r0 r6 mov rO E7 mov __s INIT_BSEC const r8 mov _e INIT_BSEC const r9 jarl ___INITSCT_RH lp CCV850 compiler First define kernel_data_init section where the kernel initialization flag is allocated with the CLEAR section attribute added in the link directive file so that the section is initialized in the boot processing The following shows a sample code in the link directive file MEMORY ROM_MEMORY ORIGIN 0x00007000 LENGTH 0x003f9000 RAM_MEMORY ORIGIN Oxfedf0000 LENGTH 0x00010000 SECTIONS kernel_data_init CLEAR gt RAM_MEMORY A R20UT2889EJ0101 Rev 1 01 RENESAS Page 149 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 14 SYSTEM INITIALIZATION ROUTINE Withthis definition the kernel_data_init section information is included in the runtime clear tables __ghsbinfo_clear and __ ghseinfo_clear generated by the CCV850 compiler The following shows a sample code for initializing the section area included in the runtime clear tables initialize memory meminit void void b void __ghsbinfo_clear void e
353. tion processing is therefore not performed but E_QOVR is returned Note 2 Extended information specified in Task information is passed to the task activated by issuing these service calls R20UT2889EJ0101 Rev 1 01 2tENESAS Page 26 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 3 TASK MANAGEMENT FUNCTIONS 3 4 2 Not queuing an activation request A task not queuing an activation request is activated by issuing the following service call from the processing program sta_tsk ista_tsk These service calls move a task specified by parameter tskid from the DORMANT state to the READY state As a result the target task is queued at the end on the ready queue corresponding to the initial priority and becomes subject to scheduling by the RI850V4 This service call does not perform queuing of activation requests If the target task is in a state other than the DORMANT state the status manipulation processing for the target task is therefore not performed but E_OBu is returned Specify for parameter stacd the extended information transferred to the target task The following describes an example for coding this service call include lt kernel h gt Standard header file definition include lt kernel_id h gt System information header file definition void task VP_INT exinf ID tskid 8 Declares and initializes variable VP_INT stacd 123 Declares and initializes variable sta_tsk tskid stacd Activate task does
354. tivated preserving the activation phase Structure of cycatr 15 2 1 0 Ls TA_HLNG 0 TA_ASM 1 TA_STA 1 TA_PHS 1 cyctim Stores the activation cycle unit millisecond cycphs Stores the activation phase unit millisecond In the RI850V4 the initial activation phase means the relative interval from when generation of s cyclic handler is completed until the first activation request is issued R20UT2889EJ0101 Rev 1 01 2tENESAS Page 167 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 15 DATA TYPES AND MACROS 15 3 Data Macros This section explains the data macros for current state processing program attributes or the like used when issuing a service call provided by the RI850V4 15 3 1 Current state The following lists the management object current states acquired by issuing service calls ref_tsk ref_sem or the like Macro definition of the current state is performed by the header file lt ri_root gt include os option h which is called from standard the header file lt ri_root gt include kernel h and the ITRON general definition header file lt ri_root gt include itron h Table 15 2 Current State Macro Value Description TTS_RUN 0x01 RUNNING state TTS_RDY 0x02 READY state TTS_WAI 0x04 WAITING state TTS_SUS 0x08 SUSPENDED state TTS_WAS Ox0c WAITING SUSPENDED state TTS_DMT 0x10 DORMANT state TCYC_ST
355. tn Declares variable ATR flgatr Declares variable ref_flg flgid amp pk_rflg Reference eventflag state wtskid pk_rflg wtskid Reference ID number of the task at the head of the wait queue flgptn pk_rflg flgptn Reference current bit pattern flgatr pk_rflg flgatr Reference attribute Note For details about the eventflag state packet refer to 15 2 4 Eventflag state packet R20UT2889EJ0101 Rev 1 01 ztENESAS Page 61 of 366 Sep 30 2015 CHAPTER 5 SYNCHRONIZATION AND COMMUNICATION RI850V4 V2 FUNCTIONS 5 4 Data Queues Multitask processing requires the inter task communication function data transfer function that reports the processing result of a task to another task The RI850V4 therefore provides the data queues that have the data queue area in which data read write is enabled for transferring the prescribed size of data The following shows a processing flow when using a data queue Figure 5 3 Processing Flow Data Queue Task A Task B Priority High Priority Low Receive from data queue Reception wait period Send to data queue Note Data units of 4 bytes are transmitted or received at a time 5 4 1 Create data queue In the RI850V4 the method of creating a data queue is limited to static creation Data queues therefore cannot be created dynamically using a method such as issuing a service call from a processing program Static data
356. to the WAITING state If a suspend request is queued subtraction result is other than 0x0 when this service call is issued the counter manipulation processing is not performed but only the suspend request counter decrement processing is executed Note This service call does not perform queuing of cancellation requests If the target task is in a state other than the SUSPENDED or WAITING SUSPENDED state E_OBJ is therefore returned Return value Macro Value Description E_OK 0 Normal completion Invalid ID number E ID 18 tskid lt 0x0 tskid gt Maximum ID number Context error E CTX 25 This service call was issued in the CPU locked state Object state error E_OBJ 41 Specified task is neither in the SUSPENDED state nor WAITING SUSPENDED state Non existent object E_NOEXS 42 Specified task is not registered R20UT2889EJ0101 Rev 1 01 tENESAS Page 202 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 16 SERVICE CALLS Outline Forcibly resume suspended task C format ER frsm_tsk ID tskid ER ifrsm_tsk ID tskid Parameter s 1 0 Parameter Description l ID tskid ID number of the task to be resumed Explanation These service calls cancel all of the suspend requests issued for the task specified by parameter tskid by setting the suspend request counter to 0x0 As a result the target task moves from the SUSPENDED state to the READY state
357. ts the relationship between a name and an ID number to the system information header file in the following format define mplid value 2 Attribute mplatr Specifies the task queuing method for a variable sized memory pool The keyword that can be specified for mplatris TA_TFIFO or TA_TPRI TA_TFIFO Task wait queue is in FIFO order TA_TPRI Task wait queue is in task priority order 3 Pool size mplsz memory area name sec_nam Specifies the variable size memory pool size unit bytes and the name of the memory area secured for the variable size memory pool Only 4 byte boundary values from 0x1 to Ox7ffffffc can be specified for mpisz and only memory area name sec_area defined in Memory area information can be specified for sec_nam Note If specification of sec_nam is omitted the variable sized memory pool is allocated to kernel_work sec tion 4 Reserved for future use mpl System reserved area Values that can be specified for mpl are limited to NULL characters R20UT2889EJ0101 Rev 1 01 2tENESAS Page 321 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 17 SYSTEM CONFIGURATION FILE 17 5 9 Cyclic handler information The cyclic handler information defines ID number cycid Attribute cycatr Extended information exinf Start address cychdr Activation cycle cyctim Activation phase cycphs for a cyclic handler The number of items that can be defined as cycic handler information is limited to one for each ID numbe
358. ty maxmpri Reserved for future use mprihd for a mailbox The The number of items that can be defined as mailbox information is limited to one for each ID number following shows the mailbox information format CRI E_ MBX mbxid mbxatr maxmpri mprihd The 1 items constituting the mailbox information are as follows ID number mbxid Specifies the ID number for a mailbox A value from 0x1 to Oxff or a name can be specified for mbxid Note When a name is specified the CF850V4 automatically assigns an ID number The CF850V4 outputs the relationship between a name and an ID number to the system information header file in the following format define mbxid value Attribute mbxatr Specifies the attribute for a mailbox The keyword that can be specified for mbxatr is TA_TFIFO TA_TPRI TA_MFIFO and TA_MPRI Task queuing method TA_TFIFO Task wait queue is in FIFO order TA_TPRI Task wait queue is in task priority order Message queuing method TA_MFIFO Message wait queue is in FIFO order TA_MPRI Message wait queue is in message priority order Maximum message priority maxmpri Specifies the maximum message priority for a mailbox A value from 0x1 to Ox7fff can be specified for maxmpri Note maxmpri is valid only when TA_MPRI is specified for mqueue It is invalid when TA_MFIFO is specified for mqueue 4 Reserved for future use mprihd System reserved area Values that can be
359. ueue as a result of issuing snd_dtq E_OK Data was written to the data queue area of the target data queue as a result of issuing psnd_diq E OR Data was written to the data queue area of the target data queue as a result of issuing ipsnd_dtq E OK Data was written to the data queue area of the target data queue as a result of issuing tsnd_dtq E_OK Data was written to the data queue area of the target data queue as a result of issuing fsnd_dtq E_OK Data was written to the data queue area of the target data queue as a result of issuing ifsnd_dtq oo Forced release from waiting accept rel_wai while waiting E RLWAI Forced release from waiting accept irel_ wai while waiting E RLWAI Polling failure or timeout E TMOUT R20UT2889EJ0101 Rev 1 01 tENESAS Page 235 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 16 SERVICE CALLS Note 1 Invoking tasks are queued to the reception wait queue of the target data queue in the order of the data reception request Note 2 If the data reception wait state is cancelled because rel_wai or irel_wai was issued or the wait time elapsed the contents in the area specified by parameter p_data become undefined Note 3 TMO_FEVR is specified for wait time tmout processing equivalent to rcv_dtq will be executed When TMO_POL is specified processing equivalent to prcv_dtq iprcv_dtq will be executed Return value Macro Value Description E OK 0 No
360. ufficient memory E OBJ 41 Object state error E_NOEXS 42 Non existent object E_QOVR 43 Queue overflow E_RLWAI 49 Forced release from the WAITING state E_TMOUT 50 Polling failure or timeout FALSE 0 False TRUE 1 True R20UT2889EJ0101 Rev 1 01 2tENESAS Page 170 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 15 DATA TYPES AND MACROS 15 3 6 Kernel configuration constants The configuration constants are listed below The macro definitions of the configuration constants are made in the header file lt ri_root gt include os component h which is called from lt ri_root gt include itron h Note however that some numerical values with variable macro definitions are defined in the system information header file in accordance with the settings in the system configuration file Table 15 7 Priority Range Macro Value Description TMIN_TPRI 1 Minimum task priority TMAX_TPRI variable Maximum task priority TMIN_MPRI 1 Minimum message priority TMAX_MPRI Ox7fff Maximum message priority Table 15 8 Version Information Macro Value Description TKERNEL_MAKER 0x011b Kernel maker code TKERNEL_PRID 0x0000 Identification number of kernel TKERNEL_SPVER 0x5403 Version number of the ITRON Specification TKERNEL_PRVER 0x01 xx Version number of the kernel Table 15 9 Maximum Queuing Count Macro Value Description TMAX_ACTCNT 127 Maximum task activation request count TMAX_WUPCNT 127 Maxim
361. um task wakeup request count TMAX_SUSCNT 127 Maximum suspension count Table 15 10 Number of Bits in Bit Patterns Macro Value Description TBIT_FLGPTN 32 Number of bits in the an eventtflag Table 15 11 Base Clock Interval Macro Value Description TIC_NUME variable base clock interval numerator TIC_DENO 1 base clock interval denominator R20UT2889EJ0101 Rev 1 01 Sep 30 2015 7tENESAS Page 171 of 366 RI850V4 V2 CHAPTER 15 DATA TYPES AND MACROS 15 4 Conditional Compile Macro The header file of the RI850V4 is conditionally compiled by the following macros Define macros such as the compiler activation option D according to the environment used when building the source files that include the header file of the RI850V4 Table 15 12 Conditional Compile Macros Classification C compiler package Coding language Macro Description rel CC RH is used e Add two underscores before and after rel hg CCV850 is used 9ns__ Add two underscores before and after ghs Asm The assembly language is used Add two underscores before and after asm R20UT2889EJ0101 Rev 1 01 Sep 30 2015 ztENESAS Page 172 of 366 RI850V4 V2 CHAPTER 16 SERVICE CALLS CHAPTER 16 SERVICE CALLS This chapter describes the service calls supported by the RI850V4 16 1 Outline The service calls provided by the RI850V4 are service routin
362. unit millisecond TMO tmout TMO_FEVR Waiting forever TMO_POL Polling Value Specified timeout Explanation This service call acquires a variable size memory block of the size specified by parameter blksz from the variable size memory pool specified by parameter mplid and stores its start address into the area specified by parameter p_bik If no variable size memory blocks could be acquired from the target variable size memory pool no successive areas equivalent to the requested size were available when this service call is issued this service call does not acquire variable size memory blocks but queues the invoking task to the target variable size memory pool wait queue and moves it from the RUNNING state to the WAITING state with timeout variable size memory block acquisition wait state The WAITING state for a variable sized memory block is cancelled in the following cases and then moved to the READY state WAITING State for a Variable sized Memory Block Cancel Operation Return Value The variable size memory block that satisfies the requested size was returned to the target E OK variable size memory pool as a result of issuing rel_mpl The variable size memory block that satisfies the requested size was returned to the target E OK variable size memory pool as a result of issuing irel_mopl E Forced release from waiting accept rel_wai while waiting E_RLWAI Forced release from waiting accept irel_wai while
363. urn processing is not performed but fixed sized memory blocks are returned to the relevant task first task of wait queue As a result the relevant task is unlinked from the wait queue and is moved from the WAITING state WAITING state for a fixed sized memory block to the READY state or from the WAITING SUSPENDED state to the SUSPENDED state Note 1 The RI850V4 does not perform memory clear processing when returning the acquired fixed size memory block The contents of the returned fixed size memory block are therefore undefined Note 2 When returning fixed size memory blocks be sure to issue either of these service calls for the acquired fixed size memory pools If the service call is issued for another fixed size memory pool no error results but the operation is not guaranteed after that Return value Macro Value Description E OK 0 Normal completion Invalid ID number E ID 18 mpfid lt 0x0 mpfid gt Maximum ID number Context error E CIX 25 This service call was issued in the CPU locked state R20UT2889EJ0101 Rev 1 01 2tENESAS Page 265 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 16 SERVICE CALLS Macro Value Description E_NOEXS 42 Non existent object Specified fixed sized memory pool is not registered R20UT2889EJ0101 Rev 1 01 Sep 30 2015 ztENESAS Page 266 of 366 RI850V4 V2 CHAPTER 16 SERVICE CALLS ref_mpf iref_mpf
364. using C or assembly language When coding in C they can be coded in the same manner as ordinary functions coded When coding in assembly language code them according to the calling rules prescribed in the compiler used Stack switching The RI850V4 switches to the system stack specified in Basic information when passing control to an initialization routine and switches to the relevant stack when returning control to the Kernel Initialization Module Coding regarding stack switching is therefore not required in initialization routines Service call issue The RI850V4 prohibits issue of service calls in Initialization routines Acceptance of El level maskable interrupts When passing control to the initialization routine the RI850V4 disables acceptance of El level maskable interrupts by manipulating the PMn bits in the priority mask register PMR and the ID bit in the program status word PSW The PMn bits to be manipulated correspond to the interrupt priority range defined as the Maximum interrupt priority maxintpri during configuration Note As the RI850V4 initialization processing is not completed acceptance is disabled for El level maskable interrupts corresponding to the Base clock timer exception code tim_intno defined in the Basic information and Exception code inhno defined in the Interrupt handler information Note 1 When the RI850V4 initializes the hardware OS timer used for time management appropriate settings should be ma
365. utine The RI850V4 manages interrupt handlers themselves by using management objects extended service call routine control blocks corresponding to extended service call routines one to one 11 2 1 Basic form extended service call routines Code extended service call routines by using the ER_UINT type argument that has three VP_INT type arguments Transferred data specified when a call request cal_svc or ical_svc is issued is set to arguments par1 par2 and par3 The following shows the basic form of extended service call routines in C include lt kernel h gt Standard header file definition include lt kernel_id h gt System information header file definition ER_UINT svcrtn VP_INT parl VP_INT par2 VP_INT par3 return ER_UINT ercd Terminat xtended service call routine R20UT2889EJ0101 Rev 1 01 7tENESAS Page 137 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 11 SERVICE CALL MANAGEMENT FUNCTIONS 11 2 2 Internal processing of extended service call routine The RI850V4 executes the original extended service call routine pre processing when passing control from the processing program that issued a call request to an extended service call routine as well as the original extended service call routine post processing when returning control from the extended service call routine to the processing program Therefore note the following points when coding extended service call routines Coding method
366. v 1 01 7tENESAS Page 15 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 2 SYSTEM CONSTRUCTION 2 6 Creating Load Module Run a build on CS for files created in sections from 2 2 Cording System Configuration File to 2 4 Coding User Own Coding Module the trace information file and the library files provided by the RI850V4 and C compiler package to create a load module 1 Create or load a project Create a new project or load an existing one Note See RI Series Real time OS User s Manual Start or CS Integrated Development Environment User s Manual Start for details about creating a new project or loading an existing one 2 Seta build target project Specify a project as the target of build Note See CS Integrated Development Environment User s Manual RH850 Build for details about setting the active project 3 Set build target files For the project add or remove build target files and update the dependencies Note See CS Integrated Development Environment User s Manual RH850 Build for details about adding or removing build target files for the project and updating the dependencies The following lists the files required for creating a load module System configuration file created in CHAPTER 2 2 Cording System Configuration File SYSTEM CONFIGURATION FILE Note Specify cfg as the extension of the system configuration file name If the extension is different cfg is automatically added for example if you desi
367. v_dtq Available space was secured in the data queue area of the target data queue as a result of E OK issuing trcv_dtq Forced release from waiting accept rel_wai while waiting E_RLWAI Forced release from waiting accept irel_wai while waiting E_RLWAI If a task has been queued to the reception wait queue of the target data queue when this service call is issued this service call does not write data but transfers the data to the task As a result the task is unlinked from the reception wait queue and moves from the WAITING state data reception wait state to the READY state or from the WAITING SUSPENDED state to the SUSPENDED state The following describes an example for coding this service call include lt kernel h gt Standard header file definition include lt kernel_id h gt System information header file definition void task VP_INT exinf ER ercd Declares variable ID dtqid ID_DTQ1 Declares and initializes variable VP_INT data 123 Declares and initializes variable ercd snd_dtq dtqid data Send to data queue waiting forever if ercd E_OK sade Reta Normal termination processing iise if ercd E_RLWAI E E Forced termination processing R20UT2889EJ0101 Rev 1 01 RENESAS Page 63 of 366 Sep 30 2015 CHAPTER 5 SYNCHRONIZATION AND COMMUNICATION RI850V4 V2 FUNCTIONS Note 1 Data is written to the data queue area
368. ve Normal completion activation request count value R20UT2889EJ0101 Rev 1 01 tENESAS Page 177 of 366 Sep 30 2015 RI850V4 V2 16 2 1 Task management functions The following shows the service calls provided by the RI850V4 as the task management functions Table 16 1 Task Management Functions CHAPTER 16 SERVICE CALLS Service Call Function Origin of Service Call act_tsk Activate task queues an activation request Hae NO Weer Initialization rou P PAn Task Non task Initialization rou iact_tsk Activate task queues an activation request rss parte tia ae Task Non task Initialization rou can_act Cancel task activation requests tine F ge a Task Non task Initialization rou ican_act Cancel task activation requests tine et Task Non task Initialization rou sta_tsk Activate task does not queue an activation request a on task dninealiale Moia Task Non task Initialization rou ista_tsk Activate task does not queue an activation request e gn task nilalizatio ext_tsk Terminate invoking task Task ter_tsk Terminate task Task Initialization routine PE Task Non task Initialization rou chg_pri Change task priority Pza on ta on Task Non task Initialization rou ichg_pri Change task priority Paa on ta vod Task Non task Initialization rou get_pri Reference task priority tine P i oe Task Non task Initialization rou iget_pri Reference task prio
369. waiting E_RLWAI Polling failure or timeout E_TMOUT Note 1 The RI850V4 acquires variable size memory blocks in the unit of integral multiple of 4 If a value other than an integral multiple of 4 is specified for parameter b ksz it is rounded up to be an integral multiple of 4 Note 2 Invoking tasks are queued to the target variable size memory pool wait queue in the order defined during configuration FIFO order or priority order R20UT2889EJ0101 Rev 1 01 7tENESAS Page 274 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 16 SERVICE CALLS Note 3 If the variable size memory block acquisition wait state is cancelled because rel_wai or irel_wai was issued or the wait time elapsed the contents in the area specified by parameter p_bik become undefined Note 4 TMO_FEVR is specified for wait time tmout processing equivalent to get_mpl will be executed When TMO_POL is specified processing equivalent to pget_mpl ipget_mpl will be executed Return value Macro Value Description E OK 0 Normal completion Parameter error blksz 0x0 blksz gt Ox7fffffff tmout lt TMO_FEVR E_PAR 17 Invalid ID number E ID 18 mplid lt 0x0 mplid gt Maximum ID number Context error This service call was issued from a non task E CTX 25 This service call was issued in the CPU locked state This service call was issued in the dispatching disabled state Non existent o
370. ware manual for the specific values If omitted The initial FPSR register value is 0x00020000 Note 1 This item setting is only valid for a PE incorporating an FPU If this item is specified for a PE that does not have an FPU an error will occur Note 2 When using floating point operation in the imprecise exception mode in a user routine issue the syncp and synce instructions for synchronization to complete the floating point operation before terminating the user routine processing by issuing a service call such as ext_tsk R20UT2889EJ0101 Rev 1 01 ztENESAS Page 311 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 17 SYSTEM CONFIGURATION FILE 17 4 4 Memory area information The memory area information defines Memory area name sec_nam Memory area size memsz for a memory area The number of the definition as the memory area information is one it s one per a section The following shows the memory area information format MEM_AREA sec_nam memszZ The items constituting the memory area information are as follows 1 Memory area name sec_nam Specifies the name of the memory area used for management objects Only the section name defined in link directive file sec_nam from which a dot is excluded can be specified for sec_nam 2 Memory area size memsz Specifies the size of the memory area used for management objects unit bytes Only 4 byte boundary values from 0x0 to Ox7ffffffc or SIZE_AUTO can
371. where dynamic data of trace function is allocated Area where system stack task stack data queue fixed sized memory pool and kernel_work variable sized memory pool is allocated datified area Area where task stack data queue fixed sized memory pool or variable sized nee NAM VUSEFCEMMEC area memory pool is allocated B 1 1 kernel_system The size of kernel_system section depends on the trace mode and the kernel library used There are four types of kernel library as follows CC RH version not supporting the FPU CC RH version supporting the FPU CCV850 version not supporting the FPU CCV850 version supporting the FPU The type of the trace mode is selected in the Property panel gt Task Analyzer tab gt Trace category gt Selection of trace mode 1 CC RH version not supporting the FPU Type of the Trace Mode Size of the Memory Area Not tracing 20 0K Bytes Taking in trace chart by hardware trace mode 20 3K Bytes Taking in trace chart by software trace mode 20 8K Bytes Taking in long statistics by software trace mode 20 7K Bytes 2 CC RH version supporting the FPU R20UT2889EJ0101 Rev 1 01 2tENESAS Page 353 of 366 Sep 30 2015 RI850V4 V2 APPENDIX B SIZE OF MEMORY Type of the Trace Mode Size of the Memory Area Not tracing 20 3K Bytes Taking in trace chart by hardware trace mode 20 6K Bytes Taking in trace chart by software trace
372. wing service call from the processing program sta_cyc ista_cyc This service call moves the cyclic handler specified by parameter cycid from the non operational state STP state to operational state STA state As a result the target cyclic handler is handled as an activation target of the RI850V4 The relative interval from when either of this service call is issued until the first activation request is issued varies depending on whether the TA_PHS attribute is specified for the target cyclic handler during configuration If the TA_PHS attribute is specified The target cyclic handler activation timing is set based on the activation phases initial activation phase cycphs and activation cycle cyctim defined during configuration If the target cyclic handler has already been started however no processing is performed even if this service call is issued but it is not handled as an error The following shows a cyclic handler activation timing image Figure 9 1 TA_PHS Attribute Specified m Start m Start m Start m Start cycphs wv cyctim y cyctim v cyctim v po t Start cyclic handler operation Start cyclic handler operation Generation processing completed Ifthe TA_PHS attribute is not specified The target cyclic handler activation timing is set based on the activation phase activation cycle cyctim when this service call is issued This setting is performed regardless of the operating status of the t
373. x with timeout ercd trcv_mbx mbxid amp ppk_msg tmout Normal termination processing E_RLWAI Forced termination processing E_TMOUT Timeout processing Note 1 Note 2 Note 3 Note 4 Invoking tasks are queued to the target mailbox wait queue in the order defined during configuration FIFO order or priority order If the message reception wait state is cancelled because rel_wai or irel_wai was issued or the wait time elapsed the contents in the area specified by parameter pok_msg become undefined TMO_FEVR is specified for wait time tmout processing equivalent to rcv_mbx will be executed When TMO_POL is specified processing equivalent to prcv_mbx iprcv_mbx will be executed For details about the message packet refer to 15 2 6 Message packet R20UT2889EJ0101 Rev 1 01 2tENESAS Page 80 of 366 Sep 30 2015 RI850V4 V2 CHAPTER 5 SYNCHRONIZATION AND COMMUNICATION FUNCTIONS 5 5 5 Reference mailbox state A mailbox status is referenced by issuing the following service call from the processing program ref_mbx iref_mbx Stores mailbox state packet ID number of the task at the head of the wait queue start address of the message packet at the head of the wait queue of the mailbox specified by parameter mbxid in the area specified by parameter pk_rmbx The following describes an example for coding this service call include include void ta
374. y parameter blik to the fixed sized memory pool specified by parameter mpfid If a task is queued to the target fixed sized memory pool wait queue when this service call is issued fixed sized memory block return processing is not performed but fixed sized memory blocks are returned to the relevant task first task of wait queue As a result the relevant task is unlinked from the wait queue and is moved from the WAITING state WAITING state for a fixed sized memory block to the READY state or from the WAITING SUSPENDED state to the SUSPENDED state The following describes an example for coding this service call include lt kernel h gt Standard header file definition include lt kernel_id h gt System information header file definition void task VP_INT exinf ER ercd Declares variable ID mpfid 1 Declares and initializes variable VP blk Declares variable ercd get_mpf mpfid amp blk Acquire fixed sized memory block waiting forever if ercd E_OK Sacer eee Normal termination processing rel_mpf mpfid blk Release fixed sized memory block lse if ercd E_RLWAI E EE vanes Forced termination processing Note 1 The RI850V4 does not perform memory clear processing when returning the acquired fixed size memory block The contents of the returned fixed size memory block are therefore undefined Note 2 When returning fixed size memory block
375. zation rou iwup_tsk Wakeup task Non task Initialization rou Task Non task Initialization rou can_wup Cancel task wakeup requests tire Task Non task Initialization rou ican_wup Cancel task wakeup requests tine si Task Non task Initialization rou rel_wai Release task from waiting tine P Task Non task Initialization rou irel_wai Release task from waiting tine z itializati sus_tsk Suspend task Task Non task Initialization rou tine isus_tsk Suspend task Task Non task Initialization rou tine rsm_tsk Resume suspended task i Non task Initialization rou irsm_tsk Resume suspended task Hay Non task Initialization tale frsm_tsk Forcibly resume suspended task baa PGi tei Initialization rou ifrsm_tsk Forcibly resume suspended task He Nonitask Initalzation rou dly_tsk Delay task Task R20UT2889EJ0101 Rev 1 01 Sep 30 2015 2tENESAS Page 192 of 366 RI850V4 V2 CHAPTER 16 SERVICE CALLS Outline Put task to sleep waiting forever C format ER slp_tsk Parameter s None Explanation void As a result the invoking task is unlinked from the ready queue and excluded from the RI850V4 scheduling subject If a wakeup request has been queued to the target task the wakeup request counter is not set to 0x0 when this service call is issued this service call does not move the state but decrements the wakeup request counter by subtracting 0x1 from the wakeup request counter Th
376. zed memory block are therefore undefined Note 2 Invoking tasks are queued to the target fixed size memory pool wait queue in the order defined during configuration FIFO order or priority order Note 3 If the fixed size memory block acquisition wait state is cancelled because rel_wai or irel_wai was issued the contents in the area specified by parameter p_b k become undefined Return value R20UT2889EJ0101 Rev 1 01 Sep 30 2015 2tENESAS Page 259 of 366 RI850V4 V2 CHAPTER 16 SERVICE CALLS Macro Value Description E OK 0 Normal completion Invalid ID number E ID 18 mpfid lt 0x0 mpfid gt Maximum ID number Context error i i i f k E CTX 25 This service call was issued from a tas This service call was issued in the CPU locked state This service call was issued in the dispatching disabled state Non existent object E_NOEXS 42 Specified fixed sized memory pool is not registered Forced release from the WAITING state E RLWAI 49 Accept rel_wai irel_wai while waiting R20UT2889EJ0101 Rev 1 01 Sep 30 2015 ztENESAS Page 260 of 366 RI850V4 V2 CHAPTER 16 SERVICE CALLS pget_mpf ipget_mpf Outline Acquire fixed sized memory block polling C format ER pget_mpf ID mpfid VP p_blk ER ipget_mpf ID mpfid VP p_blik Parameter s 1 0 Parameter Description ID number of the fixed sized memory pool from which

Download Pdf Manuals

image

Related Search

Related Contents

User Manual - Controls Warehouse  TAFCO WINDOWS NU2-301V-W Installation Guide  FLEX BLOWER      取扱説明書  Fixapart W8-12365 lighting accessory  Recuperación - Instituto Tecnólogico de La Laguna    Manual de Instruções  

Copyright © All rights reserved.
Failed to retrieve file