Home

RI78V4 Real-Time Operating System User`s Manual: Coding

image

Contents

1. S INCLUDE kernel inc SINCLUDE kernel_id inc PUBLIC _func_inthdr EXTRN _ RTARGO EXTRN _ RTARG2 EXTRN _ RTARG4 EXTRN _ RTARG6 EXTRN _ SEGAX EXTRN _ SEGDE CSEG _func_inthdr CALL _ kernel_int_entry OVW AX _ RTARGO PUSH AX OVW AX _ RTARG2 PUSH AX OVW AX _ RTARG4 PUSH AX OVW AX _ RTARG6 PUSH AX OVW AX _ SEGAX PUSH AX OVW AX _ SEGDE PUSH AX Ge nice aan E POP AX OVW _ SEGDE AX POP AX OVW _ SEGAX AX POP AX OVW _ RTARG6 AX POP AX OVW _ RTARG4 AX POP AX OVW _ RTARG2 AX POP AX OVW _ RTARGO AX BR _ret_int END Standard header file definition System information header file definition Switches to system stack Saves registers Saves saddr area Main processing Restores saddr area Terminate interrupt handler Restores registers R20UT0511EJ0101 Rev 1 01 Apr 01 2012 2tENESAS Page 97 of 272 RI78V4 CHAPTER 9 INTERRUPT MANAGEMENT FUNCTIONS 9 3 3 Internal processing of interrupt handler The RI78V4 handles the interrupt handler as a non task Moreover the RI78V4 executes original pre processing when passing control to the interrupt handler as well as original post processing when regaining control from the interrupt handler Therefore note the following points when coding interrupt handlers Coding method Code interrupt handlers using C or assembly language in the format shown in 9 3 2 Basic form of interrupt handlers Stack switching For inte
2. Standard header file definition System information header file definition pragma rtos_task func_task include lt kernel h gt include lt kernel_id h gt void ER ercd Declares variable ID mpfid ID_mpfA Declares and initializes variable VP p_blk Declares variable Se cian Bienen la io Acquire fixed sized memory block polling ercd pget_mpf mpfid amp p_ blk if ercd E_OK EX EEE ada bt KJ Polling success processing Release fixed sized memory block rel_mpf mpfid p_blk else if ercd E_TMOUT EP te tees aca S EJ Polling failure processing MA raa N E aA R20UT0511EJ0101 Rev 1 01 Apr 01 2012 2tENESAS Page 69 of 272 RI78V4 CHAPTER 6 MEMORY POOL MANAGEMENT FUNCTIONS tget_mpf This service call acquires the 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 memory block could not be acquired from the target fixed sized memory pool no available memory blocks exist when this service call is issued memory block acquisition processing is not performed but the invoking task is queued to the target fixed sized memory pool wait queue in the order of memory block acquisition request FIFO order 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
3. Standard header file definition System information header file definition pragma rtos_task func_task include lt kernel h gt include lt kernel_id h gt void Declares and initializes variable suspended task Forcibly resum Note 1 Note 2 If the target task is moved to the READY state after this service call is issued this service call also re queues the task at the end of the ready queue corresponding to the priority of the task This service call does not perform queuing of forced cancellation requests If the target task is in a state other than the SUSPENDED or WAITING SUSPENDED state E_OBu is therefore returned R20UT0511EJ0101 Rev 1 01 Apr 01 2012 2tENESAS Page 42 of 272 RI78V4 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 RI78V4 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 diytim has elapsed E OK Forced release from waiting accept rel_wai while waiting E RLWAI Forced release from wait
4. EOF All Output Messages J Disconnected R20UT0511EJ0101 Rev 1 01 ztENESAS Page 244 of 272 Apr 01 2012 RI78V4 APPENDIX A WINDOW REFERENCE Explanation of each area 1 Menu bar Displays the menus relate to realtime OS Contents of each menu can be customized in the User Setting dialog box View The View menu shows the cascading menu to start the tools of realtime Realtime OS OS Opens the Realtime OS Resource Information panel Note that this menu is disabled when the debug tool is not connected Opens the AZ78KOR window Note that this menu is disabled when the debug tool is not connected Resource Information Performance Analyzer 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 Note that this button 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 CubeSuite Integrated Development User s Manual RL78 78KOR Build for details about the Output panel R20UT0511EJ0101 Rev 1 01 2tENESAS Page 245 of 272 Apr 01 2012 R
5. 201 stp_cyc 203 timeout 74 timer handler 73 trcv_mbx 188 tslp_tsk 151 twai_flg 179 twai_sem 168 U unl_cpu 211 user own coding module 13 boot processing 13 idle routine 13 initialization routine 13 interrupt entry processing 13 R20UT0511EJ0101 Rev 1 01 Apr 01 2012 2tENESAS Page 265 of 272 RI78V4 APPENDIX C INDEX Vv version information packet 137 Ww wai_flg 175 wai_sem 166 WAITING state 23 WAITING SUSPENDED state 23 WAITING type 127 wup_tsk 153 R20UT0511EJ0101 Rev 1 01 Apr 01 2012 2tENESAS Page 266 of 272 Revision Record Description Summary Apr 01 2011 First Edition issued 14 130 Table 2 1 RI78V4 Segments Changed as follows the information contained in Segment Attribute column of k_system line and k_info line CSEG UINTP gt CSEG UNITP Table 2 1 RI78V4 Segments Changed as follows the information contained in Description column of k_system line and k_info line from 0x000c0 to OxOffff gt from 0x000c0 to Oxeffff Table 12 4 WAITING Types Changed as follows the information contained in Description column Sleeping state Delayed state Waiting state for a semaphore resource Waiting state for an eventflag Receiving waiting state for a mailbox Waiting state for a fixed sized memory block aa A task enters this state i
6. 23 S scheduler 109 driving method 109 scheduling system 109 scheduling system 109 FCFS method 109 priority level method 109 segment 14 k_const 15 66 k_data 15 66 k_info 15 66 k_stack 15 66 k_system 15 66 k_workO 16 66 k_work1 16 66 k_work2 16 66 k_work3 16 66 semaphore 44 isig_sem 164 pol_sem 167 ref_sem 170 sig_sem 164 twai_sem 168 wai_sem 166 semaphore information 227 semaphore state packet 131 set_flg 172 service call 121 sig_sem 164 slp_tsk 150 snd_mbx 183 sns_ctx 214 sns_dpn 217 sns_dsp 216 sns_loc 215 stack size estimation 234 sta_cyc 201 static API information 221 224 cyclic handler information 232 eventflag information 228 fized sized memory pool information 230 mailbox information 229 semaphore information 227 task information 224 sta_tsk 142 stp_cyc 203 SUSPENDED state 23 sus tsk 157 synchronization and communication function 44 eventflag 50 171 mailbox 59 182 semaphore 44 163 System Configuration File Related Information tab 253 system configuration file 12 220 system configuration management function 103 218 ref_ver 219 system construction 11 system information 221 222 sytem stack information 222 task priority information
7. CHAPTER 10 SYSTEM CONFIGURATION MANAGEMENT RI78V4 FUNCTIONS 10 3 4 Internal processing of initialization routine Moreover the RI78V4 executes original pre processing when passing control to the initialization routine as well as original post processing when regaining control from the initialization routine Therefore note the following points when coding initialization routines Coding method Code initialization routines using C or assembly language in the format shown in 10 3 3 Basic form of initialization routine Stack switching The RI78V4 executes processing to switch to the system stack when passing control to the initialization routine and processing to switch to the stack for the Kernel Initialization Module when regaining control from the initialization routine The user is therefore not required to code processing related to stack switching in initialization routines Interrupt status Maskable interrupt acknowledgement is prohibited in the RI78V4 when control is passed to the initialization routine Kernel Initialization Module is not completed at the point when control is passed to the initialization routine The system may therefore hang up when acknowledgment of maskable interrupts is explicitly enabled within the initialization routine Therefore enabling maskable interrupt acknowledgment in the initialization routine is prohibited in the RI78V4 Service call issuance The RI78V4 prohibits issuance of
8. Standard header file definition include lt kernel_id h gt System information header file definition void func_task VP_INT exinf JP coi E S toc epu J Lock the CPU ee re eee N af CPU locked state unl_cpu Unlock the CPU E Siete te triste tees 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 The RI78V4 implements disabling of maskable interrupt acknowledgment bu manipulating the interrupt mask flag register MKxx and the in service priority flag ISPx of the program status word PSW Therefore manipulating of these registers from the processing program is prohibited from when this service call is issued until unl_cpu or iunl_cpu is issued R20UT0511EJ0101 Rev 1 01 2tENESAS Page 84 of 272 Apr 01 2012 RI78V4 CHAPTER 8 SYSTEM STATE MANAGEMENT FUNCTIONS 8 5 Unlock the CPU 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 maskable interrupts prohibited through issuance of either loc_cpu or iloc_cpu is enabled a
9. 223 R20UT0511EJ0101 Rev 1 01 Apr 01 2012 ztENESAS Page 264 of 272 RI78V4 APPENDIX C INDEX system information header file 238 system information table file 238 system stack information 222 system state management function 80 205 dis_dsp 212 ena_dsp 213 get_tid 208 iget_tid 208 iloc_cpu 209 irot_rdq 206 iunl_cpu 211 loc_cpu 209 rot_rdq 206 sns_ctx 214 sns_dpn 217 sns_dsp 216 sns_loc 215 unl_cpu 211 T task 12 22 basic form 25 internal processing 26 task dependent synchronization function 34 149 ican_wup 155 can_wup 155 dly_tsk 162 frsm_tsk 161 ifrsm_tsk 161 irel_wai 156 irsm_tsk 159 isus tsk 157 iwup_tsk 153 rel_wai 156 rsm_tsk 159 slp_tsk 150 sus_tsk 157 tslp_tsk 151 wup_tsk 153 task information 224 task management function 22 138 act_tsk 139 can_act 141 chg_pri 146 ext_tsk 144 iact_tsk 139 ichg_pri 146 ista_tsk 142 ref_tsk 148 sta_tsk 142 ter_tsk 145 task priority information 223 task state 22 DORMANT state 23 READY state 23 RUNNING state 23 SUSPENDED state 23 WAITING state 23 WAITING SUSPENDED state 23 task state packet 129 ter_tsk 145 tget_mpf 195 time management function 73 200 ref_cyc 204 sta_cyc
10. As a result the target cyclic handler is excluded from activation targets of the RI78V4 until issuance of sta_cyc The following describes an example for coding this service call pragma rtos_task include lt kernel h gt include lt kernel_id h gt void func_task VP_INT exinf ID cycid ID_cycA stp_cyc cycid func_task Standard header file definition System information header file definition Declares and initializes variable Stop cyclic handler operation 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 as an error R20UT0511EJ0101 Rev 1 01 Apr 01 2012 2tENESAS Page 78 of 272 RI78V4 CHAPTER 7 TIME MANAGEMENT FUNCTIONS 7 5 7 Reference cyclic handler state A cyclic handler status by issuing the following service call from the processing program ref_cyc Stores cyclic handler state packet such as current status 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 pragma rtos_task func_task include lt kernel h gt Standard header file definition include lt kernel_id h gt System information header file definition void func_task VP_INT exinf ID cycid ID
11. C format ER stp_cyc ID cycid Assembly format MOVW AX cycid CALL _stp_cyc Parameter s O Parameter Description 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 RI78V4 until issuance of sta_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 as an error Return value Macro Value Description E OK 0 Normal completion R20UT0511EJ0101 Rev 1 01 ztENESAS Page 203 of 272 Apr 01 2012 RI78V4 CHAPTER 12 SERVICE CALLS Outline Reference cyclic handler state C format ER ref_cyc ID cycid T_RCYC pk_rcyc Assembly format MOV A ES MOV C A MOVW DE pk_rcyc_lo PUSH BC PUSH DE MOVW AX cycid CALL ref cyc addw sp 04H Parameter s 0 Parameter Description ID cycid ID number of the cyclic handler to be referenced O T_RCYC pk_reyc Pointer to the packet returning the cyclic handler state Explanation Stores cyclic handler state packet such
12. Interrupt status Note 3 If the return instruction is written in a task it executes the same operation as this service call Note 4 In the RI78V4 code efficiency is enhanced by coding the return instruction as a Terminate invoking task Return value None R20UT0511EJ0101 Rev 1 01 ztENESAS Page 144 of 272 Apr 01 2012 RI78V4 CHAPTER 12 SERVICE CALLS Outline Terminate task C format ER ter_tsk ID tskid Assembly format MOVW AX tskid CALL _ter_tsk Parameter s O Parameter Description 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 RI78V4 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 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 This service call does not return the OS resource that the target task acquired by issuing a service call such as sig_sem or get_mpf The OS resource have been acquired must therefore be returned before issuing this service call Note 2 When moving a task to the DORMANT state this service call i
13. Note When 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 will be executed R20UT0511EJ0101 Rev 1 01 ztENESAS Page 70 of 272 Apr 01 2012 RI78V4 CHAPTER 6 MEMORY POOL MANAGEMENT FUNCTIONS 6 2 4 Release fixed sized memory block A memory block is returned by issuing the following service call from the processing program rel_mpf This service call returns the 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 memory block return processing is not performed but 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 func_task VP_INT exinf ER ercd ID mpfid ID_mpfA VP blk auth acta Oh ae eestor xf if ercd E_OK YM i white ew eel ease see rel_mpf mpfid blk else if ercd E_RLWAI POR Na apa ea aaa R TE aa ee ree ae ercd get_mpf mpfid amp blik Standard header file definition
14. Table 7 1 Delayed Wakeup Service Call Function dly_tsk Delay task 7 4 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 Table 7 2 Timeout Service Call Function tslp_tsk Put task to sleep twai_sem Acquire semaphore resource twai_flg Wait for eventflag trcv_mbx Receive from mailbox tget_mpf Acquire fixed sized memory block R20UT0511EJ0101 Rev 1 01 ztENESAS Page 74 of 272 Apr 01 2012 RI78V4 CHAPTER 7 TIME MANAGEMENT FUNCTIONS 7 5 Cyclic Handlers The cyclic handler is a routine dedicated to cycle processing that is activated periodically at a constant interval activation cycle and is called from the Timer Handler The RI78V4 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 7 5 1 Create
15. 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 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 R20UT0511EJ0101 Rev 1 01 2tENESAS Page 175 of 272 Apr 01 2012 RI78V4 CHAPTER 12 SERVICE CALLS 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 wa
16. the file tothe Project tree If this item is selected when there is already project nda a system information header file then the file itself is not deleted Specify the folder for outputting the system information header file for assembly language 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 This property is not displayed when No It does not register the file that is added to the project nda in the Generate a file property is selected Output folder Default BuildModeName How io Directly enter to the text box or edit by the Browse For Folder dialog box which appears when clicking the change button Restriction Up to 247 characters R20UT0511EJ0101 Rev 1 01 tENESAS Page 258 of 272 Apr 01 2012 RI78V4 APPENDIX A WINDOW REFERENCE Specify the system information header file for assembly language name If the file name is changed the name of the file displayed on the project tree Use the extension automatically added This property is not displayed when No It does not register the file that is inc
17. 16 66 k_work3 segment 16 66 L load module 17 loc_cpu 209 M mailbox 59 message 60 ref_mbx 190 snd_mbx 183 trcv_mbx 188 mailbox information 229 mailbox state packet 134 Main window 244 memory pool management function 66 191 message 60 basic form 60 securement of memory area 60 message packet 133 multiple interrupts 101 multi task OS 10 P packet format 129 cyclic handler state packet 136 eventflag state packet 132 fixed sized memory pool packet 135 mailbox state packet 134 message packet 133 semaphore state packet 131 task state packet 129 version information packet 137 pget_mpf 194 pol_flg 177 pol_sem 167 prcv_mbx 187 priority 24 current priority 24 initialpriority 24 priority level method 109 processing program 12 cyclic handler 12 interrupt handler 12 task 12 Project Tree panel 246 Property panel 249 R20UT0511EJ0101 Rev 1 01 Apr 01 2012 2tENESAS Page 263 of 272 RI78V4 APPENDIX C INDEX R rcv_mbx 185 ready queue 110 READY state 23 real time OS 10 ref_cyc 204 ref_flg 181 ref_mbx 190 ref_mpf 199 ref_sem 170 ref_tsk 148 ref_ver 219 rel_mpf 197 rel_wai 156 return value 128 RI78V4 10 RI78V4 tab 252 rot_rdq 206 rsm_tsk 159 RUNNING state
18. 242 APPENDIX A WINDOW REFERENCE 243 A 1 Description 243 APPENDIX B CAUTIONS 260 B 1 Restriction of Compiler Option 260 B 2 Handling Register Bank 260 B 3 Pointer Declarations 261 APPENDIX C INDEX 262 RI78V4 CHAPTER1 OVERVIEW CHAPTER1 OVERVIEW 1 1 Outline The RI78V4 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 RI78V4 is a high speed compact OS capable of being stored in and run from the ROM of a target system 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 OS A task is the minimum unit in which a program
19. 8 3 Reference Task ID in the RUNNING State 82 8 4 Lock the CPU 83 8 5 Unlock the CPU 85 8 6 Disable Dispatching 86 8 7 Enable Dispatching 88 8 8 Reference Contexts 89 8 9 Reference CPU State 90 8 10 Reference Dispatching State 91 8 11 Reference Dispatch Pending State 92 CHAPTER 9 INTERRUPT MANAGEMENT FUNCTIONS 93 9 1 Outline 93 9 2 Interrupt Entry Processing 93 9 2 1 Basic form of interrupt entry processing 94 9 2 2 Internal processing of interrupt entry processing 94 9 3 Interrupt Handlers 95 9 3 1 Define interrupt handler 95 9 3 2 Basic form of interrupt handlers 96 9 3 3 Internal processing of interrupt handler 98 9 4 Controlling Enabling Disabling of Interrupts 99 9 4 1 Interrupt level under management of the RI78V4 99 9 4 2 Controlling enabling disabling of interrupts in the RI78V4 99 9 4 3 Controlling enabling disabling of interrupts in user processes 9 5 Multiple Interrupts 101 CHAPTER 10 SYSTEM CONFIGURATION MANAGEMENT FUNCTIONS 103 10 1 Outline 103 10 2 Boot Processing 104 10 2 1 Define boot processing 104 10 2 2 Basic form of boot processing 104 10 2 3 Internal processing of boot processing 105 10 3 Initialization Routine 106 10 3 1 Define initialization routine 106 10 3 2 Undefine initialization routine 106 10 3 3 Basic form of initialization routine 106 10 3 4 Internal processin
20. Add Shows the cascading menu to add files and category nodes to the project F Opens the Add Existing File dialog box to add the selected file to the Add File project Add New File Opens the Add File dialog box to create a file with the selected file type and add to the project R20UT0511EJ0101 Rev 1 01 Apr 01 2012 2tENESAS Page 247 of 272 RI78V4 APPENDIX A WINDOW REFERENCE Adds a new category node at the same level as the selected file You can rename the category This menu is disabled while the build tool is running and if categories are nested 20 levels Add New Category Removes the selected file from the project Remove from Project The file itself is not deleted from the file system Note that this menu is disabled when the build tool is in operation Copies the selected file to the clipboard Copy When the file name is in editing the characters of the selection are copied to the clipboard Paste This menu is always disabled You can rename the selected file Rename tee a The actual file is also renamed Property Displays the selected file s property on the Property panel R20UT0511EJ0101 Rev 1 01 tENESAS Page 248 of 272 Apr 01 2012 RI78V4 APPENDIX A WINDOW REFERENCE Property panel Outline This panel is used to display the detailed information on the Realtime OS node system configuration file or the like that is selecte
21. Bit pattern to clear 16 bits Explanation This service call sets the result of ANDing 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 eventtflag Note 1 This service call does not perform queuing of clear requests If the bit pattern has been cleared therefore no processing is performed but it is not handled as an error Note 2 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 Note 3 This service call does not cancel tasks in the waiting state for an eventflag Return value Macro Value Description E OK 0 Normal completion R20UT0511EJ0101 Rev 1 01 2tENESAS Page 174 of 272 Apr 01 2012 RI78V4 CHAPTER 12 SERVICE CALLS Outline Wait for eventflag waiting forever C format ER wai_flg ID flgid FLGPIN waiptn MODE wfmode FLGPTN p_flgptn Assembly format OV A ES OV Cy OVW DE p_flgptn_lo PUSH BC PUSH DE OVW AX wfmode PUSH AX OVW AX waiptn PUSH AX OVW AX flgid CALL _ wai_flg addw sp 08H Parameter s 1 O Parameter Description l ID flgid ID number of the eventflag wait for l FLGPTN waiptn Wait bit pattern 16 bits Wait mode
22. CENESAS C n D ms n lt A 5 D RI78V4 Real Time Operating System User s Manual Coding Target Device RL78 Family 78KOR Microcontroller All information contained in these matenals 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 Awww renesas com Renesas Electronics www renesas com Rev 1 01 Apr 2012 8 10 11 12 Notice All information included in this document is current as of the date this document is issued Such information however is subject to change without any prior notice Before purchasing or using any Renesas Electronics products listed herein please confirm the latest product information with a Renesas Electronics sales office Also please pay regular and careful attention to additional and different information to be disclosed by Renesas Electronics such as that disclosed through our website 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 gran
23. CRE_FLG flgid flgatr iflgptn The items constituting the eventflag information are as follows 1 Eventflag name figid Specifies the eventflag name An object name can be specified for flgid Note The CF78V4 outputs to the system information header file the correspondence between the eventflag names and IDs in the following format Consequently eventflag names can be used in the place of IDs by including the relevant system information header file using the processing program Output format to system information header file for C define flgid ID Output format to system information header file for assembly language flgid equ ID 2 Attribute queuing method queuing count bit pattern clear flgatr Specifies the attributes queuing method queuing count clear of the eventtflag The keywords that can be specified for flgatr are TA_TFIFO TA_WSGL and TA_CLR Queuing method TA_TFIFO If the bit pattern of the eventflag does not satisfy the required condition when wai_flg or twai_flg is issued the task is queued to the eventflag wait queue Queuing count TA_WSGL Only one task is 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 that eventtflag Note If specification of TA_CLR is omitted not clear bit patterns if the required condition is satisfied
24. CSEG _func_task PUSH BC Stores the higher 2 bytes of argument exinf into stack PUSH AX Stores the lower 2 bytes of argument exinf into stack MOVW AX ID_tskA Parameter setting CALL act_tsk Call service call MOVW AX BC MOVW _ercd AX Return value setting oe ar tence ascend BR _ext_tsk Call service call Note To call the service calls provided by the RI78V4 from a processing program the header files listed below must be coded include processing kernel inc Standard header file for assembly language kernel_id inc System information header file for assembly language R20UT0511EJ0101 Rev 1 01 2tENESAS Page 123 of 272 Apr 01 2012 RI78V4 CHAPTER 12 SERVICE CALLS 12 3 Amount of Stack Used by Service Calls The RI78V4 saves restores the values of registers PC PSW and HL to from the stack of the processing program that issued the relevant service call task stack or system stack during preprocessing postprocessing of the service call The stack of the processing program that issued a service call is used for storing the service call arguments and the system stack is used as the stack area required for executing internal processing of the service call When securing the task stack and system stack areas the stack amount consumed upon issuance of a service call must therefore be considered The following lists the stack sizes required upon issuance of a service call Table 12 1 Stack Amount Used by
25. Declares Declares Declares Declares Reference Reference Reference Reference Reference waiting Reference and initializes variable data structure variable variable variable variable variable variable variable task state task current state task current priority reason for waiting object ID number for which the task is activation request count Referenc wakeup request count Referenc suspension count Note For details about the task state packet refer to 12 5 1 Task state packet R20UT0511EJ0101 Rev 1 01 Apr 01 2012 ztENESAS Page 33 of 272 RI78V4 CHAPTER 4 TASK DEPENDENT SYNCHRONIZATION FUNCTIONS CHAPTER 4 TASK DEPENDENT SYNCHRONIZATION FUNCTIONS This chapter describes the task dependent synchronization functions performed by the RI78V4 4 1 Outline The RI78V4 provides several task dependent synchronization functions 4 2 Put Task to Sleep A task is moved to the sleeping state waiting forever or with timeout 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 RI78V4 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 sub
26. E OK 0 Normal completion E RLWAI 49 Forced release from waiting accept rel_wai irel_wai while waiting R20UT0511EJ0101 Rev 1 01 Apr 01 2012 2tENESAS Page 193 of 272 RI78V4 CHAPTER 12 SERVICE CALLS Outline Acquire fixed sized memory block polling C format ER pget_mpf ID mpfid VP p_blk Assembly format MOV A ES MOV C A MOVW DE p_blk_lo PUSH BC PUSH DE MOVW AX mpfid CALL _pget_mpf addw sp 04H Parameter s 1 O Parameter Description 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 Explanation This service call acquires the 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 memory block could not be acquired from the target fixed sized memory pool no available memory blocks exist when this service call is issued memory block acquisition processing is not performed but E_TMOUT is returned Return value Macro Value Description E OK 0 Normal completion E TMOUT 50 Polling failure R20UT0511EJ0101 Rev 1 01 2tENESAS Page 194 of 272 Apr 01 2012 RI78V4 CHAPTER 12 SERVICE CALLS Outline Acquire fixed sized memory block with timeout C format ER tget_mpf ID mpfid
27. E_OK PP Bohs E E A aA Polling success processing else if ercd E_TMOUT JE bua Rees ate ahs Polling failure processing YR ieee EEES ay R20UT0511EJ0101 Rev 1 01 tENESAS Page 47 of 272 Apr 01 2012 RI78V4 CHAPTER 5 SYNCHRONIZATION AND COMMUNICATION FUNCTIONS twai_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 the invoking task is queued to the target semaphore wait queue in the order of resource acquisition request FIFO order 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 a semaphore resource 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_ T
28. E_TMOUT OO satan ie means E Timeout processing AET E ETE a Note When TMO_FEVR is specified for wait time tmout processing equivalent to slp_tsk will be executed R20UT0511EJ0101 Rev 1 01 2tENESAS Page 36 of 272 Apr 01 2012 RI78V4 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 func_task func_task pragma rtos_task include lt kernel h gt include lt kernel_id h gt void VP_INT exinf Standard header file definition System information header file definition ID tskid ID_tskA Declares and initializes variable Wakeup task Note 1 If the target task is moved to the READY state after this service call is issued this service call also re queues the task at the end of the ready queue correspondin
29. PUSH DE OVW AX wfmode PUSH AX OVW AX waiptn PUSH AX OVW AX flgid CALL _pol_flg addw sp 08H Parameter s 0 Parameter Description ID flgid ID number of the eventflag wait for l FLGPTN waiptn Wait bit pattern 16 bits 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 waipin 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 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 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 eventtflag R20UT0511EJ0101 Rev 1 01 ztENESAS Page 177 of 272 Apr 01 2012 RI78V4 CHAPTER 12 SERVICE CALLS wfmode TWF_ORW Checks which bit among bits to which 1 is set by parameter waiptn is set as the target eventflag Note 1 In the RI78V4 the number of tasks that can be queued to the eve
30. RI78V4 CHAPTER 8 SYSTEM STATE MANAGEMENT FUNCTIONS 8 4 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 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 issuance is also restricted If a maskable interrupt is created during this period the RI78V4 delays transition to the relevant interrupt processing interrupt handler until either unl_cpu or iunl_cpu is issued 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_ctx Reference contexts sns_loc Reference CPU state sns_dsp Reference dispatching state sns_dpn Reference dispatch pending state The following shows a processing flow when using this service call Figure 8 2 Lock the CPU Task Interrupt handler mer S an CPU Suppressed period Unlock the CPU return R20UT0511EJ0101 Rev 1 01 ztENESAS Page 83 of 272 Apr 01 2012 RI78V4 CHAPTER 8 SYSTEM STATE MANAGEMENT FUNCTIONS The following describes an example for coding this service call pragma rtos_task func_task include lt kernel h gt
31. Stores the lower 2 bytes of argument exinf into stack fi ienie aS Main processing BR _ext_tsk Terminate invoking task END R20UT0511EJ0101 Rev 1 01 tENESAS Page 25 of 272 Apr 01 2012 RI78V4 CHAPTER 3 TASK MANAGEMENT FUNCTIONS 3 2 6 Internal processing of task In the RI78V4 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 in the format shown in 3 2 5 Basic form of tasks Stack switching In the RI78V4 switching to the stack for the switching destination task task stack is executed during task switching The user is therefore not required to code processing related to stack switching in tasks Interrupt status In the RI78V4 the initial interrupt state specified in Task information when a task is switched from the READY state to the RUNNING state To change disable or enable the interrupt status in the task writing of pragma DI or pragma El directive and calling of the DI or El function are therefore required Service call issuance 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 issuance range of each service call refer to Table 12 8 to Table 12 16 R20UT0511EJ0101 Rev 1 01 2tENESAS Page 26 of 272 Apr 01 2012 RI78V4 CHAPTER 3 TASK MANAGEMENT FUNCTIONS 3 3 Activate
32. Value Description E_ QOVR 43 Queue overflow release will exceed maximum resource count 127 R20UT0511EJ0101 Rev 1 01 Apr 01 2012 2tENESAS Page 165 of 272 RI78V4 CHAPTER 12 SERVICE CALLS Outline Acquire semaphore resource waiting forever C format ER wai_sem ID semid Assembly format MOVW AX semid CALL _wai_sem Parameter s O Parameter Description 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 counter is set to 0x0 when this service call is issued the counter manipulation processing is not performed but the invoking task is queued to the target semaphore wait queue in the order of resource acquisition request FIFO order 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 a semaphore state Waiting State for a Semaphore State 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 w
33. 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 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 E_RLWAI 49 Forced release from waiting accept rel_wai irel_wai while waiting R20UT0511EJ0101 Rev 1 01 tENESAS Page 150 of 272 Apr 01 2012 RI78V4 CHAPTER 12 SERVICE CALLS Outline Put task to sleep with timeout C format ER tslp_tsk TMO tmout Assembly format MOVW AX tmout_lo MOVW BC tmout_hi CALL _ tslp_tsk Parameter s 0 Parameter Description Specified timeout unit ticks 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 RI78V4 scheduling subject If a wakeup request has been queued to the target task the wakeup request counter is not set to 0x0
34. issued in order to quickly complete the processing in the interrupt handler during the interval until the processing in the interrupt handler ends the RI78V4 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 R20UT0511EJ0101 Rev 1 01 ztENESAS Page 98 of 272 Apr 01 2012 RI78V4 CHAPTER 9 INTERRUPT MANAGEMENT FUNCTIONS 9 4 Controlling Enabling Disabling of Interrupts 9 4 1 Interrupt level under management of the RI78V4 The microcontroller manages four levels of interrupts level O to level 3 On the RI78V4 the interrupt levels at which service calls can be issued from an interrupt are permanently set to levels 2 and 3 these are treated as the interrupt levels managed by the RI78V4 Interrupt levels 2 and 3 are managed by the RI78V4 Service calls can be issued from levels 2 and 3 Interrupt handlers which are interrupts including timer interrupts managed by the RI78V4 must be set to level 2 or 3 Interrupt levels 0 and 1 are not managed by the RI78V4 Service calls cannot be issued from levels 0 or 1 Behavior is not guaranteed if a service call is issued from level 0 or 1 Interrupt processes which are interrupts not managed by the RI78V4 must be set to level O or 1 There is however an exception user applications that dis
35. lt kernel h gt lt kernel_id h gt VP_INT exinf mpfid ID_mpfA Declares pk_rmpf Declares wt skid Declares fblkent Declares saia Abs mpfid amp pk_rmpf Referenc Standard header file definition System information header file definition and initializes variable data structure variable variable pk_rmpf wtskid the wait Reference ID number of the task at the head of fixed sized memory pool state queue pk_rmpf fblkcnt Referenc number of free memory blocks Note packet For details about the fixed sized memory pool state packet refer to 12 5 6 Fixed sized memory pool state R20UT0511EJ0101 Rev 1 01 Apr 01 2012 2tENESAS Page 72 of 272 RI78V4 CHAPTER 7 TIME MANAGEMENT FUNCTIONS CHAPTER 7 TIME MANAGEMENT FUNCTIONS This chapter describes the time management functions performed by the RI78V4 7 1 Outline The time management functions of the RI78V4 include Delayed Wakeup Timeout and Cyclic Handlers that use timer interrupts created as fixed intervals as means for realizing time dependent processing Note The RI78V4 does not execute initialization of hardware that creates timer interrupts clock controller etc This initialization processing must therefore be coded by the user in the Boot Processing or Initialization Routine 7 2 Timer Handler The timer handler is a dedicated time control processing routine that consists
36. rot_rdq irot_rdq Outline Rotate task precedence C format ER rot_rdq PRI tskpri ER irot_rdq PRI tskpri Assembly format MOVW AX tskpri CALL tt rot rdg MOVW AX tskpri CALL _irot_rdq Parameter s 1 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 realizes the RI78V4 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 prop
37. semid CALL _sig_sem MOVW AX semid CALL _isig_sem Parameter s 1 O Parameter Description 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 1 If the first task linked in the wait queue is moved to the READY state after this service call is issued this service call also re queues the task at the end of the ready queue corresponding to the priority of the task Note 2 The semaphore counter managed by the RI78V4 is configured in 7 bit widths If the number of resources 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 Return value Macro Value Description E OK 0 Normal completion R20UT0511EJ0101 Rev 1 01 2tENESAS Page 164 of 272 Apr 01 2012 RI78V4 CHAPTER 12 SERVICE CALLS Macro
38. this service call also re queues the task at the end of the ready queue corresponding to the priority of the task Return value 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 Macro Value Description E OK 0 Normal completion R20UT0511EJ0101 Rev 1 01 ztENESAS Page 159 of 272 Apr 01 2012 RI78V4 CHAPTER 12 SERVICE CALLS Macro Value Description E OBJ 41 Object state error specified task is neither in the SUSPENDED state nor WAITING SUSPENDED state R20UT0511EJ0101 Rev 1 01 Apr 01 2012 2tENESAS Page 160 of 272 RI78V4 CHAPTER 12 SERVICE CALLS Outline Forcibly resume suspended task C format ER frsm_tsk ID tskid ER ifrsm_tsk ID tekid Assembly format MOVW AX tskid CALL _frsm_tsk MOVW AX tskid CALL _ifrsm tsk Parameter s 1 O Parameter Description l ID tskid ID number of the task to be resumed Explanation These service calls set the suspend request counter for the task specified by parameter tskid to 0x1 f and then forcibly cancel 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 to the WAITING
39. 01 2012 RI78V4 CHAPTER 12 SERVICE CALLS Waiting State for a Fixed sized Memory Block Cancel Operation Return Value A memory block was returned to the target fixed sized memory pool as a result of issuing E OK rel_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 When 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 will be executed Return value Macro Value Description E OK 0 Normal completion E_RLWAI 49 Forced release from waiting accept rel_wai irel_wai while waiting E_TMOUT 50 Polling failure or timeout R20UT0511EJ0101 Rev 1 01 tENESAS Page 196 of 272 Apr 01 2012 RI78V4 CHAPTER 12 SERVICE CALLS Outline Release fixed sized memory block C format ER rel_mpf ID mpfid VP bik Assembly format MOV A ES MOV Cc A MOVW DE blk_lo PUSH BC PUSH DE MOVW AX mpfid CALL _rel_mpf addw sp 04H Parameter s 1 O Parameter Description 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 memory block spe
40. 10 SYSTEM CONFIGURATION MANAGEMENT RI78V4 FUNCTIONS CHAPTER 10 SYSTEM CONFIGURATION MANAGE MENT FUNCTIONS This chapter describes the system configuration management functions performed by the RI78V4 10 1 Outline The system configuration management functions of the RI78V4 provides system initialization processing which is required from the reset interrupt output until control is passed to the task and version information referencing processing The following shows a processing flow from when a reset interrupt occurs until the control is passed to the task Reset interrupt N Interrupt Entry Processing Figure 10 1 Processing Flow System Initialization System initialization Boot Processing E Kernel Initialization Module Initialization Routine 4 p SCHEDULER ER Task R20UT0511EJ0101 Rev 1 01 ztENESAS Page 103 of 272 Apr 01 2012 CHAPTER 10 SYSTEM CONFIGURATION MANAGEMENT RI78V4 FUNCTIONS 10 2 Boot Processing Boot processing is a routine dedicated to initialization processing that is extracted as a user own coding module to initialize the minimum required hardware for the RI78V4 to perform processing Boot processing is called from Interrupt Entry Processing that is assigned to the vector table address to which the CPU forcibly passes the control when a reset interrupt occurs 10 2 1 Define boot processing Boot processing registration is re
41. 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 aresult 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 ID tskid a eer rel_wai tskid PPO eh tee aetna dics pragma rtos_task include lt kernel h gt include lt kernel_id h gt void func_task VP_INT exinf ID_tskA func_task Standard header file definition System information header file definition Declares and initializes variable Release task from waiting Note 1 If the target task is moved to the READY state after this service call is issued this service call also re queues the task at the end of the ready queue corresponding to the priority of the task Note 2 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 st
42. As a result the relevant task is unlinked from the wait queue and is moved from the WAITING state receiving waiting for a mailbox to the READY state or from the WAITING SUSPENDED state to the SUSPENDED state Note 1 If the first task of the wait queue is moved to the READY state after this service call is issued this service call also re queues the task at the end of the ready queue corresponding to the priority of the task Note 2 Messages are queued to the target mailbox wait queue in the order defined by Attribute queuing method mbxatr during configuration FIFO order or priority order Note 3 With the RI78V4 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 4 For details about the message packet refer to 12 5 4 Message packet R20UT0511EJ0101 Rev 1 01 ztENESAS Page 183 of 272 Apr 01 2012 RI78V4 CHAPTER 12 SERVICE CALLS Return value Macro Value Description E OK 0 Normal completion R20UT0511EJ0101 Rev 1 01 2tENESAS Page 184 of 272 Apr 01 2012 RI78V4 CHAPTER 12 SERVICE CALLS rcv_mbx Outline Receive from mailbox waiting forever C format ER rcev_mbx ID mbxid T_MSG ppk_msg Assembly format MOV A ES M
43. CPU locked state FALSE 0 Normal completion CPU unlocked state R20UT0511EJ0101 Rev 1 01 ztENESAS Page 215 of 272 Apr 01 2012 RI78V4 CHAPTER 12 SERVICE CALLS Outline Reference dispatching state C format BOOL sns_dsp void Assembly format CALL _sns_dsp Parameter s None Explanation This service call acquires the system status type when this service call is issued dispatching disabled state or dispatching enabled state When this service call is terminated normally the acquired system state type TRUE dispatching disabled state FALSE dispatching enabled state is returned Note The system enters the dispatching disabled state when dis_dsp is issued and enters the dispatching enabled state when ena_dsp is issued Return value Macro Value Description TRUE 1 Normal completion dispatching disabled state FALSE 0 Normal completion dispatching enabled state R20UT0511EJ0101 Rev 1 01 ztENESAS Page 216 of 272 Apr 01 2012 RI78V4 CHAPTER 12 SERVICE CALLS Outline Reference dispatch pending state C format BOOL sns_dpn void Assembly format CALL _sns_dpn 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 dispatc
44. Declares and initializes variable JE napeta Ghee A ber tek tskid J gt Terminate task SE aapea euog aaas Note 1 This service call does not return the OS resource that the target task acquired by issuing a service call such as sig_sem or get_mpf The OS resource have been acquired must therefore be returned before issuing this service call Note 2 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 R20UT0511EJ0101 Rev 1 01 ztENESAS Page 31 of 272 Apr 01 2012 RI78V4 CHAPTER 3 TASK MANAGEMENT FUNCTIONS 3 6 Change Task Priority The priority is changed by issuing the following service call from the processing program chg_opri ichg_pri These service calls change the priority of the task specified by parameter tskid current priority to a value specified by parameter tskpri The following describes an example for coding this service call pragma rtos_task func_task include lt kernel h gt Standard header file definition include lt kernel_id h gt System information header file definition void func_task VP_INT exinf ID tskid ID_tskA Declares and initializes variable PRI tskpri 15 Declares and initializes variable LE swctehy Bile eth a Beas chg_pri tskid tskpri Change t
45. ID number of the task to be woken up l 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 1 Note 2 If the target task is moved to the READY state after this service call is issued this service call also re queues the task at the end of the ready queue corresponding to the priority of the task The wakeup request counter managed by the RI78V4 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 R20UT0511EJ0101 Rev 1 01 Apr 01 2012 2tENESAS Page 153 of 272 RI78V4 CHAPTER 12 SERVICE CALLS Return value Macro Value Description E OK 0 Normal completion E OBJ 41 Object state error specified task is in the DORMANT state E_QOVR 43 Queue overflow overflow of wakeup request count 127 R20UT05
46. 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 Return value Macro Value Description E OK 0 Normal completion E RLWAI 49 Forced release from waiting accept rel_wai irel_wai while waiting R20UT0511EJ0101 Rev 1 01 tENESAS Page 162 of 272 Apr 01 2012 RI78V4 CHAPTER 12 SERVICE CALLS 12 8 Synchronization and Communication Functions Semaphores The following lists the service calls provided by the RI78V4 as the synchronization and communication functions sema phores Table 12 10 Synchronization and Communication Functions Semaphores Service Call Function Origin of Service Call sig_sem Release semaphore resource Task Non task isig_sem Release semaphore resource Task Non task wai_sem Acquire semaphore resource waiting forever Task pol_sem Acquire semaphore resource polling Task Non task twai_sem Acquire semaphore resource with timeout Task ref_sem Reference semaphore state Task Non task R20UT0511EJ0101 Rev 1 01 tENESAS Page 163 of 272 Apr 01 2012 RI78V4 CHAPTER 12 SERVICE CALLS sig sem isig sem Outline Release semaphore resource C format ER sig_sem ID semid ER isig_sem ID semid Assembly format MOVW AX
47. 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 included herein Renesas Electronics products are classified according to the following three quality grades Standard High Quality and Specific The recommended applications for each Renesas Electronics product depends on the product s quality grade as indicated below 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 categorized as Specific without the prior written consent of Renesas Electronics Further you may not use any Renesas Electronics product for any application for which it is not intended without the prior written consent of Renesas Electronics 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 an application categorized as Specific or for which the product is not intended where you have failed to obtain the prior written consent of Renesas Electronics The quality grade of each Renesas Electronics product is Standard unless otherwise expressly specified in a Renesas Electronics data sheets or data books etc Standard Computers office
48. Service Call Unit Bytes Service Call a j a one PY For ni Service Call Task Management Functions act_tsk iact_tsk 0 10 4 can_act 0 10 4 sta_tsk ista_tsk 0 8 4 ext_tsk 0 8 4 ter_tsk 0 8 4 chg_pri ichg_pri 2 8 4 ref_tsk 4 8 4 Task Dependent Synchronization Functions slp_tsk 0 8 4 tslp_tsk 0 8 4 wup_tsk iwup_tsk 0 8 4 can_wup ican_wup 0 8 4 rel_wai irel_wai 0 8 4 sus_tsk isus_tsk 0 8 4 rsm_tsk irsm_tsk 0 8 4 frsm_tsk ifrsm_tsk 0 8 4 dly_tsk 0 8 4 Synchronization and Communication Functions Semaphores sig_sem isig_sem 0 8 4 wai_sem 0 8 4 pol_sem 0 8 4 twai_sem 4 8 4 ref_sem 4 8 4 Synchronization and Communication Functions Eventflags set_flg iset_flg 2 8 4 clr_flg 2 8 4 wai_flg 8 8 6 pol_flg 8 8 6 twai_flg 12 8 6 R20UT0511EJ0101 Rev 1 01 ztENESAS Page 124 of 272 Apr 01 2012 RI78V4 CHAPTER 12 SERVICE CALLS Service Call r Service Call ee oe by For System Stack Internal rguments Service Call Processing ref _flg 4 8 4 Synchronization and Communication Functions Mailboxes snd_mbx 4 8 4 rcv_mbx 4 8 6 prcv_mbx 4 8 6 trcv_mbx 8 8 6 ref_mbx 4 8 4 Memory Pool Management Functions get_mpf 4 8 6 pget_mpf 4 8 6 tget_mpf 8 8 6 rel_mpf 4 8 6 ref_mpf 4 8 4 Time Management Fu
49. Standard header file definition include lt kernel_id h gt System information header file definition void func_task VP_INT exinf forever ercd get_mpf mpfid amp p_blk if ercd E_OK PAE Ale a ani a bate Yong ae dpa Lf Normal termination processing Release fixed sized memory block rel_mpf mpfid p bik ER ercd Declares variable ID mpfid ID_mpfA Declares and initializes variable VP p_blk Declares variable fo E 2 hte Sani A Acquire fixed sized memory block wait else if ercd E_RLWAI ee ae eee fs Forced termination processing PRS E alae eee R20UT0511EJ0101 Rev 1 01 ztENESAS Page 67 of 272 Apr 01 2012 RI78V4 CHAPTER 6 MEMORY POOL MANAGEMENT FUNCTIONS R20UT0511EJ0101 Rev 1 01 2tENESAS Page 68 of 272 Apr 01 2012 RI78V4 CHAPTER 6 MEMORY POOL MANAGEMENT FUNCTIONS pget_mpf This service call acquires the 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 memory block could not be acquired from the target fixed sized memory pool no available memory blocks exist when this service call is issued memory block acquisition processing is not performed but E_TMOUT is returned The following describes an example for coding this service call func_task VP_INT exinf
50. System information header file definition pragma rtos_task func_task include lt kernel h gt include lt kernel_id h gt void Declares variable Declares and initializes variable Declares variable Acquire fixed sized memory block Normal termination processing Releas fixed sized memory block Forced termination processing Note 1 Note 2 blocks are therefore undefined If the first task of the wait queue is moved to the READY state after this service call is issued this service call also re queues the task at the end of the ready queue corresponding to the priority of the task The RI78V4 does not clear the memory blocks before returning them The contents of the returned memory R20UT0511EJ0101 Rev 1 01 Apr 01 2012 2tENESAS Page 71 of 272 RI78V4 CHAPTER 6 MEMORY POOL MANAGEMENT FUNCTIONS 6 2 5 Reference fixed sized memory pool state A fixed sized memory pool status is referenced by issuing the following service call from the processing program ref_mpf Stores fixed sized memory pool state packet such as existence of waiting tasks of the fixed sized memory pool specified by parameter mpfid in the area specified by parameter pk_rmpf The following describes an example for coding this service call pragma include include void func_task ID T_RMPF ID UINT ref_mpf fblkcnt wtskid rtos_task func_task
51. This service call does not perform queuing of disable requests If the system is in the dispatching disabled state therefore no processing is performed but it is not handled as an error R20UT0511EJ0101 Rev 1 01 ztENESAS Page 86 of 272 Apr 01 2012 RI78V4 CHAPTER 8 SYSTEM STATE MANAGEMENT FUNCTIONS Note 2 The dispatching disabled state changed by issuing this service call must be cancelled before the task that issued this service call moves to the DORMANT state R20UT0511EJ0101 Rev 1 01 2tENESAS Page 87 of 272 Apr 01 2012 RI78V4 CHAPTER 8 SYSTEM STATE MANAGEMENT FUNCTIONS 8 7 Enable Dispatching The dispatching 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 dispatching 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 RI78V4 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 describes an example for coding this service call pragma rtos_task func_task include lt kernel h gt Standar
52. Tree Panel After Running Build Project Tree a Fr sample Project B uPD78F1166_A40 Microcontroller A Pin Configurator Design Tool Code Generator Design Tool A CA78KOR Build Tool Z RI7BV4 Realtime OS 78KOR Simulator Debug Tool D Program Analyzer Analyze Tool B E File ral Build tool generated files ime sample Im map sample map hex sample hex sym sample sym sJ Startup aam start asm ej idlrtn c c inirtn c C_ init c cj inthdr c ar sample dr c j task c c cychdr c h init h h user h Pf E af Realtime OS generated files asm sit asm h kernel_id h ing kernel_id inc 8 Save the project Save the setting information of the project to the project file Note See CubeSuite Integrated Development Environment User s Manual Start for details about saving the project R20UT0511EJ0101 Rev 1 01 2tENESAS Page 20 of 272 Apr 01 2012 RI78V4 CHAPTER 2 SYSTEM CONSTRUCTION 2 7 Embedding System If the output of hex files are set in 4 of 2 6 Creating Load Module hex files are created After that embed the modules to the system by using a flash programmer R20UT0511EJ0101 Rev 1 01 2tENESAS Page 21 of 272 Apr 01 2012 RI78V4 CHAPTER 3 TASK MANAGEMENT FUNCTIONS CHAPTER3 TASK MANAGEMENT FUNCTIONS This chapter describes the task management functions performed by the RI78V4 3 1 Outline The task control functions provided by the RI78V4 include a function to re
53. VP p_blk TMO tmout Assembly format OVW AX tmout_hi PUSH AX OVW AX tmout_lo PUSH AX OV A ES OV C A OVW DE p_blk_lo PUSH BC PUSH DE OVW AX mpfid CALL _tget_mpf addw sp 08H Parameter s 1 O Parameter Description 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 ticks TMO tmout TMO_FEVR Waiting forever TMO_POL Polling Value Specified timeout Explanation This service call acquires the memory block from the fixed sized memory pool specified by parameter mpfid and stores the start address in the area specified by parameter p_blk If a memory block could not be acquired from the target fixed sized memory pool no available memory blocks exist when this service call is issued memory block acquisition processing is not performed but the invoking task is queued to the target fixed sized memory pool wait queue in the order of memory block acquisition request FIFO order 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 a fixed sized memory block The waiting state for a fixed sized memory block is cancelled in the following cases and then moved to the READY state R20UT0511EJ0101 Rev 1 01 ztENESAS Page 195 of 272 Apr
54. a fixed sized memory block 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 memory block was returned to the target fixed sized memory pool as a result of issuing E OK rel_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 The following describes an example for coding this service call pragma rtos_task func_task include lt kernel h gt Standard header file definition include lt kernel_id h gt System information header file definition void func_task VP_INT exinf ER ercd Declares variable ID mpfid ID_mpfA Declares and initializes variable VP p_blk Declares variable TMO tmout 3600 Declares and initializes variable PRO ecb aw Boa RS Ra s Acquire fixed sized memory block with timeout ercd tget_mpf mpfid amp p_ blk tmout if ercd E_OK E E dune 7 Normal termination processing Release fixed sized memory block rel_mpf mpfid p blk else if ercd E_RLWAI PPE sae Bea tains Bt Ee Kj Forced termination processing else if ercd E_TMOUT ee ate eee Timeout processing PP Geaen tia Af
55. a task is queued to the wait queue TSK_NONE No applicable task Value ID number of the task at the head of the wait queue flgptn rflg_flgptn Stores the current bit pattern of the eventtflag R20UT0511EJ0101 Rev 1 01 2tENESAS Page 132 of 272 Apr 01 2012 RI78V4 CHAPTER 12 SERVICE CALLS 12 5 4 Message packet The following shows message packet T MSG and T_MSG_PRI used when issuing snd_mbx rcv_mbx prcv_mbx or trcv_mbx Definition of message packet T_MSG and T_MSG_PRI is performed by header file lt ri_root gt include types h which is called from standard header file lt ri_root gt include kernel h Message packet for TA_MFIFO attribute typedef struct t_msg struct t_msg __far T_MSG msgque Reserved for future use Message packet for TA_MPRI attribute struct t_msg __far PRI msgpri T_MSG_PRI typedef struct t_msg_pri msgque Reserved for future use Message priority The following shows details on message packet T_ MSG and T_MSG_PRI msgque System reserved area msgpri Stores the priority of the message Note 1 In the RI78V4 a message having a smaller priority number is given a higher priority Note 2 Values that can be specified for the priority of a message are limited from 1 to 31 R20UT0511EJ0101 Rev 1 01 Apr 01 2012 2tENESAS Page 133 of 272 RI78V4 CHAPTER 12 SERVICE CALLS 12 5 5 Mailbox state packet
56. align2 flgnum 3 mbxnum 8 align2 primbx mpfnum 4 cycnum 8 40 maxtpri Priority range specified in Task priority information tsknum Total amount of Task information semnum Total amount of Semaphore information flgnum Total amount of Eventflag information mbxnum Total amount of Mailbox information primbx Total amount of Mailbox information for which the priority is specified for the attribute message queuing method mpfnum Total amount of Fixed sized memory pool information cycnum Total amount of Cyclic handler information 2 5 5 k_ stack segment The following shows an expression required for estimating the k_stack segment size unit bytes tsknum stack stksZ 28 sys_stksz 2 k 1 tsknum Total amount of Task information StkSZ x Stack size specified in Task information sys_stksz Stack size specified in System stack information R20UT0511EJ0101 Rev 1 01 ztENESAS Page 15 of 272 Apr 01 2012 RI78V4 CHAPTER 2 SYSTEM CONSTRUCTION 2 5 6 k_work0 k_work1 k_work2 k_work3 segment The following shows an expression required for estimating the size of the k_workO k_work1 k_work2 and k_work3 segments unit bytes mpfnum workX blkent blksz k 1 mpfnum Total number of segment units for Fixed sized memory pool information blkent x Number of fixed sized memory blocks specified in Fixed sized memory pool information blksz x Block size specified in Fixed s
57. 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 R20UT0511EJ0101 Rev 1 01 2tENESAS Page 10 of 272 Apr 01 2012 RI78V4 CHAPTER 2 SYSTEM CONSTRUCTION CHAPTER 2 SYSTEM CONSTRUCTION This chapter describes how to build a system load module that uses the functions provided by the RI78V4 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 RI78V4 s supply media The following shows the procedure for organizing the system Figure 2 1 Example of System Construction Processing Programs System Configuration File User own Coding Module C Configurator y Information Files Yy y y C C Compiler Assembler Directive File Library Files Kernel Librar
58. compiler package REL The CA78KOR is used 12 4 6 Others The following lists other macros used when issuing a service call Macro definition of other macros is performed by standard header file lt ri_root gt include kernel h Table 12 7 Others Macro Value Description TSK_SELF 0 Invoking task TPRI_INI 0 Initial priority of the task 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 TSK_NONE 0 No applicable task NULL 0 No applicable message R20UT0511EJ0101 Rev 1 01 ztENESAS Page 128 of 272 Apr 01 2012 RI78V4 CHAPTER 12 SERVICE CALLS 12 5 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 RI78V4 12 5 1 Task state packet The following shows task state packet T_RTSK used when issuing ref_tsk Definition of task state packet T_RTSK is performed by header file lt ri_root gt include os packet h packet inc which is called from standard header file lt ri_root gt include kernel h kernel inc packet h typedef struct t_rtsk STA tskstat Task current state PRI tskpri Task current priority PRI tskbpri Reserved for future use STA tskwait Reason for waiting ID wobjid Object ID numbe
59. count positive value or 0 R20UT0511EJ0101 Rev 1 01 2tENESAS Page 141 of 272 Apr 01 2012 RI78V4 CHAPTER 12 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 Assembly format MOVW AX stacd_hi PUSH AX MOVW AX stacd_lo PUSH AX MOVW AX tskid CALL _sta_tsk addw sp 04H MOWW AX stacd_hi PUSH AX MOVW AX stacd_lo PUSH AX MOVW AX tskid CALL _ista_tsk addw sp 04H Parameter s O Parameter Description l ID tskid ID number of the task to be activated l VP_INT stacd Start code of the task 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 RI78V4 Note 1 This service call does not perform queuing of activation requests If the target task is in a state other than the DORMANT state the counter manipulation processing is therefore not performed but E_OBJ is returned Note 2 A start code staca is passed to the task activated by issuing this service call R20UT0511EJ0101 Rev 1 01 ztENESAS Page 142 of 272 Apr 01 2012 RI78V4 CHAPTER 12 SERVICE CALLS Return value Macro Valu
60. cyclic handler In the RI78V4 the method of creating a cyclic handler is limited to static creation by the Kernel Initialization Module Cyclic handlers therefore cannot be created dynamically using a method such as issuing a service call from a processing program Static create Static cyclic handler creation is realized by defining Cyclic handler information in the system configuration file The RI78V4 executes cyclic handler creation processing based on data stored in information files using the Kernel Initialization Module and handles the created cyclic handlers as management targets 7 5 2 Delete cyclic handler In the RI78V4 cyclic handlers created statically by the Kernel Initialization Module cannot be deleted dynamically using a method such as issuing a service call from a processing program 7 5 3 Basic form of cyclic handlers Write cyclic handlers using void type functions that do not have arguments function any The following shows the basic form of cyclic handlers C Language include lt kernel h gt Standard header file definition include lt kernel_id h gt System information header file definition void func_cychdr void E bce ep eae be tebe EJ Main processing return Terminate cyclic handler Assembly Language SINCLUDE kernel inc Standard header file definition S INCLUDE kernel_id inc System information header file definition PUBLIC _fu
61. equipment communications equipment test and measurement equipment audio and visual equipment home electronic appliances machine tools personal electronic equipment and industrial robots High Quality Transportation equipment automobiles trains ships etc traffic control systems anti disaster systems anti crime systems safety equipment and medical equipment not specifically designed for life support Specific Aircraft aerospace equipment submersible repeaters nuclear reactor control systems medical equipment or systems for life support e g artificial life support devices or systems surgical implantations or healthcare intervention e g excision etc and any other applications or purposes that pose a direct threat to human life 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 c
62. h gt Standard header file definition include lt kernel_id h gt System information header file definition void func_task VP_INT exinf ER ercd Declares variable ID semid ID_semA Declares and initializes variable JE sek ew be ae da Bd rcd wai_sem semid Acquire semaphore resource waiting forever if ercd E_OK FFs EE NS Normal termination processing else if ercd E_RLWAI a E eT ee Ef Forced termination processing eee R20UT0511EJ0101 Rev 1 01 tENESAS Page 46 of 272 Apr 01 2012 CHAPTER 5 SYNCHRONIZATION AND COMMUNICATION RI78V4 FUNCTIONS pol_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 pragma rtos_task func_task include lt kernel h gt Standard header file definition include lt kernel_id h gt System information header file definition void func_task VP_INT exinf ER ercd Declares variable ID semid ID_semA Declares and initializes variable EPO iaa naan rcd pol_sem semid Acquire semaphore resource polling if ercd
63. handlers Note 1 Data of the PSW and PC are automatically saved and stored by the CPU Note 2 Saving and restoring of data in the saddr area is unnecessary if functions written in C are not called or service calls are not issued in the interrupt handler Interrupt status The RI78V4 goes into the following state when passing control to an interrupt handler Consequently after control has passed to an interrupt handler if an interrupt occurs with a higher precedence than the current level then multiple interrupts can be processed Acceptance of maskable interrupts is permitted IE 0 Interrupts with the precedence below are disabled A level 2 interrupt handler process is ongoing ISP1 0 ISPO 1 A level 3 interrupt handler process is ongoing ISP1 1 ISPO 0 Note It is not possible to define level 0 or 1 as an interrupt handler Note Even if the acceptance of maskable interrupts is disabled inside an interrupt handler IE 0 it will be enabled IE 1 after control returns from the interrupt handler Service call issuance The RI78V4 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 For details on the valid issuance range of each service call refer to Table 12 8 to Table 12 16 Note 2 If a service call ichg_pri isig sem etc accompanying dispatch processing task scheduling processing is
64. in order to reduce the danger of a stack overflow The example is shown below Conditions Execute a pol_flg service call from task task1 Execute a snd_mbx service call from task task2 Interrupt intO is a level O interrupt process not managed by the OS The stack is not used in the interrupt Interrupt int2 is a level 2 OS interrupt handler Execute the snd_mbx service call and use 12 bytes of stack in the interrupt Interrupt int3A is a level 3 OS interrupt handler Execute the pol_flg service call and use 16 bytes of stack in the interrupt Interrupt int3B is a level 3 OS interrupt handler Execute Timer_Handler the stack is not used in the interrupt Idle idl does not use the stack The initialization routine ini uses 24 bytes of stack in the routine R20UT0511EJ0101 Rev 1 01 2tENESAS Page 234 of 272 Apr 01 2012 RI78V4 CHAPTER 13 SYSTEM CONFIGURATION FILE Expression tsksvc MAX size of system stack used by pol_flg size of system stack used by snd_mbx MAX 6 4 6 bytes int0 0 0 0 byte inti undefined 0 byte int2 12 4 8 4 16 44 bytes int3 MAX int3A int3B MAX 54 20 54 bytes int3A 16 8 8 6 16 54 bytes int3B 0 0 0 6 16 20 bytes sys_stkA tsksvc intO int1 int2 int3 6 0 0 44 54 104 bytes Note This is the max in sys_stkA B C so after this size or greater is secured sys_stkB Stack size used by user in idle routine 0 byte
65. information header file then the file itself is not deleted Specify the folder for outputting the system information header file for C language 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 This property is not displayed when No It does not register the file that is added to the project ndc in the Generate a file property is selected Output folder Default BuildModeName How to Directly enter to the text box or edit by the Browse For Folder dialog box which appears when clicking the change button Restriction Up to 247 characters R20UT0511EJ0101 Rev 1 01 tENESAS Page 256 of 272 Apr 01 2012 RI78V4 APPENDIX A WINDOW REFERENCE Specify the system information header file for C language 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 File name added to the project ndc in the Gener
66. interrupt mask flag register MKxx and the in service priority flag ISPx of the program status word PSW Therefore manipulating of these registers from the processing program is prohibited from when this service call is issued until unl_cpu or iunl_cpu is issued Return value Macro Value Description E OK 0 Normal completion R20UT0511EJ0101 Rev 1 01 2tENESAS Page 210 of 272 Apr 01 2012 RI78V4 CHAPTER 12 SERVICE CALLS Outline Unlock the CPU C format ER unl_cpu void ER iunl_cpu void Assembly format CALL Il unl_cpu CALL _iunl_cpu Parameter s None Explanation These service calls change the system status to the CPU unlocked state As a result acknowledge processing of maskable interrupts prohibited through issuance of either loc_cpu or iloc_cpu is enabled and the restriction on service call issuance is released If a maskable interrupt is created during the interval from when either loc_cpu or iloc_cpu is issued until this service call is issued the RI78V4 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 The RI78V4 implements enabling of maskable interrupt acknowledgment bu manipula
67. is set by parameter waiptn is set as the target eventflag The following describes an example for coding this service call func_task VP_INT exinf pragma rtos_task func_task include lt kernel h gt Standard header file definition include lt kernel_id h gt System information header file definition void ER ercd Declares variable ID flgid ID_f1gA Declares and initializes variable FLGPTN waiptn 0B1110 Declares and initializes variable ODE wfmode TWF_ANDW Declares and initializes variable FLGPTN p_flgptn Declares variable JE aod ow ne Sone ae Wait for eventflag waiting forever ercd wai_flg flgid waiptn wfmode amp p_flgptn if ercd E_OK PP elena EE apace a Normal termination processing else if ercd E_RLWAI YR seca E bead eect wy Forced termination processing R20UT0511EJ0101 Rev 1 01 Apr 01 2012 2tENESAS Page 53 of 272 CHAPTER 5 SYNCHRONIZATION AND COMMUNICATION RI78V4 FUNCTIONS Note 1 In the RI78V4 the number of tasks that can be queued to the eventflag wait queue is one If this service call is issued for the eventflag to which a task is queued therefore E_ILUSE is returned regardless of whether or not the required condition is immediately satisfied Note 2 The RI78V4 performs bit pattern clear processing 0x0 setting when the required condition of the target eve
68. packet 136 12 5 8 Version information packet 137 12 6 Task Management Functions 138 12 7 Task Dependent Synchronization Functions 149 12 8 Synchronization and Communication Functions Semaphores 163 12 9 Synchronization and Communication Functions Eventflags 171 12 10 Synchronization and Communication Functions Mailboxes 182 12 11 Memory Pool Management Functions 191 12 12 Time Management Functions 200 12 13 System State Management Functions 205 12 14 System Configuration Management Functions 218 CHAPTER 13 SYSTEM CONFIGURATION FILE 220 13 1 Notation Method 220 13 2 Configuration Information 221 13 2 1 Cautions 221 13 3 System Information 222 13 3 1 System stack information 222 13 3 2 Task priority information 223 13 4 Static API Information 224 13 4 1 Task information 224 13 4 2 Semaphore information 227 13 4 3 Eventflag information 228 13 4 4 Mailbox information 229 13 4 5 Fixed sized memory pool information 230 13 4 6 Cyclic handler information 232 13 5 Stack Size Estimation 234 13 5 1 System stack size 234 13 5 2 Stack size of the task 235 13 6 Description Examples 237 CHAPTER 14 CONFIGURATOR CF78V4 238 14 1 Outline 238 14 2 Activation Method 239 14 2 1 Activating from command line 239 14 2 2 Activating from CubeSuite 240 14 2 3 Command file 241 14 2 4 Command input examples
69. pattern specified by parameter ci rptn as the bit pattern of the target eventflag The following describes an example for coding this service call pragma rtos_task func_task include lt kernel h gt Standard header file definition include lt kernel_id h gt System information header file definition void func_task VP_INT exinf ID flgid ID_fl1gA Declares and initializes variable FLGPTN clrptn 0B1010 Declares and initializes variable PE paaa clr_flg flgid clrptn Clear eventflag Note 1 This service call does not perform queuing of clear requests If the bit pattern has been cleared therefore no processing is performed but it is not handled as an error Note 2 If the bit pattern set to the target eventflag is B 1100 and the bit pattern specified by parameter c rpin is B 1010 when this service call is issued the bit pattern of the target eventflag is set to B 1110 Note 3 This service call does not cancel tasks in the waiting state for an eventflag R20UT0511EJ0101 Rev 1 01 2tENESAS Page 52 of 272 Apr 01 2012 CHAPTER 5 SYNCHRONIZATION AND COMMUNICATION RI78V4 FUNCTIONS 5 3 5 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 con
70. routine registration processing based on relevant symbol information using the Kernel Initialization Module and handles the registered idle routines as management targets 11 7 2 Undefine idle routine In the RI78V4 idle routines registered statically by the Kernel Initialization Module cannot be unregistered dynamically using a method such as issuing a service call from a processing program 11 7 3 Basic form of idle routine Write idle routines using void type functions that do not have arguments function idle_handler The following shows the basic form of idle routine C Language include lt kernel h gt Standard header file definition include lt kernel_id h gt System information header file definition void idle_handler void JE sie Si eat baa a Main processing return Terminate idle routine Assembly Language SINCLUDE kernel inc Standard header file definition S INCLUDE kernel_id inc System information header file definition PUBLIC _idle handler CSEG _idle_handler BY REENEN Main processing RET Terminate idle routine END R20UT0511EJ0101 Rev 1 01 2tENESAS Page 119 of 272 Apr 01 2012 RI78V4 CHAPTER 11 SCHEDULER 11 7 4 Internal processing of idle routine The RI78V4 handles the idle routine as a non task module independent from tasks Moreover the RI78V4 executes original pre processing when passing control t
71. sized memory pool from which a memory block ID mpfid is acquired O VP p blk Start address of the acquired memory block Explanation This service call acquires the 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 memory block could not be acquired from the target fixed sized memory pool no available memory blocks exist when this service call is issued memory block acquisition processing is not performed but the invoking task is queued to the target fixed sized memory pool wait queue in the order of memory block acquisition request FIFO order 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 a fixed sized memory block 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 memory block was returned to the target fixed sized memory pool as a result of issuing E OK rel_mpf Forced release from waiting accept rel_wai while waiting E_RLWAI Forced release from waiting accept irel_wai while waiting E_RLWAI R20UT0511EJ0101 Rev 1 01 ztENESAS Page 192 of 272 Apr 01 2012 RI78V4 CHAPTER 12 SERVICE CALLS Return value Macro Value Description
72. 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 task linked in the wait queue is moved to the READY state after this service call is issued this service call also re queues the task at the end of the ready queue corresponding to the priority of the task Note 2 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 target eventflag is set to B 1110 R20UT0511EJ0101 Rev 1 01 2tENESAS Page 172 of 272 Apr 01 2012 RI78V4 CHAPTER 12 SERVICE CALLS Return value Macro Value Description E OK 0 Normal completion R20UT0511EJ0101 Rev 1 01 2tENESAS Page 173 of 272 Apr 01 2012 RI78V4 CHAPTER 12 SERVICE CALLS Outline Clear eventflag C format ER clr_flg ID flgid FLGPTN clrptn Assembly format MOVW AX clrptn PUSH AX MOVW AX flgid CALL Wl ely tig POP AX Parameter s 1 O Parameter Description l ID flgid ID number of the eventflag to be cleared l FLGPTN clrptn
73. this service call the counter manipulation processing is therefore not performed but E_QOVR is returned Note 2 An extended information Extended information exinf is passed to the task activated by issuing this service call R20UT0511EJ0101 Rev 1 01 ztENESAS Page 27 of 272 Apr 01 2012 RI78V4 CHAPTER 3 TASK MANAGEMENT FUNCTIONS 3 3 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 RI78V4 The following describes an example for coding this service call pragma rtos_task func_task include lt kernel h gt Standard header file definition include lt kernel_id h gt System information header file definition void func_task VP_INT exinf ID tskid ID_tskA Declares and initializes variable VP_INT stacd 1048575 Declares and initializes variable LR wis Segre E ay sta_tsk tskid stacd Activate task does not queue an activation request Note 1 This service call does not perform queuing of activation requests If the target task is in a state other than the DORMANT state the counter manipulation p
74. this state if it cannot acquire a TTW_SEM 0x0004 resource from the relevant semaphore upon the issuance of a wai_sem or twai_sem A task enters this state if a relevant eventflag does TTW_FLG 0x0008 not satisfy a predetermined condition upon the issu ance of a wai_flg or twai_fig A task enters this state if cannot receive a message TTW_MBX 0x0040 from the relevant mailbox upon the issuance of a rcv_mbx or trcv_mbx A task enters this state if it cannot acquire a fixed sized memory block from the relevant fixed sized TTW_MPF 0x2000 memory pool upon the issuance of a get_mpf or tget_mpf R20UT0511EJ0101 Rev 1 01 ztENESAS Page 127 of 272 Apr 01 2012 RI78V4 CHAPTER 12 SERVICE CALLS 12 4 4 Return value The following lists the values returned from service calls Macro definition of the return value is performed by standard header file lt ri_root gt include kernel h Table 12 5 Return Value Macro Value Description E OK 0 Normal completion E ILUSE 28 Illegal service call use E OBJ 41 Object state error E QOVR 43 Queue overflow E RLWAI 49 F e a from waiting accept rel_wai irel_wai while E_TMOUT 50 Polling failure or timeout FALSE 0 False TRUE 1 True 12 4 5 Conditional compile macro The RI78V4 header files are conditionally compiled by the following macro Table 12 6 Conditional Compile Macro Classification Macro Description C
75. to be allocated k_workO k_work1 k_work2 k_work3 segment Area where fixed sized memory pools are to be allocated 6 2 Fixed Sized Memory Pool When a dynamic memory manipulation request is issued from a processing program in the RI78V4 the fixed sized memory pool is provided as a usable memory area Dynamic memory manipulation of the fixed sized memory pool is executed in fixed size memory block units 6 2 1 Create fixed sized memory pool In the RI78V4 the method of creating a fixed sized memory pool is limited to static creation by the Kernel Initialization Module Fixed sized memory pools therefore cannot be created dynamically using a method such as issuing a service call from a processing program Static create Static fixed sized memory pool creation is realized by defining Fixed sized memory pool information in the system configuration file The RI78V4 executes fixed sized memory pool creation processing based on data stored in information files using the Kernel Initialization Module and handles the created fixed sized memory pools as management targets R20UT0511EJ0101 Rev 1 01 ztENESAS Page 66 of 272 Apr 01 2012 RI78V4 CHAPTER 6 MEMORY POOL MANAGEMENT FUNCTIONS 6 2 2 Delete fixed sized memory pool In the RI78V4 fixed sized memory pools created statically by the Kernel Initialization Module cannot be deleted dynamically using a method such as issuing a service call from a processing program 6 2 3 A
76. 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 RI78V4 provides a utility tool configurator CF78V4 that converts a system configuration file which excels in descriptiveness and readability into information files The CF78V4 reads the system configuration file as a input file and then outputs information files The information files output from the CF78V4 are explained below System information table file An information file that stores data required for the operation of the RI78V4 System information header file An information file that stores matching between ID numbers and object names e g task and semaphore names described in the system configuration file The CF78V4 can output two types of system information header files for C and assembly languages R20UT0511EJ0101 Rev 1 01 2tENESAS Page 238 of 272 Apr 01 2012 RI78V4 CHAPTER 14 CONFIGURATOR CF78V4 14 2 Activation Method 14 2 1 Activating from command line The following is how to activate the CF78V4 from the command line Note that in the examples below C gt indicates the command prompt A 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 cf 78v4 exe A command file A
77. to the dispatching disabled state by issuing the following service call from the processing program dis_dsp This service call changes the system status to the dispatching 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 RI78V4 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 The following shows a processing flow when using this service call Figure 8 3 Disable Dispatching Task Task 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 pragma rtos_task func_task include lt kernel h gt Standard header file definition include lt kernel_id h gt System information header file definition void func_task VP_INT exinf LP co Baar eb eke x dis_dsp Disable dispatching PP a ire thee BS ce Dispatching disabled state ena_dsp Enable dispatching ee Coe eee a Note 1
78. user in addition to the 28 bytes of argument stack size The argument stack sized used by each service call is different Table 12 1 summarizes these sizes The task stack size is the largest stack size used in the task in question For this reason if there is a service call with an argument stack of 4 bytes and another with 8 bytes then the pattern that uses the most stack 8 bytes will be secured R20UT0511EJ0101 Rev 1 01 ztENESAS Page 235 of 272 Apr 01 2012 RI78V4 CHAPTER 13 SYSTEM CONFIGURATION FILE The above material refers to tasks where interrupts are not accepted all interrupts are disabled An additional 18 bytes must be secured for tasks where interrupts are accepted Note that these 18 bytes include the stack size when the _kernel_int_entry function is called required to be called when an interrupt starts _kernel_int_entry only retires the 18 bytes of data from the stack it does not replace it The data is recovered upon the call to the ret_int function which must be called when the interrupt ends Example 1 Task taski uses the pol_flg and snd_mbx service calls and has no other functions or processes that use the stack If interrupts are not accepted in the task interrupts are not accepted in task1 so Expression 1 is the formula for calculating stack usage Because there are no functions or processes that use the stack the size used by the user is 0 When the size of arguments to all service calls is inv
79. waiptn 0B1110 Declares and initializes variable ODE wfmode TWF_ANDW Declares and initializes variable FLGPIN p flgptn Declares variable PoP E E S Wait for eventflag polling ercd pol_flg flgid waiptn wfmode amp p_flgptn if ercd E_OK PR Ea San ocean i Polling success processing lse if ercd E_TMOUT ee a a eee Polling failure processing oP wouter a a 8 aia Note 1 In the RI78V4 the number of tasks that can be queued to the eventflag wait queue is one If this service call is issued for the eventflag to which a task is queued therefore E_ILUSE is returned regardless of whether or not the required condition is immediately satisfied Note 2 The RI78V4 performs bit pattern clear processing 0x0 setting when the required condition of the target eventflag TA_CLR attribute is satisfied R20UT0511EJ0101 Rev 1 01 Apr 01 2012 2tENESAS Page 55 of 272 CHAPTER 5 SYNCHRONIZATION AND COMMUNICATION RI78V4 FUNCTIONS twai_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 eventtflag 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_figptn If the bit pa
80. 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 Items enclosed by square brackets can be omitted 13 3 1 System stack information Define the following item as system stack information 1 Stack size sys_stksz Only one information item can be defined as stack information The following shows the system stack information format SYS_STK sys_stksz The items constituting the system stack information are as follows 1 Stack size sys_stksz Specifies the system stack size in bytes A value between 0 and 65534 aligned to a 2 byte boundary can be specified for sys_siksz Note 1 The system stack is allocated to the k_stack segment Note 2 For details about the estimation of the system stack size refer to See 13 5 1 System stack size R20UT0511EJ0101 Rev 1 01 2tENESAS Page 222 of 272 Apr 01 2012 RI78V4 CHAPTER 13 SYSTEM CONFIGURATION FILE 13 3 2 Task priority information Define the following items as task priority information 1 Priority range maxtpri The number of task priority information items that can be specified is defined as being within the range of 0 to 1 The following shows the task priority information format MAX_PRI maxtpri The items constituting the task priorit
81. 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 R20UT0511EJ0101 Rev 1 01 2tENESAS Page 151 of 272 Apr 01 2012 RI78V4 CHAPTER 12 SERVICE CALLS Return value Macro Value Description E OK 0 Normal completion E RLWAI 49 Forced release from waiting accept rel_wai irel_wai while waiting E TMOUT 50 Polling failure or timeout R20UT0511EJ0101 Rev 1 01 Apr 01 2012 2tENESAS Page 152 of 272 RI78V4 CHAPTER 12 SERVICE CALLS Outline Wakeup task C format ER wup_tsk ID tskid ER iwup_tsk ID tskid Assembly format MOVW AX tskid CALL wup_tsk MOVW AX tskid CALL _iwup_tsk Parameter s 1 O Parameter Description
82. 1 01 ztENESAS Page 225 of 272 Apr 01 2012 RI78V4 CHAPTER 13 SYSTEM CONFIGURATION FILE 6 Stack size stksz Specifies the stack size in bytes of the task A value between 0 and 65534 aligned to a 2 byte boundary can be specified for stksz Note 1 The task stack is allocated to the k_stack segment Note 2 For details about the estimation of the stack size of the task refer to See 13 5 2 Stack size of the task 7 System reserved area stk System reserved area Values that can be specified for stk are limited to NULL characters R20UT0511EJ0101 Rev 1 01 2tENESAS Page 226 of 272 Apr 01 2012 RI78V4 CHAPTER 13 SYSTEM CONFIGURATION FILE 13 4 2 Semaphore information Define the following items as semaphore information 1 Semaphore name semid 2 Attribute queuing method sematr 3 Initial resource count isemcnt 4 System reserved area maxsem The number of semaphore information items that can be specified is defined as being within the range of 0 to 127 The following shows the semaphore information format CRE_SEM semid sematr isemcnt maxsem The items constituting the semaphore information are as follows 1 Semaphore name semid Specifies the semaphore name An object name can be specified for semid Note The CF78V4 outputs to the system information header file the correspondence between the semaphore names and IDs in the following format Con
83. 11EJ0101 Rev 1 01 Apr 01 2012 2tENESAS Page 154 of 272 RI78V4 CHAPTER 12 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 Assembly format MOVW AX tskid CALL can_wup MOVW AX tskid CALL _ican_wup Parameter s 1 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 E_OBJ 41 Object state error specified task is in the DORMANT state Normal completion wakeup request count positive value or 0 R20UT0511EJ0101 Rev 1 01 2tENESAS Page 155 of 272 Apr 01 2012 RI78V4 CHAPTER 12 SERVICE CALLS rel_ wai irel_ wai Outline Release task from waiting C format ER rel_wai ID tskid ER irel_wai ID tskid Assembly format MOVW AX tskid CALL I _rel_wai MOVW AX tskid CALL _irel_wai Parameter s 1 O Para
84. 12 SERVICE CALLS Outline Reference contexts C format BOOL sns_ctx void Assembly format CALL I sns ctx 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 Non task contexts cyclic handler interrupt handler Task contexts task Return value Macro Value Description TRUE 1 Normal completion Non task contexts FALSE 0 Normal completion Task contexts R20UT0511EJ0101 Rev 1 01 2tENESAS Page 214 of 272 Apr 01 2012 RI78V4 CHAPTER 12 SERVICE CALLS Outline Reference CPU state C format BOOL sns_loc void Assembly format CALL tt sne loc Parameter s None Explanation 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 Note The system enters the CPU locked state when loc_cpu or iloc_cpu is issued and enters the CPU unlocked state when unl_cpu or iunl_cpu is issued Return value Macro Value Description TRUE 1 Normal completion
85. 1EJ0101 Rev 1 01 ztENESAS Page 253 of 272 Apr 01 2012 RI78V4 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 now to Select from the drop down list change Generates a new system information table Yes It i file and displays it on the project tree updates the ee If the system configuration file is changed file when the F ae when there is already a system information cfg file is changed i table file then the system information table file is updated Generate a file Yesili dogs Does not update the system information not update te table file when the system configuration file the file when Restriction the cfg file is changed A An error occurs during build if this item is is selected when the system information table changed fil ni ile does not exist Does not generate a system information No It does table file and does not display it on the not register project tree the file to the If this item is selected when there is already project ni a system information table file then the file itself is not de
86. 2 3 Coding of System Configuration File 12 2 4 Coding of User Own Coding Module 13 2 5 Coding of Directive File 14 2 5 1 k_system segment 15 2 5 2 k_info segment 15 2 5 3 k_const segment 15 2 5 4 k_data segment 15 2 5 5 k_stack segment 15 2 5 6 k_workO k_work1 k_work2 k_work3 segment 16 2 6 Creating Load Module 17 2 7 Embedding System 21 CHAPTER 3 TASK MANAGEMENT FUNCTIONS 22 3 1 Outline 22 3 2 Tasks 22 3 2 1 Task state 22 3 2 2 Task priority 24 3 2 3 Create task 24 3 2 4 Delete task 24 3 2 5 Basic form of tasks 25 3 2 6 Internal processing of task 26 3 3 Activate Task 27 3 3 1 Queuing an activation request 27 3 3 2 Not queuing an activation request 28 3 4 Cancel Task Activation Requests 29 3 5 Terminate Task 30 3 5 1 Terminate invoking task 30 3 5 2 Terminate task 31 3 6 Change Task Priority 32 3 7 Reference Task State 33 CHAPTER 4 TASK DEPENDENT SYNCHRONIZATION FUNCTIONS 34 4 1 Outline 34 4 2 Put Task to Sleep 34 4 3 Wakeup Task 37 4 4 Cancel Task Wakeup Requests 38 4 5 Release Task from Waiting 39 4 6 Suspend Task 40 4 7 Resume Suspended Task 41 4 8 Delay Task 43 CHAPTER 5 SYNCHRONIZATION AND COMMUNICATION FUNCTIONS 44 5 1 Outline 44 5 2 Semaphores 44 5 2 1 Create semaphore 44 5 2 2 Delete semaphore 44 5 2 3 Release semaphore resou
87. 4 Mailboxes The RI78V4 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 3 Processing Flow Mailbox Task Task Priority High Priority Low x Receive from mailbox Reception wait period Send to mailbox 5 4 1 Create mailbox In the RI78V4 the method of creating a mailbox is limited to static creation by the Kernel Initialization Module Mailboxes therefore cannot be created dynamically using a method such as issuing a service call from a processing program Static create Static mailbox creation is realized by defining Mailbox information in the system configuration file The RI78V4 executes mailbox creation processing based on data stored in information files using the Kernel Initialization Module and handles the created mailboxes as management targets 5 4 2 Delete mailbox In the RI78V4 mailboxes created statically by the Kernel Initialization Module cannot be deleted dynamically using a method such as issuing a service call from a processing program R20UT0511EJ0101 Rev 1 01 ztENESAS Page 59 of 272 Apr 01 2012 RI78V4 CHAPTER 5 SYNCHRONIZATION AND COMMUNICATION FUNCTIONS 5 4 3 Message The information exchanged among processing programs via the mailbox is called messages Messages can be transmitted to any processing pro
88. A task in the DORMANT state while being under management of the RI78V4 is not subject to the RI78V4 scheduling 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 is currently being processed the task is waiting to be given the CPU s use right 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 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 RI78V4 the WAITING state is classified into the following six types according to their required conditions and managed Table 3 1 Waiting States Waiting States Description A task enters this state if the counter for the task registering Sleeping state the number of times the wakeup request has been issued indicates 0x0 upon the issuance of a slp_tsk or tslp_tsk Delayed state A task enters this state upon the issuance of a dly_tsk A task enters this state if it cannot acquire
89. ANAGEMENT FUNCTIONS 8 10 Reference Dispatching State The dispatching 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 dispatching disabled state or dispatching enabled state When this service call is terminated normally the acquired system state type TRUE dispatching disabled state FALSE dispatching enabled 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 func_sub void BOOL ercd Declares variable ae eee ay ercd sns_dsp Reference dispatching state if ercd TRUE PR Behl ities eiei Dispatching disabled state else if ercd FALSE TEE a os wld las ond aie Dispatching enabled state PE etnias en Note The system enters the dispatching disabled state when dis_dsp is issued and enters the dispatching enabled state when ena_dsp is issued R20UT0511EJ0101 Rev 1 01 2tENESAS Page 91 of 272 Apr 01 2012 RI78V4 CHAPTER 8 SYSTEM STATE MANAGEMENT FUNCTIONS 8 11 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 th
90. C language By calling using the same method as for normal C functions service call parameters are handed over to the RI78V4 as arguments and the relevant processing is executed C Language pragma rtos_func func_task include lt kernel h gt Standard header file definition include lt kernel_id h gt System information header file definition void func_task VP_INT exinf ER ercd Declares variable ID tskid ID_tskA Declares and initializes variable ercd act_tsk tskid Call service call ext_tsk Call service call Note To call the service calls provided by the RI78V4 from a processing program the header files listed below must be coded include processing kernel h Standard header file for C language kernel_id h System information header file for C language R20UT0511EJ0101 Rev 1 01 2tENESAS Page 122 of 272 Apr 01 2012 RI78V4 CHAPTER 12 SERVICE CALLS 12 2 2 Assembly language By calling with the CALL instruction after performing the parameter settings according to the assembler s function calling rules the service call parameters are handed over to the RI78V4 and the relevant processing is executed Assembly Language SINCLUDE kernel inc standard header file definition S INCLUDE kernel_id inc System information header file definition DESG _ercd DS 2 Secures area for storing return value PUBLIC _func_task
91. E to 1 Inside the __kernel_int_entry function which performs interrupt handler start processing IE is set to 1 R20UT0511EJ0101 Rev 1 01 2tENESAS Page 99 of 272 Apr 01 2012 RI78V4 CHAPTER 9 INTERRUPT MANAGEMENT FUNCTIONS 9 4 3 Controlling enabling disabling of interrupts in user processes User applications use the El function or El instruction and DI function or DI instruction to manipulate interrupts In a task or other user process using the DI function disables all maskable interrupts from being accepted using the El function enables maskable interrupts to be accepted in accordance with the state of the ISP1 and ISPO bits The RI78V4 sets whether interrupts are enabled or disabled upon start of the user process The states are listed below Table 9 2 States Enabling and Disabling Interrupts upon Process Start Process to Start IE ISP1 ISPO Interrupt Enabled Disabled on Start Interrupts disabled behavior is not Initialization routine 0 1 1 guaranteed when it is enabled by the process idle routine A A A sai enabled all interrupt levels When interrupts specified as 1 1 A Interrupts enabled all interrupt levels enabled accepted Task When interrupts specified as 0 A A Interrupts disabled if enabled all interrupt disabled levels accepted When a level 2 interrupt A 0 A Interrupts enabled level O and level 1 Cyclic occurs levels accepted handler When a level 3
92. ES OV C A OVW DE p_figptn_lo PUSH BC PUSH DE OVW AX wfmode PUSH AX OVW AX waiptn PUSH AX OVW AX flgid CALL _twai_flg addw sp 0CH Parameter s 1 O Parameter Description l ID flgid ID number of the eventflag wait for l FLGPTN waiptn Wait bit pattern 16 bits 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 Specified timeout unit ticks TMO tmout TMO_FEVR Waiting forever TMO_POL Polling Value Specified timeout R20UT0511EJ0101 Rev 1 01 tENESAS Page 179 of 272 Apr 01 2012 RI78V4 CHAPTER 12 SERVICE CALLS 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 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 eventflag The waiting state for an eventfla
93. I78V4 APPENDIX A WINDOW REFERENCE Project Tree panel Outline This panel is used to display the project components such as Realtime OS node system configuration file etc in tree view This panel can be opened as follows From the View menu select Project Tree Display image Project Tree EJ Er sample Project uPD78F1166_40 Microcontroller A Pin Configurator Design Tool Code Generator Design Tool A CA78KOR Build Tool A RI7BV4 Realtime OS S gt 78KOR Simulator Debug Tool P Program Analyzer Analyze Tool B Ei File tl Build tool generated files S Startup asm start asm cj idlrtn c cj inirtn c init c c inthdr c dr sample dr ej task c c cychdr c h init h h user h of EN ef Realtime OS generated files asm sit asm h kernel_id h ing kernel_id inc R20UT0511EJ0101 Rev 1 01 2tENESAS Page 246 of 272 Apr 01 2012 RI78V4 Explanation of each area 1 Project tree area APPENDIX A WINDOW REFERENCE Project components are displayed in tree view with the following given node Node Description RI78V4 Realtime OS referred to as Realtime OS node Realtime OS to be used XXx Cfg System configuration file Realtime OS generated files referred to as Realtime OS generated files node The following information files appear directly below the node created when a system configuration file is a
94. ICE CALLS Note When 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 will be executed Return value Macro Value Description E OK 0 Normal completion E RLWAI 49 Forced release from waiting accept rel_wai irel_wai while waiting E TMOUT 50 Polling failure or timeout R20UT0511EJ0101 Rev 1 01 Apr 01 2012 2tENESAS Page 169 of 272 RI78V4 CHAPTER 12 SERVICE CALLS Outline Reference semaphore state C format ER ref_sem ID semid T_RSEM pk_rsem Assembly format MOV A ES MOV Cc A MOVW DE pk_rsem_lo PUSH BC PUSH DE MOVW AX semid CALL _ref_sem addw sp 04H 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 Explanation Stores semaphore state packet such as existence of waiting tasks of the semaphore specified by parameter semid in the area specified by parameter pk_rsem Note For details about the semaphore state packet refer to 12 5 2 Semaphore state packet Return value Macro Value Description E OK 0 Normal completion R20UT0511EJ0101 Rev 1 01 2tENESAS Page 170 of 272 Apr 01 2012 RI78V4 CHAPTER 12 SERVICE CALLS 12 9 Synchroni
95. If the extension is different or omitted inc is File name added to the project nda in the Generate a file property is selected Default kernel_id inc How ig Directly enter to the text box change Restriction Up to 259 characters R20UT0511EJ0101 Rev 1 01 tENESAS Page 259 of 272 Apr 01 2012 RI78V4 APPENDIX B CAUTIONS APPENDIX B CAUTIONS B 1 Restriction of Compiler Option Systems embedding the RI78V4 cannot use the following compile options Option Meaning Prohibits from inserting the align data to allocate the members consisting of 2 or more bytes ina rC structure to even address B 2 Handling Register Bank Systems embedding the RI78V4 should generally operate with register bank 0 If it is necessary to change the register bank do so in accordance with the specifications below Changing the register bank is enabled for some routines and disabled for others Routines where changing the register bank is enabled Task In the task the initial register bank number is set permanently to 0 When switching tasks in the RI78V4 only the register bank number and one bank s worth of general registers task switching bank are retired restored The remaining three banks of general registers are not retired or restored so if more than two register banks are to be used in the task process then when changing the register banks the general register of the register ban
96. L isus_tsk Parameter s 0 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 SUSPENDED State Cancel Operation Return Value A cancel request was issued as a result of issuing rsm_tsk E OK A cancel request was issued as a result of issuing irsm_tsk E OK Forced release from suspended accept frsm_tsk while suspended E OK Forced release from suspended accept ifrsm_tsk while suspended E OK Note 1 If the target task is the invoking task when this service call is issued it is unlinked from the ready queue and excluded from the RI78V4 scheduling subject R20UT0511EJ0101 Rev 1 01 ztENESAS Page 157 of 272 Apr 01 2012 RI78V4 CHAPTER 12 SERVICE CALLS Note 2 The suspend request counter managed by the RI78V4 is configured in 7 bit widths If the number of suspend requests exceeds the maximum count valu
97. MOUT The following describes an example for coding this service call pragma rtos_task func_task include lt kernel h gt Standard header file definition include lt kernel_id h gt System information header file definition void func_task VP_INT exinf ER ercd Declares variable ID semid ID_semA Declares and initializes variable TMO tmout 3600 Declares and initializes variable PE pae Senta tee ay Acquire semaphore resource with timeout ercd twai_sem semid tmout if ercd E_OK EP a EEE th aan aed ky Normal termination processing else if ercd E_RLWAI PP co E A xf Forced termination processing else if ercd E_TMOUT PPR oe ses Sacto ara eae k Timeout processing Ye Sahl oy atheros Sees cee Note When 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 will be executed R20UT0511EJ0101 Rev 1 01 Apr 01 2012 ztENESAS Page 48 of 272 CHAPTER 5 SYNCHRONIZATION AND COMMUNICATION RI78V4 FUNCTIONS 5 2 5 Reference semaphore state A semaphore status is referenced by issuing the following service call from the processing program ref_sem Stores semaphore state packet such as existence of waiting tasks of the semaphore specified by parameter semid in the area specified by parameter pk_rsem The fol
98. N RI78V4 FUNCTIONS 5 2 4 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 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 the invoking task is queued to the target semaphore wait queue in the order of resource acquisition request FIFO order 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 a semaphore resource The waiting state for a semaphore state is cancelled in the following cases and then moved to the READY state Waiting State for a Semaphore State 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 pragma rtos_task func_task include lt kernel
99. OM PAGEG64KP as system information tables The start can be aligned at an even address that does not span a 64K boundary Area where information items required to implement the functionalities provided by the RI78V4 and information k data RAM DSEG items related to OS resources that change dynamically PAGE64KP are allocated as management objects The start can be aligned at an even address that does not span a 64K boundary Area where the system stack and the task stack are to DSEG be allocated Kostacx iat BASEP The start can be aligned at an even address in the built in RAM area from Oxfxxxx to Oxffeff k_work0 Area where fixed sized memory pools are to be k_work1 RAM DSEG allocated k_work2 PAGE64KP The start can be aligned at an even address that does k_work3 not span a 64K boundary Note 1 The k_stack segment can be allocated only to the near area Oxf0000 to Oxffe1f Note 2 Specification of k_workO k_work1 k_work2 and k_work3 is required only when the relevant segment names are specified in Fixed sized memory pool information Note 3 The RI78V4 occupies the 8 byte area from the saddr area Oxffe20 to Oxfffif Therefore the available saddr area for the user is up to 247 bytes Note 4 For details about the directive file refer to CubeSuite Integrated Development Environment User s Manual RL78 78KOR Coding R20UT0511EJ0101 Rev 1 01 Apr 01 2012 ztENESAS Page 14 of 272 RI78V4 CHAPTER 2 SYSTEM C
100. ONSTRUCTION 2 5 1 k_system segment The size of the k_system segment is approximately 1 KB to 8 KB depends on the service calls used in the processing program 2 5 2 k_info segment The size of the k_info segment is approximately 1 KB 2 5 3 k_const segment The following shows an expression required for estimating the k_const segment size unit bytes const tsknum 10 semnum flgnum mpfnum 8 cycnum 8 kindnum 4 15 tsknum Total amount of Task information semnum Total amount of Semaphore information filgnum Total amount of Eventtflag information mpfnum Total amount of Fixed sized memory pool information kindnum Total number of types defined in the system configuration file among five types of information related to OS resources Semaphore information Eventflag information Mailbox information Fixed sized memory pool information and Cyclic handler information 2 5 4 k_data segment The following shows an expression required for estimating the k_data segment size unit bytes The expression varies depending on whether or not Semaphore information is defined in the system configuration file When semaphore information is defined data align2 maxtpri 1 align2 tsknum 24 semnum 2 1 align2 flgnum 3 mbxnum 8 align2 primbx mpfnum 4 cycnum 8 40 When semaphore information is not defined data align2 maxtpri 1 tsknum 24
101. OV Cc A MOVW DE ppk_msg_lo PUSH BC PUSH DE MOVW AX mbxid CALL _rev_msg addw sp 04H 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 packet received from the mailbox 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 the invoking task is queued to the target mailbox wait queue in the order of message reception request FIFO order As a result the invoking task is unlinked from the ready queue and is moved from the RUNNING state to the WAITING state receiving waiting state for a mailbox 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 Forced release from waiting accept rel_wai while waiting E RLWAI Forced release from waiting accept irel_wai while waiting E RLWAI Note For details about the message packet refer to 12 5 4 Message packet R20UT0511EJ0101 Rev 1 01 2tENESAS Page 185 of 272 Apr 01 2012 RI78V4 CHAPTER 12 SERVICE CALLS Return value Mac
102. PTER 12 SERVICE CALLS 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 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 When 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 will be executed Note 2 For details about the message packet refer to 12 5 4 Message packet Return value Macro Value Description E OK 0 Normal completion E_RLWAI 49 Forced release from waiting accept rel_wai irel_wai while waiting E TMOUT 50 Polling failure or timeout R20UT0511EJ0101 Rev 1 01 Apr 01 2012 2tENESAS Page 189 of 272 RI78V4 CHAPTER 12 SERVICE CALLS Outline Reference mailbox state C format ER ref_mbx ID mbxid T_RMBX pk_rmbx Assembly format MOV A ES MOV Cc A MOVW DE pk_rmbx_lo PUSH BC PUSH DE MOVW AX mbxid CALL _ref_mbx addw sp 04H Parameter s 0 Parameter Description ID mbxid ID number of the mailbox to be referenced O T_RMBX pk_rmbx Pointer to the packet returning the mailbox state Explanation Stores mailbox state packet suc
103. Program Tasks Cyclic Handlers Interrupt Handlers System configuration file created in 2 3 Coding of System Configuration File SYSTEM CONFIGURATION FILE Note Specify cfg as the extention of the system configuration file name If the extension is different cfg is automatically added for example if you designate aaa c as a file name the file is named as aaa c cfg C assembly language source files created in 2 4 Coding of User Own Coding Module Interrupt Entry Processing Boot Processing Initialization Routine Idle Routine Directive file created in 2 5 Coding of Directive File Directive file Library files provided by the RI78V4 Kernel library Library files provided by the C compiler assembler package Standard library runtime library etc Note 1 If the system configuration file is added to the Project Tree panel the Realtime OS generated files node is appeared The following information files are appeared under the Realtime OS generated files node However these files are not generated at this point in time System information table file R20UT0511EJ0101 Rev 1 01 ztENESAS Page 17 of 272 Apr 01 2012 RI78V4 CHAPTER 2 SYSTEM CONSTRUCTION System information header file for C language System information header file for assembly language Figure 2 2 Project Tree Panel After Adding sys cfg Project Tree 2 O8 iz sample Project J uPD78F1166_A0 M
104. STA is omitted the cyclic handler initial activation status is set to non operational state STP state System reserved area exinf System reserved area Values that can be specified for exinf are limited to 0 R20UT0511EJ0101 Rev 1 01 2tENESAS Page 232 of 272 Apr 01 2012 RI78V4 CHAPTER 13 SYSTEM CONFIGURATION FILE 4 Start address cychdr Specifies the start address of the cyclic handler Values that can be specified for cychdr are symbol names written in C Note 1 When the cyclic handler is in written in C as shown below the value specified by this item is func_cychdr include lt kernel h gt include lt kernel_id h gt void func_cychdr void Note 2 When the cyclic handler is in written in assembly language as shown below the value specified by this item is func_cychdr S INCLUDE kernel inc S INCLUDE kernel_id inc PUBLIC _func_cychdr CSEG _func_cychdr x Gl 4 5 Activation cycle cyctim Specifies the activation cycle unit ticks of the cyclic handler A value between 1 and 4294967295 can be specified for cyctim 6 System reserved area cycphs System reserved area Values that can be specified for cycphs are limited to 0 R20UT0511EJ0101 Rev 1 01 ztENESAS Page 233 of 272 Apr 01 2012 RI78V4 CHAPTER 13 SYSTEM CONFIGURATION FILE 13 5 Stack Size Estimation 13 5 1 System stack size The formula for calculating the s
105. Task The RI78V4 provides two types of interfaces for task activation queuing an activation request queuing and not queuing an activation request 3 3 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 RI78V4 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 pragma rtos_task func_task include lt kernel h gt Standard header file definition include lt kernel_id h gt System information header file definition void func_task VP_INT exinf ID tskid ID_tskA Declares and initializes variable Ra aig aed cae Sees act_tsk tskid Activate task queues an activation request JE a Bee ie des Note 1 The activation request counter managed by the RI78V4 is configured in 7 bit widths If the number of activation requests exceeds the maximum count value 127 as a result of issuing
106. The following shows mailbox state packet T_RMBX used when issuing ref_mbx Definition of mailbox state packet T_RMBxX is performed by header file lt ri_root gt include os packet h packet inc which is called from standard header file lt ri_root gt include kernel h kernel inc packet h typedef struct t_rmbx ID wtskid ID number of the task at the head of the wait queue T_MSG __far pk_msg Start address of the message packet at the head of the message queue T_RMBX packet inc rmbx_wtskid EQU 00h ID number of the task at the head of the wait queue rmbx_pk_msg EQU 02h Start address of the message packet at the head of the message queu The following shows details on mailbox state packet T_RMBX wtskid rmbx_wtskid Stores information whether a task is queued to the wait queue TSK_NONE No applicable task Value ID number of the task at the head of the wait queue pk_msg rmbx_pk_msg Stores information whether a message is queued to the message queue NULL No applicable message Value Start address of the message packet at the head of the message queue R20UT0511EJ0101 Rev 1 01 ztENESAS Page 134 of 272 Apr 01 2012 RI78V4 CHAPTER 12 SERVICE CALLS 12 5 6 Fixed sized memory pool state packet The following shows fixed sized memory pool state packet T_RMPF used when issuing ref_mpf Definition of fixed sized memory pool state packet T_RMPF is performed b
107. USH AX MOVW AX tmout_lo PUSH AX MOVW AX semid CALL twai_sem addw sp 04H Parameter s 0 Parameter Description l ID semid ID number of the semaphore from which resource is acquired Specified timeout unit ticks 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 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 the invoking task is queued to the target semaphore wait queue in the order of resource acquisition request FIFO order 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 a semaphore resource 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 R20UT0511EJ0101 Rev 1 01 2tENESAS Page 168 of 272 Apr 01 2012 RI78V4 CHAPTER 12 SERV
108. V4 executes task creation processing based on data stored in information files using the Kernel Initialization Module and handles the created tasks as management targets 3 2 4 Delete task In the RI78V4 tasks created statically by the Kernel Initialization Module cannot be deleted dynamically using a method such as issuing a service call from a processing program R20UT0511EJ0101 Rev 1 01 2tENESAS Page 24 of 272 Apr 01 2012 RI78V4 CHAPTER 3 TASK MANAGEMENT FUNCTIONS 3 2 5 Basic form of tasks When coding a task use a void function with one VP_INT argument any function name is fine using the pragma rtos_task directive 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 C Language pragma rtos_task func_task include lt kernel h gt Standard header file definition include lt kernel_id h gt System information header file definition void func_task VP_INT exinf FS chose eo eid hia te ete xy Main processing ext_tsk Terminate invoking task Assembly Language SINCLUDE kernel inc Standard header file definition SINCLUDE kernel_id inc System information header file definition PUBLIC _func_task CSEG _func_task PUSH BC Stores the higher 2 bytes of argument exinf into stack PUSH AX
109. _cycA Declares and initializes variable T_RCYC pk_rcyc Declares data structure STAT cycstat Declares variable RELTIM lefttim Declares variable PE secs a ee aa Bee a ref_cyc cycid amp pk_rcyc Reference cyclic handler state cycstat pk_rcyc cycstat Reference cyclic handler operational state lefttim pk_rcyc lefttim Reference time left before the next activation Note For details about the cyclic handler state packet refer to 12 5 7 Cyclic handler state packet R20UT0511EJ0101 Rev 1 01 2tENESAS Page 79 of 272 Apr 01 2012 RI78V4 CHAPTER 8 SYSTEM STATE MANAGEMENT FUNCTIONS CHAPTER 8 SYSTEM STATE MANAGEMENT FUNC TIONS This chapter describes the system state management functions performed by the RI78V4 8 1 Outline The system state control functions of the RI78V4 include in addition to functions to manipulate the state of the system such as transition to the CPU locked state and transition to the dispatching disabled state functions for referencing the state of the system such as context type referencing and CPU locked state referencing 8 2 Rotate Task Precedence A ready queue is rotated by issuing the following service call from the processing program rot_rdaq 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 Th
110. a Mailbox Cancel Operation Return Value A message was transmitted to the target mailbox as a result of issuing snd_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 pragma rtos_task func_task include lt kernel h gt Standard header file definition include lt kernel_id h gt System information header file definition void func_task VP_INT exinf ER ercd Declares variable ID mbxid ID_mbxA Declares and initializes variable T_MSG ppk_msg Declares data structure anne eet ee er eee a Receive from mailbox waiting forever ercd rcv_mbx mbxid amp ppk_msg if ercd E_OK VR Neo td Setanta te Ted se ay Normal termination processing else if ercd E_RLWAI FEY Scat tel i se tee Forced termination processing PP Geaen tia Af Note For details about the message packet refer to 12 5 4 Message packet R20UT0511EJ0101 Rev 1 01 ztENESAS Page 62 of 272 Apr 01 2012 CHAPTER 5 SYNCHRONIZATION AND COMMUNICATION RI78V4 FUNCTIONS prcv_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 message
111. a resource from Waiting state for a semaphore resource the relevant semaphore upon the issuance of a wai_sem or twai_sem A task enters this state if a relevant eventflag does not satisfy Waiting state for an eventflag a predetermined condition upon the issuance of a wai_flg or twai_flg A task enters this state if cannot receive a message from the Receiving waiting state for a mailbox relevant mailbox upon the issuance of a rcv_mbx or trcv_mbx A task enters this state if it cannot acquire a fxed sized mem Waiting state for a fixed sized memory block ory block from the relevant memory pool upon the issuance of a get_mpf or tget_mpf 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 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 R20UT0511EJ0101 Rev 1 01 ztENESAS Page 23 of 272 Apr 01 2012 RI78V4 CHAPTER 3 TASK MANAGEMENT FUNCTIONS 3 2 2 Task priority A priority level that determines the order in which that task will be processed in relation to the othe
112. able multiple interrupts see below can set interrupts to level 2 or 3 9 4 2 Controlling enabling disabling of interrupts in the RI78V4 The RI78V4 uses the ISP1 and ISPO bits in the PSW register to enable and disable interrupts Set ISP1 to 0 and ISPO to 1 to disable interrupts in the RI78V4 Set ISP1 to 1 and ISPO to 1 to enable interrupts in the RI78V4 Figure 9 2 ISP1 and ISPO Bits in PSW Register PSW register IE Z RBSB1 AC RBSBO ISP1 ISPO CY j ISP1 ISPO Interrupt priority in current process Enable level 0 interrupts Q E While processing a level 1 or level 0 interrupt 0 1 Enable level 0 and level 1 interrupts While processing a level 2 interrupt A 0 Enable level 0 level 1 and level 2 interrupts While processing a level 3 interrupt Enable all interrupts Standby for the acceptance of interrupts The IE bit of the RI78V4 s PSW register inherits the value of the service call or RI78V4 function issuer El and DI instructions do not manipulate the IE value As exceptions however there are places in the RI78V4 where El and DI instructions are used Immediately before starting a task specifying interrupts as disabled a DI instruction is used to set IE to 0 Immediately before starting a task specifying interrupts as enabled an El instruction is used to set IE to 1 Immediately before starting the idle routine an El instruction is used to set I
113. ag does not satisfy the required condition when wai_flg or twai_flg is issued the task is Description 1 01 Apr 01 2012 oe queued to the eventflag wait queue 229 13 4 4 Mailbox information Change as follows the sentence in the item 2 Task queu ing TA_TFIFO Task wait queue is in FIFO order gt If the message could not be received from the mailbox no messages were queued in the wait queue when rcv_mbx or trcv_mbx is issued the task is queued to the mailbox wait queue in the order of message reception request 229 13 4 4 Mailbox information Changed as follows the sentence in the item 2 Message queuing method TA_MFIFO Message queue is in FIFO order If a task is not queued to the mailbox wait queue when snd_mbx is issued the message is queued to the mailbox wait queue in the order of message transmission request 229 13 4 4 Mailbox information Changed as follows the sentence in the item 2 Message queuing method TA_MPRI Message queue is in message priority order gt If a task is not queued to the mailbox wait queue when snd_mbx is issued the message is queued to the mailbox wait queue in the order of message priority 230 13 4 5 Fixed sized memory pool information Changed as follows the sentence in the item 2 Queuing method TA_TFIFO Task wait queue is in FIFO order gt If a memory block could not be acquired no available memory blocks exist when get_mpf or tg
114. alized by coding Interrupt Entry Processing branch instruction to boot processing to the vector table address to which the CPU forcibly passes control upon occurrence of a reset interrupt The code of Interrupt Entry Processing varies depending on whether boot processing is allocated to the near area or to the far area The following shows examples for coding Interrupt Entry Processing When boot processing is allocated to the near area RESET CSEG AT 0000h Vector table address setting DW _boot Jump to boot processing _boot When boot processing is allocated to the far area EXTRN intent _ RESET Declares symbol external referenc RESET CSEG AT 0000h Vector table address setting DW intent _ RESET intent CSEG UNITP intent _ RESET BR I _boot Jump to boot processing _boot 10 2 2 Basic form of boot processing Write Boot processing as a function that does not include arguments and return values function name any name The following shows the basic form of boot processing PUBLIC _boot EXTRN __ STBEG _hdwinit __urx_start LCODE CSEG BASE _ boot SEL RBO Sets register bank MOVW SP LOWW_ STBEG Sets stack pointer SP CALL _hdwinit Initializes internal units and peripheral controllers OV B OFEDFH OFE20H 1 Clears saddr area CLRW AX LSADR1 DEC B DEC B OVW OFE20H B AX BNZ SLSADR1 OV ES 0OFH Clear
115. and cast it to a far pointer when passing it to a service call The example is shown below VP _ far pk_msg get_mpf ID_MPF1 VP _ far amp pk_msqg snd_mbx ID_MBX1 T_MSG __far pk_msg Particular care is needed if a small model or medium model is selected because pointers will be near if not explicitly declared as near or far Care must be taken however not to pass pointers explicitly declared as near to a service call R20UT0511EJ0101 Rev 1 01 2tENESAS Page 261 of 272 Apr 01 2012 RI78V4 APPENDIX C INDEX A act_tsk 139 B boot processing 13 104 basic form 104 internal processing 105 Cc can_act 141 can_wup 155 CF78V4 238 activation method 239 chg_pri 146 clr_flg 174 conditional compile macro 128 configuration information 221 static API information 221 system information 221 configurator 238 current priority 24 current state 127 cyclic handler 12 75 basic form 75 internal processing 76 cyclic handler information 232 cyclic handler state packet 136 D data type 126 directive file 14 dis_dsp 212 dly_tsk 162 DORMANT state 23 driving method 109 event driven system 109 E embedding system 21 APPENDIX C INDEX ena_dsp 213 event driven system 109 eventflag 50 clr_flg 174 iset_flg 172 pol_flg 177 ref_flg 181 set_f
116. as current status 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 12 5 7 Cyclic handler state packet Return value Macro Value Description E OK 0 Normal completion R20UT0511EJ0101 Rev 1 01 ztENESAS Page 204 of 272 Apr 01 2012 RI78V4 12 13 System State Management Functions CHAPTER 12 SERVICE CALLS The following lists the service calls provided by the RI78V4 as the system state management functions Table 12 15 System State Management Functions Service Call Function Origin of Service Call rot_rdq Rotate task precedence Task Non task irot_rdq Rotate task precedence Task Non task get_tid Reference task ID in the RUNNING state Task Non task iget_tid Reference task ID in the RUNNING state Task Non task 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 dis_dsp Disable dispatching Task ena_dsp Enable dispatching Task sns_ctx Reference contexts Task Non task sns_loc Reference CPU state Task Non task sns_dsp Reference dispatching state Task Non task sns_dpn Reference dispatch pending state Task Non task R20UT0511EJ0101 Rev 1 01 Apr 01 2012 2tENESAS Page 205 of 272 RI78V4 CHAPTER 12 SERVICE CALLS
117. 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 RI78V4 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 R20UT0511EJ0101 Rev 1 01 2tENESAS Page 81 of 272 Apr 01 2012 RI78V4 CHAPTER 8 SYSTEM STATE MANAGEMENT FUNCTIONS 8 3 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 func_cychdr void ID p_tskid Declares variable ear ar te eee er iget_tid amp p_tskid Reference task ID in the RUNNING state TOP a hoe eat ave ce a return Terminate cyclic 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 R20UT0511EJ0101 Rev 1 01 2tENESAS Page 82 of 272 Apr 01 2012
118. ask is unlinked from the ready queue and excluded from the RI78V4 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 pragma rtos_task func_task include lt kernel h gt Standard header file definition include lt kernel_id h gt System information header file definition void func_task VP_INT exinf ER ercd Declares variable TMO tmout 3600 Declares and initializes variable PR weeping ercd tslp_tsk tmout Put task to sleep with timeout if ercd E_OK LS Bieta aie RA E7 Normal termination processing else if ercd E_RLWAI TE aiei or ae tee E Forced termination processing else if ercd
119. ask priority Note 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 R20UT0511EJ0101 Rev 1 01 2tENESAS Page 32 of 272 Apr 01 2012 RI78V4 CHAPTER 3 TASK MANAGEMENT FUNCTIONS 3 7 Reference Task State A task status is referenced by issuing the following service call from the processing program ref_tsk Stores task state packet such as current status of the task specified by parameter tskid in the area specified by parameter pk_rtsk The following describes an example for coding this service call ID tskid T_RTSK pk_rtsk STA tskstat PRI tskpri STA tskwait ID wobjid UINT actcnt UINT wupcnt UINT suscnt JP aaa eta be Ss ref_tsk tskid func_task VP_INT exinf ID_tskA Standard header file definition System information header file definition pragma rtos_task func_task include lt kernel h gt include lt kernel_id h gt void amp pk_rtsk tskstat pk_rtsk tskstat tskpri pk_rtsk tskpri tskwait pk_rtsk tskwait wobjid pk_rtsk wobjid actcnt pk_rtsk actcnt wupent pk_rtsk wupcnt suscnt pk_rtsk suscnt Declares Declares Declares Declares Declares
120. at can be specified is defined as being within the range of 0 to 127 The following shows the fixed sized memory pool information format CRE_MPF mpfid mpfatr blkcnt blksz seg_nam mpf The items constituting the fixed sized memory pool information are as follows 1 Fixed sized memory pool name mpfid Specifies the fixed sized memory pool name An object name can be specified for mpfid Note The CF78V4 outputs to the system information header file the correspondence between the fixed sized memory pool names and IDs in the following format Consequently fixed sized memory pool names can be used in the place of IDs by including the relevant system information header file using the processing program Output format to system information header file for C define mpfid ID Output format to system information header file for assembly language mpfid equ ID 2 Attribute queuing method mpfatr Specifies the attribute queuing method of the fixed sized memory pool The keywords that can be specified for mpfatr are TA_TFIFO Queuing method TA_TFIFO If a memory block could not be acquired no available memory blocks exist when get_mpf or tget_mpf is issued the task is queued to the fixed sized memory pool wait queue in the order of memory block acquisition request 3 Total number of memory blocks b kcnt Specifies the total number of memory blocks A value between 1 and 16383 can be specified for bikcnt 4 M
121. ate E_OBu is returned R20UT0511EJ0101 Rev 1 01 Apr 01 2012 2tENESAS Page 39 of 272 RI78V4 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 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 The SUSPENDED state is cancelled in the following cases and then moved to the READY state SUSPENDED State Cancel Operation Return Value A cancel request was issued as a result of issuing rsm_tsk E OK A cancel request was issued as a result of issuing irsm_tsk E OK Forced release from suspended accept frsm_tsk while suspended E OK Forced release from suspended accept ifrsm_tsk while suspended E OK The following describes an example for coding this service call pragma rtos_task func_task include lt kernel h gt Standard header file definition include lt kernel_id h gt System informati
122. ate a file property is selected Default kernel_id h pow tg Directly enter to the text box change Restriction Up to 259 characters R20UT0511EJ0101 Rev 1 01 tENESAS Page 257 of 272 Apr 01 2012 RI78V4 APPENDIX A WINDOW REFERENCE 3 System Information Header File for Assembly Language The detailed information on the system information header file for assembly language are displayed and the configuration can be changed Select whether to generate a system information header file for assembly language 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 da pow to Select from the drop down list change Yes lt Generates a system information header file updates the and displays it on the project tree file when the If the system configuration file is changed cfg file is when there is already a system information changed header file then the system information da header file is updated Generate a file YESUT deS Does not update the system information not update header file when the system configuration the file when ee Restriction the cfg file eis changed is An error occurs during build if this item is selected when the system information changed header file does not exist nda No It does Does not generate a system information header file and does not display it on the not register
123. c for assembly language is output to a folder in C tmp Figure 14 1 Example of Command File Description Command File i C Program Files tmp sit_file asm dc C tmp C_header h da C tmp ASM_header inc CF_file cfg R20UT0511EJ0101 Rev 1 01 ztENESAS Page 241 of 272 Apr 01 2012 RI78V4 CHAPTER 14 CONFIGURATOR CF78V4 14 2 4 Command input examples The following shows the CF78V4 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 After loading command file cmd_file from the current folder the activation option defined in cmd_file is executed C gt cf78v4 exe A cmd_file lt Enter gt 2 After loading system configuration file CF_file cfg from the current folder system information table filesit_file asm the system information header file C_header h for C and system information header file ASM_header inc for assembly language are output to the current folder C gt cf78v4 exe A iAsit_file asm A dc A C_header h A da A ASM _header inc A CF_file cfg lt Enter gt 3 After loading system configuration file CF_file cfg from the current folder system information table filesit asm the system information header file kernel_id h for C and system information header file kernel_id inc for assembly language are output to the current folder C gt cf78v4 ex
124. cation verinf_prver EQU 06h Version number of the kernel verinf_prno EQU 08h Management information of the kernel product The following shows details on version information packet T_RVER maker verinf_maker Stores the kernel maker s code 0x011b Renesas Electronics Co Ltd prid verinf_prid Stores the identification number of the kernel 0x0006 Identification number spver verinf_spver Stores the version number of the ITRON Specification 0x5403 u ITRON4 0 Specification Ver 4 03 00 prver verinf_prver Stores the version number of the kernel 0x01 xx Ver 1 xx prno 0 verinf_prno Stores the kernel version type 0x0 V version prnof 1 verinf_prno 0x2 Stores the memory model of the kernel 0x1 Large model prno 2 verinf_prno 0x4 System reserved area prno 8 verinf_prno 0x6 System reserved area R20UT0511EJ0101 Rev 1 01 2tENESAS Page 137 of 272 Apr 01 2012 RI78V4 CHAPTER 12 SERVICE CALLS 12 6 Task Management Functions The following lists the service calls provided by the RI78V4 as the task management functions Table 12 8 Task Management Functios Service Call Function Origin of Service Call act_tsk Activate task queues an activation request Task Non task iact_tsk Activate task queues an activation request Task Non task can_act Cancel task activation requests Task Non task sta_tsk Activate task does not queue an ac
125. ces for task termination termination of invoking task and forced termination of other tasks 3 5 1 Terminate invoking task An invoking task is terminated 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 RI78V4 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 pragma rtos_task func_task include lt kernel h gt Standard header file definition include lt kernel_id h gt System information header file definition void func_task VP_INT exinf ext_tsk Terminate invoking task Note 1 This service call does not return the OS resource that the invoking task acquired by issuing a service call such as sig_sem or get_mpf The OS resource have been acquired must therefore be returned before issuing this service call Note 2 When moving a task from the RUNNING state to the DORMANT state this service call ini
126. change Restriction Up to 259 characters R20UT0511EJ0101 Rev 1 01 tENESAS Page 255 of 272 Apr 01 2012 RI78V4 APPENDIX A WINDOW REFERENCE 2 System Information Header File for C Language The detailed information on the system information header file for C language are displayed and the configuration can be changed Select whether to generate a system information header file for C language 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 dc FOW to Select from the drop down list change Yes It Generates a system information header file updates the and displays it on the project tree file when the If the system configuration file is changed Cfg file is when there is already a system information changed header file then the system information dc header file is updated Generate a file Nesuneees Does not update the system information not update i header file when the system configuration the file when ae Restriction the cfg file Mee cnangea is An error occurs during build if this item is selected when the system information changed i header file does not exist ndc No It does Does not generate a system information header file and does not display it on the not register the file tothe Project tree If this item is selected when there is already project ndc a system
127. cified by 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 memory block return processing is not performed but 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 If the first task of the wait queue is moved to the READY state after this service call is issued this service call also re queues the task at the end of the ready queue corresponding to the priority of the task Note 2 The RI78V4 does not clear the memory blocks before returning them The contents of the returned memory blocks are therefore undefined R20UT0511EJ0101 Rev 1 01 2tENESAS Page 197 of 272 Apr 01 2012 RI78V4 CHAPTER 12 SERVICE CALLS Return value Macro Value Description E OK 0 Normal completion R20UT0511EJ0101 Rev 1 01 2tENESAS Page 198 of 272 Apr 01 2012 RI78V4 CHAPTER 12 SERVICE CALLS Outline Reference fixed sized memory pool state C format ref_mpf ID mpfid T_RMPF pk_rmpf Assembly format MOV A ES MOV Cc A MOVW DE pk_rmpf_lo PUSH BC PUSH DE MOVW AX mpf
128. cquire fixed sized memory block A 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 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 memory block could not be acquired from the target fixed sized memory pool no available memory blocks exist when this service call is issued memory block acquisition processing is not performed but the invoking task is queued to the target fixed sized memory pool wait queue in the order of memory block acquisition request FIFO order 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 a fixed sized memory block 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 memory block was returned to the target fixed sized memory pool as a result of issuing E OK rel_mpf 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 pragma rtos_task func_task include lt kernel h gt
129. d West Mongkok Kowloon Hong Kong Tel 852 2886 9318 Fax 852 2886 9022 9044 Renesas Electronics Taiwan Co Ltd 13F No 363 Fu Shing North Road Taipei Taiwan Tel 886 2 8175 9600 Fax 886 2 8175 9670 Renesas Electronics Singapore Pte Ltd 1 harbourFront Avenue 06 10 keppel Bay Tower Singapore 098632 Tel 65 6213 0200 Fax 65 6278 8001 Renesas Electronics Malaysia Sdn Bhd Unit 906 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 Korea Co Ltd 11F Samik Lavied or Bldg 720 2 Yeoksam Dong Kangnam ku Seoul 135 080 Korea Tel 82 2 558 3737 Fax 82 2 558 5141 2012 Renesas Electronics Corporation All rights reserved Colophon 1 1 RI78V4 7rtENESAS Renesas Electronics Corporation R20UT0511EJ0101
130. d header file definition include lt kernel_id h gt System information header file definition void func_task VP_INT exinf PR space geeks ab Hise my dis_dsp Disable dispatching JES wie tard e aaa Dispatching disabled state ena_dsp Enable dispatching TP Sc atti Bk Note This service call does not perform queuing of enable requests If the system is in the dispatching enabled state therefore no processing is performed but it is not handled as an error R20UT0511EJ0101 Rev 1 01 ztENESAS Page 88 of 272 Apr 01 2012 RI78V4 CHAPTER 8 SYSTEM STATE MANAGEMENT FUNCTIONS 8 8 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 Non task contexts cyclic handler interrupt handler task contexts 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 func_sub void BOOL ercd Declares variable YE sid Ye et E es lesa es ercd sns ctx Re
131. d on the Project Tree panel by every category and change the settings of the information This panel can be opened as follows On the Project Tree panel select the Realtime OS node system configuration file or the like and then select the View menu gt Property or the Property from the context menu Note When either one of the Realtime OS node system configuration file or the like on the Project Tree panel while the Property panel is opened the detailed information of the selected node is displayed Display image Property a RI 78V4 Property E YersionInformaton Kernel version This is the version of the Rl78V4 to be used in this project 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 area 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 d
132. dc A lt C header file gt ndc A help A lt CF file gt lt Enter gt i A lt SIT file gt ni A da A lt ASM header file gt nda A v A The details of each activation option are explained below command file Specifies the command file name to be input If omitted The activation options specified on the command line is valid Note 1 Specify the input file name command file within 255 characters including the path name Note 2 For the details about the command file refer to 14 2 3 Command file iA lt SIT file gt Specifies the system information table file name to be output If omitted If omitted the CF78V4 interprets it that iAsit asm is specified Note Specify the output file name lt SIT file gt within 255 characters including the path name ni Disables output of the system information table file If omitted If omitted the CF78V4 interprets it that iAsit asm is specified dcA lt C header file gt Specifies the system information header file for C language name to be output If omitted If omitted the CF78V4 interprets it that dcAkernel_id h is specified Note Specify the output file name lt SIT file gt within 255 characters including the path name ndc Disables output of the system information header file for C language If omitted If omitted the CF78V4 interprets it that dcAkernel_id h is specified daA lt ASM header file gt Specifie
133. dded System information table file asm System information header file for C language h System information header file for assembly language inc 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 Context menu 1 When the Realtime OS node or Realtime OS generated files node is selected 2 Property Displays the selected node s property on the Property panel When the system configuration file or an information file is selected Assembles the selected assembler source file Note that this menu is only displayed when a system information table file is Assemble selected Note that this menu is disabled when the build tool is in operation Opens the selected file with the application corresponds to the file Open extension Note that this menu is disabled when multiple files are selected Open with Internal Editor Opens the selected file with the Editor panel Note that this menu is disabled when multiple files are selected Open with Selected Application Opens the Open with Program dialog box to open the selected file with the designated application Note that this menu is disabled when multiple files are selected Open Folder with Explorer Opens the folder that contains the selected file with Explorer
134. decrement processing is executed The following describes an example for coding this service call ID tskid pragma rtos_task include lt kernel h gt include lt kernel_id h gt void func_task VP_INT exinf ID_tskA rsm_tsk tskid func_task Standard header file definition System information header file definition Declares and initializes variable Resume suspended task Note 1 If the target task is moved to the READY state after this service call is issued this service call also re queues the task at the end of the ready queue corresponding to the priority of the task Note 2 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 R20UT0511EJ0101 Rev 1 01 Apr 01 2012 2tENESAS Page 41 of 272 RI78V4 CHAPTER 4 TASK DEPENDENT SYNCHRONIZATION FUNCTIONS frsm_tsk ifrsm_tsk These service calls set the suspend request counter for the task specified by parameter tskid to 0x1 f and then forcibly cancel 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 to the WAITING state The following describes an example for coding this service call func_task VP_INT exinf ID tskid ID_tskA frsm_tsk tskid
135. dition specified by parameter wfmode are set to the eventtflag 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 eventtflag 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 E 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 eventtflag wfmode TWF_ORW Checks which bit among bits to which 1
136. ds that can be specified for mbxatr are TA_TFIFO TA_MFIFO and TA_MPRI Task queuing method TA_TFIFO If the message could not be received from the mailbox no messages were queued in the wait queue when rcv_mbx or trcv_mbx is issued the task is queued to the mailbox wait queue in the order of message reception request Message queuing method TA_MFIFO If a task is not queued to the mailbox wait queue when snd_mbx is issued the message is queued to the mailbox wait queue in the order of message transmission request TA_MPRI If a task is not queued to the mailbox wait queue when snd_mbx is issued the message is queued to the mailbox wait queue in the order of message priority 3 System reserved area maxmpri System reserved area Values that can be specified for maxmpri are limited to 0 4 System reserved area mprihd System reserved area The keywords that can be specified for mprihd are NULL R20UT0511EJ0101 Rev 1 01 ztENESAS Page 229 of 272 Apr 01 2012 RI78V 4 CHAPTER 13 SYSTEM CONFIGURATION FILE 13 4 5 Fixed sized memory pool information Define the following items as fixed sized memory pool information 1 Fixed sized memory pool name mpfid 2 Attribute queuing method mpfatr 3 Total number of memory blocks blkcnt 4 Memory block size blksz 5 Segment name seg_nam 6 System reserved area mpf The number of fixed sized memory pool information items th
137. dths 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 An extended infomration Extended information exinf is passed to the task activated by issuing this service call R20UT0511EJ0101 Rev 1 01 Apr 01 2012 ztENESAS Page 139 of 272 RI78V4 CHAPTER 12 SERVICE CALLS Return value Macro Value Description E OK 0 Normal completion E_ QOVR 43 Queue overflow overflow of activation request count 127 R20UT0511EJ0101 Rev 1 01 Apr 01 2012 2tENESAS Page 140 of 272 RI78V4 CHAPTER 12 SERVICE CALLS Outline Cancel task activation requests C format ER_UINT can_act ID tskid Assembly format MOVW AX tskid CALL can_act Parameter s 1 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 Return value Macro Value Description Normal completion activation request
138. e T_MSG When using a mailbox with the TA_MPRI attribute The contents and length past the first 5 bytes of a message system reserved area msgque priority level msgpri are not restricted in particular in the RI78V4 Therefore the contents and length past the first 5 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 far PRI msgpri T_MSG_PRI Reserved for future use Message priority msgque Note 1 Note 2 A value between 1 and 31 can be specified for message priority In the RI78V4 a message having a smaller priority number is given a higher priority Note 3 For details about the message packet refer to 12 5 4 Message packet ztENESAS Page 60 of 272 Apr 01 2012 CHAPTER 5 SYNCHRONIZATION AND COMMUNICATION RI78V4 FUNCTIONS 5 4 4 Send to mailbox A message is transmitted by issuing the following service call from the processing program snd_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
139. e control is passed to the interrupt handler The following shows a processing flow from when an interrupt occurs until the control is passed to the interrupt handler Figure 9 1 Processing Flow Interrupt Handler 4 Si Interrupt Entry Processing Interrupt handler 9 3 1 Define interrupt handler Interrupt handler registration is realized by coding Interrupt Entry Processing branch instruction to interrupt handler to the vector table address to which the CPU forcibly passes control upon occurrence of an interrupt The code of Interrupt Entry Processing varies depending on whether the interrupt handler is allocated to the near area or to the far area Note 1 For the coding method of interrupt entry processing refer to 9 2 Interrupt Entry Processing Note 2 For interrupt handlers written using the pragma rtos_interrupt directive the user is not required to write the relevant interrupt entry processing because the C compiler automatically outputs the interrupt entry processing corresponding to the interrupt request name R20UT0511EJ0101 Rev 1 01 2tENESAS Page 95 of 272 Apr 01 2012 RI78V4 CHAPTER 9 INTERRUPT MANAGEMENT FUNCTIONS 9 3 2 Basic form of interrupt handlers When coding interrupt handlers in C use void type functions that do not have arguments any function name is fine using the pragma rtos_interrupt directive or __rtos_interrupt qualifier The following shows the basic form of coding
140. e 127 as a result of issuing this service call the counter manipulation processing is therefore not performed but E_QOVR is returned Return value Macro Value Description E OK 0 Normal completion E OBJ 41 Object state error specified task is in the DORMANT state E_QOVR 43 Queue overflow overflow of suspension count 127 R20UT0511EJ0101 Rev 1 01 tENESAS Page 158 of 272 Apr 01 2012 RI78V4 CHAPTER 12 SERVICE CALLS Outlin e Resume suspended task C format ER rsm_tsk ID tskid ER irsm_tsk ID tskid Assembly format MOVW AX tskid CALL lI rsm_tsk MOVW AX tskid CALL _irsm_tsk Parameter s 1 O Parameter Description 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 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 1 Note 2 If the target task is moved to the READY state after this service call is issued
141. e A CF_file cfg lt Enter gt 4 After loading system configuration file CF_file cfg from a folder in C tmp system information table filesit_file asm the system information header file C_header h for C is output to a folder in C tmp C gt cf 78v4 exe A i A C tmp sit_file asm A dc A C tmp C_header h A nda A C tmp CF_file cfg lt Enter gt 5 After loading system configuration file CF_file cfg from a folder in C tmp the system information table file sit_file asm is output to a folder in C Program Files tmp C gt cf 78v4 exeA i A C Program Files tmp sit_file asm A ndc A nda A C tmp CF_file cfg lt Enter gt 6 CF78V4 version information is output to the standard output C gt cf78v4 exe A V lt Enter gt 7 Information related to the CF78V4 activation option type usage or the like is output to the standard output C gt cf78v4 exe A help lt Enter gt R20UT0511EJ0101 Rev 1 01 2tENESAS Page 242 of 272 Apr 01 2012 RI78V4 APPENDIX A WINDOW REFERENCE APPENDIX A WINDOW REFERENCE This appendix explains the window panels that are used when the activation option for the CF78V4 is specified from the integrated development environment platform CubeSuite A 1 Description The following shows the list of window panels Table A 1 List of Window Panels Window Panel Name Function Description ae This is the first w
142. e Description E OK 0 Normal completion E OBJ 41 Object state error specified task is not in the DORMANT state R20UT0511EJ0101 Rev 1 01 Apr 01 2012 2tENESAS Page 143 of 272 RI78V4 CHAPTER 12 SERVICE CALLS Outline Terminate invoking task C format void ext_tsk void Assembly format BR I l _ext_tsk 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 RI78V4 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 Note 1 This service call does not return the OS resource that the invoking task acquired by issuing a service call such as sig_sem or get_mpf The OS resource have been acquired must therefore be returned before issuing this service call Note 2 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
143. e RI78V4 interrupt servicing managed by the RI78V4 is called interrupt handler which is distinguished from interrupt servicing that operates without being managed by the RI78V4 The following lists the differences between interrupt handlers and interrupt servicing Table 9 1 Differences Between Interrupt Handlers and Interrupt Servicing Interrupt Handler Interrupt Servicing Service call issuance Available Not available Maskable interrupt Interrupt type Maskable interrupt Software interrupt Reset interrupt Interrupt priority level Levels 2 3 Levels 0 1 Itis also possible to assign a level of 2 or 3 to an application that disables multiple interrupts Note 1 The interrupt priority level is set using the priority specification flag register of the target CPU Note 2 The RI78V4 does not execute initialization of hardware that creates interrupts clock controller etc This initialization processing must therefore be coded by the user in the Boot Processing or Initialization Routine 9 2 Interrupt Entry Processing Interrupt entry processing is a routine dedicated to entry processing that is extracted as a user own coding module to assign instructions to branch to relevant processing such as Interrupt Handlers or Boot Processing to the vector table address to which the CPU forcibly passes the control when an interrupt occurs Note For interrupt handlers written using the pragma rtos_interrupt di
144. e 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 RI78V4 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 describes an example for coding this service call pragma rtos_task func_task include lt kernel h gt Standard header file definition include lt kernel_id h gt System information header file definition void func_task VP_INT exinf EE Siu anes seks dis_dsp Disable dispatching re ee ae ee Dispatching disabled state ena_dsp Enable dispatching PPS 3 cw bat hee a tye Note This service call does not queue enable requests If the system is in the dispatching enabled state therefore no processing is performed but it is not handled as an error R20UT0511EJ0101 Rev 1 01 2tENESAS Page 117 of 272 Apr 01 2012 RI78V4 CHAPTER 11 SCHEDULER 11 6 Delay of Scheduling If a service call ichg_pri isig_sem etc accompanying dispatch processing task scheduling processing is issued in order to quickly complete the processing in a non task cyclic handler interrupt handler etc during the interval until the processing in the non task ends the RI78V4 executes only processin
145. e following shows the status transition when this service call is used Figure 8 1 Rotate Task Precedence Ready queue 1 Invoking task RUNNING state Task A Task B Task C READY state READY state READY state tskpri maxtpri rot_rdq tskpri Ready queue 1 Invoking task RUNNING state tskpri Task B Task C Task A READY state READY state READY state maxtpri R20UT0511EJ0101 Rev 1 01 2tENESAS Page 80 of 272 Apr 01 2012 RI78V4 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 func_cychdr void PRI tskpri 8 Declares and initializes variable FE edant eiaa ay irot_rdq tskpri Rotate task precedence PIS a betel eae Sioa 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
146. e in the fields of electrical engineering logic circuits microcontrollers C language and assemblers To understand the hardware functions of the RL78 family and 78KOR microcontroller gt Refer to 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 No Document Name RI Series Start R20UT0751E Message R20UT0756E RI78V4 This manual R20UT0753E Analysis R20UT0513E 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 10 1 1 Outline 10 1 1 1 Real time OS 10 1 1 2 Multi task OS 10 CHAPTER 2 SYSTEM CONSTRUCTION 11 2 1 Outline 11 2 2 Coding of Processing Program 12
147. e limited to numeric values 0 to 9 Object name In a system configuration file words starting with a letter of a to z A to Z or underscore _ within 24 characters are regarded as object names Note Elements of a word are limited to alphanumeric characters a to z A to Z 0 to 9 and underscore _ Symbol name In a system configuration file words starting with a letter of a to z A to Z or underscore _ within 30 characters are regarded as symbol names Note 1 Elements of a word are limited to alphanumeric characters a to z A to Z 0 to 9 and underscore _ Note 2 The CF78V4 distinguishes the object name and symbol name according to the context in the system configuration file Keywords The words shown below are reserved by the CF78V4 as keywords Using these words for any other purpose specified is therefore prohibited CRE_CYC CRE_FLG CRE MBX CRE_MPF CRE_SEM CRE_TSK kl_work0 k_work1 k_work2 k_work3 MAX_PRI null NULL SYS_STK TA_ACT TA_ASM TA_CLR TA_DISINT TA_ENAINT TA_HLNG TA_MFIFO TA_MPRI TA_PHS TA_RSTR TA_STA TA_TFIFO TA_TPRI TA_WMUL TA_WSGL Note The CF78V4 does not call C preprocessors Coding of preprocessing directives include define if or the like in the system configuration file is therefore prohibited R20UT0511EJ0101 Rev 1 01 ztENESAS Page 220 of 272 Apr 01 2012 RI78V4 CHAPTER 13 SYSTEM CONFIGURATION FILE 13 2 Configuration Information The configurat
148. e 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 func_sub void BOOL ercd Declares variable ee ee eee ay ercd sns_dpn Reference dispatch pending state if ercd TRUE PR Beha te ticks eiei Ef Dispatch pending state else if ercd FALSE TR E A E taste E A ey Other state PE etnias en Note The dispatch pending state designates the state in which explicit execution of dispatch processing task scheduling processing is prohibited by issuing either the dis_dsp loc_cpu or iloc_cpu service call as well as the state during which processing of a non task is being executed R20UT0511EJ0101 Rev 1 01 ztENESAS Page 92 of 272 Apr 01 2012 RI78V4 CHAPTER 9 INTERRUPT MANAGEMENT FUNCTIONS CHAPTER9Y INTERRUPT MANAGEMENT FUNCTIONS This chapter describes the interrupt management functions performed by the RI78V4 9 1 Outline The RI78V4 provides as interrupt management functions related to the interrupt handlers activated when a maskable interrupt is occurred In th
149. ef struct t_rsem ID wtskid ID number of the task at the head of the wait queue UINT semcnt Current resource count T_RSEM packet inc rsem_wtskid EQU 00h ID number of the task at the head of the wait queue rsem_semcnt EQU 02h Current resource count The following shows details on semaphore state packet T_RSEM wtskid rsem_wtskid Stores information whether a task is queued to the wait queue TSK_NONE No applicable task Value ID number of the task at the head of the wait queue semcnt rsem_semcnt Stores the current resource count of the semaphore R20UT0511EJ0101 Rev 1 01 2tENESAS Page 131 of 272 Apr 01 2012 RI78V4 CHAPTER 12 SERVICE CALLS 12 5 3 Eventflag state packet The following shows eventtflag state packet T_RFLG used when issuing ref_flg Definition of eventflag state packet T_RFLG is performed by header file lt ri_root gt include os packet h packet inc which is called from standard header file lt ri_root gt include kernel h kernel inc packet h typedef struct t_rflg ID wtskid ID number of the task at the head of the wait queue FLGPTN flgptn Current bit pattern T_RFLG packet inc rflg_wtskid EQU 00h ID number of the task at the head of the wait queue rflg_flgptn EQU 02h Current bit pattern The following shows details on eventflag state packet T_RFLG wtskid rflg_wtskid Stores information whether
150. em A task enters this state if a relevant eventflag does not satisfy a predetermined condition upon the issuance of a wai_flg or twai_flg A task enters this state if cannot receive a message from the relevant mailbox upon the issuance of a rcv_mbx or trcv_mbx A task enters this state if it cannot acquire a fixed sized mem ory block from the relevant fixed sized memory pool upon the issuance of a get_mpf or tget_mpf loc_cpu iloc_cpu Changed as follows the sentence in the Explanation If a maskable interrupt is created during this period gt If a maskable interrupt is created during the interval from this service call is issued until unl_cpu or iunl_cpu is issued 13 2 1 Cautions Changed as follows the sentence in this section Figure 13 1 illustrates how the system configuration file is described gt The following describes a system configuration file description format 13 4 2 Semaphore information Changed as follows the sentence in the item 2 Queuing method TA_TFIFO Task wait queue is in FIFO order at If a resource could not be acquired semaphore counter is set to 0x0 when wai_sem or twai_sem is issued the task is queued to the semaphore wait queue in the order of resource acquisition request 13 4 3 Eventflag information Changed as follows the sentence in the item 2 Queuing method TA_TFIFO Task wait queue is in FIFO order gt If the bit pattern of the eventfl
151. emory block size blksz Specifies the memory block size in bytes A value between 4 and 65534 aligned to a 2 byte boundary can be specified for biksz R20UT0511EJ0101 Rev 1 01 tENESAS Page 230 of 272 Apr 01 2012 RI78V4 CHAPTER 13 SYSTEM CONFIGURATION FILE 5 Segment name seg_nam Specifies where the fixed sized memory pool is to be allocated Values that can be specified for seg_nam are limited to k_workO k_work1 k_work2 or k_work3 Fixed sized memory pool allocation segment k_workO k_work1 k_work2 k_work3 Allocates the fixed sized memory pool to the k_workO segment Allocates the fixed sized memory pool to the k_work1 segment Allocates the fixed sized memory pool to the k_work2 segment Allocates the fixed sized memory pool to the k_work3 segment Note If specification of seg_nam is omitted the fixed sized memory pool is allocated to the k_workO segment 6 System reserved area mpf System reserved area Values that can be specified for mpf are limited to NULL characters R20UT0511EJ0101 Rev 1 01 2tENESAS Apr 01 2012 Page 231 of 272 RI78V4 CHAPTER 13 SYSTEM CONFIGURATION FILE 13 4 6 Cyclic handler information Define the following items as cyclic handler information The The Cyclic handler name cycid Attribute coding language initial activation status cycatr System reserved area exinf Start address cychdr Activation cycle cyctim System reserved area c
152. en TMO_POL is specified processing equivalent to pol_flg will be executed R20UT0511EJ0101 Rev 1 01 2tENESAS Page 57 of 272 Apr 01 2012 CHAPTER 5 SYNCHRONIZATION AND COMMUNICATION RI78V4 FUNCTIONS 5 3 6 Reference eventflag state An eventflag status is referenced by issuing the following service call from the processing program ref_fig Stores eventflag state packet such as existence of waiting tasks of the eventflag specified by parameter flgid in the area specified by parameter pk_rfig The following describes an example for coding this service call pragma rtos_task func_task include lt kernel h gt Standard header file definition include lt kernel_id h gt System information header file definition void func_task VP_INT exinf ID flgid ID_flgA Declares and initializes variable T_RFLG pk_rflg Declares data structure ID wt skid Declares variable FLGPIN flgptn Declares variable SE TEE ee 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 oP sid tere dca Reem N Note For details about the eventflag state packet refer to 12 5 3 Eventflag state packet R20UT0511EJ0101 Rev 1 01 2tENESAS Page 58 of 272 Apr 01 2012 CHAPTER 5 SYNCHRONIZATION AND COMMUNICATION RI78V4 FUNCTIONS 5
153. en the cfg file is changed i Output folder BuildModeN ame File name sit asm E System Information Header File for C Language Generate a file Yes lt updates the file when the cfg file is changed dc Output folder BuildModeName File name kermel_id h E System Information Header File for Assembly Language Generate a file Yes lt updates the file when the cfg file is changed da Output folder BuildModeN ame File name kermel_id ine Generate afile Select whether to make a System Information Table File which is output from a system configuration file This file includes information of system initialization iy File Information 5 Specify the output of a load module file Set the output of a load module file as the product of the build Note See CubeSuite Integrated Development Environment User s Manual RL78 78KOR Build for details about specifying the output of a load module file Set build options Set the options for the compiler assembler linker and the like Note See CubeSuite Integrated Development Environment User s Manual RL78 78KOR Build for details about setting build options R20UT0511EJ0101 Rev 1 01 ztENESAS Page 19 of 272 Apr 01 2012 RI78V4 CHAPTER 2 SYSTEM CONSTRUCTION 7 Runa build Run a build to create a load module Note See CubeSuite Integrated Development Environment User s Manual RL78 78KOR Build for details about runnig a build Figure 2 4 Project
154. er priority level R20UT0511EJ0101 Rev 1 01 ztENESAS Page 206 of 272 Apr 01 2012 RI78V4 CHAPTER 12 SERVICE CALLS Return value Macro Value Description E OK 0 Normal completion R20UT0511EJ0101 Rev 1 01 2tENESAS Page 207 of 272 Apr 01 2012 RI78V4 CHAPTER 12 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 Assembly format MOVW AX p_tskid_lo MOVW BC p_tskid_hi CALL _get_tid MOVW AX p_tskid_lo MOVW BC p_tskid_hi CALL _iget_tid 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 R20UT0511EJ0101 Rev 1 01 2tENESAS Page 208 of 272 Apr 01 2012 RI78V4 loc_cpu iloc_cpu Outline Lock the CPU CHAPTER 12 SERVICE CALLS C format ER loc_cpu ER iloc_cpu i Assembly format CALL l _ loc cpu CALL I _ iloc_cpu Parameter s None Explanation Th
155. ercd E_TMOUT PoP toed ete stash a tes Timeout processing Note 1 When 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 will be executed Note 2 For details about the message packet refer to 12 5 4 Message packet R20UT0511EJ0101 Rev 1 01 Apr 01 2012 ztENESAS Page 64 of 272 CHAPTER 5 SYNCHRONIZATION AND COMMUNICATION RI78V4 FUNCTIONS 5 4 6 Reference mailbox state A mailbox status is referenced by issuing the following service call from the processing program ref_mbx Stores mailbox state packet such as existence of waiting tasks 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 pragma rtos_task func_task include lt kernel h gt Standard header file definition include lt kernel_id h gt System information header file definition void func_task VP_INT exinf ID mbxid ID_mbxA Declares and initializes variable T_RMBX pk_rmbx Declares data structure ID wt skid Declares variable T_MSG ok_msg Declares data structure ee eee ae ref_mbx mbxid amp pk_rmbx Reference mailbox state wtskid pk_rmbx wtskid Reference ID number of the task at the head of the wait queue pk_msg pk_rmbx pk_msg Referenc start addre
156. ertain use conditions Further Renesas Electronics products 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 system 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 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 Electro
157. ervice call re queues the task at the end of the ready queue corresponding to the priority specified by parameter tskpri following priority change processing R20UT0511EJ0101 Rev 1 01 2tENESAS Page 114 of 272 Apr 01 2012 RI78V4 CHAPTER 11 SCHEDULER 11 5 Scheduling Disabling The RI78V4 provides a function to disable scheduler activation by referencing the system state from the processing program and explicitly prohibiting dispatch processing task scheduling processing The following shows a processing flow when using the scheduling suppressing function Figure 11 4 Scheduling Suppression Function Task Task Priority High Priority Low Acquire semaphore resource 4 Disable dispatching Release semaphore resource Suppressed period Enable dispatching R20UT0511EJ0101 Rev 1 01 2tENESAS Page 115 of 272 Apr 01 2012 RI78V4 CHAPTER 11 SCHEDULER 11 5 1 Disable dispatching A task is moved to the dispatching disabled state by issuing the following service call from the processing program dis_dsp This service call changes the system status to the dispatching 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 RI78V4 executes only
158. escription area Display the brief description of the categories and their contents selected in the detailed information display change area R20UT0511EJ0101 Rev 1 01 ztENESAS Page 249 of 272 Apr 01 2012 RI78V4 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 RI78V4 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 is 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 Note1 See CubeSuite Integrated Development Environment User s Manual RL78 78KOR Build for details about the File Information tab Category Information tab Build Settings tab and Individual Assemble Options tab Note2 When multiple components are selected on the Project Tree panel only the tab that is common to all the components is d
159. ese service calls change the system status type to the CPU locked state As a result 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 issuance is also restricted If a maskable interrupt is created during the interval from this service call is issued until unl_cpu or iunl_cpu is issued the RI78V4 delays transition to the relevant interrupt processing interrupt handler until either unl_cpu or iunl_cpu is issued 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_ctx Reference contexts sns_loc Reference CPU state sns_dsp Reference dispatching state sns_dpn Reference dispatch pending state 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 R20UT0511EJ0101 Rev 1 01 Apr 01 2012 2tENESAS Page 209 of 272 RI78V4 CHAPTER 12 SERVICE CALLS Note 3 The RI78V4 implements disabling of maskable interrupt acknowledgment bu manipulating the
160. estigated the results are as shown below Service call argument size pol_flg 8 bytes Service call argument size snd_mbx 4 bytes The largest stack size is used in the call to pol_flg so this is specified in Expression 1 Task stack size size used by user service call argument size pol_flg 28 0 8 28 36 bytes The size specified in the system configuration file will be the above minus 28 bytes which equals 8 bytes Example 2 In task task1 function A using 12 bytes of stack makes a pol_flg service call and function B using 20 bytes of stack makes a snd_mbx service call Since interrupts are accepted in the task Expression 2 is used as the calculation formula List the patterns in order to find the one that uses the most stack Pattern A size used by user for function A service call argument size pol_flg 28 18 12 8 28 18 66 bytes Pattern B size used by user for function B service call argument size snd_mbx 28 18 20 4 28 18 70 bytes Compare pattern B with pattern A The pattern that uses the most stack is pattern A at 70 bytes The size specified in the system configuration file will be the above minus 28 bytes which equals 42 bytes R20UT0511EJ0101 Rev 1 01 tENESAS Page 236 of 272 Apr 01 2012 RI78V4 CHAPTER 13 SYSTEM CONFIGURATION FILE 13 6 Description Examples The following describes an example for coding the system configuration file Figure 13 2 Example of System Conf
161. et_mpf is issued the task is queued to the fixed sized memory pool wait queue in the order of memory block acquisition request RI78V4 User s Manual Coding Publication Date Rev 1 00 Apr 01 2011 Rev 1 01 Apr 01 2012 Published by Renesas Electronics Corporation tENESAS SALES OFFICES Renesas Electronics Corporation http www renesas com Refer to http www renesas com for the latest and detailed information Renesas Electronics America Inc 2880 Scott Boulevard Santa Clara CA 95050 2554 U S A Tel 1 408 588 6000 Fax 1 408 588 6130 Renesas Electronics Canada Limited 1101 Nicholson Road Newmarket Ontario L3Y 9C3 Canada Tel 1 905 898 5441 Fax 1 905 898 3220 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 D sseldorf Germany Tel 49 211 65030 Fax 49 211 6503 1327 Renesas Electronics China Co Lid 7th Floor Quantum Plaza No 27 ZhiChunLu Haidian District Beijing 100083 P R China Tel 86 10 8235 1155 Fax 86 10 8235 7679 Renesas Electronics Shanghai Co Ltd Unit 204 205 AZIA Center No 1233 Lujiazui Ring Rd Pudong District Shanghai 200120 China Tel 86 21 5877 1818 Fax 86 21 6887 7858 7898 Renesas Electronics Hong Kong Limited Unit 1601 1613 16 F Tower 2 Grand Century Place 193 Prince Edward Roa
162. f the counter for the task registering the number of times the wakeup request has been issued indicates 0x0 upon the issuance of a slp_tsk or tslp_tsk A task enters this state upon the issuance of a dly_tsk A task enters this state if it cannot acquire a resource from the relevant semaphore upon the issuance of a wai_sem or twai_sem A task enters this state if a relevant eventflag does not satisfy a predetermined condition upon the issuance of a wai_flg or twai_flg A task enters this state if cannot receive a message from the relevant mailbox upon the issuance of a rcv_mbx or trcv_mbx A task enters this state if it cannot acquire a fixed sized mem ory block from the relevant fixed sized memory pool upon the issuance of a get_mpf or tget_mpf 12 5 1 Task state packet Changed as follows the sentence in the item tskwait rtsk_wait Sleeping state Delayed state Waiting state for a semaphore resource Waiting state for an eventflag pm om en i f 209 Description Summary Receiving waiting state for a mailbox Waiting state for a fixed sized memory block gt A task enters this state if the counter for the task registering the number of times the wakeup request has been issued indicates 0x0 upon the issuance of a slp_tsk or tslp_tsk A task enters this state upon the issuance of a dly_tsk A task enters this state if it cannot acquire a resource from the relevant semaphore upon the issuance of a wai_sem or twai_s
163. ference contexts if ercd TRUE ee eae a Non task contexts else if ercd FALSE JR ae BA a tava tabs Task contexts E sock ew Boa Beas R20UT0511EJ0101 Rev 1 01 tENESAS Page 89 of 272 Apr 01 2012 RI78V4 CHAPTER 8 SYSTEM STATE MANAGEMENT FUNCTIONS 8 9 Reference CPU State The CPU locked state 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 func_sub void BOOL ercd Declares variable a ee ree eee aif ercd sns_loc Reference CPU state if ercd TRUE E E E athe och ee CPU locked state else if ercd FALSE TR E T E fects onside CPU unlocked state Pe 28s iene ay Note The system enters the CPU locked state when loc_cpu or iloc_cpu is issued and enters the CPU unlocked state when unl_cpu or iunl_cpu is issued R20UT0511EJ0101 Rev 1 01 2tENESAS Page 90 of 272 Apr 01 2012 RI78V4 CHAPTER 8 SYSTEM STATE M
164. ference task statuses in addition to a function to manipulate task statuses 3 2 Tasks A task is processing program that is not executed unless it is explicitly manipulated via service calls provided by the RI78V4 unlike other processing programs cyclic handler and interrupt handler and is called from the scheduler Note The 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 RI78V4 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 RI78V4 The RI78V4 classifies task states into the following six types Figure 3 1 Task State e READY state RUNNING state A A i WAITING state i WAITING SUSPENDED state gt gt SUSPENDED state y DORMANT state i R20UT0511EJ0101 Rev 1 01 ztENESAS Page 22 of 272 Apr 01 2012 RI78V4 CHAPTER 3 TASK MANAGEMENT FUNCTIONS DORMANT state State of a task that is not active or the state entered by a task whose processing has ended
165. 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 is called from the scheduler when there no longer remains a task subject to scheduling by the RI78V4 task in the RUNNING or READY state in the system Note For details about the idle routine refer to 11 7 Idle Routine R20UT0511EJ0101 Rev 1 01 ztENESAS Page 13 of 272 Apr 01 2012 RI78V4 2 5 Coding of Directive File Code the directive file used by the user to fix the address allocation done by the linker In the RI78V4 the allocation CHAPTER 2 SYSTEM CONSTRUCTION destinations segment names of management objects modularized for each function are specified The following lists the segment names prescribed in the RI78V4 Table 2 1 RI78V4 Segments Segment Name ROM RAM Segment Attribute Description Area where the RI78V4 s core processing part and main processing part of service calls provided by the RI78V4 CSEG k_system ROM UNITP are to be allocated The start can be aligned at an even address in the area from 0x000c0 to Oxeffff Area where information items such as the RI78V4 k info ROM CSEG version are to be allocated l UNITP The start can be aligned at an even address in the area from 0x000c0 to Oxeffff Area where initial information items related to OS resources that do not change dynamically are allocated CSEG k_const R
166. g 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 wimode TWF_ANDW Checks whether all of the bits to which 1 is set by parameter waiptn are set as the target eventtflag wfmode TWF_ORW Checks which bit among bits to which 1 is set by parameter waiptn is set as the target eventflag Note 1 In the RI78V4 the number of tasks that can be queued to the eventflag wait queue is one If this service call is issued for the eventflag to which a task is queued therefore E_ILUSE is returned regardless of whether or not the required condition is immediately satisfied Note 2 The RI78V4 performs bit pattern clear processing 0x0 setting when the required condition of the target eventflag TA_CLR attribute is satisfied Note 3 When TMO_FEVR is specified for wait time tmout processing equivalent to wai_flg will be executed When TMO_POL i
167. g of initialization routine 107 10 4 Kernel Initialization Module 107 10 5 Reference Version Information 108 CHAPTER 11 SCHEDULER 109 11 1 11 2 11 3 11 4 11 5 11 6 11 7 Outline 109 Driving Method 109 Scheduling System 109 Ready Queue 110 11 4 1 Create ready queue 110 11 4 2 Delete ready queue 110 11 4 3 Rotate task precedence 111 11 4 4 Change task priority 113 Scheduling Disabling 115 11 5 1 Disable dispatching 116 11 5 2 Enable dispatching 117 Delay of Scheduling 118 Idle Routine 119 11 7 1 Define idle routine 119 11 7 2 Undefine idle routine 119 11 7 3 Basic form of idle routine 119 11 7 4 Internal processing of idle routine 120 CHAPTER 12 SERVICE CALLS 121 12 1 12 2 12 3 12 4 12 5 Outline 121 Call Service Call 122 12 2 1 C language 122 12 2 2 Assembly language 123 Amount of Stack Used by Service Calls 124 Data Macros 126 12 4 1 Datatypes 126 12 4 2 Current state 127 12 4 3 WAITING types 127 12 4 4 Return value 128 12 4 5 Conditional compile macro 128 12 4 6 Others 128 Packet Formats 129 12 5 1 Task state packet 129 12 5 2 Semaphore state packet 131 12 5 3 Eventflag state packet 132 12 5 4 Message packet 133 12 5 5 Mailbox state packet 134 12 5 6 Fixed sized memory pool state packet 135 12 5 7 Cyclic handler state
168. g such as queue manipulation counter manipulation etc and the actual dispatch processing is delayed until a return instruction is issued by the non task upon which the actual dispatch processing is performed in batch The following shows a processing flow when a service call that involves dispatch processing in a non task is issued Figure 11 5 Delay of Scheduling Task Task Priority High Priority Low Interrupt handler Acquire semaphore resource Release semaphore resource Delayed period return R20UT0511EJ0101 Rev 1 01 2tENESAS Page 118 of 272 Apr 01 2012 RI78V4 CHAPTER 11 SCHEDULER 11 7 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 RI78V4 task in the RUNNING or READY state in the system 11 7 1 Define idle routine In the RI78V4 the method of registering an idle routine is limited to static registration by the Kernel Initialization Module Idle routines therefore cannot be created dynamically using a method such as issuing a service call from a processing program Static define Static idle routine registration is realized by coding idle routines by using the prescribed function name idle_handler The RI78V4 executes idle
169. g to the priority of the task Note 2 The wakeup request counter managed by the RI78V4 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 R20UT0511EJ0101 Rev 1 01 Apr 01 2012 2tENESAS Page 37 of 272 RI78V4 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 ER_UINT ercd ID tskid ercd can_wup if ercd gt 0x0 pragma rtos_task include lt kernel h gt include lt kernel_id h gt void func_task VP_INT exinf PO te rela E Reese ack func_task Standard header file definition System information header file definition Declares variable Declares and initializes variable Cancel task wakeup requests Normal termination processing R20UT0511EJ0101 Rev 1 01 Apr 01 2012 2tENESAS Page 38 of 272 RI78V4 CHAPTER
170. gram via the mailbox but it should be noted that in the case of the synchronization and communication functions of the RI78V4 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 R20UT0511EJ0101 Rev 1 01 Securement of memory area In the case of the RI78V4 it is recommended to use the memory area secured by issuing service calls such as get_mpf and pget_mpf for messages Note The RI78V4 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 RI78V4 it must be secured from 4 byte aligned addresses Basic form of messages In the RI78V4 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 msgque are not restricted in particular in the RI78V4 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 __far msgque Reserved for future us
171. h as existence of waiting tasks of the mailbox specified by parameter mbxid in the area specified by parameter pk_rmbx Note For details about the mailbox state packet refer to 12 5 5 Mailbox state packet Return value Macro Value Description E OK 0 Normal completion R20UT0511EJ0101 Rev 1 01 ztENESAS Page 190 of 272 Apr 01 2012 RI78V4 CHAPTER 12 SERVICE CALLS 12 11 Memory Pool Management Functions The following lists the service calls provided by the RI78V4 as the memory pool management functions Table 12 13 Memory Pool Management Functions 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 Task Non task tget_mpf Acquire fixed sized memory block with timeout Task rel_mpf Release fixed sized memory block Task Non task ref_mpf Reference fixed sized memory pool state Task Non task R20UT0511EJ0101 Rev 1 01 2tENESAS Page 191 of 272 Apr 01 2012 RI78V4 CHAPTER 12 SERVICE CALLS Outline Acquire fixed sized memory block waiting forever C format ER get_mpf ID mpfid VP p_bik Assembly format MOV A ES MOV C A MOVW DE p_blk_lo PUSH BC PUSH DE MOVW AX mpfid CALL _get_mpf addw sp 04H Parameter s 1 O Parameter Description ID number of the fixed
172. h pending state FALSE dispatch not pending state is returned Note The dispatch pending state designates the state in which explicit execution of dispatch processing task scheduling processing is prohibited by issuing either the dis_dsp loc_cpu or iloc_cpu service call as well as the state during which processing of a non task is being executed Return value Macro Value Description TRUE 1 Normal completion dispatch pending state FALSE 0 Normal completion other state R20UT0511EJ0101 Rev 1 01 ztENESAS Page 217 of 272 Apr 01 2012 RI78V4 CHAPTER 12 SERVICE CALLS 12 14 System Configuration Management Functions The following lists the service calls provided by the RI78V4 as the system configuration management functions Table 12 16 System Configuration Management Functions Service Call Function Origin of Service Call ref_ver Reference version information Task Non task R20UT0511EJ0101 Rev 1 01 2tENESAS Page 218 of 272 Apr 01 2012 RI78V4 CHAPTER 12 SERVICE CALLS ref_ver Outline Reference version information C format ref_ver T_RVI ER pk_rver Assembly format MOV A ES MOV C A MOVW AX pk_rver_lo CALL _ref_ver Parameter s 0 Parameter Description O T_RVER pk_rver Pointer to the packet returning the version information Explanation The service call stores version
173. handler 9 2 2 Internal processing of interrupt entry processing Interrupt entry processing is a routine dedicated to processing of entries called without using the RI78V4 when an interrupt occurs Therefore note the following points when coding interrupt entry processing Coding method Code interrupt entry processing in assembly language in formats compliant with the assembler s function calling rules Stack switching No stack requiring switching exists in interrupt entry processing execution The code regarding stack switching during interrupt entry processing is therefore not required Service call issuance The RI78V4 prohibits issuance of service calls in interrupt entry processing The following lists processing that should be executed in interrupt entry processing Vector table address setting Passing of control to relevant processing Interrupt Handlers Boot Processing or the like R20UT0511EJ0101 Rev 1 01 ztENESAS Page 94 of 272 Apr 01 2012 RI78V4 CHAPTER 9 INTERRUPT MANAGEMENT FUNCTIONS 9 3 Interrupt Handlers The interrupt handler is a routine dedicated to interrupt servicing that is activated when an interrupt occurs and is called from Interrupt Entry Processing The RI78V4 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 th
174. he selected item to the default configuration of the project Peseti Draut For the Individual Assemble Options tab restores to the configuration of the general option Restores all the configuration of the current tab to the default configuration of the project For the Individual Assemble Options tab restores to the configuration of the general option Reset All to Default R20UT0511EJ0101 Rev 1 01 2tENESAS Page 251 of 272 Apr 01 2012 RI78V4 APPENDIX A WINDOW REFERENCE RI78V4 tab Outline This tab shows the detailed information on the RI78V4 to be used categorized by the following Version Information Display image Explanation of each area 1 Version Information A RI78V 4 Property E Yersion Information Kernel version This is the version of the RI78V4 to be used in this project The detailed information on the version of the RI78V4 are displayed Display the version of the RI78V4 to be used Note that the version is set permanently when the project is created and cannot be changed Kernel version Default Using the RI78V4 version How to Changes not allowed change Display the folder in which the RI78V4 to be used is installed with the absolute path Install folder Default The folder in which the RI78V4 to be used is installed How to Changes not allowed change Display the memory model set in the project Display the same val
175. he transition states of dynamically changing tasks so that the CPU use right is given to the optimum task 11 2 Driving Method The RI78V4 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 RI78V4 the scheduler is activated upon occurrence of the events listed below and dispatch processing task scheduling processing is executed Issuance of service call that may cause task state transition Issuance of instruction for returning from non task cyclic handler interrupt handler etc Occurrence of clock interrupt used when achieving TIME MANAGEMENT FUNCTIONS 11 3 Scheduling System As task scheduling methods the RI78V4 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 the RI78V4 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 Note In the RI78V4 a task having a smaller priority number is given a higher priority FCFS method The same priority level can be defined for multiple tasks in the RI78V4 Therefore multiple tasks with the highest priority level which is used as the criterion for task selection under the Priority level me
176. hile waiting E RLWAI Forced release from waiting accept irel_ wai while waiting E RLWAI Return value Macro Value Description E OK 0 Normal completion E RLWAI 49 Forced release from waiting accept rel_wai irel_wai while waiting R20UT0511EJ0101 Rev 1 01 Apr 01 2012 ztENESAS Page 166 of 272 RI78V4 CHAPTER 12 SERVICE CALLS Outline Acquire semaphore resource polling C format ER pol_sem ID semid Assembly format MOVW AX semid CALL _pol_sem Parameter s O Parameter Description 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 counter 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 E TMOUT 50 Polling failure R20UT0511EJ0101 Rev 1 01 2tENESAS Page 167 of 272 Apr 01 2012 RI78V4 CHAPTER 12 SERVICE CALLS Outline Acquire semaphore resource with timeout C format ER twai_sem ID semid TMO tmout Assembly format MOVW AX tmout_hi P
177. ice call operational mode TMO signed long int Timeout unit ticks RELTIM unsigned long int Relative time unit ticks Note The ID type definition in the RI78V4 differs from that of the uITRON 4 0 specification R20UT0511EJ0101 Rev 1 01 Apr 01 2012 ztENESAS Page 126 of 272 RI78V4 CHAPTER 12 SERVICE CALLS 12 4 2 Current state The following lists the status at the point acquired by issuing a service call ref_tsk ref_cyc Macro definition of the current status is performed by standard header file lt ri_root gt include kernel h Table 12 3 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_STP 0x00 Non operational state TCYC_STA 0x01 Operational state 12 4 3 WAITING types The following lists WAITING types acquired by issuing a service call ref_tsk Macro definition of the WAITING type is performed by standard header file lt ri_root gt include kernel h Table 12 4 WAITING Types Macro Value Description A task enters this state if the counter for the task register ing the number of times the wakeup request has been a 0x000 issued indicates 0x0 upon the issuance of a slp_tsk or tslp_tsk TTW_DLY 0x0002 A task enters this state upon the issuance of a dly_tsk A task enters
178. ice calls that can be issued in cyclic handlers are limited to the service calls that can be issued from non tasks Note 1 For details on the valid issuance range of each service call refer to Table 12 8 to Table 12 16 Note 2 If a service call ichg_pri isig sem 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 RI78V4 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 R20UT0511EJ0101 Rev 1 01 2tENESAS Page 76 of 272 Apr 01 2012 RI78V4 CHAPTER 7 TIME MANAGEMENT FUNCTIONS 7 5 5 Start cyclic handler operation Moving to the operational state STA state is implemented by issuing the following service call from the processing program sta_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 RI78V4 The following describes an example for coding this service call pragma rtos_task func_task include lt kernel h gt Standard header file definition include lt kernel_id h gt System i
179. icrocontroller A Pin Configurator Design Tool Code Generator Design Tool A CA78KOR Build Tool Z RI7BV4 Realtime OS S 78KOR Simulator Debug Tool P Program Analyzer Analyze Tool E E File s Startup aam start asm c idirtn c c inirtn c c init c cj inthdr c ar sample dr c_ task c c cychdr c h init h h user h vf sys cfg ef Realtime OS generated files asm sit asm n_ kernel_id h ind kernel_id inc 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 R20UT0511EJ0101 Rev 1 01 ztENESAS Page 18 of 272 Apr 01 2012 RI78V4 CHAPTER 2 SYSTEM CONSTRUCTION 4 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 and system information header files Figure 2 3 Property Panel System Configuration File Related Information Tab Property vf sys cfg Property E System Information T able Fie Generate a file Yesflt updates the file wh
180. id CALL ref mpf addw sp 04H Parameter s 1 O 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 Explanation Stores fixed sized memory pool state packet such as existence of waiting tasks of the fixed sized memory pool specified by parameter mpfid in the area specified by parameter pk_rmpf Note For details about the fixed sized memory pool state packet refer to 12 5 6 Fixed sized memory pool state packet Return value Macro Value Description E OK 0 Normal completion R20UT0511EJ0101 Rev 1 01 ztENESAS Page 199 of 272 Apr 01 2012 RI78V4 CHAPTER 12 SERVICE CALLS 12 12 Time Management Functions The following lists the service calls provided by the RI78V4 as the time management functions Table 12 14 Time Management Functions Service Call Function Origin of Service Call sta_cyc Start cyclic handler operation Task Non task stp_cyc Stop cyclic handler operation Task Non task ref_cyc Reference cyclic handler state Task Non task R20UT0511EJ0101 Rev 1 01 tENESAS Page 200 of 272 Apr 01 2012 RI78V4 CHAPTER 12 SERVICE CALLS Outline Start cyclic handler operation C format ER sta_cyc ID cycid Assembly format MOVW AX cycid CALL _sta_cyc Parameter s 1 O Pa
181. iguration File System Information description SYS_STK 256 MAX PRI 15 Static API Information description CRE_TSK ID_tsk TA_HLNG TA_ACT TA_DISINT Oxa func_task 1 256 NULL CRE_TSK ID_tskA TA_HLNG TA_ACT 0x14 func_taskA 2 256 NULL CRE_TSK ID_tskB TA_ASM TA_ENAINT Oxle func_taskB 3 512 NULL CRE_SEM ID_semA A_TFIFO 0 127 CRE_SEM ID_semB A_TFIFO 127 127 CRE_FLG ID_flgA A_TFIFO TA_WSGL TA_CLR 0 CRE_FLG ID_flgB A_TFIFO TA_WSGL 0 CRE_MBX ID_mbxA A_TFIFO TA_MFIFO 0 NULL CRE_MBX ID_mbxB A_TFIFO TA_MPRI 0 MULL CRE_MPF ID_mpfA A_TFIFO 10 8 k_work1l NULL CRE_MPF ID_mpfB A_TFIFO 8 16 NULL CRE_CYC ID_cycA TA_HLNG TA_STA 0 func_cychdrA 1 0 CRE_CYC ID_cycB TA_ASM 0 func_cychdrB 2 0 R20UT0511EJ0101 Rev 1 01 tENESAS Page 237 of 272 Apr 01 2012 RI78V4 CHAPTER 14 CONFIGURATOR CF78V4 CHAPTER 14 CONFIGURATOR CF78V4 This chapter explains configurator CF78V4 which is provided by the RI78V4 as a utility tool useful for system construction 14 1 Outline To build systems load module that use functions provided by the RI78V4 the information storing data to be provided for the RI78V4 is required Since information files are basically enumerations of data it is possible
182. indow to be open when the CubeSuite is Main window launched Project Tree panel This panel is used to display the project components in tree view This panel is used to display the detailed information on the Realtime OS node system configuration file or the like that is selected on the Project Tree panel and change the settings of the information Property panel R20UT0511EJ0101 Rev 1 01 2tENESAS Page 243 of 272 Apr 01 2012 RI78V4 APPENDIX A WINDOW REFERENCE Outline This is the first window to be open when the CubeSuite is launched This window is used to control the user program execution and open panels for the build process This window can be opened as follows Select Windows start gt All programs gt Renesas Electronics CubeSuite gt CubeSuite Display image 3 sample CubeSuite Project Tree File Edit View Project Build Debug Tool Window Help GH start tS XS 0 a ae GELS Gs 9 ox cr 2a st Project Tree Property 7 4b KX a UR ple Project E File uPD78F1166_A40 Microcontroller File name ample mtp Absolute Path D sample sample cs aA Pin Configurator Design Tool hi 1 gt io eE Notes a P Code Generator Design Tool A CA78KOR Build Tool A RI7BV4 Realtime OS File name 78KOR Simulator Debug Tool This is the name of the file to which the D Pooran Areias niake Tan ee of this main project is to be w File
183. information packet such as kernel maker s code to the area specified by parameter pk_rver Note For details about the version information packet refer to 12 5 8 Version information packet Return value Macro Value Description E OK 0 Normal completion R20UT0511EJ0101 Rev 1 01 ztENESAS Page 219 of 272 Apr 01 2012 RI78V4 CHAPTER 13 SYSTEM CONFIGURATION FILE CHAPTER 13 SYSTEM CONFIGURATION FILE This chapter explains the coding method of the system configuration file required to output information files system information table file and system information header file that contain data to be provided for the RI78V4 13 1 Notation Method The following shows the notation method of system configuration files Character code Create the system configuration file using ASCII code The CF78V4 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 CF78V4 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 Elements of a word ar
184. ing the task execution order The following shows the status transition when this task priority is changed Ready queue Figure 11 3 Change Task Priority 1 Invoking task RUNNING state tskpri Task A READY state Task B READY state Task C READY state maxtpri chg_pri D_tskB maxtpri Ready queue 1 Invoking task RUNNING state tskpri Task A Task C READY state READY state maxtpri Task B READY state R20UT0511EJ0101 Rev 1 01 2tENESAS Page 113 of 272 Apr 01 2012 RI78V4 CHAPTER 11 SCHEDULER A priority is changed by issuing the following service call from the processing program chg_pri ichg_pri This service call changes the priority of the task specified by parameter tskid current priority to a value specified by parameter tskpri The following describes an example for coding this service call pragma rtos_task func_task include lt kernel h gt Standard header file definition include lt kernel_id h gt System information header file definition void func_task VP_INT exinf ID tskid ID_tskA Declares and initializes variable PRI tskpri 9 Declares and initializes variable fF E E EEE chg_pri tskid tskpri Change task priority Note If the target task is in the RUNNING or READY state after this service call is issued this s
185. ing accept irel_wai while waiting E RLWAI The following describes an example for coding this service call pragma rtos_task func_task include lt kernel h gt Standard header file definition include lt kernel_id h gt System information header file definition void func_task VP_INT exinf ER ercd Declares variable RELTIM dlytim 3600 Declares and initializes variable J tented wie eai i ercd dly_tsk dlytim Delay task if ercd E_OK ES Bein ce eaten 7 Normal termination processing else if ercd E_RLWAI E aae ea os asd sas EJ Forced termination processing PP E EEEE facta tier ie R20UT0511EJ0101 Rev 1 01 tENESAS Page 43 of 272 Apr 01 2012 CHAPTER 5 SYNCHRONIZATION AND COMMUNICATION RI78V4 FUNCTIONS CHAPTER5 SYNCHRONIZATION AND COMMUNICA TION FUNCTIONS This chapter describes the synchronization and communication functions performed by the RI78V4 5 1 Outline The synchronization and communication functions of the RI78V4 consist of Semaphores Eventflags and Mailboxes that are provided as means for realizing exclusive control queuing and communication among tasks 5 2 Semaphores In the RI78V4 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 re
186. interrupt i 0 Interrupts enabled level 0 level 1 and occurs level 2 levels accepted When a level 2 interrupt A 0 A Interrupts enabled level O and level 1 Interrupt occurs levels accepted handler When a level 3 interrupt 1 1 0 Interrupts enabled level 0 level 1 and occurs level 2 levels accepted When a level 0_ interrupt 0 0 0 Interrupts disabled if enabled a lelvel 0 occurs interrupt accepted When a level 1 interrupt 0 0 0 Interrupts disabled if enabled a lelvel 0 Interrupt occurs interrupt accepted Servicing When a level 2 interrupt 0 0 1 Interrupts disabled if enabled lelvel 0 occurs and lebel 1 interrupts accepted When a level 3 interrupt 0 A 0 Interrupts disabled if enabled lelvel 0 occurs level 1 and lebel 2 interrupts accepted Note that a separate IE state is maintained for each task If a suspended task is resumed the IE state before suspension is restored R20UT0511EJ0101 Rev 1 01 2tENESAS Page 100 of 272 Apr 01 2012 RI78V4 CHAPTER 9 INTERRUPT MANAGEMENT FUNCTIONS 9 5 Multiple Interrupts The reoccurrence of an interrupt within an interrupt handler is called multiple interrupt The following shows the flow of the processing for handling multiple interrupts Figure 9 3 Multiple Interrupts Interrupt Interrupt Interrupt handler handler servicing Task Level 3 Level 2 Level 1 Interrupt servicing Level 0 of El function E return Calling of DI f
187. interrupt handlers in C When using pragma rtos_interrupt directive pragma rtos_interrupt INTTMOO func_inthdr include lt kernel h gt Standard header file definition include lt kernel_id h gt System information header file definition void func_inthdr void JE Oe re Ey Main processing return Terminate interrupt handler When using __rtos_interrupt qualifier include lt kernel h gt Standard header file definition include lt kernel_id h gt System information header file definition __rtos_interrupt void func_inthdr void PP se nthe alae seh Led Main processing return Terminate interrupt handler Note Interrupt handlers coded by using the pragma rtos_interrupt directive or __rtos_interrupt qualifier can be allocated to the near area only R20UT0511EJ0101 Rev 1 01 2tENESAS Page 96 of 272 Apr 01 2012 RI78V4 CHAPTER 9 INTERRUPT MANAGEMENT FUNCTIONS When coding interrupt handlers in assembly language use void type functions that do not have arguments function any Save registers and saddr areas at the beginning of the interrupt handler call processing to switch to the system stack function name _kernel_int_entry and then call end processing at the end of the interrupt handler function name ret_int Assembly Language
188. ion Functions Mailboxes The following lists the service calls provided by the RI78V4 as the synchronization and communication functions mail boxes Table 12 12 Synchronization and Communication Functions Mailboxes Service Call Function Origin of Service Call snd_mbx Send to mailbox Task Non task rcv_mbx Receive from mailbox waiting forever Task prcv_mbx Receive from mailbox polling Task Non task trcv_mbx Receive from mailbox with timeout Task ref_mbx Reference mailbox state Task Non task R20UT0511EJ0101 Rev 1 01 2tENESAS Page 182 of 272 Apr 01 2012 RI78V4 CHAPTER 12 SERVICE CALLS Outline Send to mailbox C format ER snd_mbx ID mbxid T_MSG pk_msg Assembly format MOV A ES MOV C A MOVW DE pk_msg_lo PUSH BC PUSH DE MOVW AX mbxid CALL _ and_mbx addw sp 04H Parameter s V O 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 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
189. ion information that is described in a system configuration file is divided into the following two main types System Information This information consists of fundamental data required for the RI78V4 operation System stack information Task priority information Static API Information This information consists of data for management objects required to implement the functions probided by the RI78V4 Task information Semaphore information Eventflag information Mailbox information Fixed sized memory pool information Cyclic handler information 13 2 1 Cautions In the system configuration file describe the system configuration information System Information Static API Information in the following order 1 System Information description 2 Static API Information description The following describes a system configuration file description format Figure 13 1 System Configuration File Description Format System Information System stack information etc descriptin EO EE TINE EEN ay Static API Information Task information etc description PPO se cbusar aig wat wen ations Ay Note Up to 40 000 lines and up to 1 000 characters per line can be written in a system configuration file R20UT0511EJ0101 Rev 1 01 ztENESAS Page 221 of 272 Apr 01 2012 RI78V4 CHAPTER 13 SYSTEM CONFIGURATION FILE 13 3 System Information The following describes the format that must be observed
190. is omitted the initial task activation status is set to the DORMANT state Note 2 If specification of TA_ENAINT and TA_DISINT is omitted the initial task interrupt status is set to interrupts acknowledgment enabled 3 Extended information exinf Specifies the extended information of the task Values that can be specified for exinf are from 0 to 1048575 or symbol names written in C Note exinf is passed as an extended information to the target task when the task is activated by act_tsk or iact_tsk The target task can therefore handle exinf in the same manner as handling function parameters 4 Start address task Specifies the start address of the task Values that can be specified for task are symbol names written in C Note 1 When a task is in written in C as shown below the value specified by this item is func_task pragma rtos_task func_task include lt kernel h gt include lt kernel_id h gt void func_task VP_INT exinf rae ear A ext_tsk Note 2 When a task is in written in assembly language as shown below the value specified by this item is func_task SINCLUDE kernel inc S INCLUDE kernel_id inc PUBLIC _func_task CSEG _func_task PUSH BC PUSH AX BR ext_tsk END 5 Initial priority itskpri Specifies the initial priority of the task Values that can be specified for itskpri are limited to 1 to Priority range maxtpri R20UT0511EJ0101 Rev
191. is service call pragma rtos_task func_task include lt kernel h gt Standard header file definition include lt kernel_id h gt System information header file definition void func_task VP_INT exinf T_RVER pk_rver Declares data structure UH maker Declares variable UH prid Declares variable UH spver Declares variable UH prver Declares variable UH prno 4 Declares variable PE Societe EE zy ref_ver amp pk_rver Reference version information maker pk_rver maker Reference Kernel maker s code prid pk_rver prid Reference identification number of the kernel spver pk_rver spver Reference version number of the ITRON Specification prver pk_rver prver Reference version number of the kernel prno 0 pk_rver prno 0 Reference management information of the kernel product version type prno 1 pk_rver prno 1 Reference management information of the kernel product memory model Note For details about the version information packet refer to 12 5 8 Version information packet R20UT0511EJ0101 Rev 1 01 ztENESAS Page 108 of 272 Apr 01 2012 RI78V4 CHAPTER 11 SCHEDULER CHAPTER 11 SCHEDULER This chapter describes the scheduler of the RI78V4 11 1 Outline The scheduling functions provided by the RI78V4 consist of functions manage decide the order in which tasks are executed by monitoring t
192. is set 3 System reserved area iflgptn System reserved area Values that can be specified for flgptn are limited to 0 R20UT0511EJ0101 Rev 1 01 ztENESAS Page 228 of 272 Apr 01 2012 RI78V4 CHAPTER 13 SYSTEM CONFIGURATION FILE 13 4 4 Mailbox information Define the following items as mailbox information Mailbox name mbxid Attribute queuing method mbxatr System reserved area maxmpri System reserved area mprihd The number of mailbox information items that can be specified is defined as being within the range of 0 to 127 The following shows the mailbox information format CRE_MBX mbxid mbxatr maxmpri mprihd The items constituting the mailbox information are as follows 1 Mailbox name mbxid Specifies the mailbox name An object name can be specified for mbxid Note The CF78V4 outputs to the system information header file the correspondence between the mailbox names and IDs in the following format Consequently mailbox names can be used in the place of IDs by including the relevant system information header file using the processing program Output format to system information header file for C define mbxid ID Output format to system information header file for assembly language mbxid equ ID 2 Attribute queuing method mbxair Specifies the attributes task queuing method message queuing method of the mailbox The keywor
193. isplayed If the value of the property is modified that is taken effect to the selected components all of which are common to all Edit menu only available for the Project Tree panel Undo Cancels the previous edit operation of the value of the property While editing the value of the property cuts the selected characters and copies Cut them to the clip board Copy Copies the selected characters of the property to the clip board Paste While editing the value of the property inserts the contents of the clip board Delete While editing the value of the property deletes the selected character string Select All While editing the value of the property selects all the characters of the selected property Context menu Undo Cancels the previous edit operation of the value of the property While editing the value of the property cuts the selected characters and copies Cut them to the clip board Copy Copies the selected characters of the property to the clip board R20UT0511EJ0101 Rev 1 01 tENESAS Page 250 of 272 Apr 01 2012 RI78V4 APPENDIX A WINDOW REFERENCE Paste While editing the value of the property inserts the contents of the clip board Delete While editing the value of the property deletes the selected character string Select All While editing the value of the property selects all the characters of the selected property Restores the configuration of t
194. iting 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 eventtflag wfmode TWF_ORW Checks which bit among bits to which 1 is set by parameter waiptn is set as the target eventflag Note 1 In the RI78V4 the number of tasks that can be queued to the eventtflag wait queue is one If this service call is issued for the eventflag to which a task is queued therefore E_ILUSE is returned regardless of whether or not the required condition is immediately satisfied Note 2 The RI78V4 performs bit pattern clear processing 0x0 setting when the required condition of the target eventflag TA_CLR attribute is satisfied Return value Macro Value Description E OK 0 Normal completion E ILUSE 28 Illegal service call use there is already a task waiting for an eventflag with the TA_WSGL attribute E_RLWAI 49 Forced release from waiting accept rel_wai irel_wai while waiting R20UT0511EJ0101 Rev 1 01 ztENESAS Page 176 of 272 Apr 01 2012 RI78V4 CHAPTER 12 SERVICE CALLS Outline Wait for eventflag polling C format ER pol_flg ID flgid FLGPTN waiptn MODE wfmode FLGPIN p_flgptn Assembly format OV A ES OV Cc A OVW DE p_flgptn_lo PUSH BC
195. ized memory pool information R20UT0511EJ0101 Rev 1 01 tENESAS Page 16 of 272 Apr 01 2012 RI78V4 CHAPTER 2 SYSTEM CONSTRUCTION 2 6 Creating Load Module Run a build on the CubeSuite for files created in sections from 2 2 Coding of Processing Program to 2 5 Coding of Directive File and library files provided by the RI78V4 and C compiler package to create a load module The following lists the files required for creating load modules 1 Create or load a project Create a new project or load an existing one Note See RI Series Real Time Operating System User s Manual Start or CubeSuite Integrated Development Environment User s Manual Start for details about creating a new project or loading an existing one 2 Seta build target project When making settings for or running a build set the active project If there is no subproject the project is always active Note See CubeSuite Integrated Development Environment User s Manual 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 CubeSuite Integrated Development Environment User s Manual 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 C assembly language source files created in 2 2 Coding of Processing
196. k before the change must be retired If it is not retired then the register bank could be corrupted in the task that is switched to Interrupt servicing not managed by an OS When changing a register bank in an interrupt process not matched by the OS restore the register bank number of the interrupt source when the interrupt ends Routines where changing the register bank is disabled Interrupt handler Interrupt handlers inherit the register bank number of the source of the interrupt Cyclic handler Cyclic handlers inherit the register bank number of the source of the timer handler interrupt Idle routine In the idle routine the initial register bank number is set permanently to 0 Initialization routine In the initialization routine the initial register bank number is set permanently to 0 It is overwritten by register bank 0 regardless of the register bank set before OS initialization before the call to the __urx_start function R20UT0511EJ0101 Rev 1 01 2tENESAS Page 260 of 272 Apr 01 2012 RI78V4 APPENDIX B CAUTIONS B 3 Pointer Declarations When passing a pointer to the RI78V4 service call care is needed to ensure that a far pointer is passed Behavior is not guaranteed subsequent to passing a near pointer Particular care is needed if a small model or medium model is selected because pointers will be near if not explicitly declared as near or far As shown below explicitly declare the pointer as far
197. leted 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 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 Output folder Default BuildModeName How io Directly enter to the text box or edit by the Browse For Folder dialog box which appears when clicking the change button Restriction Up to 247 characters R20UT0511EJ0101 Rev 1 01 tENESAS Page 254 of 272 Apr 01 2012 RI78V4 APPENDIX A WINDOW REFERENCE 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 asm If the extension is different or omitted asm is automatically added This property is not displayed when No It does not register the file that is File name added to the project ni in the Generate a file property is selected Default sit asm pow tg Directly enter to the text box
198. lg 172 twai_flg 179 wai_flg 175 eventtflag information 228 eventtflag state packet 132 ext_tsk 144 F FCFS method 109 fixed sized memory pool 66 get_mpf 192 pget_mpf 194 ref_mpf 199 rel_mpf 197 tget_mpf 195 fixed sized memory pool information 230 fixed sized memory pool state packet 135 frsm_tsk 161 G get_mpf 192 get_tid 208 l iact_tsk 139 ican_wup 155 ichg_pri 146 idle routine 13 119 basic form 119 internal processing 120 ifrsm_tsk 161 R20UT0511EJ0101 Rev 1 01 Apr 01 2012 2tENESAS Page 262 of 272 RI78V4 APPENDIX C INDEX iget_tid 208 prcv_mbx 187 iloc_cpu 209 rcv_mbx 185 initialization routine 13 106 basic form 106 internal processing 107 initial priority 24 interrupt entry processing 13 93 basic form 94 internal processing 94 interrupt handler 12 95 basic form 96 internal processing 98 interrupt management function 93 irel_wai 156 irot_rdq 206 irsm_tsk 159 iset_flg 172 isig_sem 164 ista_tsk 142 isus tsk 157 iunl_cpu 211 iwup_tsk 153 K k_const segment 15 66 k_data segment 15 66 kernel initialization module 107 k_info segment 15 66 k_stack segment 15 66 k_system segment 15 66 k_workO segment 16 66 k_work1 segment 16 66 k_work2 segment
199. lowing describes an example for coding this service call pragma rtos_task func_task include lt kernel h gt Standard header file definition include lt kernel_id h gt System information header file definition void func_task VP_INT exinf ID semid ID_semA Declares and initializes variable T_RSEM pk_rsem Declares data structure ID wt skid Declares variable UINT semcnt Declares variable aore ae eae ref_sem semid amp pk_rsem Reference semaphore state wtskid pk_rsem wtskid Reference ID number of the task at the head of the wait queue semcnt pk_rsem semcnt Reference current resource count a a eee ee ay Note For details about the semaphore state packet refer to 12 5 2 Semaphore state packet R20UT0511EJ0101 Rev 1 01 2tENESAS Page 49 of 272 Apr 01 2012 CHAPTER 5 SYNCHRONIZATION AND COMMUNICATION RI78V4 FUNCTIONS 5 3 Eventflags The RI78V4 provides 16 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 Eventflag Task Task Priority High Priority Low Wait for eventflag Queuing period Set eventtflag 5 3 1 Create eventflag In the RI78V4 the method of creating an eventtflag is limited to static c
200. meter Description 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_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 Note 1 If the target task is moved to the READY state after this service call is issued this service call also re queues the task at the end of the ready queue corresponding to the priority of the task Note 2 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 Return value Macro Value Description E OK 0 Normal completion Object state error specified task is neither in the WAITING state nor WAITING E SUSPENDED state R20UT0511EJ0101 Rev 1 01 ztENESAS Page 156 of 272 Apr 01 2012 RI78V4 CHAPTER 12 SERVICE CALLS Outline Suspend task C format ER sus_tsk ID tskid ER isus_tsk ID tskid Assembly format MOVW AX tskid CALL sus_tsk MOVW AX tskid CAL
201. ms constituting the task information are as follows 1 Task name tskid Specifies the task name An object name can be specified for tskid Note The CF78V4 outputs to the system information header file the correspondence between the task names and IDs in the following format Consequently task names can be used in the place of IDs by including the relevant system information header file using the processing program Output format to system information header file for C define tskid ID Output format to system information header file for assembly language tskid equ ID 2 Attribute coding language initial activation status initial interrupt status tskatr Specifies the attributes coding language initial activation status initial interrupt status of the task The keywords that can be specified for tskatr are TA_HLNG TA_ASM TA_ACT TA_ENAINT and TA_DISINT Coding language TA_HLNG Start a processing unit through a C language interface TA_ASM Start a processing unit through an assembly language interface Initial activation status TA_ACT Task is activated after the creation R20UT0511EJ0101 Rev 1 01 2tENESAS Page 224 of 272 Apr 01 2012 RI78V4 CHAPTER 13 SYSTEM CONFIGURATION FILE Initial interrupt status TA_ENAINT Enables acknowledgment of maskable interrupts TA_DISINT Disables acknowledgment of maskable interrupts Note 1 If specification of TA_ACT
202. n routine registration is realized by coding initialization routines by using the prescribed function name init_handler The RI78V4 executes initialization routine registration processing based on relevant symbol information using the Kernel Initialization Module and handles the registered initialization routines as management targets 10 3 2 Undefine initialization routine In the RI78V4 initialization routines registered statically by the Kernel Initialization Module cannot be unregistered dynamically using a method such as issuing a service call from a processing program 10 3 3 Basic form of initialization routine Write initialization routines using void type functions that do not have arguments function init_handler The following shows the basic form of initialization routine C Language include lt kernel h gt Standard header file definition include lt kernel_id h gt System information header file definition void init_handler void PP soe Se aces baa a Main processing return Terminate initialization routine Assembly Language SINCLUDE kernel inc Standard header file definition S INCLUDE kernel_id inc System information header file definition PUBLIC _init_handler CSEG _init_handler Ph senate ahore ean anes Main processing RET Terminate initialization routine END R20UT0511EJ0101 Rev 1 01 2tENESAS Page 106 of 272 Apr 01 2012
203. n 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 pragma rtos_task func_task include lt kernel h gt Standard header file definition include lt kernel_id h gt System information header file definition void func_task VP_INT exinf ID semid ID_semA Declares and initializes variable JE marende Di aaia A sig_sem semid Release semaphore resource JE apee a aes Note 1 If the first task linked in the wait queue is moved to the READY state after this service call is issued this service call also re queues the task at the end of the ready queue corresponding to the priority of the task Note 2 The semaphore counter managed by the RI78V4 is configured in 7 bit widths If the number of resources 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 R20UT0511EJ0101 Rev 1 01 ztENESAS Page 45 of 272 Apr 01 2012 CHAPTER 5 SYNCHRONIZATION AND COMMUNICATIO
204. nc_cychdr CSEG _func_cychadr oY eae RE Ew ROA Main Processing RET Terminate cyclic handler END R20UT0511EJ0101 Rev 1 01 2tENESAS Page 75 of 272 Apr 01 2012 RI78V4 CHAPTER 7 TIME MANAGEMENT FUNCTIONS 7 5 4 Internal processing of cyclic handler The RI78V4 handles the cyclic handler as a non task Moreover the RI78V4 executes original pre processing when passing control to the cyclic handler as well as original post processing when regaining control from the cyclic handler Therefore note the following points when coding cyclic handlers Coding method Code cyclic handlers using C or assembly language in the format shown in 7 5 3 Basic form of cyclic handlers Stack switching The RI78V4 executes processing to switch to the system stack when passing control to the cyclic handler and processing to switch to the stack for the switch destination processing program system stack or task stack when regaining control from the cyclic handler The user is therefore not required to code processing related to stack switching in cyclic handlers Interrupt status Maskable interrupt acknowledgement is prohibited in the RI78V4 when control is passed to the cyclic handler To change enable the interrupt status in the cyclic handler writing of pragma EIl directive and calling of the El function are therefore required Service call issuance The RI78V4 handles the cyclic handler as a non task Serv
205. nctions sta_cyc 0 8 4 stp_cyc 0 8 4 ref_cyc 4 8 4 System State Management Functions rot_rdq irot_rdq 0 8 4 get_tid iget_tid 0 8 4 loc_cpu iloc_cpu 0 8 4 unl_cpu iunl_cpu 0 8 4 ena_dsp 0 8 4 dis_dsp 0 8 4 sns_ctx 0 8 4 sns_loc 0 8 4 sns_dsp 0 8 4 sns_dpn 0 8 4 System Configuration Management Functions ref_ver 0 8 4 R20UT0511EJ0101 Rev 1 01 ztENESAS Page 125 of 272 Apr 01 2012 RI78V4 CHAPTER 12 SERVICE CALLS 12 4 Data Macros This section explains the data macros for data types current state or the like used when issuing a service call provided by the RI78V4 12 4 1 Datatypes The following lists the data types of parameters specified when issuing a service call Macro definition of the data type is performed by header file lt ri_root gt include os types h which is called from standard header file lt ri_root gt include kernel h Table 12 2 Data Types Macro Data Type Description UH unsigned short int Unsigned 16 bit integer VP void __ far Pointer to an unknown data type UINT unsigned int Unsigned 16 bit integer VP_INT signed long int adi to an unknown data type or a signed 32 bit ID Note unsigned char Object ID number BOOL signed int Boolean value STAT unsigned short int Object state ER signed short int Return value ER_UINT unsigned short int Unsigned 16 bit integer PRI signed char Priority FLGPTN unsigned short int Bit pattern MODE unsigned char Serv
206. nd the restriction on service call issuance is released If a maskable interrupt is created during the interval from when either loc_cpu or iloc_cpu is issued until this service call is issued the RI78V4 delays transition to the relevant interrupt processing interrupt handler until this service call is issued The following describes an example for coding this service call pragma rtos_task func_task include lt kernel h gt Standard header file definition include lt kernel_id h gt System information header file definition void func_task VP_INT exinf PR a paai ab Hise my ise epu Fy Lock the CPU Res oe Roe ew ES my CPU locked state unl_cpu Unlock the CPU TOP se cele eaoaai 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 The RI78V4 implements enabling of maskable interrupt acknowledgment bu manipulating the interrupt mask flag register MKxx and the in service priority flag ISPx of the program status word PSW Therefore manipulating of these registers from the processing program is prohibited from when loc_cpu or iloc_cpu is issued until this service call is issued R20UT0511EJ0101 Rev 1 01 2tENESAS Page 85 of 272 Apr 01 2012 RI78V4 CHAPTER 8 SYSTEM STATE MANAGEMENT FUNCTIONS 8 6 Disable Dispatching A task is moved
207. nformation header file definition void func_task VP_INT exinf ID cycid ID_cycA Declares and initializes variable PEO BRE See See sta_cyc cycid Start cyclic handler operation PR atari lid ai Re E uae Note This service call does not perform queuing of start requests If the target cyclic handler has been moved to the operational state STA state only activation cycle re set processing is executed The relative time interval from the output of this service call until the first activation request is output is always the activation phase activation cycle cyctim using the output of this service call as the reference point Cyclic handler activation image r Start m Start m Start m Start Start cyctin w cyctim w cyctim w cyctim w cyctim cyctim w cyctim cyctim l A 1 ra Activation enabled by sta_cyc Activation enabled by sta_cyc Activation disabled by stp_cyc Creation TA_STA attribute R20UT0511EJ0101 Rev 1 01 ztENESAS Page 77 of 272 Apr 01 2012 RI78V4 CHAPTER 7 TIME MANAGEMENT FUNCTIONS 7 5 6 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 This service call moves the cyclic handler specified by parameter cycid from the operational state STA state to non operational state STP state
208. ng 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 pragma rtos_task func_task include lt kernel h gt Standard header file definition include lt kernel_id h gt System information header file definition void func_task VP_INT exinf ID flgid ID_flgA Declares and initializes variable FLGPTN setptn 0B1010 Declares and initializes variable oP E EE a bai zy set_flg flgid setptn Set eventflag Note 1 If the task linked in the wait queue is moved to the READY state after this service call is issued this service call also re queues the task at the end of the ready queue corresponding to the priority of the task Note 2 If 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 R20UT0511EJ0101 Rev 1 01 2tENESAS Page 51 of 272 Apr 01 2012 CHAPTER 5 SYNCHRONIZATION AND COMMUNICATION RI78V4 FUNCTIONS 5 3 4 Clear eventflag A bit pattern is cleared by issuing the following service call from the processing program clr_fig This service call sets the result of ANDing the bit pattern set to the eventflag specified by parameter flgid and the bit
209. nics 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 Readers Purpose Organization How to Read This Manual Conventions How to Use This Manual This manual is intended for users who design and develop application systems using RL78 family and 78KOR microcontrollers products This manual is intended for users to understand the functions of real time OS RI78V4 manufactured by Renesas Electronics described the organization listed below This manual consists of the following major sections CHAPTER 1 CHAPTER 2 CHAPTER 3 CHAPTER 4 CHAPTER 5 CHAPTER 6 CHAPTER 7 CHAPTER 8 CHAPTER 9 CHAPTER 10 CHAPTER 11 CHAPTER 12 CHAPTER 13 CHAPTER 14 APPENDIX A APPENDIX B APPENDIX C OVERVIEW SYSTEM CONSTRUCTION TASK MANAGEMENT FUNCTIONS TASK DEPENDENT SYNCHRONIZATION FUNCTIONS SYNCHRONIZATION AND COMMUNICATION FUNCTIONS MEMORY POOL MANAGEMENT FUNCTIONS TIME MANAGEMENT FUNCTIONS SYSTEM STATE MANAGEMENT FUNCTIONS INTERRUPT MANAGEMENT FUNCTIONS SYSTEM CONFIGURATION MANAGEMENT FUNCTIONS SCHEDULER SERVICE CALLS SYSTEM CONFIGURATION FILE CONFIGURATOR CF78V4 WINDOW REFERENCE CAUTIONS INDEX It is assumed that the readers of this manual have general knowledg
210. nitializes the following information to values that are set during task creation Priority current priority Wakeup request count Suspension count Interrupt status Return value Macro Value Description E OK 0 Normal completion E OBJ 41 Object state error specified task is in the DORMANT state R20UT0511EJ0101 Rev 1 01 ztENESAS Page 145 of 272 Apr 01 2012 RI78V4 CHAPTER 12 SERVICE CALLS chg_pri ichg_pri Outline Change task priority C format ER chg_pri ID tskid PRI tskpri ER ichg_pri ID tskid PRI tskpri Assembly format OVW AX tskpri PUSH AX OVW AX tskid CALL t1 chg_pri POP AX OVW AX tskpri PUSH AX OVW AX tskid CALL _ichg_pri POP AX Parameter s O Parameter Description ID number of the task whose priority is to be changed 1D tskid TSK_SELF Invoking task Value ID number of the task whose priority is to be changed New current priority of the task PRI tskprij TPRI_INI Initial priority of the task Value New current priority of the task Explanation These service calls change the priority of the task specified by parameter tskid current priority to a value specified by parameter tskpri Note 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
211. ntflag TA_CLR attribute is satisfied R20UT0511EJ0101 Rev 1 01 2tENESAS Page 54 of 272 Apr 01 2012 RI78V4 CHAPTER 5 SYNCHRONIZATION AND COMMUNICATION FUNCTIONS pol_fig This service call checks whether the bit pattern specified by parameter waipin and the bit pattern that satisfies the required condition specified by parameter wfmode are set to the eventtflag 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 eventflag is stored in the area specified by parameter p_flgptn If the bit pattern of the E TMOUT is returned target eventflag does not satisfy the required condition when this service call is issued 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 eventtflag 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 pragma rtos_task func_task include lt kernel h gt Standard header file definition include lt kernel_id h gt System information header file definition void func_task VP_INT exinf ER ercd Declares variable ID flgid ID_fl1gA Declares and initializes variable FLGPTN
212. ntflag wait queue is one If this service call is issued for the eventflag to which a task is queued therefore E_ILUSE is returned regardless of whether or not the required condition is immediately satisfied Note 2 The RI78V4 performs bit pattern clear processing 0x0 setting when the required condition of the target eventflag TA_CLR attribute is satisfied Note 3 Inthe RI78V4 the number of tasks that can be queued to the eventflag wait queue is one If this service call is issued for the eventflag to which a task is queued therefore E_ILUSE is returned regardless of whether or not the required condition is immediately satisfied Note 4 The RI78V4 performs bit pattern clear processing 0x0 setting when the required condition of the target eventflag TA_CLR attribute is satisfied Return value Macro Value Description E OK 0 Normal completion i Illegal service call use there is already a task waiting for an eventflag with the a 28 TA WSGL attribute E TMOUT 50 Polling failure R20UT0511EJ0101 Rev 1 01 tENESAS Page 178 of 272 Apr 01 2012 RI78V4 CHAPTER 12 SERVICE CALLS Outline Wait for eventflag with timeout C format ER twai_flg ID flgid FLGPTN waiptn MODE wfmode FLGPTIN p_flgptn TMO tmout Assembly format OVW AX tmout_hi PUSH AX OVW AX tmout_lo PUSH AX OV A
213. o 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 in the format shown in 11 7 3 Basic form of idle routine Stack switching The RI78V4 executes processing to switch to the system stack when passing control to the idle routine and processing to switch to the stack for the switch destination processing program system stack or task stack when regaining control from the idle routine The user is therefore not required to code processing related to stack switching in idle routines Interrupt status Maskable interrupt acknowledgement is prohibited in the RI78V4 when control is passed to the idle routine The user is therefore not required to write the code related to maskable interrupt acknowledgment in idle routines Service call issuance The RI78V4 prohibits issuance of service calls in idle routines The following lists processing that should be executed in idle routines Effective use of standby function provided by the CPU R20UT0511EJ0101 Rev 1 01 2tENESAS Page 120 of 272 Apr 01 2012 RI78V4 CHAPTER 12 SERVICE CALLS CHAPTER 12 SERVICE CALLS This chapter describes the service calls supported by the RI78V4 12 1 Outline The service calls provided by the RI78V4 are service routines provided for indirectly manipulating the resources
214. of the processing required to realize delayed wakeup of tasks timeout during the WAITING state and cyclic handler activation and is called from the interrupt handler that is activated upon output of a timer interrupt Note The timer handler is part of the functions provided by the RI78V4 The user therefore need not code the processing contents of the timer handler 7 2 1 Define timer handler Timer handler registration is realized by coding the timer handler function name Timer_Handler call processing in the interrupt handler to be activated upon occurrence of a timer interrupt A timer handler call example is described below pragma rtos_interrupt INTTMOO func_inthdr include lt kernel h gt Standard header file definition include lt kernel_id h gt System information header file definition void func_inthdr void Timer_Handler Call timer handler return Terminate timer handler R20UT0511EJ0101 Rev 1 01 2tENESAS Page 73 of 272 Apr 01 2012 RI78V4 CHAPTER 7 TIME MANAGEMENT FUNCTIONS 7 3 Delayed 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
215. on File Related Information tab R20UT0511EJ0101 Rev 1 01 2tENESAS Page 240 of 272 Apr 01 2012 RI78V4 CHAPTER 14 CONFIGURATOR CF78V4 14 2 3 Command file The CF78V4 performs command file support from the objectives that eliminate specified probable activation option character count restrictions in the command lines Description formats of the command file are described below 1 Comment lines Lines that start with are treated as comment lines 2 Dilimiting activation options Delimit activation options using a space code tab code or a linefeed code Note For activation options consist of the xxx part and parameter part like iA lt SIT file gt dcA lt C header file gt and daA lt ASM header file gt delimit the xxx part and parameter part using a space code tab code or a linefeed code When specifying a folder name that includes a space code in the parameter part enclose the parameter part using double quotation marks as shown in Figure 14 1 3 Maximum number of characters Up to 50 lines and up to 4 096 characters per line can be coded in a command file The following shows an example of activation option coding whereby system configuration file CF_file cfg is loaded from the current folder system information table filesit_file asm is output to a folder in C Program Files tmp system information header file C_header h for C is output to a folder in C tmp system information header file ASM_header in
216. on header file definition void func_task VP_INT exinf ID tskid ID_tskA Declares and initializes variable PRO aore abe aaa als sus_tsk tskid Suspend task JE wud a wei a ks as ep Note 1 If the target task is the invoking task when this service call is issued it is unlinked from the ready queue and excluded from the RI78V4 scheduling subject Note 2 The suspend request counter managed by the RI78V4 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 R20UT0511EJ0101 Rev 1 01 ztENESAS Apr 01 2012 Page 40 of 272 RI78V4 CHAPTER 4 TASK DEPENDENT SYNCHRONIZATION FUNCTIONS 4 7 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 the 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
217. ot available Interrupt level 3 Available Not available If a user application disables multiple interrupts then it is necessary to set the interrupt level of the interrupt handler process to one of the patterns shown below Pattern 1 Set the level of all interrupt handlers and interrupt processes to 2 Pattern 2 Set the level of all interrupt handlers and interrupt processes to 3 Pattern 3 Set the level of all interrupt handlers and to 2 and the level of all interrupt processes to either 2 or 3 Interrupts are disabled during an interrupt process with an interrupt level of 3 IE 0 Table 9 4 Settable Interrupt Level Disabling Multiple Interrupts from User Application Pattern 1 Pattern 2 Pattern 3 Interrupt Interrupt Interrupt Interrupt Interrupt Interrupt Handler Servicing Handler Servicing Handler Servicing Interrupt level 0 Not available Not available Not available Not available Not available Not available Interrupt level 1 Not available Not available Not available Not available Not available Not available Interrupt level 2 Available Available Not available Not available Available Available Interrupt level 3 Not available Not available Available Available Not available Available Interrupts are disabled during this interrupt process IE 0 R20UT0511EJ0101 Rev 1 01 Apr 01 2012 2tENESAS Page 102 of 272 CHAPTER
218. out C format ER trcv_mbx ID mbxid T_MSG ppk_msg TMO tmout Assembly format OVW AX tmout_hi PUSH AX OVW AX tmout_lo PUSH AX OV A ES OV Cc A OVW DE ppk_msg_lo PUSH BC PUSH DE OVW AX mbxid CALL _trcev_mbx addw sp 08H Parameter s O Parameter ID mbxid ID number of the mailbox from which a message is received O MSG ppk_msgj Start address of the message packet received from the mailbox Specified timeout unit ticks TMO tmout TMO_FEVR Waiting forever TMO_POL Polling Value Specified timeout 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 the invoking task is queued to the target mailbox wait queue in the order of message reception request FIFO order As a result the invoking task is unlinked from the ready queue and is moved from the RUNNING state to the WAITING state receiving waiting state for a mailbox The receiving waiting state for a mailbox is cancelled in the following cases and then moved to the READY state R20UT0511EJ0101 Rev 1 01 Apr 01 2012 ztENESAS Page 188 of 272 RI78V4 CHA
219. p request has been issued indicates 0x0 upon the issuance of a slp_tsk or tslp_tsk A task enters this state upon the issuance of a dly_tsk A task enters this state if it cannot acquire a resource from the relevant semaphore upon the issuance of a wai_sem or twai_sem A task enters this state if a relevant eventflag does not satisfy a predetermined condition upon the issuance of a wai_flg or twai_flg A task enters this state if cannot receive a message from the relevant mailbox upon the issuance of a rcv_mbx or trcv_mbx A task enters this state if it cannot acquire a fixed sized memory block from the relevant fixed sized memory pool upon the issuance of a get_mpf or tget_mpf wobjid rtsk_wobjid D number for which the task is waiting lefttmo rtsk_lefttmo System reserved area actent rtsk_actcnt Stores the activation request count of the task wupcnt rtsk_wupcnt Stores the wakeup request count of the task suscnt rtsk_suscnt Stores the suspention count of the task R20UT0511EJ0101 Rev 1 01 2tENESAS Page 130 of 272 Apr 01 2012 RI78V4 CHAPTER 12 SERVICE CALLS 12 5 2 Semaphore state packet The following shows semaphore state packet T_RSEM used when issuing ref_sem Definition of semaphore state packet T_RSEM is performed by header file lt ri_root gt include os packet h packet inc which is called from standard header file lt ri_root gt include kernel h kernel inc packet h typed
220. 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 The following describes an example for coding this service call pragma rtos_task func_task include lt kernel h gt Standard header file definition include lt kernel_id h gt System information header file definition void func_task VP_INT exinf rae eee dis_dsp Disable dispatching PR ese toe ts isa iatoaciold xf Dispatching disabled state ena_dsp Enable dispatching JOP pic EEEE Note 1 This service call does not perform queuing of disable requests If the system is in the dispatching disabled state therefore no processing is performed but it is not handled as an error Note 2 The dispatching disabled state changed by issuing this service call must be cancelled before the task that issued this service call moves to the DORMANT state R20UT0511EJ0101 Rev 1 01 2tENESAS Page 116 of 272 Apr 01 2012 RI78V4 CHAPTER 11 SCHEDULER 11 5 2 Enable dispatching The dispatching 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 dispatching enabled state As a result dispatch processing task scheduling that has been disabled by issuing dis_dsp is enabled If a servic
221. quired 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 RI78V4 the method of creating a semaphore is limited to static creation by the Kernel Initialization Module Semaphores therefore cannot be created dynamically using a method such as issuing a service call from a processing program Static create Static semaphore creation is realized by defining Semaphore information in the system configuration file The RI78V4 executes semaphore creation processing based on data stored in information files using the Kernel Initialization Module and handles the created semaphores as management targets 5 2 2 Delete semaphore In the RI78V4 semaphores created statically by the Kernel Initialization Module cannot be deleted dynamically using a method such as issuing a service call from a processing program R20UT0511EJ0101 Rev 1 01 ztENESAS Page 44 of 272 Apr 01 2012 CHAPTER 5 SYNCHRONIZATION AND COMMUNICATION RI78V4 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 i
222. r for which the task is waiting TMO lefttmo Reserved for future use UINT act cnt Activation request count UINT wupcnt Wakeup request count UINT suscnt Suspension count T_RTSK packet inc rtsk_tskstat EQU 00h Task current state rtsk_tskpri EQU 02h Task current priority rtsk_tskbpri EQU 03h Reserved for future use rtsk_tskwait EQU 04h Reason for waiting rtsk_wobjid EQU 06h Object ID number for which the task is waiting rtsk_lefttmo EQU 08h Reserved for future use rtsk_actcnt EQU Och Activation request count rtsk_wupcnt EQU Oeh Wakeup request count rtsk_suscnt EQU 10h Suspension count The following shows details on task state packet T_RTSK tskstat rtsk_tskstat Stores the current state of the task 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 rtsk_tskpri Stores the current priority of the task tskbpri rtsk_tskbpri System reserved area tskwait risk_tskwait Stores the reason for waiting TTW_NONE Has not moved to the WAITING state R20UT0511EJ0101 Rev 1 01 ztENESAS Page 129 of 272 Apr 01 2012 RI78V4 CHAPTER 12 SERVICE CALLS TTW_SLP TTW_DLY TTW_SEM TTW_FLG TTW_MBX TTW_MPF Stores the object A task enters this state if the counter for the task registering the number of times the wakeu
223. r tasks is assigned to each task As a result in the RI78V4 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 RI78V4 the following two types of priorities are used for management purposes Task initial priority Priority set when a task is created Task current priority This is the general term used to describe the priority level of a task from the time it enters the READY state from the DORMANT state until it returns to the DORMANT state Therefore the current priority level of a task that enters the READY state from the DORMANT state has the same value as the initial priority level and the current priority level when the priority level is changed by issuing chg_pri or ichg_pri is the same value as the priority level after change Note 1 In the RI78V4 a task having a smaller priority number is given a higher priority Note 2 The priority that can be specified in a system is in the priority range specified in Task priority information 3 2 3 Create task In the RI78V4 the method of creating a task is limited to static creation by the Kernel Initialization Module Tasks therefore cannot be created dynamically using a method such as issuing a service call from a processing program Static create Static task creation is realized by defining Task information in the system configuration file The RI78
224. rameter Description 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 RI78V4 Note This service call does not perform queuing of start requests If the target cyclic handler has been moved to the operational state STA state only activation cycle re set processing is executed The relative time interval from the output of this service call until the first activation request is output is always the activation phase activation cycle cyctim using the output of this service call as the reference point Cyclic handler activation image r Start r Start Start r Start Start cyctin w cyctim w cyctin w cyctim w cyctim cyctim w cyctim l cyctim A A a Activation enabled by sta_cyc Activation enabled by sta_cyc Activation disabled by stp_cyc Creation TA_STA attribute R20UT0511EJ0101 Rev 1 01 2tENESAS Page 201 of 272 Apr 01 2012 RI78V4 CHAPTER 12 SERVICE CALLS Return value Macro Value Description E OK 0 Normal completion R20UT0511EJ0101 Rev 1 01 2tENESAS Page 202 of 272 Apr 01 2012 RI78V4 CHAPTER 12 SERVICE CALLS Outline Stop cyclic handler operation
225. rce 45 5 2 4 Acquire semaphore resource 46 5 2 5 Reference semaphore state 49 5 3 Eventflags 50 5 3 1 Create eveniflag 50 5 3 2 Delete eventflag 50 5 3 3 Set eventflag 51 5 3 4 Clear eventflag 52 5 3 5 Wait for eventflag 53 5 3 6 Reference eventflag state 58 5 4 Mailboxes 59 5 4 1 Create mailbox 59 5 4 2 Delete mailbox 59 5 4 3 Message 60 5 4 4 Send to mailbox 61 5 4 5 Receive from mailbox 62 5 4 6 Reference mailbox state 65 CHAPTER 6 MEMORY POOL MANAGEMENT FUNCTIONS 66 6 1 Outline 66 6 2 Fixed Sized Memory Pool 66 6 2 1 Create fixed sized memory pool 66 6 2 2 Delete fixed sized memory pool 67 6 2 3 Acquire fixed sized memory block 67 6 2 4 Release fixed sized memory block 71 6 2 5 Reference fixed sized memory pool state 72 CHAPTER 7 TIME MANAGEMENT FUNCTIONS 73 7 1 Outline 73 7 2 Timer Handler 73 7 2 1 Define timer handler 73 7 3 Delayed Wakeup 74 7 4 Timeout 74 7 5 Cyclic Handlers 75 7 5 1 Create cyclic handler 75 7 5 2 Delete cyclic handler 75 7 5 3 Basic form of cyclic handlers 75 7 5 4 Internal processing of cyclic handler 76 7 5 5 Start cyclic handler operation 77 7 5 6 Stop cyclic handler operation 78 7 5 7 Reference cyclic handler state 79 CHAPTER 8 SYSTEM STATE MANAGEMENT FUNCTIONS 80 8 1 Outline 80 8 2 Rotate Task Precedence 80
226. reation by the Kernel Initialization Module Eventflags therefore cannot be created dynamically using a method such as issuing a service call from a processing program Static create Static eventflag creation is realized by defining Eventflag information in the system configuration file The RI78V4 executes eventflag creation processing based on data stored in information files using the Kernel Initialization Module and handles the created eventflags as management targets Note In the RI78V4 0x0 is the initial bit pattern for eventflag creation processing 5 3 2 Delete eventflag In the RI78V4 eventflags created statically by the Kernel Initialization Module cannot be deleted dynamically using a method such as issuing a service call from a processing program R20UT0511EJ0101 Rev 1 01 ztENESAS Page 50 of 272 Apr 01 2012 CHAPTER 5 SYNCHRONIZATION AND COMMUNICATION RI78V4 FUNCTIONS 5 3 3 Set eventflag A 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 ORing the bit pattern of the eventflag specified by parameter figid and the bit pattern specified by parameter sefptn as the bit pattern of the target eventtflag 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 processi
227. rective the user is not required to write the relevant interrupt entry processing because the C compiler automatically outputs the interrupt entry processing corresponding to the interrupt request name R20UT0511EJ0101 Rev 1 01 ztENESAS Page 93 of 272 Apr 01 2012 RI78V4 CHAPTER 9 INTERRUPT MANAGEMENT FUNCTIONS 9 2 1 Basic form of interrupt entry processing The code of interrupt entry processing varies depending on whether the relevant processing Interrupt Handlers Boot Processing or the like is allocated to the near area or to the far area The following shows examples for coding interrupt entry processing When the relevant processing Interrupt Handlers Boot Processing or the like is allocated to the near area RESET CSEG A 0000h Vector table address setting DW _boot Jump to boot processing INTTMOO CSEG A 002ch Vector table address setting DW _func_inthdr Jump to interrupt handler When the relevant processing Interrupt Handlers Boot Processing or the like is allocated to the far area EXTRN intent_RESET Declares symbol external referenc EXTRN intent_INTTMOO Declares symbol external referenc RESET CSEG A 0000h Vector table address setting DW intent_RESET INTTMOO CSEG A 002ch Vector table address setting DW intent_INTTM00 intent CSEG UNITP intent_RESET BR l _boot Jump to boot processing intent_INTTMOO0 BR func_inthdr Jump to interrupt
228. riable FLGPTN waiptn 0B1110 Declares and initializes variable ODE wfmode TWF_ANDW Declares and initializes variable FLGPIN p_figptn Declares variable TMO tmout 3600 Declares and initializes variable LR RES Wait for eventflag with timeout ercd twai_flg flgid waiptn wfmode amp p_flgptn tmout pragma rtos_task func_task include lt kernel h gt Standard header file definition include lt kernel_id h gt System information header file definition void if ercd E_OK PE Geshe a genoa K Normal termination processing else if ercd E_RLWAI UR SEEDEDE ENNA E Forced termination processing lse if ercd E_TMOUT PPR aaa a tras os Spans J Timeout processing R20UT0511EJ0101 Rev 1 01 2tENESAS Page 56 of 272 Apr 01 2012 CHAPTER 5 SYNCHRONIZATION AND COMMUNICATION RI78V4 FUNCTIONS Note 1 In the RI78V4 the number of tasks that can be queued to the eventflag wait queue is one If this service call is issued for the eventflag to which a task is queued therefore E_ILUSE is returned regardless of whether or not the required condition is immediately satisfied Note 2 The RI78V4 performs bit pattern clear processing 0x0 setting when the required condition of the target eventflag TA_CLR attribute is satisfied Note 3 When TMO_FEVR is specified for wait time tmout processing equivalent to wai_flg will be executed Wh
229. ro Value Description E OK 0 Normal completion E RLWAI 49 Forced release from waiting accept rel_wai irel_wai while waiting R20UT0511EJ0101 Rev 1 01 Apr 01 2012 2tENESAS Page 186 of 272 RI78V4 CHAPTER 12 SERVICE CALLS Outline Receive from mailbox polling C format ER prcev_mbx ID mbxid T_MSG ppk_msg Assembly format MOV A ES MOV C A MOVW DE ppk_msg_lo PUSH BC PUSH DE MOVW AX mbxid CALL prcv_mbx addw sp 04H 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 packet received from the mailbox 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 For details about the message packet refer to 12 5 4 Message packet Return value Macro Value Description E OK 0 Normal completion E TMOUT 50 Polling failure R20UT0511EJ0101 Rev 1 01 2tENESAS Page 187 of 272 Apr 01 2012 RI78V4 CHAPTER 12 SERVICE CALLS Outline Receive from mailbox with time
230. rocessing is therefore not performed but E_OBu is returned Note 2 An start code staca is passed to the task activated by issuing this service call R20UT0511EJ0101 Rev 1 01 2tENESAS Page 28 of 272 Apr 01 2012 RI78V4 CHAPTER 3 TASK MANAGEMENT FUNCTIONS 3 4 An activation request is cancelled by issuing the following service call from the processing program can_act This service call cancels all of the activation requests queued to the task specified by parameter tskid sets the activati When this service call is terminated normally the number of cancelled activation requests is returned on request counter to 0x0 Cancel Task Activation Requests The following describes an example for coding this service call pra inc inc void gma rtos_task lude lt kernel h gt lude lt kernel_id h gt func_task VP_INT exinf ER_UINT ercd ID tskid ID_tskA PPR sec da mack gets eddie ercd can_act tskid if ercd gt 0x0 JE os deel areata EJ func_task Standard header file definition System information header file definition Declares variable Declares and initializes variable Cancel task activation requests Normal termination processing R20UT0511EJ0101 Rev 1 01 Apr 01 201 2 2tENESAS Page 29 of 272 RI78V4 CHAPTER 3 TASK MANAGEMENT FUNCTIONS 3 5 Terminate Task The RI78V4 provides two types of interfa
231. rrupt handlers written using the pragma rtos_interrupt directive or __rtos_interrupt qualifier the user is not required to write the relevant stack switch processing because the C compiler automatically outputs the calls for system stack switch processing function name _kernel_int_entry When coding interrupt handlers in assembly language save registers and saddr areas at the beginning of the interrupt handler call processing to switch to the system stack function name _kernel_int_entry and then call end processing at the end of the interrupt handler function name ret_int explicitly Saving storing of data in register and saddr areas When executing an interrupt handler written with the pragma rtos_interrupt directive or __rtos_interrupt qualifier the user does not need to write save store processing for it because the C compiler automatically outputs _kernel_int_entry ret_int When executing an interrupt handler written in the assembly language data of general purpose registers AX BC DE HL and registers ES CS is saved and restored in that function execution by explicitly calling register data save processing function name _kernel_int_entry at the beginning of the interrupt handler and calling data restore processing function name ret_int at the end of the interrupt handler Saving and restoring of data in the saadr area RTARGxx _ SEGAX or _SEGDE must be written explicitly before and after main processing of interrupt
232. s RAM area OVW BC 0FE20H 0D700H R20UT0511EJ0101 Rev 1 01 tENESAS Page 104 of 272 Apr 01 2012 CHAPTER 10 SYSTEM CONFIGURATION MANAGEMENT RI78V4 FUNCTIONS CLRW AX LSADR2 DECW BC DECW BC OVW OD7OOH BC AX CMPW AX BC BNZ SLSADR2 BR __urx_start Jump to Kernel Initialization Module END 10 2 3 Internal processing of boot processing Boot processing is a routine dedicated to initialization processing called from Interrupt Entry Processing without using the RI78V4 Therefore note the following points when coding boot processing Coding method Code boot processing in assembly language 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 Interrupt status The Kernel Initialization Module is not executed at the point when control is passed to boot processing The system may therefore hang up when an interrupt is created before the processing is completed To avoid this explicitly prohibit acknowledgment of maskable interrupts by manipulating interrupt enable flag IE of program status word PSW during boot processing Register bank setting The RI78V4 prohibits switching of a register bank that was set before __urx_start is called in boot processing to another register bank except for the case when interr
233. s specified processing equivalent to pol_flg will be executed Return value Macro Value Description E OK 0 Normal completion E ILUSE 28 Illegal service call use there is already a task waiting for an eventflag with the z TA_WSGL attribute E RLWAI 49 Forced release from waiting accept rel_wai irel_wai while waiting E TMOUT 50 Polling failure or timeout R20UT0511EJ0101 Rev 1 01 ztENESAS Page 180 of 272 Apr 01 2012 RI78V4 CHAPTER 12 SERVICE CALLS Outline Reference eventtflag state C format ER ref_flg ID flgid T_RFLG pk_rflg Assembly format MOV A ES MOV Cc A MOVW DE pk_rflg_lo PUSH BC PUSH DE MOVW AX f lgid CALL ref _flg addw sp 04H Parameter s 0 Parameter Description ID flgid ID number of the eventflag to be referenced O T_RFLG pk_rflg Pointer to the packet returning the eventflag state Explanation Stores eventflag state packet such as existence of waiting tasks of the eventflag specified by parameter flgid in the area specified by parameter pk_rfig Note For details about the eventflag state packet refer to 12 5 3 Eventflag state packet Return value Macro Value Description E OK 0 Normal completion R20UT0511EJ0101 Rev 1 01 ztENESAS Page 181 of 272 Apr 01 2012 RI78V4 CHAPTER 12 SERVICE CALLS 12 10 Synchronization and Communicat
234. s the system information header file for assembly language name to be output If omitted If omitted the CF78V4 interprets it that daAkernel_id inc is specified R20UT0511EJ0101 Rev 1 01 2tENESAS Page 239 of 272 Apr 01 2012 RI78V4 CHAPTER 14 CONFIGURATOR CF78V4 Note Specify the output file name lt ASM header file gt within 255 characters including the path name nda Disables output of the system information header file for assembly language If omitted If omitted the CF78V4 interprets it that daAkernel_id inc inc is specified V Outputs version information for the CF78V4 to the standard output Note If this activation option is specified the CF78V4 handles other activation options as invalid options and suppresses outputting of information files help Outputs the usage of the activation options for the CF78V4 to the standard output Note If this activation option is specified the CF78V4 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 This input file name can be omitted only when V or help is specified 14 2 2 Activating from CubeSuite This is started when the CubeSuite performs a build in accordance with the setting on the Property panel on the System Configurati
235. s 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 pragma rtos_task func_task include lt kernel h gt Standard header file definition include lt kernel_id h gt System information header file definition void func_task VP_INT exinf ER ercd Declares variable ID mbxid ID_mbxA Declares and initializes variable T_MSG ppk_msg Declares data structure PO ET E Bee Ay Receive from mailbox polling ercd prcv_mbx mbxid amp ppk_msg if ercd E_OK ER E seats K Polling success processing else if ercd E_TMOUT IEP secrete tia Seana Sei Ge Polling failure processing E raa EERS a Note For details about the message packet refer to 12 5 4 Message packet R20UT0511EJ0101 Rev 1 01 2tENESAS Page 63 of 272 Apr 01 2012 RI78V4 CHAPTER 5 SYNCHRONIZATION AND COMMUNICATION FUNCTIONS trcv_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 the invoking task is queued to the targe
236. sequently semaphore names can be used in the place of IDs by including the relevant system information header file using the processing program Output format to system information header file for C define semid ID Output format to system information header file for assembly language semid equ ID 2 Attribute queuing method sematr Specifies the attribute queuing method of the semaphore The keywords that can be specified for sematr are TA_TFIFO Queuing method TA_TFIFO If a resource could not be acquired semaphore counter is set to 0x0 when wai_sem or twai_sem is issued the task is queued to the semaphore wait queue in the order of resource acquisition request 3 Initial resource count isemcnt Specifies the initial resource count of the semaphore A value between 0 and 127 can be specified for isemcnt 4 System reserved area maxsem System reserved area Values that can be specified for maxsem are limited to 127 R20UT0511EJ0101 Rev 1 01 tENESAS Page 227 of 272 Apr 01 2012 RI78V4 CHAPTER 13 SYSTEM CONFIGURATION FILE 13 4 3 Eventflag information Define the following items as eventflag information 1 Eventflag name flgid 2 Attribute queuing method queuing count bit pattern clear flgatr 3 System reserved area iflgptn The number of eventflag information items that can be specified is defined as being within the range of 0 to 127 The following shows the eventflag information format
237. service calls in initialization routines The following lists processing that should be executed in initialization routines Initialization of internal units and peripheral controllers Initialization of RAM area initialization of memory area without initial value copying of initialization data Returning of control to Kernel Initialization Module 10 4 Kernel Initialization Module The kernel initialization module is a dedicated initialization processing routine provided for initializing the minimum required software for the RI78V4 to perform processing and is called from Boot Processing The following processing is executed in the kernel initialization module Securement of memory area Creating and registering management objects Calling of initialization routine Passing of control to scheduler Note The kernel initialization module is part of the functions provided by the RI78V4 The user therefore need not code the processing contents of the kernel initialization module R20UT0511EJ0101 Rev 1 01 ztENESAS Page 107 of 272 Apr 01 2012 CHAPTER 10 SYSTEM CONFIGURATION MANAGEMENT RI78V4 FUNCTIONS 10 5 Reference Version Information Version information is referenced by issuing the following service call from the processing program ref_ver The service call stores version information packet such as kernel maker s code to the area specified by parameter pk_rver The following describes an example for coding th
238. specified by parameter tskpri following priority change processing R20UT0511EJ0101 Rev 1 01 ztENESAS Page 146 of 272 Apr 01 2012 RI78V4 CHAPTER 12 SERVICE CALLS Return value Macro Value Description E OK 0 Normal completion E OBJ 41 Object state error specified task is in the DORMANT state R20UT0511EJ0101 Rev 1 01 Apr 01 2012 2tENESAS Page 147 of 272 RI78V4 CHAPTER 12 SERVICE CALLS Outline Reference task state C format ER ref_tsk ID tskid T_RTSK pk_rtsk Assembly format MOV A ES MOV Cc A MOVW DE pk_rtsk_lo PUSH BC PUSH DE MOVW AX tskid CALL _ref_tsk addw sp 04H Parameter s 1 O Parameter Description ID number of the task to be referenced ID tskid TSK_SELF Invoking task Value ID number of the task to be referenced O T_RTSK pk_rtsk Pointer to the packet returning the task state Explanation Stores task state packet such as current status of the task specified by parameter tskid in the area specified by parameter pk_rtsk Note For details about the task state packet refer to 12 5 1 Task state packet Return value Macro Value Description E OK 0 Normal completion R20UT0511EJ0101 Rev 1 01 ztENESAS Page 148 of 272 Apr 01 2012 RI78V4 CHAPTER 12 SERVICE CALLS 12 7 Task Dependent Synchronization Functions The following li
239. ss of the message packet at the head of the message queue Note For details about the mailbox state packet refer to 12 5 5 Mailbox state packet R20UT0511EJ0101 Rev 1 01 2tENESAS Page 65 of 272 Apr 01 2012 RI78V4 CHAPTER 6 MEMORY POOL MANAGEMENT FUNCTIONS CHAPTER6 MEMORY POOL MANAGEMENT FUNC TIONS This chapter describes the memory pool management functions performed by the RI78V4 6 1 Outline The statically secured memory areas in the Kernel Initialization Module are subject to management by the memory pool management functions of the RI78V4 In the RI78V4 the allocation destinations segment names of management objects modularized for each function are specified The following lists the segment names prescribed in the RI78V4 k_system segment Area where the RI78V4 s core processing part and main processing part of service calls provided by the RI78V4 are to be allocated k_info segment Area where information items such as the RI78V4 version are to be allocated k_const segment Area where initial information items related to OS resources that do not change dynamically are allocated as system information tables k_data segment Area where information items required to implement the functionalities provided by the RI78V4 and information items related to OS resources that change dynamically are allocated as management objects k_stack segment Area where the system stack and the task stack are
240. stat EQU 00h Cyclic handler operational state reyc_lefttim EQU 02h Time left before the next activation The following shows details on cyclic handler state packet T_RCYC cycstat rcyc_cycstat Stores the operational state of the cyclic handler TCYC_STP Operational state TCYC_STA _Non operational state lefttim rcyc_lefttim Stores the time unit tick left before the next activation The contents of this member become an undefined value if the target cyclic handler is in the non operational state STP state R20UT0511EJ0101 Rev 1 01 2tENESAS Page 136 of 272 Apr 01 2012 RI78V4 CHAPTER 12 SERVICE CALLS 12 5 8 Version information packet The following shows version information packet T_RVER used when issuing ref_ver Definition of version information packet T_RVER is performed by header file lt ri_root gt include os packet h packet inc which is called from standard header file lt ri_root gt include kernel h kernel inc packet h typedef struct t_rver UH maker Kernel maker s code UH prid Identification number of the kernel UH spver Version number of the ITRON Specification UH prver Version number of the kernel UH prno 4 Management information of the kernel product T_RVER packet inc verinf_maker EQU 00h Kernel maker s code verinf_prid EQU 02h Identification number of the kernel verinf_spver EQU 04h Version number of the ITRON Specifi
241. state Note 1 If the target task is moved to the READY state after this service call is issued this service call also re queues the task at the end of the ready queue corresponding to the priority of the task Note 2 This service call does not perform queuing of forced cancellation requests If the target task is in a state other than the SUSPENDED or WAITING SUSPENDED state E_OBU is therefore returned Return value Macro Value Description E OK 0 Normal completion E OBJ At Object state error specified task is neither in the SUSPENDED state nor WAITING SUSPENDED state R20UT0511EJ0101 Rev 1 01 Apr 01 2012 2tENESAS Page 161 of 272 RI78V4 CHAPTER 12 SERVICE CALLS dly_tsk Outline Delay task C format ER dly_tsk RELTIM dlytim Assembly format MOVW AX dlytim_lo MOVW BC dlytim_hi CALL lt dly_tsk Parameter s 1 O Parameter Description RELTIM dlytim Amount of relative time to delay the invoking task unit ticks 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 RI78V4 scheduling subject The delayed state is cancelled in the following cases and then moved to the READY state Delayed State Cancel
242. state READY state maxtpri R20UT0511EJ0101 Rev 1 01 ztENESAS Page 111 of 272 Apr 01 2012 RI78V4 CHAPTER 11 SCHEDULER A ready queue is rotated by issuing the following service call from the processing program rot_rdaq irot_rdq These service calls re queue the first task of the ready queue corresponding to the priority specified by parameter tskprito the end of the queue to change the task execution order explicitly 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 func_cychdr void PRI tskpri 8 Declares and initializes variable E gt sehen Sikhs Snes ay irot rag tskpri Rotate task precedence Ee ae Sean se ay 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 R20UT0511EJ0101 Rev 1 01 2tENESAS Page 112 of 272 Apr 01 2012 RI78V4 11 4 4 Change task priority CHAPTER 11 SCHEDULER The RI78V4 provides a function to change the priority level of tasks from the processing program explicitly switch
243. sts the service calls provided by the RI78V4 as the task dependent synchronization functions Table 12 9 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 Task Non task iwup_tsk Wakeup task Task Non task can_wup Cancel task wakeup requests Task Non task ican_wup Cancel task wakeup requests Task Non task rel_wai Release task from waiting Task Non task irel_wai Release task from waiting Task Non task sus_tsk Suspend task Task Non task isus_tsk Suspend task Task Non task rsm_tsk Resume suspended task Task Non task irsm_tsk Resume suspended task Task Non task frsm_tsk Forcibly resume suspended task Task Non task ifrsm_tsk Forcibly resume suspended task Task Non task dly_tsk Delay task Task R20UT0511EJ0101 Rev 1 01 Apr 01 2012 2tENESAS Page 149 of 272 RI78V4 CHAPTER 12 SERVICE CALLS Outline Put task to sleep waiting forever C format ER slp_tsk void Assembly format CALL _slp_tsk Parameter s None Explanation As a result the invoking task is unlinked from the ready queue and excluded from the RI78V4 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
244. sys_stkC Stack size used by user in initialization routine 20 bytes sys_stk MAX sys_stkA sys_stkB sys_stkC 2 MAX 104 0 20 104 2 106 bytes The system stack size will be the 104 bytes of sys_stkA The size specified in the system configuration file will be 104 bytes Note Below is shown the stack size used in service calls functions used in the example For Service Call For intemal F r cessing For System Stack by Program Issued the Arguments i Internal Processing Service Call pol_flg 8 8 6 snd_mbx 4 8 4 Timer_Handler function 0 6 13 5 2 Stack size of the task The formula for calculating the stack size of the task is shown below Expression 1 No interrupts generated in task Task stack size size used by user service call argument size 28 bytes Expression 2 Interrupts generated in task Task stack size size used by user service call argument size 28 18 bytes Specify the task stack size in the system configuration file Note however that the size that is actually secured is the value specified in the configurator 28 bytes Consequently the value that is actually specified in the system configuration file is the sys_stk value calculated in expression 1 or expression 2 minus 28 bytes These 28 bytes include the stack size used when system calls are issued Note however that the stack size used when issuing system calls must secure the size used by the
245. t mailbox wait queue in the order of message reception request FIFO order As a result the invoking task is unlinked from the ready queue and is moved from the RUNNING state to the WAITING state receiving waiting for a mailbox The receiving waiting for a mailbox is cancelled in the following cases and then moved to the READY state Receiving Waiting for a Mailbox Cancel Operation Return Value A message was transmitted to the target mailbox as a result of issuing snd_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 pragma rtos_task func_task include lt kernel h gt Standard header file definition include lt kernel_id h gt System information header file definition void func_task VP_INT exinf ER ercd Declares variable ID mbxid ID_mbxA Declares and initializes variable T_MSG ppk_msg Declares data structure TMO tmout 3600 Declares and initializes variable ee ae ae ae ay Receive from mailbox with timeout ercd trcv_mbx mbxid amp ppk_msg tmout if ercd E_OK AE EE EE Normal termination processing else if ercd E_RLWAI YER hese tne Seana Saat xy Forced termination processing else if
246. t 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 Note 1 For details about the interrupt handler refer to 9 3 Interrupt Handlers Note 2 The user must code the interrupt handlers that calls the Timer Handler 2 3 Coding of System Configuration File Code the SYSTEM CONFIGURATION FILE required for creating information files system information table file system information header file that contain data to be provided for the RI78V4 Note For details about the system configuration file refer to CHAPTER 13 SYSTEM CONFIGURATION FILE R20UT0511EJ0101 Rev 1 01 ztENESAS Page 12 of 272 Apr 01 2012 RI78V4 CHAPTER 2 SYSTEM CONSTRUCTION 2 4 Coding of User Own Coding Module Code the user own coding modules that are extracted to allow the RI78V4 to be supported in various execution environments In the RI78V4 the user own coding module is classified into the following four types in accordance with the types and purposes of the processing that should be implemented Interrupt Entry Processing A routine dedicated to entry processing that is extracted from the INTERRUPT MANAGEMENT FUNCTIONS as a user own coding module to assign instructions to branch to relevant processing such as Interrupt Handlers or Boot Processing to
247. 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 pragma rtos_task func_task include lt kernel h gt Standard header file definition include lt kernel_id h gt System information header file definition void func_task VP_INT exinf ID mpfid ID_mpfA Declares and initializes variable VP p_blk Declares variable char p Declares variable ID mbxid ID_mbxA Declares and initializes variable T_MSG_PRI pk_msg Declares data structure a eee er get_mpf mpfid amp p_ bik Secures memory area for message Initializes variable p char p_blk sizeof T_MSG_PRI j while expr AERE A Sica einai ces aod EG Creates message contents Initializes data structure T_MSG_PRI p_blk gt msgpri 8 Send to mailbox snd_mbx mbxid T_MSG_PRI p_bik Note 1 If the first task of the wait queue is moved to the READY state after this service call is issued this service call also re queues the task at the end of the ready queue corresponding to the priority of the task Note 2 Messages are queued to the target mailbox wait queue in the order defined by Attribute queuing method mbxatr d
248. tasks semaphores etc managed by the RI78V4 from a processing program The service calls provided by the RI78V4 are listed below by management module Task Management Functions act_tsk iact_tsk can_act sta_tsk ista_tsk ext_tsk ter_tsk chg_pri ichg_pri ref_tsk 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 sig_sem isig_sem wai_sem pol_sem twai_sem ref_sem Synchronization and Communication Functions Eventflags set_flg iset_flg clr_flg wai_flg pol_flg twai_flg ref_flg Synchronization and Communication Functions Mailboxes snd_mbx rcv_mbx prcv_mbx trcv_mbx ref_mbx Memory Pool Management Functions get_mpf pget_mpf tget_mpf rel_mpf ref_mpf Time Management Functions sta_cyc stp_cyc ref_cyc System State Management Functions rot_rdq irot_rdg get_tid iget_tid loc_cpu iloc_cpu unl_cpu iunl_cpu ena_dsp dis_dsp sns_ctx sns_loc sns_dsp sns_dpn System Configuration Management Functions ref_ver R20UT0511EJ0101 Rev 1 01 ztENESAS Page 121 of 272 Apr 01 2012 RI78V4 CHAPTER 12 SERVICE CALLS 12 2 Call Service Call The method for calling service calls from processing programs coded either in C or assembly language is described below 12 2 1
249. tching disabled state changed by issuing this service call must be cancelled before the task that issued this service call moves to the DORMANT state Return value Macro Value Description E OK 0 Normal completion R20UT0511EJ0101 Rev 1 01 ztENESAS Page 212 of 272 Apr 01 2012 RI78V4 CHAPTER 12 SERVICE CALLS Outline Enable dispatching C format ER ena_dsp void Assembly format CALL _ena_dsp Parameter s None Explanation This service call changes the system status to the dispatching 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 RI78V4 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 This service call does not perform queuing of enable requests If the system is in the dispatching enabled state therefore no processing is performed but it is not handled as an error Return value Macro Value Description E OK 0 Normal completion R20UT0511EJ0101 Rev 1 01 ztENESAS Page 213 of 272 Apr 01 2012 RI78V4 CHAPTER
250. ted 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 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 When exporting the 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 You should not use Renesas Electronics products or the technology described in this document for any purpose relating to military applications or use by the military including but not limited to the development of weapons of mass destruction 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 Renesas Electronics has used reasonable care in preparing the information included in this document but
251. the vector table address to which the CPU forcibly passes the control when an interrupt occurs Note 1 For details about the interrupt entry processing refer to 9 2 Interrupt Entry Processing Note 2 For interrupt handlers written using the pragma rtos_interrupt directive the user is not required to write the relevant interrupt entry processing because the C compiler automatically outputs the interrupt entry processing corresponding to the interrupt request name Boot Processing A routine dedicated to initialization processing that is extracted from the SYSTEM CONFIGURATION MANAGEMENT FUNCTIONS as a user own coding module to initialize the minimum required hardware for the RI78V4 to perform processing It is called from Interrupt Entry Processing that is assigned to the vector table address to which the CPU forcibly passes the control when a reset interrupt occurs Note For details about the boot processing refer to 10 2 Boot Processing Initialization Routine A routine dedicated to initialization processing that is extracted from the SYSTEM CONFIGURATION MANAGEMENT FUNCTIONS 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 Note For details about the initialization routine refer to 10 3 Initialization Routine Idle Routine A routine dedicated to idle processing that is extracted
252. thod may exist simultaneously To remedy this dispatch processing task scheduling processing is executed on a first come first 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 R20UT0511EJ0101 Rev 1 01 ztENESAS Page 109 of 272 Apr 01 2012 RI78V4 CHAPTER 11 SCHEDULER 11 4 Ready Queue The RI78V4 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 RI78V4 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 11 1 Implementation of Scheduling Method Priority Level Method or FCFS Method Ready queue Priority High 5 1 Invoking task RUNNING state tskpri Task A Task B Task C READY state READY state READY state maxtpri Priority Low 11 4 1 Create ready queue In the RI78V4 the method of creating a ready queue is limited to static crea
253. tializes the following information to values that are set during task creation Priority current priority Wakeup request count Suspension count Interrupt status Note 3 If the return instruction is written in a task it executes the same operation as this service call Note 4 Inthe RI78V4 code efficiency is enhanced by coding the return instruction as a Terminate invoking task R20UT0511EJ0101 Rev 1 01 ztENESAS Page 30 of 272 Apr 01 2012 RI78V4 CHAPTER 3 TASK MANAGEMENT FUNCTIONS 3 5 2 Terminate task Other tasks are forcibly terminated by issuing the following service call from the processing program 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 RI78V4 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 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 pragma rtos_task func_task include lt kernel h gt Standard header file definition include lt kernel_id h gt System information header file definition void func_task VP_INT exinf ID tskid ID_tskA
254. ting the interrupt mask flag register MKxx and the in service priority flag ISPx of the program status word PSW Therefore manipulating of these registers from the processing program is prohibited from when loc_cpu or iloc_cpu is issued until this service call is issued Return value Macro Value Description E OK 0 Normal completion R20UT0511EJ0101 Rev 1 01 2tENESAS Page 211 of 272 Apr 01 2012 RI78V4 CHAPTER 12 SERVICE CALLS Outline Disable dispatching C format ER dis_dsp void Assembly format CALL _ dis_dsp Parameter s None Explanation This service call changes the system status to the dispatching 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 RI78V4 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 This service call does not perform queuing of disable requests If the system is in the dispatching disabled state therefore no processing is performed but it is not handled as an error Note 2 The dispa
255. tion by the Kernel Initialization Module Ready queues therefore cannot be created dynamically using a method such as issuing a service call from a processing program Static create Static ready queue creation is realized by defining Task priority information in the system configuration file The RI78V4 executes ready queue creation processing based on data stored in information files using the Kernel Initialization Module and handles the created ready queues as management targets 11 4 2 Delete ready queue In the RI78V4 ready queues created statically by the Kernel Initialization Module cannot be deleted dynamically using a method such as issuing a service call from a processing program R20UT0511EJ0101 Rev 1 01 ztENESAS Page 110 of 272 Apr 01 2012 RI78V4 CHAPTER 11 SCHEDULER 11 4 3 Rotate task precedence The RI78V4 provides a function to change the queuing order of tasks from the processing program explicitly switching the task execution order The following shows the status transition when the task queuing order is changed Figure 11 2 Rotate Task Precedence Ready queue 1 Invoking task RUNNING state Task A Task B Task C READY state READY state READY state tskpri maxtpri rot_rdq tskpri Ready queue 1 Invoking task RUNNING state tskpri Task B Task C Task A READY state READY
256. tivation request Task Non task ista_tsk Activate task does not queue an activation request Task Non task ext_tsk Terminate invoking task Task ter_tsk Terminate task Task chg_pri Change task priority Task Non task ichg_pri Change task priority Task Non task ref_tsk Reference task state Task Non task R20UT0511EJ0101 Rev 1 01 2tENESAS Page 138 of 272 Apr 01 2012 RI78V4 CHAPTER 12 SERVICE CALLS Outline Activate task queues an activation request C format ER act_tsk ID tskid ER iact_tsk ID tskid Assembly format MOVW AX tskid CALL IT act tsk MOVW AX tskid CALL I iact_tsk Parameter s 1 O Parameter Description ID number of the task to be activated l 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 RI78V4 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 The activation request counter managed by the RI78V4 is configured in 7 bit wi
257. tracting 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 pragma rtos_task func_task include lt kernel h gt Standard header file definition include lt kernel_id h gt System information header file definition void func_task VP_INT exinf ER ercd Declares variable OR a Bid EEE ay ercd glp tsk Put task to sleep waiting forever if ercd E_OK ae ee rere ae x Normal termination processing else if ercd E_RLWAI UR aaa cea S mf Forced termination processing are ere eee 7 R20UT0511EJ0101 Rev 1 01 tENESAS Page 34 of 272 Apr 01 2012 RI78V4 CHAPTER 4 TASK DEPENDENT SYNCHRONIZATION FUNCTIONS R20UT0511EJ0101 Rev 1 01 2tENESAS Page 35 of 272 Apr 01 2012 RI78V4 CHAPTER 4 TASK DEPENDENT SYNCHRONIZATION FUNCTIONS tslp_tsk This service call moves an invoking task from the RUNNING state to the WAITING state sleeping state As a result the invoking t
258. ttern 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 Polling failure or timeout E TMOUT 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 eventtflag wfmode TWF_ORW Checks which bit among bits to which 1 is set by parameter waipitn is set as the target eventflag The following describes an example for coding this service call func_task VP_INT exinf ER ercd Declares variable ID flgid ID_flgA Declares and initializes va
259. ue as the value of the Memory model type property of the build tool Memory mogel Default The memory model selected in the property of the build tool Sow to Changes not allowed change R20UT0511EJ0101 Rev 1 01 tENESAS Page 252 of 272 Apr 01 2012 RI78V4 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 for C language System information header file for assembly language Display image Property vf sys cfg Property E System Information T able Fie Generate a file Yes It updates the file when the cfg file is changed i Output folder BuildModeName File name sit asm E System Information Header File for C Language Generate a file Yes lt updates the file when the cfg file is changed dc Output folder BuildModeName File name kermel_id h E System Information Header File for Assembly Language Generate a file Yesflt updates the file when the cfg file is changed da Output folder BuildModeN ame File name kermel_id ine Generate afile Select whether to make a System Information Table File which is output from a system configuration file This file includes information of system initialization A File Information R20UT051
260. unction E return return E return R20UT0511EJ0101 Rev 1 01 2tENESAS Apr 01 2012 Page 101 of 272 RI78V4 CHAPTER 9 INTERRUPT MANAGEMENT FUNCTIONS When control moves to an interrupt handler then the state changes to acceptance of maskable interrupts enabled IE 1 For this reason multiple interrupts are generally accepted from interrupt handlers Multiple interrupts are likewise accepted from timer interrupts and cyclic handlers called from them When control moves to an interrupt process then the state changes to acceptance of maskable interrupts disabled because the RI78V4 does not mediate the behavior is in accordance with that of the microcontroller For this reason multiple interrupts are generally not accepted from interrupt processes To enable the acceptance of multiple interrupts it is necessary to call the El function from the interrupt process It is not allowed to accept multiple interrupt handlers from an interrupt process and behavior is not guaranteed if this occurs If a user application enables multiple interrupts then it is necessary to set the interrupt level of the interrupt handler process as shown below Table 9 3 Settable Interrupt Level Enabling Multiple Interrupts from User Application Interrupt Handler Interrupt Servicing Interrupt level 0 Not available Available Interrupt level 1 Not available Available Interrupt level 2 Available N
261. upt servicing not managed by the RI78V4 Service call issuance The RI78V4 prohibits issuance of service calls in boot processing The following lists processing that should be executed in boot processing Setting of stack pointer SP Setting of interrupt enable flag IE Initialization of internal units and peripheral controllers Initialization of RAM area initialization of memory area without initial value copying of initialization data Passing of control to Kernel Initialization Module function name _urx_start Note Setting of stack pointer SP is required only when a stack dedicated to boot processing is used in boot processing R20UT0511EJ0101 Rev 1 01 ztENESAS Page 105 of 272 Apr 01 2012 CHAPTER 10 SYSTEM CONFIGURATION MANAGEMENT RI78V4 FUNCTIONS 10 3 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 10 3 1 Define initialization routine In the RI78V4 the method of registering an initialization routine is limited to static registration by the Kernel Initialization Module Initialization routines therefore cannot be created dynamically using a method such as issuing a service call from a processing program Static define Static initializatio
262. uring configuration FIFO order or priority order Note 3 With the RI78V4 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 4 For details about the message packet refer to 12 5 4 Message packet R20UT0511EJ0101 Rev 1 01 ztENESAS Page 61 of 272 Apr 01 2012 CHAPTER 5 SYNCHRONIZATION AND COMMUNICATION RI78V4 FUNCTIONS 5 4 5 Receive from mailbox A message is received waiting forever 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 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 the invoking task is queued to the target mailbox wait queue in the order of message reception request FIFO order As a result the invoking task is unlinked from the ready queue and is moved from the RUNNING state to the WAITING state receiving waiting for a mailbox The receiving waiting for a mailbox is cancelled in the following cases and then moved to the READY state Receiving Waiting for
263. y Standard Library Runtime Library Object Files Sie C y Load Module R20UT0511EJ0101 Rev 1 01 2tENESAS Page 11 of 272 Apr 01 2012 RI78V4 CHAPTER 2 SYSTEM CONSTRUCTION 2 2 Coding of Processing Program Code the processing that should be implemented in the system In the RI78V4 the processing program is classified into the following three 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 RI78V4 unlike other processing programs cyclic handler and interrupt handler Note For details about the task refer to 3 2 Tasks Cyclic Handlers The cyclic handler is a routine dedicated to cycle processing that is activated periodically at a constant interval activation cycle The RI78V4 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 Note For details about the cyclic handler refer to 7 5 Cyclic Handlers Interrupt Handlers The interrupt handler is a routine dedicated to interrupt servicing that is activated when an interrupt occurs The RI78V4 handles the interrup
264. y header file lt ri_root gt include os packet h packet inc which is called from standard header file lt ri_root gt include kernel h kernel inc packet h typedef struct t_rmpf ID wtskid ID number of the task at the head of the wait queue UINT flblkent Number of free memory blocks T_RMPF packet inc rmpf_wtskid EQU 00h ID number of the task at the head of the wait queue rmpf_fblkcnt EQU 02h Number of free memory blocks The following shows details on fixed sized memory pool state packet T_RMPF wtskid rmpf_wtskid Stores information whether a task is queued to the wait queue TSK_NONE No applicable task Value ID number of the task at the head of the wait queue fblkcnt rmpf_folkcnt Stores the number of free memory blocks R20UT0511EJ0101 Rev 1 01 2tENESAS Page 135 of 272 Apr 01 2012 RI78V4 CHAPTER 12 SERVICE CALLS 12 5 7 Cyclic handler state packet The following shows cyclic handler state packet T_RCYC used when issuing ref_cyc Definition of cyclic handler state packet T_RCYC is performed by header file lt ri_root gt include os packet h packet inc which is called from standard header file lt ri_root gt include kernel h kernel inc packet h typedef struct t_rcyc STAT cycstat Cyclic handler operational state RELTIM lefttim Time left before the next activation T_RCYC packet inc rceyc_cyc
265. y information are as follows 1 Priority range maxtpri Specifies the priority range of a task maximum value of Initial priority itskpri or maximum value of priority specified when issuing chg_pri A value between 1 and 15 can be specified for maxtpri Note If definition of this information is omitted the task priority range is set to 15 R20UT0511EJ0101 Rev 1 01 2tENESAS Page 223 of 272 Apr 01 2012 RI78V4 CHAPTER 13 SYSTEM CONFIGURATION FILE 13 4 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 13 4 1 Task information Define the following items as task information 1 Task name tskid 2 Attribute coding language initial activation status initial interrupt status tskatr 3 Extended information exinf 4 Start address task 5 Initial priority itskpri 6 Stack size stksz 7 System reserved area stk The number of task information items that can be specified is defined as being within the range of 1 to 127 The following shows the task information format CRE_TSK tskid tskatr exinf task itskpri stksz stk The ite
266. ycphs number of cyclic handler information items that can be specified is defined as being within the range of 0 to 127 following shows the cyclic handler information format CRI E_ CYC cycid cycatr exinf cychdr cyctim cycphs The 1 items constituting the cyclic handler information are as follows Cyclic handler name cycid Specifies the cyclic handler name An object name can be specified for cycid Note The CF78V4 outputs to the system information header file the correspondence between the cyclic handler names and IDs in the following format Consequently cyclic handler names can be used in the place of IDs by including the relevant system information header file using the processing program Output format to system information header file for C define cycid ID Output format to system information header file for assembly language cycid equ ID Attribute coding language initial activation status cycatr Specifies the attributes coding language initial activation status of the cyclic handler The keywords that can be specified for cycatr are TA_HLNG TA_ASM and TA_STA Coding language TA_HLNG Start a processing unit through a C language interface TA_ASM Start a processing unit through an assembly language interface Initial operation status TA_STA Cyclic handler is in an operational state after the creation Note If specification of TA_
267. ystem stack size is shown below Expression 1 System stack size sys_stk MAX sys_stkA sys_stkB sys_stkC 2 bytes Expression 2 System stack size use pattern A sys_stkA tsksvc intO int1 int2 int3 Expression 3 System stack size use pattern B sys_stkB Size used by user in idle routine Expression 4 System stack size use pattern C sys_stkC Size used by user in initialization routine Expression 5 Maximum size of system stack used during service call executed by task Maximum size of system stack used during service call executed by task Expression 6 Size of intO int1 Intx Maximum size of interrupts used by stack in interrupts of level x Size used by user in interrupts Expression 7 Size of int2 int2 intx Maximum size of interrupts used by stack in interrupts of level x Size used by user in interrupts allsvc 16 Expression 8 Total size used by system calls used in interrupt allsvc For service call arguments For internal processing by program issued the service call For system stack internal processing Specify the system stack size in the system configuration file Note however that the size that is actually secured is the value specified in the configurator 2 bytes Consequently the value that is actually specified in the system configuration file is the sys_stk value calculated in expression 1 minus 2 bytes We recommend specifying a system stack size higher than the estimate
268. zation and Communication Functions Eventflags The following lists the service calls provided by the RI78V4 as the synchronization and communication functions event flags Table 12 11 Synchronization and Communication Functions Eventflags Service Call Function Origin of Service Call set_flg Set eventflag Task Non task iset_flg Set eventflag Task Non task clr_flg Clear eventflag Task Non task wai_flg Wait for eventflag waiting forever Task pol_flg Wait for eventflag polling Task Non task twai_flg Wait for eventflag with timeout Task ref _flg Reference eventflag state Task Non task R20UT0511EJ0101 Rev 1 01 tENESAS Page 171 of 272 Apr 01 2012 RI78V4 CHAPTER 12 SERVICE CALLS set_fig iset_flg Outline Set eventtflag C format ER set_flg ID flgid FLGPIN setptn ER iset_flg ID flgid FLGPTN setptn Assembly format OVW AX setptn PUSH AX OVW AX flgid CALL _set_flg POP AX OVW AX setptn PUSH AX OVW AX flgid CALL _iset_flg POP AX Parameter s O Parameter Description l ID flgid ID number of the eventflag to be set l FLGPTN setptn Bit pattern to set 16 bits Explanation These service calls set the result of ORing 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

Download Pdf Manuals

image

Related Search

Related Contents

MODEL MTQL  MULTIBAND SOUND PROCESSOR  USER GUIDE co m p ressed air d ryer MAXI    User Manual for entering data into the system  Phonix IP6PBCW mobile phone case  

Copyright © All rights reserved.
Failed to retrieve file