Home
HI7000/4 V.2.02, HI7700/4 V.2.02, and HI7750/4 V.2.02
Contents
1. ter_tsk Creation Deletion cre_tsk del_tsk i NON EXISTENT i R unregistered stat p Exit and deletion exd_tsk Figure 2 1 Task State Transition Diagram Rev 6 00 12 REJ10B0060 0600 RENESAS Section2 Kernel 2 6 2 Task Creation Task creation means that a NON EXISTENT task becomes DORMANT The method of creating a task differs depending on the stack type used by the task to be created For details refer to section 0 Task Stack The methods of creating a task are shown in table 2 4 Table 2 4 Task Creating Methods Stack Type Used by Created Task Stack Allocated by Task Creating Method Static Stack Dynamic Stack Application cre_tsk acre_tsk service calls v v vscr_tsk service call v Configurator v v v 2 6 3 Task Initiation A task is initiated when it moves from the DORMANT state to become READY A task can be initiated by one of two methods e By issuing the act_tsk or sta_tsk service calls for the target task e By specifying TA_ACT as a task attribute when a task is created The kernel performs the following processing at task initiation e Initialize the task base priority and current priority e Clear the number of task wake up requests e Clear the number of nestings of task suspension requests e Clear the pended task exception sources e Set task exception processing to the disabled state e Set the task event flag to 0 The following parameter is passed to
2. f NOP pa SRERIRRRCRE Hanen HOTH eee 9 Figure 3 1 Example of Service Call from an Assembly Language Program a Standard header file kernel inc is included b Service call entry table of the kernel is externally referenced c Offset value corresponding to the service call must be specified d Entry address of the service call to be called must be found e Parameters must be specified f Service call function is called g After service call processing execution returns to the address specified by the PR register except for the service calls that do not return to the calling program In this example execution returns to this location When execution returns normal end E_OK or an error code is set in RO When using SH 2A or SH2A FPU you can choose Only for service call as CFG_TBR in the configurator In this case the TBR register is used for calling kernel In most cases a service call can be called using TBR register from an assembly language program as shown in Displacement must be specified as INDEX_XXX_XXX where XXX_XXX is the service call name in uppercase characters Rev 6 00 66 REJ10B0060 0600 RENESAS Section3 Service Calls INCLUDE MOV L 1 R4 JSR N NOP Figure 3 2 kernel inc INDEX_ACT_TSK TBR Example of Service Call using TBR Register SH 2A SH2A FPU a Standard header file kernel inc is included b Parameters must be specified
3. Service Call Description T N E D U L C def_exc Defines CPU exception handler T E D U idef_exc N E D U vdef_trp Defines CPU exception handler TRAPA T E D U ivdef_trp instruction exception N E D U ref_cfg Refers to configuration information T E D U iref_cfg N E D U ref_ver Refers to version information T E D U iref_ver N E D U Notes 1 S Standard profile service calls s Service calls that are not standard profile service calls but are needed in order to use the standard profile function 2 T Can be called from task context N Can be called from non task context E Can be called from dispatch enabled state D Can be called from dispatch disabled state U Can be called from CPU unlocked state L Can be called from CPU locked state C Can be called from CPU exception handler System Configuration Management Specifications The system configuration management specifications are listed in table 3 68 Table 3 68 System Configuration Management Specifications Item Description CPU exception handler number 0 to CFG_MAXVCTNO 511 max HI7000 4 0 to CFG_MAXVCTNO H feO max HI7700 4 HI7750 4 Trap number 0 to CFG_MAXTRPNO 255 max Attribute supported TA_HLNG The task is written in a high level language TA_ASM The task is written in assembly language Restrictions HI7700 4 HI7750 4 An exception with an exception code other than a multiple of H 20 is not accepted Note that such exceptions are
4. wupcent The current wakeup request queue count is returned suscnt The current suspend request nesting count is returned Rev 6 00 91 RENESAS REJ10B0060 0600 Section3 Service Calls tskmode The task execution mode set in the service call vchg_tmd and whether there is a request that is delayed by the service call vchg_tmd are returned The following value is returned to tskmode Table 3 12 Task Execution Mode tskmode tskmode Code Description ECM_SUS H 00000001 A suspend request is masked ECM_TER H 00000002 A forcible termination request is masked PND_SUS H 00000004 A suspend request is delayed PND_TER H 00000008 A forcible termination request is delayed tflptn The current task event flag value is returned However if the task event flag function was not installed at system creation an undefined value is returned tskmode and tflptn are members not defined in the pITRON4 0 specification Rev 6 00 92 REJ10B0060 0600 RENESAS Section3 Service Calls 3 4 11 Refer to Task State Simple Version ref_tst iref_tst C Language API ER ercd ref_tst ID tskid T_RTST pk_rtst ER ercd iref_tst ID tskid T_RTST pk_rtst j Parameters ID tskid R4 Task ID T_RTST pk_rtst R5 Start address of the packet where the task state is to be returned Return Parameters ER ercd RO Normal end E_OK or error code T_RTST pk_rtst R5 Start address of the packet where th
5. Higher level Executes IRL14 processing Executes IRL15 processing void vec071 void Defines vec0O71 as a normal interrupt handler if get_imask I_HILEVEL vec0O71_handler15 else vec0O71_handler14 Figure 4 5 Example of a C Language Interrupt Handler Using IRL Interrupt 5 Defining a Normal Interrupt Handler A normal interrupt handler can be defined in the following ways e def_inh or idef_inh service call e Defined initially by the configurator RENESAS Rev 6 00 311 REJ10B0060 0600 Section4 Application Program Creation 6 Notes on the NMI HI7700 4 HI7750 4 NMI re entry can be allowed or not allowed in the following ways e To not allow the NMI re entry The BL bit of the SR must be set to 1 at the initiation of the handler which is specified when the NMI interrupt handler is defined and must not be cleared by the NMI interrupt handler Since the NMI interrupt handler is executed while the BL bit of SR is 1 the exception of the handler including TLB miss must not occur e To allow the NMI re entry The BL bit of the SR must be cleared to 0 at the initiation of the handler which is specified when the NMI interrupt is defined and the BL bit can be cleared by the NMI interrupt Note however that since re entry of NMI occurs in this case a larger stack size is required compared to that when the NMI re entry is not allowed 4 8 2 Direct Interrupt Handler HI7000 4
6. Parameters ID mbxid R4 Mailbox ID T_MSG pk_msg R5 Start address of the message to be sent Return Parameters ER ercd RO Normal end E_OK or error code Packet Structure Mailbox message header typedef struct t_msg VP msghead 0 4 Kernel management area T_MSG Mailbox message header with priority typedef struct t_msg_ pri T_MSG msgque 0 4 Message header PRI msgpri 4 2 Message priority T_MSG PRI Error Codes E_PAR p Parameter error pk_msg is other than a multiple of four or the first four bytes of the message is other than 0 k msgpri lt 0 msgpri gt CFG_MAXMSGPRI E_ID p Invalid ID number mbxid lt 0 mbxid lt 0 or mbxid gt CFG _MAXMBXID E_NOEXS k Undefined Mailbox indicated by mbxid does not exist Function Each service call sends a message specified by pk_msg to the mailbox specified by mbxid If there is a task waiting to receive a message in the mailbox the task at the head of the wait queue receives the message and is released from the WAITING state On the other hand if there are no tasks waiting to receive a message the message specified by pk_msg is linked to the end of the message queue The message queue is managed according to the attributes specified at creation To send a message to a mailbox that has the TA_MFIFO attribute the message must be created in RAM and must have the T_MSG structure at the head of the message as shown in figure 3 4 The contents of T MSG mu
7. Table 5 7 Linkage Priority of the Kernel Library HI7700 4 cont 2 sh4al_dsp_knl_ lib 3 sh4al_opttmr_ lib 4 shx2_cache_ 7 lib DSP Standby Optimized timer CPU Core Control Function Driver Function Linkage Priority SH4AL Unused Unused 1 sh4al_dsp_knl_ 7 lib DSP with 2 shx2_cache_ 7 lib ee 3 hikn _2 lib Used 1 sh4al_dsp_knl_ lib 2 sh4al_opttmr_ 7 lib 3 shx2_cache_ lib 4 hiknl_ lib Used Unused 1 sh4al_dspstby_ 7 lib 2 sh4al_dsp_knl_ lib 3 shx2_cache_ lib 4 hiknl_ lib Used 1 sh4al_dspstby_ lib 2 3 4 5 5 hiknl_ lib The following kernel libraries are used to support the debugger and usually not used e hiexpand_ lib e dsp_expand_ lib e sh4al_dsp_expand_ lib Note The 7708_cache_ lib library is not dedicated for the SH7708 it is used for all SH 3 and SH3 DSP series RENESAS Rev 6 00 369 REJ10B0060 0600 Section5 Configuration 5 9 3 HI7750 4 Table 5 8 lists the linkage priority of the HI7750 4 kernel library Table 5 8 Linkage Priority of the Kernel Library H1I7750 4 CPU Core Linkage Priority SH 4 1 7750_cache_ lib 2 hiknl_ lib SH 4A without extended function 1 sh4a_cache_ 7 lib 2 hikni_ lib SH 4A with extended function 1 shx2_cache_ lib 2 hiknl_ lib The following kernel library is used to support the debugger and usually not used e hiexpand_ lib N
8. The first time to initiate the cyclic handler occurs after cycphs initiation phase has passed since the service call that creates the cyclic handler has been called The cyclic handler is then initiated at every cyctim initiation interval The cyclic handler can also be created statically by the configurator 3 16 2 Delete Cyclic Handler del_cyc C Language API ER ercd del_cyc ID cycid Parameters ID cycid R4 Cyclic handler ID Return Parameters ER ercd RO Normal end E_OK or error code Error Codes E_ID p Invalid ID number cycid lt 0 or cycid gt CFG_MAXCYCID E_NOEXS k Undefined Cyclic handler indicated by cycid does not exist E_CTX k Context error Called from disabled system state Function Service call del_cyc deletes the cyclic handler indicated by parameter cycid Rev 6 00 203 RENESAS REJ10B0060 0600 Section3 Service Calls 3 16 3 Start Cyclic Handler sta_cyc ista_cyc C Language API ER ercd sta_cyc ID cycid j ER ercd ista_cyc ID cycid Parameters ID cycid R4 Cyclic handler ID Return Parameters ER ercd RO Normal end E_OK or error code Error Codes E_ID p Invalid ID number cycid lt 0 or cycid gt CFG_MAXCYCID E_NOEXS k Undefined Cyclic handler specified by cycid does not exist Function Each service call causes the cycle handler specified by cycid to enter the operation state If TA_PHS is not specified as a cyclic handler attribute the cyclic handle
9. For SH 2A and SH2A FPU TBR If Use for only service call or Task context is selected as CFG_TBR the TBR is guaranteed Refer to section 4 2 8 TBR Register SH 2A SH2A FPU For SH2A FPU FRO to FR11 The register contents will not be guaranteed For SH2A FPU FPSCR FPUL FR12 to FR15 The register contents will be guaranteed in the following situation e A service call is issued from a task with TA_COP1 attribute or task exception processing routine e A service call is issued in a state mentioned in the note below Note Non task context or dispatch disabled state For details on guarantee of the register contents when creating tasks and handlers refer to section 4 Application Program Creation Rev 6 00 68 REJ10B0060 0600 RENESAS Section3 Service Calls 3 2 4 Return Value of Service Call and Error Code For service calls that have return codes a positive value or 0 E_OK indicates normal end and a negative value indicates an error code However for service calls that have a BOOL type return value this is not the case The meaning of the return value at normal end differs depending on the service call however only E_OK is returned at normal end for many service calls An error code consists of main error codes lower 8 bits and sub error codes upper bits above lower 8 bits The sub error code of this kernel is always set to 1 The following macros are defined in the standard header
10. For the HI7000 4 the maximum nest count for interrupts with level higher than CFG_KNLMSKLVL must be specified 3 Interrupt nest count with a level equal to or lower than CFG_LOWINTNST the kernel interrupt mask level only for HI7000 4 For the HI7000 4 the maximum nest count for interrupts with a level equal to or lower than CFG_KNLMSKLVL must be specified 4 How to use TBR register only for HI7000 4 CFG_TBR L Can be chosen from the following 1 Kernel does not Manage 2 Only for Service Call 3 Task Context When using a microcomputer without TBR choose 1 For Details refer to section 4 2 8 TBR Register SH 2A SH2A FPU 2 Kernel Extended Function Page Service call parameter check CFG_PARCHK L When this item is checked the service call static parameter error is checked Errors that are checked are indicated by the letter p in each service call explanation in section 3 Service Calls 2 Use of SH3 DSP or SH4AL DSP only for HI7700 4 CFG_DSP L Remember to check this item when using a processor with the DSP bit such as SH7729 in the SR Refer to section 4 2 1 SR Register and section 4 2 2 Cache Lock Function SH 3 SH3 DSP 3 Use of processor with cache lock function only for CFG_CACLOC L HI7700 4 Refer to section 4 2 2 Cache Lock Function SH 3 SH3 DSP Rev 6 00 356 REJ10B0060 0600 RENESAS Section5 Configuration Table 5 5 Configurator
11. Valid only when TTS_WAI or TTS_WAS is returned to tskstat and the following values are returned Table 3 14 Cause of WAITING State tskwait tskwait Code Description TTW_SLP H 00000001 Shifted to the WAITING state by slp_tsk or tslp_tsk W_DLY H 00000002 Shifted to the WAITING state by dly_tsk W_SEM H 00000004 Shifted to the WAITING state by wai_sem or twai_sem TTW_FLG H 00000008 Shifted to the WAITING state by wai_flg or twai_flg TTW_SDTQ H 00000010 Shifted to the WAITING state by snd_dtq or tsnd_dtq TTW_RDTQ H 00000020 Shifted to the WAITING state by rcv_dtq or trev_dtq W_MBX H 00000040 Shifted to the WAITING state by rev_mbx or trcv_mbx W_MTX H 00000080 Shifted to the WAITING state by loc_mtx or tloc_mtx TTW_SMBF H 00000100 Shifted to the WAITING state by snd_mbf or tsnd_mbf TTW_RMBF H 00000200 Shifted to the WAITING state by rcv_mbf or trcev_mbf TTW_MPF H 00002000 Shifted to the WAITING state by get_mpf or tget_mpf W_MPL H 00004000 Shifted to the WAITING state by get_mpl or tget_mpl TTW_TFL H 00008000 Shifted to the WAITING state by vwai_tfl or vtwai_tfl Rev 6 00 94 REJ10B0060 0600 RENESAS Section3 Service Calls 3 4 12 Change Task Execution Mode vchg_tmd C Language API ER ercd vchg_tmd UINT tmd Parameters UINT tmd R4 Task execution mode to change Return Parameters ER ercd RO Normal end E_OK or error code Error Codes E_PAR p Parameter error tmd is invalid
12. Appendix CCalculation of Work Area Size C9 Initialization Routine Stacks The size of each initialization routine stack can be determined by substituting the size obtained from appendix C 5 above into table C 8 When each initialization routine is defined by the configurator the size obtained in this section must be used The initialization routine is executed in serial the maximum size of each initialization routine stack is allocated Table C 8 Initialization Routine Stack Size Stack Size Byte Item HI7000 4 HI7700 4 HI7750 4 Size obtained in C 4 and C 5 Calls service call 140 140 144 CFG_TRACE is selected 24 24 24 CFG_NEWMPL is selected 28 28 28 Addition when the NMI is used s Total Notes 1 Size of the stack area used by the NMI interrupt handler calculated as shown in appendixes C 4 and C 5 8 x NMI nest count When there is no nesting the NMI nest count is 1 2 With the optimization timer driver or the DSP standby control function it becomes 164 Rev 6 00 417 RENESAS REJ10B0060 0600 Appendix CCalculation of Work Area Size C 10 Timer Initialization Routine Stack The maximum stack size to be used by timer initialization routine _kernel_tmrini is determined as follows e HI7000 4 252 bytes e HI7700 4 208 bytes e HI7750 4 204 bytes When the size calculated by table C 9 exceeds the above size allocate a new stack area with the calculated size and switch
13. If there are no messages in the message buffer and there are tasks waiting to send a message the message of the task at the head of the wait queue is received by the service call As a result the task is released from the WAITING state If there are no messages in the message buffer and there are no tasks in the queue to send a message the task that called service call rcev_mbf or trcv_mbf is placed in the wait queue to receive a message With service call prev_mbf error code E_TMOUT is immediately returned The wait queue is managed on FIFO basis The msg points to a RAM area specified with the maxmsz size by service call cre_mbf icre_mbf acre_mbf or iacre_mbf In service call trev_mbf parameter tmout specifies the timeout time If a positive value is specified for parameter tmout error code E_TMOUT is returned when the tmout time has passed without the wait release conditions being satisfied If tmout TMO_POL 0 is specified the same operation as for service call prev_mbf will be performed If tmout TMO_FEVR 1 is specified timeout monitoring is not performed In other words the same operation as for service call rev_mbf will be performed If a value larger than 1 is specified for CFG_TICDENO the denominator for time tick cycles the maximum value that can be specified for tmout is H 7fffffff CFG_TICDENO If a value larger than this is specified operation is not guaranteed For detail of time watch method refer to
14. Section3 Service Calls 3 8 5 C Language API wai_flg ID flgid FLGPTN waiptn MODE wfmode FLGPTN p_flgptn ER ercd ER ercd ER ercd ER ercd TMO tmout Parameters ID FLGPTN MODE FLGPTN lt twai_flg gt TMO Return Parameters ER FLGPTN Error Codes E_PAR E_ID E_NOEXS E_ILUSE E_CTX E_DLT E_TMOUT E_RLWAI Wait for Event Flag Setting wai_flg pol_fig ipol_flg twai_flg pol_flg ID flgid FLGPTN waiptn MODE wfmode FLGPTN p_flgptn ipol_flg ID flgid FLGPTN waiptn MODE wfmode FLGPTN p_flgptn twai_flg ID flgid FLGPTN waiptn MODE wfmode FLGPTN p_flgptn flgid R4 Event flag ID waiptn R5 Wait bit pattern wfmode R6 Wait mode p_flgptn R7 Pointer to the area where the bit pattern at waiting release is to be returned tmout R15 Timeout value ercd RO Normal end E_OK or error code p_flgptn R7 Pointer to the area where the bit pattern at waiting release is stored Parameter error p_flgptn is other than a multiple of four waiptn 0 wfmode is invalid or tmout lt 2 Invalid ID flgid lt 0 flgid gt CFG_MAXFLGID Undefined Event flag indicated by flgid does not exist Illegal use of service call A task is already waiting for the event flag with TA_WSGL attribute Context error Called from disabled system state Waiting object deleted Event flag indicated by flgid has been deleted in the WAITING state Polling failed or timeout WAITI
15. Stack Size Byte Item HI7000 4 HI7700 4 HI7750 4 Size obtained in C 4 and C 5 Mandatory 1 CFG_REGBANK is not selected 144 140 144 2 CFG_REGBANK is selected 68 CFG_NEWMPL is selected 28 28 28 Calls service call 140 140 144 CFG_TRACE is selected 24 Addition considering nested i interrupts Addition when the NMI is used Total Note 1 uppintnst The nest count of direct interrupts that are higher than CFG_KNLMSKLVL and CFG_TIMINTLV lowintnst The nest count of interrupts that are lower than or equal to CFG_KNLMSKLVL and higher than CFG_TIMINTLV 1 When NOBANK NOTUSE or SELECT has been selected for CFG_REGBANK 1 1 When CFG_DIRECT has been selected 12 x uppintnst 20 x lowintnst 1 2 When CFG_DIRECT has not been selected 12 x uppintnst 24 x lowintnst 20 However when lowintnst is 0 assume the underlined part to be 0 2 When ALL has been selected for CFG_REGBANK 8 x uppintnst 16 x lowintnst If you are using UBC interrupts however the following values must also be added UBC interrupts used as direct interrupts 4 bytes UBC interrupts used as normal interrupts 28 bytes 2 Size of the stack area used by the NMI interrupt handler calculated as shown in appendixes C 4 and C 5 8 x NMI nest count When there is no nesting the NMI nest count is 1 3 With the optimization timer driver or the DSP standby control function it becomes 164 Rev 6 00 416 REJ10B0060 0600 RENESAS
16. The cpu option for the compiler and the assembler depends on the microcomputer in use In particular the correct CPU option must be specified for compilation of the files indicated in table 5 10 below Table 5 10 CPU Options Kernel CPU in Use Target Source File CPU Option HI7000 4 SH 2A 1 kernel_def c this file is included inmix and def SH2A or SH2A FPU projects SH2AFPU 2 kernel_cfg c this file is included in mix and cfg projects 3 kernel_exp src 4 All files that use service calls when Only for service call is chosen as CFG_TBR HI7700 4 SH4AL DSP 1 kernel_def c this file is included in mix and def SH4ALDSP HI7750 4 SH 4A projects SH4A 2 kernel_cfg c this file is included in mix and cfg projects 3 The source file which uses a cache support service call 5 11 2 GBR Option of Compiler Compiler Package V 7 1 or Later The GBR intrinsic function of compiler is used in the sample timer driver for some devices Specify gbr user when you use these sample timer drivers The sample timer drivers which use the GBR intrinsic function in each kernel version at this manual creation time are shown below e HI7000 4 V 2 02 All sample timer drivers other than SH72060 and SH7618 e HI7700 4 V 2 02 All sample timer drivers other than SH7290 SH7318 SH7641 and SH7343 e HI7700 4 V 2 02 All sample timer drivers other than SH7760 SH7770 and SH7785 Rev 6 00 373 RENESAS REJ10B0060 0600 Section5 Configura
17. When the following service calls are called the precedence which does not apply above can be temporarily generated a When dis_dsp is called the precedence will be the middle of 1 and 2 above The state returns to former state by calling dis_dsp b When loc_cpu or iloc_cpu is called the precedence will be the same as that of the interrupt handler of which interrupt level is the same as CFG_KNLMSKLVL The state returns to former state by calling unl_cpu or iunl_cpu c While the interrupt mask level is changed to other than 0 by chg_ims the precedence is the same as an interrupt handler which has the same level 2 4 System State The system state is classified into the following orthogonal states e Task context state non task context state e Dispatch disabled state dispatch enabled state e CPU locked state CPU unlocked state The system operations and available service calls are determined based on the above system states Rev 6 00 7 RENESAS REJ10B0060 0600 Section2 Kernel 2 4 1 Task Context State and Non Task Context State The system is executed in either task context state or non task context state The difference between task and non task context states is described in table 2 1 Table 2 1 Task Context State and Non Task Context State Item Task Context State Non Task Context State Available service calls Service calls that can be called Service calls that can be called from from the task context the
18. c Service call function is called d After service call processing execution returns to the address specified by the PR register except for the service calls that do not return to the calling program In this example execution returns to this location When execution returns normal end E_OK or an error code is set in RO 3 2 3 Guarantee of Register Contents after Issuing Service Call Some registers guarantee the contents after a service call is issued but the others do not This tule is based on that of the Renesas C compiler The details are shown below Table 3 3 Guarantee of Register Contents after Issuing Service Call Register Register State after Service Call Returned SR R8 to R15 PR GBR The register contents will be guaranteed IMASK bits in the SR MACH MACL register are updated when a service call chg_ims ichg_ims loc_cpu iloc_cpu unl_cpu or iunl_cpu is called RO Normal end E_Ok or an error code is set R1 to R7 The register contents will be guaranteed only when a service call is clearly shown as a return parameter For SH2 DSP and SH3 DSP and SH4AL DSP DSR RS RE MOD AO AOG A1 A1G MO M1 XO X1 YO Y1 The register contents will be guaranteed in the following situation A service call is issued from a task with TA_COPO attribute or task exception processing routine e A service call is issued in a state mentioned in the note on the following page For SH 4 and SH
19. ef_opttmr_set E 6 3 Notes on the Configurator 427 E 6 4 Modifying kernel Sysser E a 428 E 7 Kernel Libraries to be Used scnsccccscseccacseecacsdecaecsscatedecsessissisductsassesibedevssecensdedevsacegaviess 428 Appendix F DSP Standby Control HI7700 4 ssscscssssssssssssssssssssssssssssssseere 429 F l OV EDVICW oroni ernea aroia vaoa e E E EENES ET AE S oer he altura ania 429 F 2 Applicable MCUS sareei eirinen iasgseaisisadactiedisedssesiesvassteasatasasideiacsvaieds 431 F 3 Module Standby State when Initiating Programs Rev 6 00 vii RENESAS REJ10B0060 0600 Contents F4 Service Call for Changing the TA_COPO Attribute vchg_cCODp cece 432 F 5 Ways to Include DSP Standby Control Function ssssssesssssserersssienersisrnrnerersrernnrees 433 F5 1 OVENIOW cinch eee aes nome 433 F5 2 Creating the kernel_def_dspstby_set h Definition File F5 3 Modifying kernel_sys h F 6 Kernel Libraries to be Used F 7 INGLES E E E E a E 435 Appendix G Notes on FPU of SH2A FPU SH 4 SH4A ssesesessrosoeoeseseseseseseeosesceeee 437 G 1 Task and Task Exception Processing Routine s sssssesssssssssssrsisrsssrersrsisssresrsessres 437 G 1 1 Initialization of FPSCR a G 1 2 Attributes TA_COP1 and TA_COP2 G 2 Non Task Context Normal Interrupt Handler Direct Interrupt Handler CPU Exception Handler Time Event Handler Initialization Routine 438 G 2 1 OVERVIEW fos acovecs oc zacteties a A
20. use the standard profile function T Can be called from task context N Can be called from non task context E Can be called from dispatch enabled state D Can be called from dispatch disabled state U Can be called from CPU unlocked state L Can be called from CPU locked state C Can be called from CPU exception handler Rev 6 00 278 REJ10B0060 0600 RENESAS Section3 Service Calls 3 26 1 Initialize Cache vini_cac ivini_cac C Language API void vini_cac ATR cacatr void ivini_cac ATR cacatr Parameters ATR ccratr R4 Cache attribute Return Parameters ER ercd RO Normal end E_OK Error Codes None Function This service call initializes the cache Before using the cache function call this service call Specifically based on specified cacatr as shown in table 3 78 the CCR register and RAMCR register of a processor are set up Although the logical sum of each item of table 3 81 can be specified to be cacatr no error check of the value specified to be cacatr is performed Moreover this service call is not concerned with the contents of specification of cacatr but writes 1 in the CCR ICI and CCR OCI bit That is all the contents of the cache before this service call are canceled When the target microcomputer does not have a secondary cache do not specify TCAC_L2_ENABLE or TCAC_L2_FC In addition in this service call no registers other than CCR and RAMCR are changed This service call can be cal
21. 256 4 SH7727 SH7641 SH7660 32 kbytes SH7290 SH7294 32 kbytes mode 512 4 SH7300 SH7705 16 kbytes mode 256 4 SH7710 Rev 6 00 256 REJ10B0060 0600 RENESAS Section3 Service Calls If the usage of these service calls is mistaken coherence between the cache and the memory might not be maintained When the contents of the cache may not have been written back to the memory and you need to be sure that they have been written back make the vfls_cac or ivfls_cac service call to flush the cache before issuing this service call Specify a value for ccr_data such that the CCR CF bit becomes 1 When the CCR3 in the SH7290 etc register is to be set the CCR3 register must be set in the application before this service call is made Do not access the cache during the period between setting of the CCR3 register and return of program flow from vini_cac or ivini_cac For example have the cache disabled while setting the CCR3 register and issuing vini_cac or ivini_cac In the same way when the CCR2 in the SH7709S SH7290 etc register is to be set the CCR2 register must be set in the application before this service call is made Do not access the cache between setting of the CCR2 register and the return from vini_cac or ivini_cac For example have the cache disabled while setting the CCR2 register and issuing vini_cac or ivini_cac This service call can be called before the kernel is initiated This service call can be called even in the
22. ATR ccratr R4 Cache attribute Return Parameters ER ercd RO Normal end E_OK Error Codes None Function This service call initializes the cache Before using the cache function call this service call Specifically based on specified cacatr as shown in table 3 78 the CCR register and RAMCR register of a processor are set up Although the logical sum of each item of table 3 78 can be specified to be cacatr no error check of the value specified to be cacatr is performed Moreover this service call is not concerned with the contents of specification of cacatr but writes 1 in the CCR ICI and CCR OCI bit That is all the contents of the cache before this service call are canceled In addition in this service call no registers other than CCR and RAMCR are changed This service call can be called before the kernel is initiated This service call can be called even in the exception block state BL in SR Rev 6 00 269 RENESAS REJ10B0060 0600 Section3 Service Calls Table 3 78 Cache Attribute CCR and RAMCR Attribute Value Description Setting TCAC_IC_ENABLE H 00000100 When Enable instruction CCR ICE 1 specify cache When not Disable instruction CCR ICE 0 specify cache TCAC_OC_ENABLE H 00000001 When Enable operand cache CCR OCE 1 specify When not Disable operand cache CCR OCE 0 specify TCAC_IC_2WAY H 00800000 When 2 way instruction cache RAMCR IC2W 1 specify Whe
23. Figure 2 20 shows an example of using a cache support Clears cache velr_cac J Cache Memory Address array Data array Flushes cache Writeback vfls_cac Invalidates cache vinv_cac Figure 2 20 Example of Using a Cache Support Flushing the Cache By writing the contents of the cache to the memory coherence of the cache and the memory is established When a bus master such as the DMA reads memory updated by the CPU the contents of the cache must be flushed Note that when the cache is used in the write through mode data does not have to be flushed Rev 6 00 60 REJ10B0060 0600 RENESAS Section2 Kernel Clearing the Cache The service call vclr_cac writes the contents of cache to the memory and invalidates the contents of the cache Invalidating the Cache When the CPU reads memory updated by a bus master such as the DMA the contents of cache must be invalidated so that without fail the contents of the memory can be read by the CPU If the contents of the cache are invalidated for write back mode they will not be written back to the memory even if data not written back to the memory exists in the cache Therefore the cache contents must be written back to the memory before invalidating the cache The cache support function is used when it is necessary to establish coherence of the memory and the cache such as when transferring the memory contents of an appl
24. Parameter error p_blk is other than a multiple of four blksz is other than a multiple of four or 0 or tmout lt 2 mplsz 16 lt blksz Invalid ID number mplid lt 0 or mplid gt CFG_MAXMPLID Undefined Variable size memory pool indicated by mplid does not exist Context error Called from disabled system state Waiting object deleted The memory pool specified by mplid has been deleted Polling failed or timeout WAITING state was forcibly cancelled rel_wai service call was called in the WAITING state Note mplsz Memory pool size created at variable size memory pool creation Rev 6 00 191 RENESAS REJ10B0060 0600 Section3 Service Calls Function Each service call acquires a variable size memory block with the size specified by blksz number of bytes from the variable size memory pool indicated by mplid and returns the start address of the acquired memory block to the area indicated by p_blk After the memory block has been acquired the size of the variable size memory pool free space will decrease For details refer to section 2 15 3 Management of Variable Size Memory Pool If there are tasks already waiting for the memory pool or if no task is waiting but there is no memory block available the task having called service call get_mpl or tget_mpl is placed in the memory block wait queue and the task having called service call pget_mpl or ipget_mpl is immediately terminated with the error code E_TMOU
25. Refer to Version Information iref_ver ER ercd iref_ver T_RVER pk_rver Cache Support Function HI7700 4 for SH 3 and SH3 DSP 149 vini_cac void vini_cac UW ccr_data UW entnum UW waynum Initialize Cache ivini_cac void ivini_cac UW ccr_data UW entnum UW waynum 150 velr_cac ER ercd vclr_cac VP clradr1 VP clradr2 Clear Cache ivelr_cac ER ercd ivclr_cac VP clradr1 VP clradr2 151 vfls_cac ER ercd vfls_cac VP flsadr1 VP flsadr2 Flush Cache ivfls_cac ER ercd ivfls_cac VP flsadr1 VP flsadr2 152 vinv_cac ER ercd vinv_cac void Invalidate Cache ivinv_cac ER ercd ivinv_cac void Cache Support Function HI7750 4 for SH 4 153 vini_cac void vini_cac UW ccr_data Initialize Cache ivini_cac void ivini_cac UW ccr_data 154 velr_cac ER ercd vclr_cac VP clradr1 VP clradr2 Clear Operand Cache ivelr_cac ER ercd ivclr_cac VP clradr1 VP clradr2 155 vfls_cac ER ercd vfls_cac VP flsadr1 VP flsadr2 Flush Operand Cache ivfls_cac ER ercd ivfls_cac VP flsadr1 VP flsadr2 156 vinv_cac ER ercd vinv_cac VP invadr1 VP invadr2 Invalidate Operand Cache ivinv_cac ER ercd ivinv_cac VP invadr1 VP invadr2 Rev 6 00 399 RENESAS REJ10B0060 0600 Appendix A Service Call List No Service C Language API Function Call Cache Support Function HI7700 4 for SH4AL DSP without extended function HI7750 4
26. Rev 6 00 80 REJ10B0060 0600 RENESAS Section3 Service Calls 3 4 3 Initiate Task act_tsk iact_tsk C Language API ER ercd act_tsk ID tskid ER ercd iact_tsk ID tskid Parameters ID tskid R4 Task ID Return Parameters ER ercd RO Normal end E_OK or error code Error Codes E_ID p Invalid ID number tskid lt 0 tskid gt MAXTSKID or tskid TSK_SELF 0 is specified in a non task context E_NOEXS k Undefined Task indicated by tskid does not exist E_QOVR k Queuing overflow actcnt gt 15 Function Each service call initiates the task indicated by the parameter tskid The initiated task makes a transition from the DORMANT state to the READY state The processing that is performed during task activation is listed in table 3 8 Table 3 8 Processing to be Performed during Task Initiation Contents Initiates base priority and current priority of the task Clears the number of start request queues Clears the number of suspend request nestings Clears reserved exception factors Sets task exception processing disabled state Clears flag patterns of the task event flag By specifying tskid TSK_SELF 0 the current task is specified Extended information of the task specified at task creation will be passed to the task as the parameter If the static stack of the task indicated by tskid is not being used by any task when the service calls act_tsk and iact_tsk are called tskid 1
27. Section3 Service Calls 3 4 5 Start Task Start Code Specified sta_tsk ista_tsk C Language API ER ercd sta_tsk ID tskid VP_INT stacd ER ercd ista_tsk ID tskid VP_INT stacd Parameters ID tskid R4 Task ID VP_INT stacd R5 Task initiation code Return Parameters ER ercd RO Normal end E_OK or error code Error Codes E_ID p Invalid ID number tskid lt 0 tskid gt CFG_MAXTSKID E_NOEXS k Undefined Task indicated by tskid does not exist E_OBJ k Object state is invalid The task specified by tskid is not in the DORMANT state or the current task is specified Function Each service call initiates the task indicated by the parameter tskid The initiated task makes a transition from the DORMANT state to the READY state At this time the processing to be performed during task initiation table 3 8 is performed The task initiation code indicated by the parameter stacd will be passed to the initiated task as the parameter If the static stack of the task indicated by tskid is not being used by any task when the service calls sta_tsk and ista_tsk are called the task indicated by tskid occupies the shared stack and shifts to the READY state If the stack is being used by another task the task indicated by tskid shifts to the WAITING state and is placed in the shared stack wait queue since the stack area cannot be used The wait queue is managed on a first in first out FIFO basis Rev 6 00 83 RENE
28. ceeeees 3 13 2 Delete Fixed Size Memory Pool del_mpf 3 13 3 Get Fixed Size Memory Block get_mpf pget_mpf ipget_mpf tget_mpf 3 13 4 Release Fixed Size Memory Block rel_mpf irel_mpf 3 13 5 Refer to Fixed Size Memory Pool State ref_mpf iref_mpf 3 14 Memory Pool Management Variable Size Memory Pool 3 14 1 Create Variable Size Memory Pool 3 14 2 Delete Variable Size Memory Pool del_mpl 3 14 3 Get Variable Size Memory Block get_mpl pget_mpl ipget_mpl tget_mp 3 14 4 Release Variable Size Memory Block rel_mpl irel_mp 3 14 5 Refer to Variable Size Memory Pool State ref_mpl iref_mp 3 15 Time Management System Clock 3 15 1 Set System Clock set_tim iset_tim 3 15 2 Get System Clock get_tim iget_tim Rev 6 00 iii RENESAS REJ10B0060 0600 Contents 315 3 Supply Time Tick SISHI ssr sesasicavecsssctsessseessesncssovsedtes cassvosssusenesavedetccseenposenvdeneteveveses 3 16 Time Management Cyclic Handler 3 16 1 Create Cyclic Handler 0 3 16 2 Delete Cyclic Handler del_cyc 3 16 3 Start Cyclic Handler sta_cyc ista_cyc 3 16 4 Stop Cyclic Handler stp_cyc istp_cyc 3 16 5 Refer to Cyclic Handler State ref_cyc iref_cyc 3 17 Time Management Alarm Handler 3 17 1 Create Alarm Handler 3 17 2 Delete Alarm Handler del_alm 3 17 3 Start Alarm Handler sta_alm ista_alm 3 17 4 Stop Alarm Handler stp_alm istp_alm
29. e Create application files e Create configuration files using the configurator e Use the build function of HEW and create load modules These three operations differ slightly according to the way the load modules are created Therefore it is essential to decide on and understand the creation method first There are two different approaches to linkage whole linkage into a single load module and separate linkage into separate load modules Whole Linkage Whole linkage links the kernel and all configuration files into a single load module called a whole load module Application files can be included in a whole load module or in separate load modules called an application load module Figure 5 1 shows the flow for creating a load module using whole linkage Rev 6 00 341 RENESAS REJ10B0060 0600 Section5 Configuration Whole linkage project 4 7_mix kernel_def c Supplied library Whole load module kernel_cfg c Application project Application file Application g HEW load module Note Application files specified by the configurator are also required Figure 5 1 Whole Load Module Creation Separate Linkage Separate linkage links the kernel code portion and the data portion into separate load modules A load module with the kernel code portion called the kernel load module is created by linking kernel libraries and kernel_def c which is a part of the configurator output file The linkage unit o
30. 3 17 5 Refer to Alarm Handler State ref_alm iref_alm 3 18 Time Management Overrun Handler 3 18 1 Define Overrun Handler def_ovr 3 18 2 Start Overrun Handler sta_ovr ista_ovr 3 18 3 Stop Overrun Handler Operation stp_ovr istp_ovr 3 18 4 Refer to Overrun Handler State ref_ovr iref_ovr 3 19 System State Management 3 19 1 Rotate Ready Queue rot_rdq irot_rdq 3 19 2 Get Task ID in RUNNING State get_tid iget_tid 3 19 3 Lock CPU loc_cpu iloc_cpu 3 19 4 Unlock CPU unl_cpu iunl_cpu 3 19 5 Disable Dispatch dis_dsp 3 19 6 Enable Dispatch ena_dsp 3 19 7 Refer to Context sns_ctx 3 19 8 Refer to CPU Locked State sns_loc 3 19 9 Refer to Dispatch disabled State sns_dsp 3 19 10 Refer to Dispatch Pended State sns_dpn 3 19 11 Start Kernel vsta_knl ivsta_knl 3 19 12 System Down vsys_dwn ivsys_dwn 3 19 13 Acquire Trace Information vget_trc ivget_trc 9 3 19 14 Acquire Start of Interrupt Handler as Trace Information ivbgn_int 234 3 19 15 Acquire End of Interrupt Handler as Trace Information ivend_int s239 3 20 Interrupt Management cccccceceesseseeseseeeeeceeeeeeeeseeeeeseecesaeess 236 3 20 1 Define Interrupt Handler def_inh idef_inh 237 3 20 2 Change Interrupt Mask chg_ims ichg_ims 240 3 20 3 Refer to Interrupt Mask get_ims iget_ims 3 21 Service Call Management 3 21 1 Defin
31. A direct interrupt handler supported by HI7000 4 is initiated by the CPU without kernel intervention when an interrupt occurs In addition interrupt handlers with interrupt levels higher than the kernel interrupt mask level CFG_KNLMSKLVL must be written and defined as direct interrupt handlers including NMI If these interrupts are written and defined as the normal interrupt handlers normal system operation cannot be guaranteed Note that HI7700 4 and HI7750 4 do not support direct interrupt handlers 1 Writing a Direct Interrupt Handler A direct interrupt handler is written in C language as shown in figure 4 6 include kernel h define stksz 512 1 VW stk stksz sizeof VW static const VP p_stk VP amp stk stksz sizeof VW 2 pragma interrupt DirectInh sp p_stk tn 25 3 void DirectInh void 4 Interrupt handler processing Figure 4 6 Example of a C Language Direct Interrupt Handler Rev 6 00 312 REJ10B0060 0600 RENESAS Section4 Application Program Creation Descriptions of Figure 4 6 1 Allocate a stack area for the interrupt handler The handler except NMI must switch stacks in order to avoid overflow of the interrupted program s stack Interrupt handlers of the same interrupt level can share a stack Note however that NMI interrupt handler cannot use its dedicated stack 2 Initial stack pointer defined as const 3 The interrupt handler function is declar
32. Can be called from dispatch disabled state U Can be called from CPU unlocked state L Can be called from CPU locked state C Can be called from CPU exception handler Rev 6 00 184 REJ10B0060 0600 RENESAS Section3 Service Calls Variable Size Memory Pool Specifications The variable size memory pool specifications are listed in table 3 45 Table 3 45 Variable Size Memory Pool Specifications Item Description Variable size memory pool ID 1 to CFG_MAXMPLID 1023 max Management method Selecting CFG_NEWMPL through the configurator improves the following e Acquisition and return of memory blocks become faster when a large number of memory blocks are used in the memory pool e The VTA_UNFRAGMENT attribute can be used to reduce fragmentation of free space Attributes supported TA_TFIFO Task wait queue is managed on a FIFO basis VTA_UNFRAGMENT Sector management reducing fragmentation in free space can be specified only when CFG_NEWMPL is selected The free space in the variable size memory pool may be fragmented The VTA_UNFRAGMENT reduces this fragmentation Also refer to section 2 15 2 Controlling Fragmentation of Free Space Rev 6 00 185 RENESAS REJ10B0060 0600 Section3 Service Calls 3 14 1 Create Variable Size Memory Pool cre_mpl icre_mpl acre_mpl iacre_mpl Assign Variable Size Memory Pool ID Automatically C Language API ER ercd cre_mpl ID mplid T_CMPL pk_cmp1 ER ercd
33. D 2 Standard Timer Driver The standard timer driver is composed of the timer initialization routine and the timer interruption routine The timer interruption processing routine is called from timer interruption handler _kernel_isig_tim of the kernel and clears the interruption factor And the timer initialization routine is executed as an initialization routine D 2 1 Installing the Time Management Function To use the time management function of the kernel the following operations are required 1 Set the time management function page by the configurator Here the following kernel function constants are defined TIC_NUME Numerator of time tick cycle CFG_TICNUME TIC_DENO Denominator of time tick cycle CFG_TICDENO TIM_LVL Timer interrupt level CFG_TIMINTLVL The cycle time when the time tick is provided is TIC_NUME TIC_DENO ms Based on this cycle time the precision of the time parameter specified in the service call is determined For example when tslp_tsk 10 is executed timeout time is 12 to 15 ms if TIC_NUME 3 and TIC_DENO 1 timeout time is 10 to 10 5 ms if TIC_NUME 1 and TIC_DENO 2 Note that at least one of TIC_NUME and TIC_DENO must be specified as 1 In addition if TIC_DENO is specified as a value greater than 1 the maximum value that can be specified to TMO RELTIM and OVRTIM type parameters is limited to the available maximum value TIC_DENO Rev 6 00 419 RENESAS REJ10B0060 0600 App
34. Description T N E D U L C slp_tsk S Shifts current task to the WAITING state T E U tslp_tsk S Shifts current task to the WAITING state with timeout function T E U wup_tsk S Wakes up task T E D U iwup_tsk S N E D U can_wup S Cancels Wakeup Task T E D U ican_wup N E D U rel_wai S Forcibly cancels the WAITING state T E D U irel_wai S N E D U sus_tsk S Shifts the task to the SUSPENDED state T E D U isus_tsk N E D U rsm_tsk S Resumes the execution of a task in the SUSPENDED state T E D U irsm_tsk N E D U frsm_tsk S Forcibly resumes the execution of a task in the SUSPENDED T E D U ifrsm_tsk state N E D U dly_tsk S Delays the current task T E U vset_tfl Sets the task event flag T E D U ivset_tfl N E D U velr_tfl Clears the task event flag T E D U ivelr_tfl N E D U vwai_tfl Waits for the task event flag T E U vpol_tfl Polls and waits for the task event flag T E D U viwai_tfl Waits for the task event flag with timeout function T E U Notes 1 S Standard profile service calls s Service calls that are not standard profile service calls but are needed in order to use the standard profile function Rev 6 00 96 REJ10B0060 0600 RENESAS Section3 Service Calls 2 T Can be called from task context N Can be called from non task context E Can be called from dispatch enabled state D Can be called from dispatch disabled state U Can be called from CPU unlocked state L Can be called from CPU locked state C Can be called fro
35. E_OBJ k Operand cache is disabled Function This service call flushes the operand cache That is If the operand cache has data which has not been written to memory the data is written back to memory flsadr1 is omitted to the multiple of 32 and flsadr2 is revalued to the multiple 1 of 32 1 Flush specified range This service call flushes the operand cache entry whose logical address is from flsadr1 to flsadr2 This service call repeats and executes the OCBWB instruction from flsadr1 to flsadr2 This processing is performed in the state of SR BL 0 and SR I 15 However whenever it processes one entry this service call restores SR at the time of this call That is interruption may be accepted by SR at the time of this call In this service call only the fundamental error check indicated in the error code column is performed on flsadr1 and flsadr2 For example the following addresses should not be contained e P2 and P4 areas e Address corresponding to a physical address in the control area e Address corresponding to a physical address in X Y memory The processing time of this service call is proportional to the size of the appointed domain Rev 6 00 273 RENESAS REJ10B0060 0600 Section3 Service Calls 2 Flush all If 0 is specified to be flsadr1 and H ffffffff is specified to be flsadr2 all the entries of the operand cache will be cleared In this case this service call is processed as follows e The operan
36. ID semid Return Semaphore Resource 40 wai sem ER ercd wai_sem ID semid Wait on Semaphore 41 pol_sem ER ercd pol_sem ID semid ipol_sem ER ercd ipol_sem ID semid Poll and Wait on Semaphore 42 twai_sem_ ER ercd twai_sem ID semid TMO tmout Wait on Semaphore with Timeout 43 ref sem ER ercd ref_sem ID semid T_RSEM pk_rsem iref sem ER ercd iref_sem ID semid T_RSEM pk_rsem Refer to Semaphore State RENESAS Rev 6 00 391 REJ10B0060 0600 Appendix A Service Call List No Service C Language API Function Call Event Flag 44 cre_flg ER ercd cre_flg ID flgid T_CFLG pk_cflg Create Event Flag icre_flg ER ercd icre_flg ID flgid T_CFLG pk_cflg 45 acre_flg ER_ID flgid acre_flg T_CFLG pk_cflg iacre_flg ER_ID flgid iacre_flg T_CFLG pk_cflg Create Event Flag and Assign Event Flag ID Automatically 46 del_flg ER ercd del_fig ID flgid Delete Event Flag 47 set flg ER ercd set_flg ID flgid FLGPTN setptn Set Event Flag iset_flg ER ercd iset_flg ID flgid FLGPTN setptn 48 clr_flg ER ercd clr_flg ID flgid FLGPTN clrptn Clear Event Flag iclr_flg ER ercd iclr_flg ID flgid FLGPTN clrptn 49 wai_fig ER ercd wai_flg ID flgid FLGPTN waiptn MODE Wait for Event Flag Setting wfimode FLGPTN p_flgptn 50 pol_flg ER ercd pol_flg ID flgid FLGPTN waiptn MODE Poll and Wait for Event
37. Note that the mutex is unlocked when a task is terminated and deleted The kernel performs the following processing when a task is terminated e Unlock the mutex that is locked by the current task e Clear the upper limit processor time The kernel performs the following processing when a task is deleted e Release the task stack area 2 6 6 Task Stack There are three methods of allocating stacks Static Stack The static stack is defined for each task by the configurator when the system is configured A shared stack function which allows more than one task to use a single stack is available for tasks that use the static stack Dynamic Stack When a task is created the kernel assigns a stack area to the task The stack is allocated in the dynamic stack area CFG_TSKSTKSZ A shared stack function is not available for tasks that use a dynamic stack Stack Allocated by Application The application allocates a stack area and specifies the address at task creation A shared stack function is not available for tasks that use this type of stack Rev 6 00 15 RENESAS REJ10B0060 0600 Section2 Kernel The configurator specifies the maximum task ID CFG_STSTKID which represents the maximum ID of a task using the static stack and the maximum task ID CFG_MAXTSKID in the system Tasks with task IDs between 1 and CFG_STSTKID use the static stack while tasks with task IDs between CFG_STSTKID 1 and CFG_MAXTSKID use the dynamic s
38. Return Parameters ER ercd RO Normal end E_OK or error code T_RTEX pk_rtex R5 Pointer to the packet where the task exception processing state is stored Packet Structure typedef struct t_rtex STAT texstat 0 4 Task exception processing state TEXPTN pndptn 4 4 Pended exception factor T_RTEX Error Codes E_PAR p Parameter error pk_rtex is other than a multiple of four E_ID p Out of ID range tskid lt 0 tskid gt CFG _MAXTSKID or tskid TSK_SELF 0 is specified in a non task context E_NOEXS k Undefined Task indicated by tskid does not exist E_OBJ k Object status is invalid Task indicated by tskid is in the DORMANT state or task exception processing routine is not defined Function The state relating to task exception processing for the task specified by tskid is referenced and the result is returned to the area indicated by pk_rtex One of the following values is returned for texstat according to whether the target task is in a task exception enabled state or a task exception processing disabled state Table 3 21 Task Exception Processing State texstat texstat Code Description TTEX_ENA H 00000000 Task exception processing enabled state TTEX_DIS H 00000001 Task exception processing disabled state The pended exception factor for the target task is returned as pndptn If there are no unprocessed exception processing requests 0 is returned as pndptn By specifying tskid TSK_SELF 0 the
39. Routine processing Figure D 1 Example of a C Language Timer Interrupt Routine Rules on timer interrupt routine register specifications are the same as normal interrupt handlers For details refer to section 4 8 1 Normal Interrupt Handler To use the DSP in the timer initialization routine and the timer interrupt routine refer to section 4 13 Using the DSP in Programs for HI7000 4 and HI7700 4 only To use the FPU in the timer initialization routine and the timer interrupt routine refer to appendix G 2 Non Task Context Normal Interrupt Handler Direct Interrupt Handler CPU Exception Handler Time Event Handler Initialization Routine 3 Link the timer driver The timer driver must be linked to the kernel Rev 6 00 420 REJ10B0060 0600 RENESAS Appendix D Timer Driver D 2 2 Sample Timer Driver The sample timer driver consists of the following header files and source files 1 Device header file file name nnnn_tmrdrv h This file defines register I O addresses and initial values and timer device information These values do not need to be modified 2 Header file file name nnnn_tmrdef h This file defines information that determines timer driver operations such as clock frequency 3 Source program file file name nnnn_tmrdrv c Timer initialization routine function void _kernel_tmrini void Timer interrupt routine function void _kernel_tmrint void The timer interrupt period T i
40. Undefined to FR15_BANKO 11 SH 4 SH 4A FRO_BANK1 Undefined to FR15_BANK1 Notes 1 These registers can be used Note that some register contents cannot be guaranteed after service calls For details refer to section 3 2 3 Guarantee of Register Contents after Issuing Service Call 2 When execution is returned from the entry function RTS instruction the contents of these registers must be the same as the value at initiation 3 Except in the CPU locked state IMASK must be 0 MD 1 BL 0 RB 0 and FD 0 are required 4 Only when at least one of the TA_COP1 and TA_COP2 attributes is specified 5 Only when the TA_COP1 attribute is specified 6 Only when the TA_COP2 attribute is specified Rev 6 00 300 REJ10B0060 0600 RENESAS Section4 Application Program Creation 3 Initial Contents of Task Management Information Kernel management information is initialized when a task is initiated The task management information items and their initialized contents are shown in table 4 5 Table 4 5 Initialized Contents of Task Management Information Item Initialization Specification Task base priority The initial task priority specified at the task definition itskpri Task current priority The current task priority Task wake up request queues 0 Task suspend request nestings 0 Task event flag 0 Task exception processing Disabled Suspended exception factor 0 Task execution mode 0 4 Creating a
41. When Cache Support Function is Used on SH4AL DSP HI7700 4 or SH 4A HI7750 4 e 5 11 1 CPU Options for the Compiler and Assembler Rev 6 00 267 RENESAS REJ10B0060 0600 Section3 Service Calls Cache Support Service Calls The cache is controlled by the service calls listed in table 3 77 Table 3 77 Service Calls for Cache Support for SH4AL DSP without Extended Function and SH 4A without Extended Function System State Service Call Description T N E D U L C vini_cac Initializes cache T N E D U ivini_cac T N E D U velr_cac Clears instruction operand cache T N E D U ivelr_cac T N E D U vfls_cac Flushes operand cache T N E D U ivfls_cac T N E D U vinv_cac Invalidates instruction operand cache T N E D U ivinv_cac T N E D U Notes 1 S Standard profile service calls s Service calls that are not standard profile service calls but are needed in order to use the standard profile function 2 T Can be called from task context N Can be called from non task context E Can be called from dispatch enabled state D Can be called from dispatch disabled state U Can be called from CPU unlocked state L Can be called from CPU locked state C Can be called from CPU exception handler Rev 6 00 268 REJ10B0060 0600 RENESAS Section3 Service Calls 3 25 1 Initialize Cache vini_cac ivini_cac C Language API void vini_cac ATR cacatr void ivini_cac ATR cacatr Parameters
42. and starts HEW The shnnnn hws includes the following sample projects for the target microcomputer 1 HEW3 or later e mix Whole linkage e def Separate linkage kernel side e cfg Separate linkage kernel environment side 2 HEW1 2 e nnnn_mix Whole linkage for the microcomputer corresponding to nnnn e mnnnn_def Separate linkage kernel side for the microcomputer corresponding to nnnn e nnnn_cfg Separate linkage kernel environment side for the microcomputer corresponding to nnnn Select a project for the appropriate microcomputer and change the settings as explained below The following explains only the items that should be especially kept in mind To select a sample project select a project from the workspace window and select Set as Current Project from the pop up menu as shown in figure 5 9 Opening a project file and clicking the Build button compiles assembles links and converts the files in the project and creates a load module In addition the HEW screen carried after this section was acquired in the following environments e HEW HEW4 which is attached in compiler package V 9 00 Release 03 e Kernel HI7700 4 V 2 02 Release 00 By the HEW version or kernel HEW screen may differ from a screen found in this section Rev 6 00 365 RENESAS REJ10B0060 0600 Section5 Configuration cfg High performance Embedded Works File Edit View Project Build Debug Setup Duga e a obL
43. for SH4AL DSP with Extended Function HI7750 4 for SH 4A with Extended Function 3 26 1 Initialize Cache vini_cac ivini_cac 3 26 2 Clear Instruction Operand Cache vclr_cac ivclr_cac 3 26 3 Flush Operand Cache vfls_cac ivfls_cac 3 26 4 Invalidate Instruction Operand Cache vinv_cac ivinv_cac Section 4 Application Program Creation cscscsccssscscsscsessssssssssecssesssceseees 4 1 Header Files 4 1 1 Header Files for C C Language 4 1 2 Header Files for Assembly Language 4 2 Handling the CPU Resources 4 2 1 SR Register 4 2 2 Cache Lock Function SH 3 SH3 DSP 4 2 3 VBR REGIST issccsssenonsderccsnresderonsassesandeneas 4 2 4 MMU SH 3 SH3 DSP SH4AL DSP SH 4 SH 4A 4 2 5 Acceptance of NMI while SR BL 1 SH 3 SH3 DSP SH4AL DSP SH 4 4 2 6 Nesting the Interrupts SH 3 SH3 DSP SH4AL DSP SH 4 SH 4A 4 2 7 32 Bit Address Extension Mode SH 4A 4 2 8 TBR Register SH 2A SH2A FPU 4 2 9 Register Banks SH 2A SH2A FPU 4 3 Using SH2A FPU SH 4 or SH 4A 4 4 System Reserve 4 4 1 Reserved Name 4 4 2 Reserved TRAP Only in HI7000 4 4 5 E E A A A 4 6 Task Exception Processing Routines 00 4 7 Extended Service Call ROUES s 0 ccscccsescccessicesencascaaiesssaunsecadedcosucdcpasescssececsadesssnasacs 4 8 Interrupt Handlers 4 8 1 Normal Interrupt Handlev 4 8 2 Direct Interrupt Handler H1I7000 4 4 9 CPU Except
44. for TRAPA instruction ref_cfg iref_cfg Refers to the configuration information ref_ver iref_ver Refers to version information Interrupt handlers and CPU exception handlers including the CPU exception handler for the TRAPA instruction can also be defined by the configurator When an undefined interrupt or exception occurs the system down routine will be initiated Rev 6 00 52 REJ10B0060 0600 RENESAS Section2 Kernel 2 18 1 Resetting the CPU and Initiating the Kernel To reset the CPU and initiate the kernel refer to figure 2 18 Reset CPU initialization routine Assembly language Sample hi_cpuasm in nnnn_cpuasm src Initialize BSC JMP or JSR instruction CPU initialization routine C language Sample hi_cpuini in nnnn_cpuini src Set program execution environment Initialize sections are 5 Initialization routine vsta_knl service call Kernel initialization Sample _kernel_tmrini Create objects in nnnn_tmrdrv c Execute initialization routine Initialize the timer Move to multitasking Figure 2 18 Flowchart from CPU Reset to Kernel Initiation The CPU initialization routine should set the bus state controller BSC so that programs can correctly access memory A C language program accesses stacks therefore the stacks must be ready to be accessed before the C language program is executed The CPU initialization routine should also set the C program execution environment such as initial
45. intrinsic function set_cr which is supported by the compiler is used for this purpose To cancel the interrupt mask restore the pre change value of the BL bit in the SR register 2 18 4 Kernel Interrupt Mask Level CFG_KNLMSKLVL The kernel interrupt mask level CFG_KNLMSKLVL specifies the interrupt level to mask interrupts during kernel execution The kernel interrupt mask level can be specified by the configurator However interrupts having an interrupt level higher than the kernel interrupt mask level are immediately accepted even during kernel execution Note that handlers for the interrupts having an interrupt level higher than the kernel interrupt mask level are not allowed to issue a service call When the interrupt mask level is set higher than the kernel interrupt mask level service calls cannot be issued except when modifying the level of the interrupt mask equal to or lower than the kernel interrupt mask level by using chg_ims In the HI7000 4 interrupt handlers with interrupt levels higher than the kernel interrupt mask level must be defined as direct interrupt handlers Rev 6 00 57 RENESAS REJ10B0060 0600 Section2 Kernel 2 18 5 CPU Exception The CPU exception handler including the TRAPA instruction operates using the same context as that when an exception occurred The CPU exception handler uses the same stack as that used by the exception source Since the priority of the CPU exception handler is higher than
46. is always 1 ms Required hardware timer One channel of any timer channel 0 of the TMU is used with the sample standard timer driver Channels 0 1 and 2 of the TMU However when def_ovr is not selected channel 2 is unused Timer interrupt level A user defined value between 1 and the kernel s interrupt mask level CFG_KNLMSKLVL is set in CFG_TIMINTLVL Limited to the kernel interrupt mask level Driver creation by the user Possible Not possible RENESAS Rev 6 00 425 REJ10B0060 0600 Appendix E Optimized Timer Driver HI7700 4 E 6 Ways to Include Optimized Timer Driver E 6 1 Overview This section gives information that is supplementary to the standard configuration procedure For details see section 5 Configuration Table E 2 shows the procedures which must be followed to include a timer driver Table E 2 Including a Timer Driver No Timer Standard Timer Item Driver Driver Optimized Timer Driver Creation of a definition Not needed Not needed Needed file E 6 2 Configurator CFG_ Not checked Checked Checked TIMUSE Notes in Not relevant Not relevant Relevant E 6 3 Modifying kernel_sys h Not needed Not needed Needed E 6 4 Timer driver to be linked None Standard timer None the optimized timer driver driver is included in the kernel library E 6 2 Creating the kernel_def_opttmr_set h Definition File The following settings for the optimized timer driver
47. isig_tim cal_sve ical_sve vsta_knl ivsta_knl vsys_dwn ivsys_dwn vini_cac ivini_cac While using HI7700 4 the following service call also cannot be traced vchg_cop While using HI7750 4 the following service calls also cannot be traced vfls_cac ivfls_cac velr_cac ivelr_cac vinv_cac ivinv_cac Rev 6 00 51 RENESAS REJ10B0060 0600 Section2 Kernel 2 18 Interrupt Management and System Configuration Management In this kernel interrupts and exceptions are classified as follows e Reset CPU reset A program executed at CPU reset is called the CPU initialization routine e Interrupt An interrupt is generated from external interrupt pins and peripheral modules e CPU exception A CPU exception is an exception such as an address error or divide by zero A CPU exception also includes a trap generated by a TRAPA instruction When a CPU exception occurs a CPU exception handler is executed Interrupts and exceptions are controlled by the service calls listed in tables 2 22 and 2 23 Table 2 22 Service Calls for Interrupt Control Service Call Name Function def_inh idef_inh Defines an interrupt handler chg_ims ichg_ims Changes interrupt mask get_ims iget_ims Refers to interrupt mask Table 2 23 Service Calls for Exception Control Service Call Name Function def_exc idef_exc Defines a CPU exception handler vdef_trp ivdef_trp Defines a CPU exception handler
48. lt Mailbox message header gt typedef struct t_msg VP msghead T_MSG R4 Mailbox ID R5 Pointer to the area where the mailbox state is to be returned RO Normal end E_OK or error code R5 Pointer to the packet where the mailbox state is stored 0 2 4 4 0 4 lt Mailbox message header with priority gt typedef struct t_msg_pri Wait task ID Start address of the message to be received next Kernel management area T_MSG msgque 0 4 Message header PRI msgpri 4 2 Message priority T_MSG_PRI Error Codes E_PAR p Parameter error pk_rmbx is other than a multiple of four E_ID p Invalid ID number mbxid lt 0 or mbxid gt CFG_MAXMBXID E_NOEXS k Undefined Mailbox indicated by mbxid does not exist Rev 6 00 154 REJ10B0060 0600 RENESAS Section3 Service Calls Function Each service call refers to the state of the mailbox indicated by parameter mbxid Service calls ref_mbx and iref_mbx return the wait task ID wtskid and the start address of the message to be received next pk_msg to the area indicated by pk_rmbx If there is no task waiting for the specified message TSK_NONE 0 is returned as a wait task ID If there is no message to be received next NULL 0 is returned as a message start address Rev 6 00 155 RENESAS REJ10B0060 0600 Section3 Service Calls 3 11 Synchronization and Communication Mutex Mutex Service Calls Mutexes are controlled by the service cal
49. service calls that place a task in the WAITING state cannot be used Issuing the loc_cpu or iloc_cpu service call during task execution changes the system state to CPU locked state Issuing an unl_cpu or iunl_cpu will return the system state to the CPU unlocked state In addition issuing the sns_loc service call will check whether the system state is in CPU locked state or not In the CPU locked state service calls than can be issued are restricted as described in 3 2 5 System State and Service Calls 2 5 Objects Objects such as tasks and semaphores are manipulated by service calls Objects are identified by ID numbers or object numbers The maximum number can be specified for almost all objects in configuration 2 6 Tasks In a realtime multitasking system the user prepares an application program in terms of a set of tasks that can be processed independently and in parallel A task communicates with other tasks by using service calls Such service calls can be used to have the kernel process events that are asynchronously generated by external devices or by the MCU Tables 2 2 and 2 3 list the service calls that operate tasks Rev 6 00 9 RENESAS REJ10B0060 0600 Section2 Kernel Table 2 2 Task Management Service Calls Service Call Description cre_tsk icre_tsk Creates task using dynamic stack vscr_tsk ivscr_tsk Creates task using static stack acre_tsk iacre_tsk Creates task automati
50. sns_dpn Refers to the dispatch enable state vsta_knl ivsta_knl Initiates the kernel vsys_dwn ivsys_dwn System down vget_trc ivget_trc Acquires user event trace information ivbgn_int Acquires trace information on interrupt handler initiation ivend_int Acquires trace information on interrupt handler termination 2 17 1 System Down When an error occurs control is passed to the system down routine Errors can be classified into the following three types 1 When the service call vsys_dwn or ivsys_dwn was issued from application 2 When an error was detected inside the kernel 3 When an undefined interrupt or exception occurred The user must create the system down routine For details refer to section 4 12 System Down Routines Rev 6 00 49 RENESAS REJ10B0060 0600 Section2 Kernel 2 17 2 Service Call Trace Function The service call trace function is used to acquire the history of the service calls that are issued The debugging extension is used to visually refer to the acquired data The service call trace function automatically acquires task ID PC and service call parameters in the following timing e A service call is issued and returned e A task is initiated and terminated e A task exception processing routine is initiated and terminated If the ivbgn_int and ivend_int service calls are described at the beginning and end of the interrupt handler the trace information on interrupt handler initiation and termi
51. 0 At this point chg_ims SR_IMS0O5 1 Change SR I to 5 set_imask 8 2 Change SR I to 8 ichg_ims SR_IMS00 3 Change SR I to 0 The IMASK bits are 8 it must be 5 for this call to work To improve this example add processing which returns IMASK bits to 5 before 3 At this point Task context c SR I 0 chg_ims SR_IMS05 1 Change SR I to 5 set_imask 8 2 Change SR I to 8 set_imask 5 Add Change SR I to 5 ichg_ims SR_IMS00 3 Change SR I to 0 Change IMASK bits of the SR register without a service call The IMASK bits in the SR register are changed by the LDC instruction In the C language the intrinsic functions set_imask or set_cr which are supported by the compiler are used for this purpose Rev 6 00 56 REJ10B0060 0600 RENESAS Section2 Kernel In the task context the IMASK bits can only be changed to values greater than the kernel interrupt mask level by this method If the value of the IMASK bits is changed to some other value correct operation is not guaranteed This restriction does not apply in non task contexts To cancel the change to the interrupt mask restore the IMASK bits to their values before the change d Change BL bit of the SR register without a service call SH 3 SH3 DSP SH4AL DSP SH 4 SH 4A The BL bit in the SR register is changed to 1 by the LDC instruction In the C language the
52. 0 4 Alarm handler operation state RELTIM lefttim 4 4 Remaining time until the alarm handler is initiated T_RALM Error Codes E_PAR p Parameter error pk_ralm is other than a multiple of four E_ID p Invalid ID number almid lt 0 or almid gt CFG_MAXALMID E_NOEXS k Undefined Alarm handler specified by almid does not exist Function Each service call reads the alarm handler state indicated by almid and returns the alarm handler operating state almstat and remaining time until the alarm handler is initiated lefttim to the area indicated by parameter pk_ralm The target alarm handler activation state is returned to parameter almstat Table 3 55 Alarm Handler State almstat almstat Code Description TALM_STP H 00000000 The alarm handler is not operating TALM_STA H 00000001 The alarm handler is operating Relative time until the target alarm handler is initiated next is returned to parameter lefttim When the target alarm handler is not initiated lefttim is undefined Rev 6 00 213 RENESAS REJ10B0060 0600 Section3 Service Calls 3 18 Time Management Overrun Handler Overrun Handler Service Calls Overrun handler is controlled by the service calls listed in table 3 56 Table 3 56 Service Calls for Overrun Handler System State Service Call Description T N E D U L C def_ovr Defines overrun handler T E D U sta_ovr Starts overrun handler operation T E D U is
53. 00 104 REJ10B0060 0600 RENESAS Section3 Service Calls 3 5 8 Set Task Event Flag vset_tfl ivset_tfl C Language API ER ercd vset_tf1l ID tskid UINT setptn ER ercd ivset_tfl ID tskid UINT setptn Parameters ID tskid R4 Task ID UINT setptn R5 Bit pattern to set Return Parameters ER ercd RO Normal end E_OK or error code Error Codes E_ID p Out of ID range tskid lt 0 tskid gt CFG _MAXTSKID or tskid TSK_SELF 0 is specified in a non task context E_NOEXS ik Undefined Task indicated by tskid does not exist E_OBJ k Object status is invalid Task specified by tskid is in the DORMANT state Function The task event flag of the task indicated by parameter tskid is ORed with the value indicated by the parameter setptn Note that the lower 16 bits of the bit pattern to specify in parameter setptn must be set to 0 because the corresponding bits of the event flag are reserved for future expansion By specifying tskid TSK_SELF 0 the current task can be specified When the logical sum of the waiting pattern and the updated pattern of the task event flag is not 0 the task is released from the WAITING state and the task event flag is cleared to 0 The service calls vset_tfl and ivset_tfl are functions original to the HI7000 4 series Rev 6 00 105 RENESAS REJ10B0060 0600 Section3 Service Calls 3 5 9 Clear Task Event Flag velr_tfl ivelr_tfl C Language API ER ercd vclr_tf1 ID tskid
54. 0600 RENESAS Section3 Service Calls If the selected CPU core is not the SH 2Aor SH2A FPU or you have selected an option other than SELECT for CFG_REGBANK in the configurator handling by the HI7000 4 is as follows e When the CPU core is the SH 2A or SH2A FPU and ALL is selected for CFG_REGBANK Register banks are used for interrupts with interrupt handler numbers 14 64 and higher numbers Register banks are not used with other interrupts i e the NMI and UBC interrupts e When the CPU core is not the SH 2A or SH2A FPU or NOTUSE or NOBANK is selected for CFG_REGBANK The register banks are not used with any interrupt On the HI7700 4 and HI7750 4 inhsr sets the value of the status register SR on startup of the interrupt handler inhsr is specified using the same bit position as the SR configuration A value equal to or greater than the interrupt level should always be specified as the interrupt mask bit If a value lower than the interrupt level is specified system operation may be abnormal For information of SR register see section 4 2 1 SR Register and section 4 2 2 Cache Lock Function SH 3 SH3 DSP On actual interrupt handler start SR is as follows e Interrupt mask bit As specified by inhsr e Bits other than the interrupt mask bit As specified by inhsr In the HI7000 4 inhsr has no meaning and is simply ignored The actual value of SR on startup is determined by the CPU interrupt processing Wh
55. 1 Relationship between nnnn and Microcomputer HI7000 4 V 2 02 HEW Compiler Package Version Used nnnn CPU Core Target Microcomputer at Creation 7011 SH 2 SH7011 SH7018 1 2 6 0C 703x SH 1 SH7020 SH7021 SH7032 SH7034 1 2 6 0C 704x SH 2 SH7040 SH7041 SH7042 SH7043 1 2 6 0C SH7044 SH7045 SH7014 SH7016 SH7017 7046 SH 2 SH7046 SH7047 SH7048 SH7049 1 2 6 0C SH7144 SH7145 SH7148 7050 SH 2 SH7050 SH7051 1 2 6 0C 7052 SH 2 SH7052 SH7053 SH7054 1 2 6 0C 7065 SH2 DSP SH7065 1 2 6 0C 7604 SH 2 SH7604 1 2 6 0C 7615 SH2 DSP SH7615 SH7616 1 2 6 0C 7618 SH 2 SH7618 4 00 02 9 00 Release 03 72060 SH 2A SH72060 4 00 02 9 00 Release 03 Rev 6 00 345 RENESAS REJ10B0060 0600 Section5 Configuration Table 5 2 Relationship between mann and Microcomputer HI7700 4 V 2 02 HEW Compiler Package Version Used nnnn CPU Core Target Microcomputer at Creation 7707 SH 3 SH7707 1 2 6 0C 7708 SH 3 SH7708 SH7708R SH7708S 1 2 6 0C 7709 SH 3 SH7709 1 2 6 0C 7709a SH 3 SH7709A SH7709S SH7706 1 2 6 0C 7729 SH3 DSP SH7729 SH7729R SH7727 1 2 6 0C 7290 SH3 DSP SH7290 SH7294 SH7300 3 0 01 8 00 Release 00 7641 SH3 DSP SH7641 3 0 01 8 00 Release 00 7318 SH4AL DSP SH7318 3 0 01 8 00 Release 00 without extended function 7343 SH4AL DSP SH7343 4 00 02 9 00 Release 03 with extended function Table 5 3 Relationship between nnnn and Microcomputer
56. 2 01 or later Possible Possible Related Pages e p 292 Section 4 1 1 3 Header Files for ID Name e p 353 Section 5 4 4 1 kernel_id h kernel_id_sys h 1 12 Open the file used last time Command for the Configurator V 2 02 Release 00 A new Options menu has been added to the menu bar and contains an Open the file used last time item If you select this item the configurator will automatically open the last file to be used whenever it starts up Rev 6 00 460 REJ10B0060 0600 RENESAS Appendix J New Functions of HI7750 4 V 2 J Support of SH 4A with Extended Function V 2 01 Release 00 The cache support library shx2_cache_ lib for the SH 4A with extended function is added J 2 Specifying Address of Task Stack Fixed Size Memory Pool and Variable Size Memory Pool V 2 01 Release 00 In the previous version it was not possible to specify the addresses of task stacks fixed size memory pools and variable size memory pools at the time of creation of these objects These areas were always allocated to respective specific areas managed by the kernel In V 2 the user can also allocate each area and can specify the address at each object creation Thereby the user can allocate each stack or memory pool area to an arbitrary memory address according to the purpose of use For example only a specific task uses a stack in the high speed on chip RAM Related Pages e p 13 Section 2 6 2 Task Creation e p 76 Se
57. 2 SR V 0 3 ROtoR3 V Undefined 4 R4 V Task exception pattern 5 R5 V Extended information exinf of the task exception processing routine 6 R6to R14 MACH V Undefined MACL GBR 7 R415 V vV R15 points to the task s stack area 8 PR V v Undefined 9 SH2 DSP DSR r 0 when attribute TA_COPO is specified or undefined in other cases 10 SH2 DSP RS RE ms Undefined MOD AO AOG A1 A1G MO M1 XO X1 YO Y1 11 SH 2A SH2A FPU e R TBR 12 SH2A FPU FPSCR H 00040001 13 SH2A FPU FPUL e Undefined FRO to FR15 Notes 1 These registers can be used Note that some register contents cannot be guaranteed h after service calls For details refer to section 3 2 3 Guarantee of Register Contents after Issuing Service Call When execution is returned from the entry function RTS instruction the contents of these registers must be the same as the value at initiation Except in the CPU locked state IMASK must be 0 Only when the TA_COP0 attribute is specified Depends on CFG_TBR 1 Kernel does not manage The kernel does not operate TBR 2 Only for service call Do not modify TBR 3 Task context When execution is returned from the task exception processing routine entry function RTS instruction the contents of TBR must be the same as the value at initiation The initial value is the same as TBR of the task immediately before the task exception processing routine is started Only when the TA_COP1 attribute i
58. 26 VP_INT 32 bit signed integer 9 VW 32 bit signed integer 27 ER_BOOL 32 bit signed integer 10 VP pointer to void type 28 ER_ID 32 bit signed integer 11 FP pointer to void type 29 ER_UINT 32 bit signed integer function 12 INT 32 bit signed integer 30 TEXPTN 32 bit unsigned integer 13 UINT 32 bit unsigned integer 31 FLGPTN 32 bit unsigned integer 14 BOOL 32 bit signed integer 32 RDVPTN 32 bit unsigned integer 15 FN 32 bit signed integer 33 RDVNO 32 bit unsigned integer 16 ER 32 bit signed integer 34 OVRTIM 32 bit unsigned integer 17 ID 16 bit signed integer 35 INHNO 32 bit unsigned integer 18 ATR 32 bit unsigned integer 36 EXCNO 32 bit unsigned integer 19 STAT 32 bit unsigned integer 37 IMASK 32 bit unsigned integer 20 MODE 32 bit unsigned integer Note When the variable values of these data types are referred to or substituted the type must be explicitly converted casted RENESAS Rev 6 00 65 REJ10B0060 0600 Section3 Service Calls 3 2 2 Assembly Language API In most cases a service call can be called from an assembly language program as shown in figure 3 1 Offsets must be specified as HOFF_XXX_XXX where XXX_XXX is the service call name in uppercase characters INCLUDE kernel inc a IMPORT __kernel_cnfgtbl b task MOV L OFF_ACT_TSK RO c MOV L __kernel_cnfgtbl1 R1 MOV L RO R1 RO d MOV L 1 R4 e JSR R0
59. 28 bytes 2 Size of the stack area used by the NMI interrupt handler calculated as shown in appendixes C 4 and C 5 8 x NMI nest count When there is no nesting the NMI nest count is 1 3 With the optimization timer driver or the DSP standby control function it becomes 164 Rev 6 00 413 RENESAS REJ10B0060 0600 Appendix CCalculation of Work Area Size C 7 2 Stack Area Allocation Direct Interrupt Handlers HI7000 4 Since handlers of the same level are not activated concurrently allocate the stack area of the handler that uses the largest stack area from among the same interrupt level interrupt handlers as the handler stack area of the corresponding interrupt level Then switch to the stack at the beginning of the interrupt handler Refer to section 4 8 Interrupt Handlers when switching stacks by interrupt handler In this case separate stacks can be used instead of sharing a stack within the same interrupt level handlers Note however that a stack dedicated to the NMI interrupt handler cannot be used since NMI has the possibility of re entry The stack size to be used by the NMI interrupt must be added in appendixes C 6 to C 9 because the NMI interrupt handler uses the stack at the point of the NMI occurrence Normal Interrupt Handlers All interrupt handlers use the same interrupt handler stack The interrupt handler stack area can be automatically allocated by specifying a size in CFG_IRQSTKSZ by the configurator For C
60. 4 8 Fixed size memory pool ID Pointer to the packet where the fixed size memory pool creation information is stored Pointer to the packet where the fixed size memory pool creation information is stored Normal end E_OK or error code Created fixed size memory pool ID a positive value or error code 4 Fixed size memory pool attribute 4 Number of blocks in memory pool 4 Block size of fixed size memory pool Number of bytes 4 Start address of the fixed size memory pool area 4 Fixed size memory pool attribute 4 Number of blocks in memory pool 4 Block size of fixed size memory pool Number of bytes Rev 6 00 176 REJ10B0060 0600 RENESAS Section3 Service Calls VP mpf 12 4 Start address of the fixed size memory pool area VP mpfmb 16 4 Start address of the fixed size memory pool management table area T_CMPF Error Codes E_NOMEM k Insufficient memory Memory pool area cannot be allocated in the memory E_RSATR p Invalid attribute mpfatr is invalid E_PAR p Parameter error pk_cmpf is other than a multiple of four blkent 0 blksz is other than a multiple of four or blksz 0 mpf is other than a multiple of four if mpf is not NULL or mpfmb is other than a multiple of four when CFG_MPFMANAGE is checked k TSZ_MPF blkcnt blksz exceeds 32 bit range E_ID p Invalid ID number mpfid lt 0 or mpfid gt CFG_MAXMPFID E_OBJ k Object status is invalid Fixed size memory pool in
61. 4 14 Figure 4 7 Example of an Assembly Language Direct Interrupt Handler RENESAS Rev 6 00 317 REJ10B0060 0600 Section4 Application Program Creation Table 4 14 CFG_REGBANK Use of Register Banks Interrupt Level End Instructions for Direct Interrupt Handlers HI7000 4 End Instruction NOBANK or Higher than RTE NOTUSE CFG_KNLMSKLVL Equal to or lower than TRAPA D 25 or TRAPA CFG_KNLMSKLVL D 26 ALL or SELECT Interrupt sources Higher than None with which CFG_KNLMSKLVL register banks are used Equal to or lower than TRAPA D 26 CFG_KNLMSKLVL Interrupt sources Higher than RESBANK with which CFG_KNLMSKLVL RTE register banks Equal to or lower than TRAPA D 25 are not used CFG_KNLMSKLVL Notes 1 Register banks are never used with the NMI and UBC interrupts Register banks are used with all other interrupt sources when ALL has been selected for CFG_REGBANK When SELECT has been selected for CFG_REGBANK register banks are only used with those sources having interrupt levels for which the corresponding CFG_BANKLVL has been selected Otherwise register banks are not used with interrupt sources for which this is not the case 2 The operation is the same in both cases 3 Both instructions must be included in the order given above 3 Writing a Direct Interrupt Handler Using the DSP To use the DSP in a direct interrupt handler refer to section 4 13 Usi
62. 6 00 295 RENESAS REJ10B0060 0600 Section4 Application Program Creation 4 2 9 Register Banks SH 2A SH2A FPU The SH 2A and SH2A FPU processors provide register banks to accelerate interrupt response How and whether the register banks are used is specifiable through the Modification of Interrupt Information dialog box in the configurator 1 To use the register banks for all interrupts other than the NMI and UBC interrupts when the target MCU is equipped with register banks Select Register bank is used except NMI and UBC ALL for CFG_REGBANK and specify the address of IBNR in CFG_IBNR_ADR The kernel sets the IBNR value to 0x4000 during initialization vsta_knel 2 To select whether or not to use the register banks for interrupts with specific interrupt levels when the target MCU is equipped with register banks Select You select level to beused register bank SELECT for CFG_REGBANK and select the interrupt levels from CFG_BANKLVLO1 to CFG_BANKLVLI1S5 with which the register banks are to be used After that specify the address of IBNR in CFG_IBNR_ADR During initialization vsta_knel the kernel initializes the the IBNR value to 0xC000 and the IBCR value to a value that depends on the settings of CFG_BANKLVLO1 to CFG_BANKLVLIS 3 To select non usage of the register banks although the target MCU is equipped with register banks Select Register bank is not used NOTUSE for CFG_REGBANK and specify the address of IBNR in C
63. Creates an event flag automatically assigns ID del_fig Deletes an event flag set_flg iset_flg Sets an event flag clr_flg iclr_flg Clears an event flag wai_flg Waits for event occurrence pol_fig ipol_flg Waits for event occurrence polling twai_flg Waits for event occurrence with timeout ref_flg iref_flg Refers to the event flag status Event flags can also be created by the configurator Figure 2 6 shows an example of using event flags Rev 6 00 24 REJ10B0060 0600 RENESAS Section2 Kernel Time Task A Task B Event flag pattern 1 cre_flg 0 2 wai_flg lt WAITING gt i PLD RLONPOIBF OP LF OPP PISO A 3 lt READY gt set_flg 0 nRnRARARARReeeeeerresns0 POPOL OPO OV LOLOL OOP OO OWL OOS PO 7 isetflg 0 1 Figure 2 6 Example of Using an Event Flag Description Bold lines represent executed processing The following describes event flag operation with respect to time 1 Task A issues cre_flg to create an event flag The TA_CLR attribute clear event flag to 0 when the WAITING state is released is specified and the initial pattern is specified as 0 2 Task A issues wai_flg waiting pattern 3 AND wait to wait for an event 3 Task B issues set_flg set pattern 7 Since all bits that task A was waiting for have been set task A is released from the WAITING state In addition since the TA_CLR attribute has been specified the event flag is cleared to 0 4 Interrupt handler
64. DN Bit Remarks Zero Round to Zero B 01 The compiler does not generate any object Nearest Round to Nearest B 00 code to change the RM bits Note The compiler assumes this rounding mode in generating code at the top of the function 2 FPSCR SZ transfer size mode The compiler always assumes SZ 0 the data size of the FMOV instruction is 32 bits and does not generate any object code to change the SZ bit 3 FPSCR FR FPU register bank only in SH 4 and SH 4A The compiler does not generate any object code to change the FR bit However in the built in functions st_ext and Id_ext the FR bit is temporarily changed within these function The value of the FR bit on return from these functions is the same as the value when the function was called Rev 6 00 446 REJ10B0060 0600 RENESAS Appendix H New Functions of HI7000 4 V 2 H 1 Support of SH 2A and SH2A FPU H 1 1 FPU SH2A FPU V 2 00 Release 00 The TA_COP1 attribute is added for tasks and task exception processing routines When TA_COPI is specified the FPU registers are added as context registers for the task and the task exception processing routine and the FPU can be used in a multitasking environment The Uses FPU TA_COP1 check box is added to Creation of Task and Definition of Task Exception Processing Routine dialog box of the configurator Related Pages e p 76 Section 3 4 1 Create Task e p 111 Section 3 6 1 Define Task Excepti
65. E_CTX k Context error Called from disabled system state Function The system call tmd changes the task execution mode The execution mode can mask requests from other tasks as the task execution mode Table 3 15 Task Execution Mode tmd tmd Code Description ECM_SUS H 00000001 A suspend request is masked ECM_TER H 00000002 A forcible termination request is masked When the suspend request is masked even if service calls sus_tsk and isus_tsk are called their requests are delayed until the mask is cancelled with tmd 0 specified by the service call vchg_tmd When the forced termination request is masked even if the service call ter_tsk is called its request is delayed until the mask is cancelled with tmd 0 specified by the service call vchg_tmd In task execution mode the state of the calling task is taken over as the task context in extended service call routines and task exception processing routines Delays of suspend requests and forced termination requests can be referenced through service calls ref_tsk and iref_tsk This service call is a function original to the HI7000 4 series Rev 6 00 95 RENESAS REJ10B0060 0600 Section3 Service Calls 3 5 Task Synchronization Task Synchronization Service Calls The service calls for task synchronization are listed in table 3 16 Table 3 16 Task Synchronization Service Calls System State Service Call
66. E_ID p Invalid ID number tskid lt 0 tskid gt CFG_MAXTSKID or tskid TSK_SELF 0 is specified in a non task context E_NOEXS k Undefined Task indicated by tskid does not exist E_OBJ k Object status is invalid Task specified by tskid is in the DORMANT state E_CTX k Context error tskid TSK_SELF 0 or the current task ID is specified in a task context while dispatch is disabled E_QOVR k Queuing overflow suscnt gt 15 Function Each service call suspends execution of the task specified by tskid and shifts the task to the SUSPENDED state If the specified task is in the WAITING state the task shifts to the WAITING SUSPENDED state By specifying tskid TSK_SELF 0 the current task can be specified The SUSPENDED state can be cancelled by calling the service call rsm_tsk irsm_tsk frsm_tsk or ifrsm_tsk Requests to suspend a task by calling the service calls sus_tsk and isus_tsk are nested Up to 15 requests can be stored Requests to suspend a task by calling the service calls sus_tsk and isus_tsk are delayed in the following cases 1 When the task specified by tskid masks the suspend request by calling the service call vchg_tmd the task enters the SUSPENDED state immediately after the suspend request is cancelled by the service call vchg_tmd by specifying tmd 0 2 When the task specified by tskid has called service call dis_dsp to disable task dispatch the task enters the SUSPENDED state immediately af
67. E_NOEXS k Undefined Task indicated by tskid does not exist Function Each service call refers to the state of the task indicated by the parameter tskid and then returns it to the area indicated by parameter pk_rtsk By specifying tskid TSK_SELF 0 the current task is specified The following values are returned to the area indicated by pk_rtsk Note that data with an asterisk is invalid when the task is in the DORMANT state If referenced information is related to a function that is not installed the referenced information will be undefined tskstat Rev 6 00 89 RENESAS REJ10B0060 0600 Section3 Service Calls Indicates the current task state The following values are returned Table 3 10 Current Task State tskstat tskstat Code Description TTS_RUN H 00000001 RUNNING state TTS_RDY H 00000002 READY state TTS_WAI H 00000004 WAITING state TTS_SUS H 00000008 SUSPENDED state TTS_WAS H 0000000c WAITING SUSPENDED state TTS_DMT H 00000010 DORMANT state TTS_STK H 40000000 Shared stack WAITING state tskpri Indicates the current task priority When the task is in the DORMANT state the initial priority of the task is returned tskbpri Indicates the base priority of the task When the task is in the DORMANT state the initial priority of the task is returned Rev 6 00 90 REJ10B0060 0600 RENESAS Section3 Service Calls tskwait Valid only when TTS_WAI or TTS
68. FPUL V V Undefined FR12 to FR15 Notes 1 These registers can be used Note that some register contents cannot be guaranteed after service calls For details refer to section 3 2 3 Guarantee of Register Contents after Issuing Service Call 2 When execution is returned from the entry function RTS instruction the contents of these registers must be the same as the value at initiation Rev 6 00 330 REJ10B0060 0600 RENESAS Section4 Application Program Creation 3 IMASK bits must not be lower than the value at initiation And IMASK bits must be the same as initial value when execution is returned from the handler 4 Depends on CFG_TBR 1 Kernel does not manage The kernel does not operate TBR 2 Only for service call Do not modify TBR 3 Task context When execution is returned from an interrupt handler function RTS instruction the contents of TBR must be the same as the value at initiation The initial value is undefined Table 4 19 Rules for Using Registers in Time Event Handler and Initialization Routine H1I7700 4 End Use Conditions No Registers Initial Value 1 PC V CPU exception handler start address 2 SR V a IMASK bits Same as before exception MD 1 BL 0 RB 0 DSP CL When at least one of CFG_DSP and CFG_CACLOC is checked DSP CL is 1 otherwise DSP CL is 0 Other bits Undefined 3 ROtoR3 V Undefined 4 R4 y Cyclic Alarm handler Initialization routine Ex
69. Flag Setting wfimode FLGPTN p_flgptn ipol_flg ER ercd ipol_flg ID flgid FLGPTN waiptn MODE wfmode FLGPTN p_flgptn 51 twai_fig ER ercd twai_flg ID flgid FLGPTN waiptn MODE Wait for Event Flag Setting with wfmode FLGPTN p_flgptn TMO tmout Timeout 52 ref_fig ER ercd ref_flg ID flgid T_RFLG pk_rflg Refer to Event Flag State iref_flg ER ercd iref_flg ID flgid T_RFLG pk_rflg Data Queue 53 cre_dtq ER ercd cre_dtq ID dtqid T_ CDTQ pk_cdtq Create Data Queue icre_dtq ER ercd icre_dtq ID dtqid T_CDTQ pk_cdtq 54 acre_dtq ER_ID dtqid acre_dtq T_CDTQ pk_cdtq iacre_dtq ER_ID dtqid iacre_dtq T_CDTQ pk_cdtq Create Data Queue and Assign Data Queue ID Automatically 55 del_dtq ER ercd del_dtq ID dtqid Delete Data Queue 56 snd_dtq ER ercd snd_dtq ID dtqid VP_INT data Send Data to Data Queue 57 psnd_dtq ER ercd psnd_dtq ID dtqid VP_INT data ipsnd_dtq ER ercd ipsnd_dtq ID dtqid VP_INT data Poll and Send Data to Data Queue Rev 6 00 392 REJ10B0060 0600 RENESAS Appendix A Service Call List No Service Call C Language API Function 58 tsnd_dtq ER ercd tsnd_dtq ID dtqid VP_INT data TMO Send Data to Data Queue with tmout Timeout 59 fsnd_dtq ER ercd fsnd_dtgq ID dtqid VP_INT data Send Data to Data Queue Forcibly ifsnd_dtq ER ercd ifsnd_dtq ID dtqid VP_INT data 60
70. Function code of extended service call T_DSVC pk_dsvc R5 Start address of the extended service call routine definition information Return Parameters ER ercd RO Normal end E_OK or error code Packet Structure typedef struct t_dsve ATR svcatr 0 4 Extended service call routine attribute FP svertn 4 4 Extended service call routine address T_DSVC Error Codes E_RSATR p Invalid attribute svcatr is invalid E_PAR p Parameter error pk_dsvc is other than a multiple of four svertn is an odd address fncd lt 0 or fncd gt CFG_MAXSVCCD Function The service calls def_svc and idef_svc define an extended service call routine for the extended function code indicated by fncd with the contents specified by pk_dsve The parameter svcatr is specified in the following format See table 3 66 for details svcatr TA_HLNG TA_ASM Table 3 66 Extended Service Routine Attributes svcatr svcatr Code Description TA_HLNG H 00000000 The extended service call routine is written in a high level language TA_ASM H 00000001 The extended service call routine is written in assembly language The parameter svcrtn specifies the start address of the extended service call routine If pk_dsve NULL 0 is specified for svcatr in the service call def_svc the extended service call routine defined for fncd is cancelled The state of calling task is taken over in extended service call routines Rev 6 00 243 RENESAS
71. H 80000000 or mbfsz is other than 0 and maxmsz 4 gt mbfsz E_ID p Invalid ID number mbfid lt 0 or mbfid gt CFG_MAXMBFID E_OBJ k Object status is invalid Message buffer indicated by mbfid already exists E_NOID k No ID available Rev 6 00 166 REJ10B0060 0600 RENESAS Section3 Service Calls Function Service calls cre_mbf and icre_mbf create a message buffer with an ID indicated by mbfid with the contents specified by pk_cmbf Service calls acre_mbf and iacre_mbf search for an unused message buffer ID and create a message buffer that has this ID with the contents specified by parameter pk_cmbf The created event flag ID is returned as a return parameter The range for searching for an unused message buffer ID is 1 to CFG_MAXMBFID Parameter mbfatr is specified in the following format See table 3 40 for details mbfatr TA_TFIFO TA_TPRI Table 3 40 Message Buffer Attributes mbfatr mbfatr Code Description TA_TFIFO H 00000000 Task queue waiting for sending a message is managed on a FIFO basis TA_TPRI H 00000001 Task queue waiting for sending a message is managed on priority The message queue and the task queue waiting for sending a message are managed on a first in first out FIFO basis regardless of the mbfatr specification A message buffer is created in the message buffer area CFG_MBFSZ specified by the configurator After the message buffer has been created the free message buffer
72. HI7000 4 HI7700 4 TA_COPO The task uses the DSP HI7000 4 TA_COP1 The task uses the FPU HI7750 4 TA_COP1 The task uses bank 0 in the FPU TA_COP2 The task uses bank 1 in the FPU Note This value is the same as TMAX_TPRI defined in kernel_macro h Rev 6 00 75 RENESAS REJ10B0060 0600 Section3 Service Calls 3 4 1 Create Task lt Using Dynamic Stack gt cre_tsk icre_tsk acre_tsk iacre_tsk Assign Task ID Automatically lt Using Static Stack gt vser_tsk ivscr_tsk C Language API ER ercd cre_tsk ID tskid T_CTSK pk_ctsk ER ercd icre_tsk ID tskid T_CTSK pk_ctsk ER_ID tskid acre_tsk T_CTSK pk_ctsk ER_ID tskid iacre_tsk T_CTSK pk_ctsk ER ercd vscr_tsk ID tskid T_CTSK pk_ctsk ER ercd ivscr_tsk ID tskid T_CTSK pk_ctsk Parameters lt cre_tsk icre_tsk vscr_tsk ivscr_tsk gt ID tskid R4 Task ID T_CTSK pk_ctsk R5 Pointer to the packet where task creation information is stored lt acre_tsk iacre_tsk gt T_CTSK pk_ctsk R4 Pointer to the packet where task creation information is stored Return Parameters lt cre_tsk icre_tsk vscr_tsk ivscr_tsk gt ER ercd RO Normal end E_OK or error code lt acre_tsk iacre_tsk gt ER_ID tskid RO Created task ID a positive value or error code Packet Structure typedef struct t_ctsk ATR tskatr 0 4 Task attribute VP_INT exinf 4 4 Extended information FP task 8 4 Task start address PRI itskpri 12 2 Priority at task in
73. ID mplid T RMPL pk_rmpl Pool State RENESAS Rev 6 00 395 REJ10B0060 0600 Appendix A Service Call List No Service Call C Language API Time Management Function System Clock Management Function 106 set_tim ER ercd set_tim SYSTIM p_systim Set System Clock iset_tim ER ercd iset_tim SYSTIM p_systim 107 get_tim ER ercd get_tim SYSTIM p_systim Get System Clock iget_tim ER ercd iget_tim SYSTIM p_systim 108 isig_tim Included automatically by selecting CFG_TIMUSE Supply Time Tick Cyclic Handler 109 cre_cyc ER ercd cre_cyc ID cycid T_CCYC pk_ccyc Create Cyclic Handler icre_cyc ER ercd icre_cyc ID cycid T_CCYC pk_ccyc 110 acre_cyc ER_ID cycid acre_cyc T_CCYC pk_ccyc Create Cyclic Handler and Assign iacre_cye ER_ID cycid iacre_cyc T_CCYC pk_ccyc Cyclic Handler ID Automatically 111 del_cyc ER ercd del_cyc ID cycid Delete Cyclic Handler 112 sta_cyc ER ercd sta_cyc ID cycid Start Cyclic Handler ista_cyc ER ercd ista_cyc ID cycid 113 stp_cyc ER ercd stp_cyc ID cycid Stop Cyclic Handler istp_cyc ER ercd istp_cyc ID cycid 114 ref_cyc ER ercd ref_cyc ID cycid T_ RCYC pk_rcyc Refer to Cyclic Handler State iref_cyc ER ercd iref_cyc ID cycid T_ RCYC pk_rcyc Alarm Handler 115 cre_alm ER ercd cre_alm ID almid T_ CALM pk_calm Create Alarm Han
74. Method Rev 6 00 144 REJ10B0060 0600 RENESAS Section3 Service Calls 3 9 5 Refer to Data Queue State ref_dtq iref_dtq C Language API ER ercd ref_dtq ID dtqid T_RDTQ pk_rdtq ER ercd ref_dtq ID dtqid T_RDTQ pk_rdtq Parameters ID dtqid R4 Data queue ID T_RDTQ pk_rdtq R5 Pointer to the packet where data queue state is to be returned Return Parameters ER ercd RO Normal end E_OK or error code T_RDTQ pk_rdtq R5 Pointer to the packet where data queue state is stored Packet Structure typedef struct t_rdtq ID stskid 0 2 Task ID waiting for sending ID rtskid 2 2 Task ID waiting for receiving UINT sdtqent 4 4 The number of data in the data queue T_RDTQ Error Codes E_PAR p Parameter error pk_rdtgq is other than a multiple of four E_ID p Invalid ID number dtqid lt 0 or dtqid gt CFG_MAXDTQID E_NOEXS k Undefined Data queue indicated by dtqid does not exist Function The state of the data queue specified by dtqid is referenced and the send waiting task IDs stskid the receive waiting task IDs rtskid and the number of data items in the data queue sdtqcnt are returned to the area specified by pk_rdtq If there are no send waiting tasks or receive waiting tasks TSK_NONE 0 is returned as the wait task ID Rev 6 00 145 RENESAS REJ10B0060 0600 Section3 Service Calls 3 10 Synchronization and Communication Mailbox Mailbox Service Calls Mailboxes are controlled
75. R a doen 438 G 2 2 SH 4 SH 4A 439 G 2 3 SH2A FPU eee 441 G3 Extended Service Call Routine 441 G 3 1 Compiler Options scicsssssacsecssssasetacsecnsaestatiecesisncssssocenenponstosesessersescenenaneasssanvebisesseveoenseneass 441 G 3 2 Called from Task Context srren e A eceeasden EA RE selaeeandes G 3 3 Called from Non Task Context G 4 Information for Reference y cc 3 csc vecsdacaceresiasisavanteseatecvacnasvcenen tesveatvensa banca rinnrsvenedaviens G 4 1 States on the Initiation of Tasks and Handlers cceccecceseseeeseeeeceeceeeeaeeeeeeeeeseeaeeeeaees 443 G 4 2 FPSCR Structure csccsssesssseerceesessessees G 4 3 Handling by the Compiler Appendix H New Functions of HI7000 4 V 2 sscsssssssscsssssssssccssssesssscssssssssseees 447 H 1 Support of SH 2A and SH2A FPU ccccceccsccsssssessesceseesseesseesseseesaeseeeesseeeeeseees H 1 1 FPU SH2A FPU V 2 00 Release 00 H 1 2 TBR Register V 2 00 Release 00 cece eeeeeeeeeeeeeee a H 1 3 Register Banks V 2 00 Release 00 V 2 01 Release 00 and V 2 02 Release 00 448 H 2 Specifying Address of Task Stack Fixed Size Memory Pool and Variable Size Memory Pool V 2 00 Release 00 ceeceescessesteeteeeeceeeeneceeeeseeeeeeeeeeseeeeeenees 448 H 3 Management Method of Fixed Size Memory Pool V 2 00 Release 00 00 449 H 4 Direct Interrupt Handler V 2 00 Release 00 and V 2 02 Release 00 0 0 450 H 5 Macros f
76. REJ10B0060 0600 Section5 Configuration 5 14 3 Setting Optimized Linkage Editor Options d Input Category Defines SuperH RISC engine Standard Toolchain Configuration C C Assembly Link Library Standard Library CPU Deb gt obj bie Fal Category Input v I F All Loaded Projects Show entries for 5 a C source file ae E C source file Add Assembly source fi _kemelenfetbl Address 080001000 J Linkage symbol file Remove def source file G source file Assembly source fi G Linkage symbol file I Use entry point Prelinker control mix e ato 4 QC source file Suto C source file Options Link Library Assembly source fi Pa RTA TSN relink nomessage A A i ist J map nooptimize Linkage symbol tile start C_hisysmt C hicfe P C D 08001 0000 v Figure 5 18 Optimized Linkage Editor Input Category Defines The following symbol address is defined e __kernel_cnfgtbl Service call interface data As this service call interface data is included in the kernel load module def the service call interface data allocation addresses must therefore be forcibly defined __kernel_cnfgtbl is the start address of the C_hibase section in the kernel side configuration file kernel_def c Rev 6 00 386 REJ10B0060 0600 RENESAS Section5 Configuration 2 Section Category SuperH RISC engine Standard Toolchain Configuration C C
77. RO Normal end E_OK or error code T_RMPL pk_rmpl R5 Pointer to the packet where the variable size memory pool state is stored Packet Structure typedef struct t_rmpl ID wtskid 0 2 Wait task ID SIZE fmplsz 4 4 Total size of available memory area Number of bytes UINT fblksz 8 4 Maximum memory area available Number of bytes T_RMPL Error Codes E_PAR p Parameter error pk_rmpl is other than a multiple of four E_ID p Invalid ID number mplid lt 0 or mplid gt CFG_MAXMPLID E_NOEXS k Undefined Variable size memory pool indicated by mplid does not exist Function Each service call refers to the status of the variable size memory pool indicated by mplid and returns the wait task ID wtskid the current free memory area total size fmplsz and the maximum free memory space size fblksz to the area indicated by pk_rmpl The free space is usually fragmented The maximum contiguous free space is returned to parameter fblksz The block up to the size fblksz can be acquired immediately by calling service call get_mpl pget_mpl ipget_mpl or tget_mpl If there is no task waiting to get a memory block TSK_NONE 0 is returned as a wait task ID Rev 6 00 194 REJ10B0060 0600 RENESAS Section3 Service Calls 3 15 Time Management System Clock System Clock Management Service Calls System clock is controlled by the service calls listed in table 3 46 Table 3 46 Service Calls for System Clock Managemen
78. Rev 6 00 280 REJ10B0060 0600 RENESAS Section3 Service Calls Table 3 81 Cache Attribute cont CCR and RAMCR Attribute Value Description Setting TCAC_L2_FC H 00020000 When Secondary cache RAMCR L2FC 1 specify operates in forcible coherency mode When not Secondary cache does RAMCR L2FC 0 specify not operate in forcible coherency mode Rev 6 00 281 RENESAS REJ10B0060 0600 Section3 Service Calls 3 26 2 Clear Instruction Operand Cache velr_cac ivelr_cac C Language API ER ercd vclr_cac VP clradrl VP clradr2 MODE mode ER ercd ivclr_cac VP clradrl VP clradr2 MODE mode Parameters VP clradr1 R4 Start address VP clradr2 R5 End address MODE mode R6 Target cache Return Parameters ER ercd RO Normal end E_OK or error code Error Codes E_PAR p Parameter error clradrl gt clradr2 or mode is invalid E_OBJ k Target cache is disabled Function This service call clears the cache That is the cache contents are invalidated If the operand cache has data which has not been written to memory the data is written back to memory The target cache is determined by mode Following either can be specified to be mode e TC_FULL H 00000000 Both instruction cache and operand cache e TC_EXCLUDE_IC H 00000001 Exclude instruction cache only operand cache TC_EXCLUDE_OC H 00000002 Exclude operand cache only instruction cache clradr1 is omitted to the multiple of 32 and clradr2
79. Selection Dialog The files listed in table 5 4 are created in the specified folder Note that if a file with the same name already exists the file is automatically overwritten 5 4 4 Configuration Files Table 5 4 shows configuration files generated by the configurator Table 5 4 Configuration Files Classification File Name Linkage Unit Header Files kernel_id h Kernel environment side kernel_id_sys h Kernel side kernel_macro h Kernel side System definition kernel_def_main h Kernel side kernel_def_inidata def Kernel side kernel_def_vct inc Kernel side only in HI7000 4 kernel_cfg_main h Kernel environment side kernel_cfg_inidata def Kernel environment side Rev 6 00 352 REJ10B0060 0600 RENESAS Section5 Configuration Distinction of linkage unit is related to the following items e Automatic assignment of ID number Refer to 1 kernel_id h kernel_id_sys h e Separate linkage Refer to section 5 4 5 Separate Linkage 1 kernel_id h kernel_id_sys h The objects which are discriminated by the ID numbers can be given ID names at the object creation The specified ID name is output to ID header files in the following form define ID_MainTask 1 The ID name in the kernel side is output to kernel_id_sys h The ID name in the kernel environment side is output to kernel_id h If the object is created in the kernel environment side without Link with Kernel Library check box the configurator c
80. Service Calls for Alarm Handler System State Service Call Description T N E D U L C cre_alm Creates alarm handler T E D U icre_alm N E D U acre_alm Creates alarm handler and assigns alarm handler T E D U iacre_alm ID automatically N E D U del_alm Deletes alarm handler T E D U sta_alm Starts alarm handler operation T E D U ista_alm N E D U stp_alm Stops alarm handler operation T E D U istp_alm N E D U ref_alm Refers to the alarm handler state T E D U iref_alm N E D U Notes 1 S Standard profile service calls s Service calls that are not standard profile service calls but are needed in order to use the standard profile function 2 T Can be called from task context N Can be called from non task context E Can be called from dispatch enabled state D Can be called from dispatch disabled state U Can be called from CPU unlocked state L Can be called from CPU locked state C Can be called from CPU exception handler Alarm Handler Specifications The alarm handler specifications are listed in table 3 53 Table 3 53 Alarm Handler Specifications Item Description Alarm handler ID 1 to CFG_MAXALMID 15 max Attribute supported TA_HLNG The task is written in a high level language TA_ASM The task is written in assembly language Rev 6 00 207 RENESAS REJ10B0060 0600 Section3 Service Calls 3 17 1 cre_alm icre_alm Create Alarm Handler acre_alm i
81. Task Tasks can be created in the following ways e Tasks that use a dynamic stack or a stack allocated by application cre_tsk icre_tsk acre_tsk or iacre_tsk service call Defined initially by the configurator e Tasks that use a static stack vscr_tsk service call Defined initially by the configurator Rev 6 00 301 RENESAS REJ10B0060 0600 Section4 Application Program Creation 4 6 Task Exception Processing Routines 1 Writing a Task Exception Processing Routine A task exception processing routine is normally written in C language as shown in figure 4 2 includle kernel h pragma noregsave Texrtn lt Since a task exception processing routine function does not need to guarantee the register pragma noregsave can be specified void Texrtn TEXPTN texptn VP_INT exinf lt Passes exception factors and extended information as a parameter Task exception processing routine Figure 4 2 Example of a C Language Task Exception Processing Routine 2 Rules on Using Registers Tables 4 6 to 4 8 show rules on using registers for HI7000 4 HI7700 4 and HI7750 4 Rev 6 00 302 REJ10B0060 0600 RENESAS Section4 Application Program Creation Table 4 6 Rules on Using Registers in a Task Exception Processing Routine H17000 4 Use End No Registers Conditions Initial Value 1 PC V Task exception processing routine start address
82. added SIZE mplsz VTSZ_MPLMB UINT sctnum Size of the management area for variable size memory pool with attribute VTA_UNFRAGMENT bytes When CFG_NEWMPL is selected new members mpfmb minblksz and sctnum are added to the T_CMPL structure which is used to create variable size memory pool Member mpfmb indicates the address of the management table area minblksz indicates the minimum block size and sctnum indicates the number of sectors These settings are ignored when the VTA_UNFRAGMENT attribute is not specified Note the use size of stack increases generally when CFG_NEWMPL is selected Related Pages e p 40 Section 2 15 2 Controlling Fragmentation of Free Space e p 186 Section 3 14 1 Create Variable Size Memory Pool cre_mpl icre_mpl e p 363 Item No 18 3 in table 5 5 of section 5 4 6 Configurator Settings e p 405 Appendix C Calculation of Work Area Size Rev 6 00 457 RENESAS REJ10B0060 0600 Appendix New Functions of HI7700 4 V2 I 5 Macros for Calculating Size V 2 01 Release 00 The following macros are added 1 SIZE mpfsz TSZ_MPF UINT blkent UINT blksz The size of fixed size memory pool area required to store the blkcnt number of blksz byte memory blocks bytes 2 SIZE size VTSZ_MPFMB UINT blkent UINT blksz The size of fixed size memory pool management area required to hold the blkcnt number of blksz byte memory blocks bytes 3 SIZE mplsz TSZ_MPL UINT blkent UINT blksz The size
83. are defined in kernel_def_opttmr_set h e hi_longticrate the ratio low precision cycle high precision cycle e hi_pclock the MCU s peripheral clock Po This file is included from the kernel_def c and kernel_cfg c 1 hi_longticrate Format define hi_longticrate lt setting value gt Specify the required result for low precision cycle high precision cycle as an integer constant The allowed range is from 2 to Oxff If some other specification is made the following error message will be displayed when kernel_def c and kernel_cfg c is compiled error directive Illegal hi_longticrate Which setting is effective depends on the form frequency or specified time of the time management functions most often used by the system This is generally in the range from 5 to 50 Rev 6 00 426 REJ10B0060 0600 RENESAS Appendix E Optimized Timer Driver HI7700 4 2 hi_pclock Format define hi_pclock lt setting value gt Specify the frequency of the MCU s peripheral clock P as a non zero integer constant Hz If some other specification is made the following error message will be displayed when kernel_def c and kernel_cfg c is compiled error directive Illegal hi_pclock E 6 3 Notes on the Configurator The following describes the items set in the configurator s Time management function page window 1 Timer interrupt number CFG_TIMINTNO Specify 0x400 which means interrupt code for channel 0 of the TMU
84. area indicated by pk_rmpf If there is no task waiting for the specified memory pool TSK_NONE 0 is returned as a wait task ID Rev 6 00 183 RENESAS REJ10B0060 0600 Section3 Service Calls 3 14 Memory Pool Management Variable Size Memory Pool Variable Size Memory Pool Service Calls Variable size memory pools are controlled by the service calls listed in table 3 44 Table 3 44 Service Calls for Variable Size Memory Pool Control System State Service Call Description T N E D U L C cre_mpl Creates variable size memory pool T E D U icre_mpl N E D U acre_mpl Creates variable size memory pool and assigns T E D U iacre_mpl variable size memory pool ID automatically N E D U del_mpl Deletes variable size memory pool T E D U get_mpl Acquires variable size memory block T E U pget_mpl Polls and acquires variable size memory block T E D U ipget_mpl N E D U tget_mpl Acquires variable size memory block with timeout T E U function rel_mpl Returns variable size memory block T E D U irel_mpl N E D U ref_mpl Refers to variable size memory pool state T E D U iref_mpl N E D U Notes 1 S Standard profile service calls 2 s Service calls that are not standard profile service calls but are needed in order to use the standard profile function T Can be called from task context N Can be called from non task context E Can be called from dispatch enabled state D
85. been called when BL in SR clear BL to 0 after returning from the service call processing Rev 6 00 258 REJ10B0060 0600 RENESAS Section3 Service Calls 3 23 3 Flush Cache vfls_cac ivfls_cac C Language API ER ercd vfls_cac VP flsadril VP flsadr2 ER ercd ivfls_cac VP flsadri VP flsadr2 Parameters VP flsadri1 R4 Flush start address VP flsadr2 R5 Flush end address Return Parameters ER ercd RO Normal end E_OK or error code Error Codes E_PAR p Parameter error flsadri gt flsadr2 Function This service call flushes the cache If the addresses from flsadr1 to flsadr2 are cached the contents that have not yet been written to memory are written to memory flsadr1 and flsadr2 must be within physical addresses H O to H 1bffffff If an address outside the range from H O to H 1bffffff is specified for flsadr1 or flsadr2 normal system operation cannot be guaranteed To specify all cache contents specify flsadr1 0 and flsadr2 H 1 bffffff In the SH 3 and SH3 DSP the cache line size is 16 bytes four least significant bits of flsadr1 are corrected to Os and four least significant bits of flsadr2 are corrected to 1s If this service call is called before calling the service call vini_cac or ivini_cac the normal system operation cannot be guaranteed This service call can be called even in the exception block state BL 1 in SR Therefore the cache can be flushed irrespective of interrupt
86. by the service calls listed in table 3 32 Table 3 32 Service Calls for Mailbox Control System State Service Call Description T N E D U L C cre_mbx s Creates mailbox T E D U icre_mbx N E D U acre_mbx Creates mailbox and assigns mailbox ID automatically 1 E D U iacre_mbx N E D U del_mbx Deletes mailbox T E D U snd_mbx S Sends data to mailbox T E D U isnd_mbx N E D U rcv_mbx S Receives data from mailbox T E U prcv_mbx S Polls and receives data from mailbox T E D U iprcv_mbx NE D U trcv_mbx S Receives data from mailbox with timeout function T E U ref_mbx Refers to mailbox state T E D U iref_mbx N E D U Notes 1 S Standard profile service calls s Service calls that are not standard profile service calls but are needed in order to use the standard profile function 2 T Can be called from task context N Can be called from non task context E Can be called from dispatch enabled state D Can be called from dispatch disabled state U Can be called from CPU unlocked state L Can be called from CPU locked state C Can be called from CPU exception handler Mailbox Specifications The mailbox specifications are listed in table 3 33 Table 3 33 Mailbox Specifications Item Description Mailbox ID 1 to CFG_MAXMBXID 1023 max Message priority 1 to CFG_MAXMSGPRI 255 max Attribute supported TA_TFIFO Task wait queue is managed on a FIFO basis TA_TPRI Task wait queu
87. by waiptn has been set in the specified event flag The parameter tmout specified by service call twai_flg specifies the timeout period If a positive value is specified for the parameter tmout error code E_TMOUT is returned when the timeout period has passed without the waiting release conditions being satisfied If tmout TMO_POL 0 is specified the same operation as for the service call pol_flg will be performed If tmout TMO_FEVR 1 is specified the timeout monitoring is not performed In this case the same operation as for service call wai_flg will be performed If a value larger than 1 is specified for CFG_TICDENO the denominator for time tick cycles the maximum value that can be specified for tmout is H 7fffffff CFG_TICDENO If a value larger than this is specified operation is not guaranteed For detail of time watch method refer to section 2 16 4 2 Time Watch Method Rev 6 00 134 REJ10B0060 0600 RENESAS Section3 Service Calls 3 8 6 Refer to Event Flag State ref_flg iref_flg C Language API ER ercd ref_flg ID flgid T_RFLG pk_rflg j ER ercd iref_flg ID flgid T_RFLG pk_rflg j Parameters ID flgid R4 Event flag ID T_RFLG pk_rflg R5 Pointer to the area where the event flag state is to be returned Return Parameters ER ercd RO Normal end E_OK or error code T_RFLG pk_rflg R5 Pointer to the packet where event flag state is stored Packet Structure typedef struct t_rflg ID w
88. bytes gt sub2 lt 8 bytes gt texrtn lt 160 gt 224 task_a lt 56 bytes gt sub3 lt 24 bytes gt texrtn lt 160 gt 240 maximum Task B task_a lt 40 bytes gt sub3 lt 24 bytes gt texrtn lt 160 gt 224 maximum task_a lt 56 bytes gt sub4 lt 12 bytes gt 68 Rev 6 00 410 REJ10B0060 0600 RENESAS Appendix CCalculation of Work Area Size C6 Task Stacks C 6 1 Stack Size Used by Each Task Each task stack size can be determined by substituting the size obtained according to appendix C 5 above into table C 5 For tasks that use the dynamic stack specify the value calculated using table C 5 as a stack size when a task is created by cre_tsk and acre_tsk service calls and the configurator For tasks that use a static stack allocate the stack size calculated using table C 5 by the configurator Rev 6 00 411 RENESAS REJ10B0060 0600 Appendix CCalculation of Work Area Size Table C 5 Task Stack Size Stack Size Byte Item HI7000 4 HI7700 4 HI7750 4 Size obtained in C 4 and C 5 Mandatory 140 184 196 TA_COPO attribute included 56 56 TA_COP1 attribute included 72 64 TA_COP2 attribute included 64 Static stacks 8 8 8 CFG_TRACE is selected 24 24 24 CFG_NEWMPL is selected 28 28 28 Addition considering nested interrupts ii The added value when the NMI is used s Total Note 1 1 When NOBANK NOTUSE or SELECT has been selected fo
89. calls listed in table 3 64 Table 3 64 Service Calls for Service Call Management System State Service Call Description T N E D U L C def_svc Defines extended service call T E D U idef_svc N E D U cal_svc Calls service call T E D U ical_svc N E D U Notes 1 S Standard profile service calls s Service calls that are not standard profile service calls but are needed in order to use the standard profile function 2 T Can be called from task context N Can be called from non task context E Can be called from dispatch enabled state D Can be called from dispatch disabled state U Can be called from CPU unlocked state L Can be called from CPU locked state C Can be called from CPU exception handler Service Call Management Specifications The service call management specifications are listed in table 3 65 Table 3 65 Service Call Management Specifications Item Description Function code of extended service call 1 to CFG_MAXSVCCD 1023 max Parameter that can be passed 0 to four VP_INT type parameters Attribute supported TA_HLNG The task is written in a high level language TA_ASM The task is written in assembly language Rev 6 00 242 REJ10B0060 0600 RENESAS Section3 Service Calls 3 21 1 Define Extended Service Call def_svc idef_svc C Language API ER ercd def_svc FN fncd T_DSVC pk_dsvc ER ercd idef_svc FN fncd T_DSVC pk_dsvc Parameters FN fncd R4
90. contained in these materials including product data diagrams charts programs and algorithms represents information on products at the time of publication of these materials and are subject to change by Renesas Technology Corp without notice due to product improvements or other reasons It is therefore recommended that customers contact Renesas Technology Corp or an authorized Renesas Technology Corp product distributor for the latest product information before purchasing a product listed herein The information described here may contain technical inaccuracies or typographical errors Renesas Technology Corp assumes no responsibility for any damage liability or other loss rising from these inaccuracies or errors Please also pay attention to information published by Renesas Technology Corp by various means including the Renesas Technology Corp Semiconductor home page http www renesas com When using any or all of the information contained in these materials including product data diagrams charts programs and algorithms please be sure to evaluate all information as a total system before making a final decision on the applicability of the information and products Renesas Technology Corp assumes no responsibility for any damage liability or other loss resulting from the information contained herein Renesas Technology Corp semiconductors are not designed or manufactured for use in a device or system that is used under circums
91. del_sem C Language API ER ercd del_sem ID semid Parameters ID semid R4 Return Parameters ER ercd RO Error Codes Semaphore ID Normal end E_OK or error code E_ID p Invalid ID number semid lt 0 or semid gt CFG_MAXSEMID E_NOEXS k Undefined Semaphore indicated by semid does not exist E_CTX k Context error Called from disabled system state Function The service call del_sem deletes the semaphore indicated by the parameter semid No error will occur even if there is a task waiting to acquire a resource with the semaphore indicated by semid However in that case the task in the WAITING state will be released and error code E_DLT will be returned Rev 6 00 121 RENESAS REJ10B0060 0600 Section3 Service Calls 3 7 3 Returns Semaphore Resource sig_sem isig_sem C Language API ER ercd sig_sem ID semid ER ercd isig_sem ID semid Parameters ID Return Parameters ER Error Codes EID E_NOEXS E_QOVR semid R4 Semaphore ID ercd RO Normal end E_OK or error code p Invalid ID number semid lt 0 or semid gt CFG _MAXSEMID k Undefined Semaphore indicated by semid does not exist k Queuing overflow semcnt gt maxsem Note maxsem Maximum number of semaphore resources specified at semaphore creation Function Each service call returns one resource to the semaphore indicated by semid If there is a task waiting for the semaphore indicated by semi
92. e __kernel_pon_sp Initial stack pointer used for power on reset e __kernel_man_sp Initial stack pointer used for manual reset Rev 6 00 382 REJ10B0060 0600 RENESAS Section5 Configuration 3 Section Category SuperH RISC engine Standard Toolchain Configuration C C Assembly Link Library Standard Library CPU Deb4 gt oibie E Category 7 EE mga Rrojecta Show entries for Section M source file Address Section a Edit C source file P hiexpent x Assembly source fi xBO00T 000 C hibase i i Phireset Linkage symbol file hireset fde C hivet C hitrp source file Phiknl C source file C hidef i P hisysdwn Assembly source fi Isysdwn Linkage symbol file Lerner cal mx C hitmrdry source file G source file Options Link Library Assembly source fi sentry hi cpuasm defines kenel pon sp 0ACI aay a i i define _kernel_man_sp 0AC1 define _kernelsysmt Likaae synbolfile 080010000 noprelink nomessage list GONFIGDIR E Figure 5 17 Optimized Linkage Editor Section Specifies the allocation addresses of each section Specify the allocation addresses for the sections in the input files according to the target hardware The __kernel_cnfgtbl address the start address of service call interface data C_hibase section must be defined during the kernel environment load modu
93. e p 363 Item No 18 3 in table 5 5 of section 5 4 6 Configurator Settings e p 405 Appendix C Calculation of Work Area Size H 10 Initial Value of DSR V 2 01 Release 00 The initial value of DSR in the task with the TA_COPO0 attribute and its task exception processing routine is changed from an undefined value to 0 Related Pages e p 337 Section 4 13 Using the DSP in Programs for HI7000 4 and H17700 4 only H 11 Initial Value of SR in Task Exception Processing Routine V 2 01 Release 00 The initial value of SR in the task exception processing routine is changed as follows Previous version Same value as in the task before initiation V 2 01 H 00000000 H 12 Handling of Vector Numbers 16 to 31 V 2 01 Release 00 Handlers can be defined for all of these vector numbers in V 2 01 Release 00 In V 2 02 Release 00 however no handler can be defined for vector number 26 because it is now used by the kernel Rev 6 00 452 REJ10B0060 0600 RENESAS Appendix H New Functions of HI7000 4 V2 H 13 Lifting of Restriction concerning Structure Alignment V 2 01 Release 00 In the previous version there is a restriction regarding the pack option and pragma pack directive for the compiler This restriction does not apply with V 2 01 and the following related note has been removed from this version of the user s manual The source program which uses the variable of the structure form defined by the kernel should surely speci
94. error p_blk is other than a multiple of four or tmout lt 2 E_ID p Invalid ID number mpfid lt 0 or mpfid gt CFG_MAXMPFID E_NOEXS k Undefined Fixed size memory pool indicated by mpfid does not exist E_CTX k Context error Called from disabled system state E_DLT k Waiting object deleted Fixed size memory pool indicated by mpfid has been deleted E_TMOUT k Polling failed or timeout E_RLWAI k WAITING state was forcibly cancelled rel_wai service call was called in the WAITING state Rev 6 00 180 REJ10B0060 0600 RENESAS Section3 Service Calls Function Each service call gets one fixed size memory block from the fixed size memory pool indicated by mpfid and returns the start address of the acquired memory block to the area indicated by p_blk If there are tasks already waiting for the memory pool or if no task is waiting but there is no memory block available in the fixed size memory pool the task having called service call get_mpf or tget_mpf is placed in the memory acquiring wait queue and the task having called service call pget_mpf or ipget_mpf is immediately returned with error code E_ TMOUT The queue is managed according to the attribute specified at creation Parameter tmout of service call tget_mpf specifies the timeout period If a positive value is specified for parameter tmout error code E_TMOUT is returned when the timeout period has passed without the wait release conditions being satisfied If tmout
95. exception block state BL 1 in SR Rev 6 00 257 RENESAS REJ10B0060 0600 Section3 Service Calls 3 23 2 Clear Cache velr_cac ivelr_cac C Language API ER ercd vclr_cac VP clradrl VP clradr2 ER ercd ivclr_cac VP clradrl VP clradr2 Parameters VP clradri R4 Start address VP clradr2 R5 End address Return Parameters ER ercd RO Normal end E_OK or error code Error Codes E_PAR p Parameter error clradrl gt clradr2 Function This service call clears the cache If the addresses from clradr1 to clradr2 are cached the cache contents are invalidated The contents that have not yet been written to memory are written to memory clradr1 and clradr2 must be within physical addresses H O to H 1bffffff If an address outside the range from H O to H 1bffffff is specified for clradr1 or clradr2 normal system operation cannot be guaranteed To specify all cache contents specify clradr1 0 and clradr2 H bffffff In the SH 3 and SH3 DSP the cache line size is 16 bytes four least significant bits of clradr1 are corrected to Os and four least significant bits of clradr2 are corrected to 1s If this service call is called before calling the service call vini_cac or ivini_cac normal system operation cannot be guaranteed This service call can be called even in the exception block state BL 1 in SR Therefore the cache can be cleared irrespective of interrupts or exceptions When this service call has
96. exception event register EXPEVT when an interrupt exception or unconditional trap occurs on the HI7700 4 and HI7750 4 2 The initial definition is processed on the kernel side and then on the kernel environment side The order of initial definition on the kernel side and kernel environment side is shown below The orders of each process are the orders that are listed in each page However the system may not go down at orders 1 to 3 on the kernel side they are not counted as the initial definition 1 Initial definition of interrupt handlers in the interrupt CPU exception handler page 2 Initial definition of CPU exception handlers in the interrupt CPU exception handler page 3 Initial definition of CPU exception handlers for trap in the trap exception handler page Initial definition of tasks and task exception processing routines in the task page Initial definition of semaphores in the semaphore page 6 Initial definition of event flags in the event flag page 7 Initial definition of data queues in the data queue page 8 Initial definition of mailboxes in the mailbox page 9 Initial definition of mutexes in the mutex page 10 Initial definition of message buffers in the message buffer page 11 Initial definition of fixed size memory pools in the fixed size memory pool page 12 Initial definition of variable size memory pools in the variable size memory pool page Initial definition of cyclic handlers in the cyclic handler pa
97. flgid does not exist Function The event flag specified by flgid is ORed with the value indicated by the parameter setptn Each service call shifts a task to the READY state after the event flag value has been changed and when the wait release conditions of a task waiting for an event flag have been satisfied Wait release conditions are checked in the queue order All bits of the event flag bit pattern and service call are cleared when the TA_CLR attribute is set to the target event flag attribute When the TA_WMUL attribute is set to the event flag and the TA_CLR attribute is not specified multiple wait tasks may be released when the service call set_flg is called only once When multiple wait tasks are released the tasks are released in the queue order of the event flag Rev 6 00 131 RENESAS REJ10B0060 0600 Section3 Service Calls 3 8 4 Clear Event Flag clr_fig iclr_flg C Language API ER ercd clr _flg ID flgid FLGPTN clrptn ER ercd iclr_flg ID flgid FLGPTN clrptn Parameters ID flgid R4 Event flag ID FLGPTN clrptn R5 Bit pattern to clear Return Parameters ER ercd RO Normal end E_OK or error code Error Codes E_ID p Invalid ID number flgid lt 0 or flgid gt CFG_MAXFLGID E_NOEXS k Undefined Event flag indicated by flgid does not exist Function The event flag bits specified by flgid is ANDed with the value indicated by the parameter clrptn Rev 6 00 132 REJ10B0060 0600 RENESAS
98. icre_mpl ID mplid T_CMPL pk_cmp1 ER_ID mplid acre_mpl T_CMPL pk_cmp1 ER_ID mplid iacre_mpl T_CMPL pk_cmp1 Parameters lt cre_mpl icre_mpl gt ID mplid R4 Variable size memory pool ID T_CMPL pk_cmpl R5 Pointer to the packet where the variable size memory pool creation information is stored lt acre_mpl iacre_mpl gt T_CMPL pk_cmpl R4 Pointer to the packet where the variable size memory pool creation information is stored Return Parameters lt cre_mpl icre_mpl gt ER ercd RO Normal end E_OK or error code lt acre_mpl iacre_mpl gt ER_ID mplid R4 Created variable size memory pool ID a positive value or error code Packet Structure 1 CFG_NEWMPL is not checked typedef struct t_cmpl ATR mplatr 0 4 Variable size memory pool attribute SIZE mplsz 4 4 Size of memory pool Number of bytes VP mpl 8 4 Start address of the variable size memory pool area T_CMPL 2 CFG_NEWMPL is checked typedef struct t_cmpl ATR mplatr 0 4 Variable size memory pool attribute SIZE mplsz 4 4 Size of memory pool Number of bytes VP mpl 8 4 Start address of the variable size memory pool area VP mplmb 12 4 Start address of the variable size memory pool management table area UINT minblksz 16 4 Minimum block size UINT sctnum 20 4 Maximum sector number T_CMPL Rev 6 00 186 REJ10B0060 0600 RENESAS Section3 Service Calls Error Codes E_NOMEM k Insufficient memory Memory pool area cannot be alloc
99. in the DORMANT state Each service call refers to the current priority of the task specified by the parameter tskid and returns it to area indicated by parameter p_tskpri By specifying tskid TSK_SELF 0 the current task is specified Rev 6 00 88 REJ10B0060 0600 RENESAS Section3 Service Calls 3 4 10 Refer to Task State ref_tsk iref_tsk C Language API ER ercd ref_tsk ID tskid T_RTSK pk_rtsk ER ercd iref_tsk ID tskid T_RTSK pk_rtsk Parameters ID tskid R4 T_RTSK pk_rtsk R5 Return Parameters Task ID Pointer to the packet where the task state is to be returned ER ercd RO Normal end E_OK or error code T_RTSK pk_rtsk R4 Pointer to the packet where the task state is stored Packet Structure typedef struct t_rtsk STAT tskstat 0 4 Task state PRI tskpri 4 2 Current priority of the task PRI tskbpri 6 2 Base priority of the task STAT tskwait 8 4 Wait cause ID wobjid 12 2 Wait object ID TMO lefttmo 16 4 Time to timeout UINT actent 20 4 Number of queued initiation requests UINT wupcent 24 4 Number of queued wakeup requests UINT suscnt 28 4 Suspend request nest count UINT tskmode 32 4 Task execution mode UINT tflptn 36 4 Current task event flag value T_RTSK Error Codes E_PAR p Parameter error pk_rtsk is other than a multiple of four E_ID p Invalid ID number tskid lt 0 tskid gt CFG _MAXTSKID or tskid TSK_SELF 0 is specified in a non task context
100. initialization routine refer to section 4 13 Using the DSP in Programs for HI7000 4 and HI7700 4 only 4 Defining Time Event Handlers and Initialization Routine a Acyclic handler can be defined in the following ways cre_cyc icre_cyc acre_cyc or iacre_cyc service call Defined initially by the configurator b An alarm handler can be defined in the following ways cre_alm icre_alm acre_alm or iacre_alm service call Defined initially by the configurator c An overrun handler can be defined in the following ways def_ovr service call Defined initially by the configurator d An initialization routine can be defined in the following ways Defined initially by the configurator Rev 6 00 334 REJ10B0060 0600 RENESAS Section4 Application Program Creation 4 11 CPU Initialization Routines 4 11 1 Creating CPU Initialization Routines in C language The CPU initialization routine is a program that is first executed after the CPU is reset For details refer to section 2 18 1 Resetting the CPU and Initiating the Kernel Also refer to sample files nnnn_cpuasm src assembly language and nnnn_cpuini c C language 4 11 2 Defining CPU Initialization Routines in HI7000 4 Define the start address of the CPU initialization routine to the reset vector address H 0 Also define the initial stack pointer to the reset vector In addition start up the kernel at the end of the CPU initialization routin
101. invalidated irrespective of interrupts or exceptions When this service call has been called when BL in SR clear BL to 0 after returning from the service call processing Rev 6 00 266 REJ10B0060 0600 RENESAS Section3 Service Calls 3 25 Cache Support Function HI7700 4 for SH4AL DSP without Extended Function HI7750 4 for SH 4A without Extended Function This function is supported only for the HI7700 4 and HI7750 4 As for a cache support function libraries differ for every microcomputer table 3 76 And a part of functions and API differ for every library Table 3 76 Library of Cache Support Functions Kernel CPU Target Cache Library HI7700 4 SH 3 SH3 DSP Mixed instruction data 7708_cache_ lib SH4AL DSP Instruction cache and operand sh4al_cache_ lib without extended cache function SH4AL DSP with Instruction cache and operand cache shx2_cache_ lib extended function HI7750 4 SH 4 Operand cache 7750_cache_ lib SH 4A without Instruction cache and operand sh4a_cache_ lib extended function cache SH 4A with Instruction cache and operand cache shx2_cache_ lib extended function The specifications of the library for SH4AL DSP without extended function sh4al_cache_ lib and the library for SH 4A without extended function sh4a_cache_ lib are the same and this section explains the specification of them In addition be sure to refer to following sections e 5 7
102. itron h The SERCD macro of this kernel always returns 1 except for normal end e ER mercd MERCD ER ercd returns the main error code from the error code e ER sercd SERCD ER ercd returns the sub error code from the error code If a service call is issued while it is not selected through the configurator error E_NOSPT is returned regardless of the return value type of the service call 3 2 5 System State and Service Calls Whether a service call can be called or not depends on the system state refer to section 2 4 System State 1 Task Context and Non Task Context Service calls can be classified as dedicated to task context dedicated to the non task context and service calls that can be called from all contexts a The names of service calls that can be called from non task context start with i b Following service calls can be called from all context e sns_tex e sns_ctx e sns_loc e sns_dsp e sns_dpn e vsta_knl ivsta_knl e vsys_dwn ivsys_dwn e vini_cac ivini_cac e vclr_cac ivelr_cac e vfls_cac ivfls_cac e vinv_cac ivinv_cac Rev 6 00 69 RENESAS REJ10B0060 0600 Section3 Service Calls Although the names of these service calls start with i these service calls can be called from task context c Service calls other than the above are service calls that are dedicated to task context Normal system operation cannot be guaranteed when a service call is called from a cont
103. memory mapped operand cache to write back the dirty U 1 entries to memory and invalidates V 0 them During this processing the SR value remains the same as when this function is called When no interrupt should be accepted during this function processing mask interrupts and then call this function In the HI7750 4 this service call can be called before the kernel is initiated This service call can be called even in the exception block state BL 1 in SR Therefore the cache can be flushed irrespective of interrupts or exceptions When this service call has been called when BL 1 in SR clear BL to 0 after returning from the service call processing Rev 6 00 285 RENESAS REJ10B0060 0600 Section3 Service Calls 3 26 4 Invalidate Instruction Operand Cache vinv_cac ivinv_cac C Language API ER ercd vinv_cac VP invadrl VP invadr2 MODE mode ER ercd ivinv_cac VP invadrl VP invadr2 MODE mode Parameters VP invadr1 R4 Start address of invalidation VP invadr2 R5 End address of invalidation MODE mode R6 Target cache Return Parameters ER ercd RO Normal end E_OK or error code Error Codes E_PAR p Parameter error invadrl gt invadr2 or mode is invalid E_OBJ k Target cache is disabled Function The service call vinv_cac invalidates the cache It is canceled even if the data which has not been written back to memory is in operand cache The target cache are determined by mode Following eithe
104. mtxid If the target mutex is not locked the current task locks the mutex and the service call processing is completed At this time the priority of the current task is raised to the ceiling priority of the mutex If the target mutex is locked the current task is placed in a wait queue and the current task enters the mutex lock wait state The wait queue is managed in priority order Parameter tmout specified by service call tloc_mtx specifies the timeout period If a positive value is specified for parameter tmout error code E_TMOUT is returned when the timeout period has passed without the wait release conditions being satisfied If tmout TMO_POL 0 is specified the same operation as for service call ploc_mtx will be performed Rev 6 00 160 REJ10B0060 0600 RENESAS Section3 Service Calls If tmout TMO_FEVR 1 is specified timeout monitoring is not performed In other words the same operation as for service call loc_mtx will be performed When a value larger than 1 is specified for CFG_TICDENO the denominator for time tick cycles the maximum value that can be specified for tmout is H 7fffffff CFG_TICDENO If a value larger than this is specified operation is not guaranteed For detail of time watch method refer to section 2 16 4 2 Time Watch Method Rev 6 00 161 RENESAS REJ10B0060 0600 Section3 Service Calls 3 11 4 Unlock Mutex unl_mtx C Language API ER ercd unl_mtx ID mtxid Paramet
105. not register banks are used with interrupts having interrupt level nn 0 Register bank is not used 1 Register bank is used This definition is possible only when the CFG_REGBANK setting is other than NOBANK VTCFG_MPFMANAGE Indicates CFG_MPFMANAGE 0 Places management tables in the memory pool The same method as the previous version 1 Places management table outside of the memory pool Extended method VTCFG_NEWMPL Indicates CFG_NEWMPL 0 Conventional method 1 New method reduced fragmentation and faster operation Notes 1 Definition differs depending on whether CFG_NEWMPL is selected 2 Only when CFG_NEWMPL is selected 3 Only in HI7000 4 RENESAS Rev 6 00 291 REJ10B0060 0600 Section4 Application Program Creation 3 Header Files for ID Names kernel_id h kernel_id_sys h An ID name can be given to each object by the configurator The configurator outputs the specified ID name to the ID name header file Application can specify an object ID by using its ID name For details refer to section 5 4 4 1 kernel_id h kernel_id_sys h wup_tsk ID_main 4 1 2 Header Files for Assembly Language 1 itron inc itron inc is a header file where the common ITRON specification definitions are described for assembly language This file can be found in the hihead folder 2 kernel inc kernel inc is a header file where the uITRON4 0 kernel specification definitions are described for a
106. of use For example only a specific task uses a stack in the high speed on chip RAM Related Pages e p 13 Section 2 6 2 Task Creation e p 76 Section 3 4 1 Create Task e p 176 Section 3 13 1 Create Fixed Size Memory Pool e p 186 Section 3 14 1 Create Variable Size Memory Pool I 3 Management Method of Fixed Size Memory Pool V 2 01 Release 00 In the previous version the kernel management table for each memory block is allocated in the memory pool area In V 2 the user can also allocate the management table area and can specify the table area address at creation In this case the memory pool area does not include management tables Rev 6 00 455 RENESAS REJ10B0060 0600 Appendix New Functions of HI7700 4 V2 By combining this management method with the new function given in appendix I 2 Specifying Address of Task Stack Fixed Size Memory Pool and Variable Size Memory Pool V 2 01 Release 00 a memory block can be acquired with a specific offset address as follows for example e Parameters for fixed size memory pool creation Address of fixed size memory pool H 0c000000 Block size H 1000 4 Kbytes Number of blocks 4 In this case one of memory blocks A B C and D shown below is acquired Each memory block is aligned with a 4 Kbyte boundary Address H 0C000000 gt Memory block A H 0C001000 gt Memory block B H 0C002000 gt Memory block C H 0C003
107. parameter tmout error code E_TMOUT is returned when tmout time has passed without the wait release condition being satisfied If tmout TMO_POL 0 is specified the same operation as for the service call vpol_tfl will be performed If tmout TMO_FEVR 1 is specified the timeout monitoring is not performed In other words the same operation as for the service call vwai_tfl will be performed If a value larger than 1 is specified for CFG_TICDENO the denominator for time tick cycles the maximum value that can be specified for tmout is H 7fffffff CFG_TICDENO If a value larger than this is specified operation is not guaranteed For details on the time watch method refer to section 2 16 4 2 Time Watch Method The service calls vwai_tfl vpol_tfl and vtwai_tfl are functions original to the HI7000 4 series Rev 6 00 108 REJ10B0060 0600 RENESAS Section3 Service Calls 3 6 Task Exception Processing Functions Task Exception Processing Service Calls Task exception processing is controlled by the service calls listed in table 3 18 Table 3 18 Service Calls for Task Exception Processing System State Service Call Description T N E D U L C def_tex s Defines the task exception processing routine T E D U idef_tex N E D U tas_tex S Requests the task exception processing T E D U C iras_tex S N E D U C dis_tex S Disables the task exception processing T E D U ena_tex S Enables the
108. pget_mpf ipget_mpf or tget_mpf must be specified for parameter blk If there are tasks waiting to get a memory block in the target fixed size memory pool the memory block returned by this service call is passed to the task at the head of the wait queue releasing it from the WAITING state Rev 6 00 182 REJ10B0060 0600 RENESAS Section3 Service Calls 3 13 5 Refer to Fixed Size Memory Pool State ref_mpf iref_mpf C Language API ER ercd ref_mpf ID mpfid T_RMPF pk_rmpf ER ercd iref_mpf ID mpfid T_RMPF pk_rmpf Parameters ID mpfid R4 Fixed size memory pool ID T_RMPF pk_rmpf R5 Pointer to the packet where the fixed size memory pool state is to be returned Return Parameters ER ercd RO Normal end E_OK or error code T_RMPF pk_rmpf R5 Pointer to the packet where the fixed size memory pool state is stored Packet Structure typedef struct t_rmpf ID wtskid 0 2 Wait task ID UINT fblkent 4 4 Number of blocks of memory space available T_RMPF Error Codes E_PAR p Parameter error pk_rmpf is other than a multiple of four E_ID p Invalid ID number mpfid lt 0 or mpfid gt CFG_MAXMPFID E_NOEXS k Undefined Fixed size memory pool indicated by mpfid does not exist Function Each service call refers to the state of the fixed size memory pool indicated by mpfid Service calls ref_mpf and iref_mpf return the wait task ID wtskid and the number of blocks of memory space available fblkcnt to the
109. process nnnn_sct src nnnn_inisct c These files are not used in the state at shipment Only for HI7000 4 Interrupt CPU exception process kernel_exp src Only for HI7700 4 and HI7750 4 Interrupt CPU exception entry process nnnn_expent src Only for HI7700 4 and HI7750 4 Undefined interrupt CPU exception process nnnn_intdwn src kernel_def c and kernel_cfg c Only for HI7700 4 DSP standby control function setting file kernel_def_dspstby_set h Only for HI7700 4 Optimized timer function setting file kernel_def_opttmr_set h Only for SH4AL DSP and SH 4A in HI7700 4 and HI7750 4 Cache support service call setting file kernel_cfg_cac_set h Rev 6 00 347 RENESAS REJ10B0060 0600 Section5 Configuration c shnnnn mix folder This folder contains the mix hwp file which is the HEW project file for whole linkage This folder also contains a folder to store object files to be generated through the mix hwp project d shnnnn def folder This folder contains the def hwp file which is the HEW project file for separate linkage kernel side This folder also contains a folder to store object files to be generated through the def hwp project e shnnnn cfg folder This folder contains the cfg hwp file which is the HEW project file for separate linkage kernel environment side This folder also contains a folder to store object files to be generated through the cfg hwp project 2 HEW1 2 The shnnnn folder contains t
110. rcv_dtq ER ercd rcv_dtq ID dtqid VP_INT p_data Receive Data from Data Queue 61 prev_dtq ER ercd prcv_dtq ID dtqid VP_INT p_data Poll and Receive Data from Data Queue 62 trcv_dtq ER ercd trcv_dtq ID dtqid VP_INT p_data TMO Receive Data from Data Queue with tmout Timeout 63 ref_dtq ER ercd ref_dtq ID dtqid T_ RDTQ pk_rdtq Refer to Data Queue State iref_dtq ER ercd iref_dtq ID dtqid T_ RDTQ pk_rdtq Mailbox 64 cre_mbx ER ercd cre_mbx ID mbxid T_CMBX pk_cmbx Create Mailbox icre_mbx ER ercd icre_mbx ID mbxid T_CMBX pk_cmbx 65 acre_mbx ER_ID mbxid acre_mbx T_CMBX pk_cmbx Create Mailbox and Assign Mailbox iacre_mbx ER_ID mbxid iacre_mbx T_CMBX pk_cmbx _ D Automatically 66 del_mbx ER ercd del_mbx ID mbxid Delete Mailbox 67 snd_mbx ER ercd snd_mbx ID mbxid T_MSG pk_msg Send Message to Mailbox isnd_mbx ER ercd isnd_mbx ID mbxid T_MSG pk_msg 68 rcv_mbx ER ercd rcv_mbx ID mbxid T_MSG ppk_msg Receive Message from Mailbox 69 prev_mbx ER ercd prcv_mbx ID mbxid T_MSG ppk_msg Poll and Receive Message from iprev_mbx ER ercd iprev_mbx ID mbxid T_MSG ppk_msg Mailbox 70 trcv_mbx ER ercd trcv_mbx ID mbxid T MSG ppk_msg Receive Message from Mailbox with TMO tmout Timeout 71 ref_mbx ER ercd ref_mbx ID mbxid T_ RMBX pk_rmbx Refer to Mailbox State iref_mbx ER ercd iref_mbx ID mbxid T_ RMBX pk_rmbx Rev 6 00 393 RENESAS REJ10B0060 0600 Appendix A S
111. register banks are used with interrupts Depends on CFG_TBR 1 Kernel does not manage The kernel does not operate TBR 2 Only for service call Do not modify TBR 3 Task context When execution is returned from an interrupt handler function RTS instruction the contents of TBR must be the same as the value at initiation The initial value is undefined Rev 6 00 316 REJ10B0060 0600 RENESAS Section4 Application Program Creation i INCLUDE kernel inc SECTION B_hiirqstk DATA ALIGN 4 RES L 128 Stk SECTION P_ISR CODE ALIGN 4 EXPORT _DirectInh DirectInh MOV L RO R15 MOV L _Stk RO MOV L R15 RO MOV L RO R15 MOV L R1 R15 MOV L R15 R1 MOV L R15 R15 MOV L R15 R0 lt End instruction gt POOL END Defines the stack used by the interrupt handler Assigns symbol Stk to the end address of the stack Start address of the interrupt handler lt Saves the contents of RO to the stack of the program that was interrupted Saves the address pointed to by the stack pointer to the stack used by the interrupt handler Switches the stack pointer to the interrupt handler stack lt Saves the contents of registers including the DSP used by the handler to stack Restores the register contents after completing handler execution Restores the address pointed to by the stack pointer Restores the contents of RO lt See table
112. release condition is satisfied The parameter iflgptn specifies the initial value of the event flag An event flag can also be created statically by the configurator Rev 6 00 129 RENESAS REJ10B0060 0600 Section3 Service Calls 3 8 2 Delete Event Flag del_flg C Language API ER ercd del_flg ID flgid Parameters ID flgid R4 Event flag ID Return Parameters ER ercd RO Normal end E_OK or error code Error Codes E_ID p Invalid ID number flgid lt 0 or flgid gt CFG_MAXFLGID E_NOEXS k Undefined Event flag indicated by flgid does not exist E_CTX k Context error Called from disabled system state Function The service call del_flg deletes the event flag indicated by the parameter flgid No error will occur even if there is a task waiting for the conditions to be met in the event flag indicated by flgid However in that case the task in the WAITING state will be released and error code E_DLT will be returned Rev 6 00 130 REJ10B0060 0600 RENESAS Section3 Service Calls 3 8 3 Set Event Flag set_flg iset_flg C Language API ER ercd set_flg ID flgid FLGPTN setptn ER ercd iset_flg ID flgid FLGPTN setptn Parameters ID flgid R4 Event flag ID FLGPIN setptn R5 Bit pattern to set Return Parameters ER ercd RO Normal end E_OK or error code Error Codes E_ID p Invalid ID number flgid lt 0 or flgid gt CFG_MAXFLGID E_NOEXS k Undefined Event flag indicated by
113. task T E D U L exd_tsk S Exits and deletes current task T E D U L ter_tsk S Forcibly terminates a task T E D U chg_pri S Changes task priority T E D U ichg_pri N E D U get_pri S Refers to task priority T E D U iget_pri N E D U ref_tsk Refers to task state T E D U iref_tsk N E D U ref_tst Refers to task state simple version T E D U iref_tst N E D U vchg_tmd Changes task execution mode T E D U Notes 1 S Standard profile service calls s Service calls that are not standard profile service calls but are needed in order to use the standard profile function 2 T Can be called from task context N Can be called from non task context E Can be called from dispatch enabled state D Can be called from dispatch disabled state U Can be called from CPU unlocked state L Can be called from CPU locked state C Can be called from CPU exception handler Rev 6 00 74 REJ10B0060 0600 RENESAS Section3 Service Calls Task Management Specifications Task management specifications are listed in table 3 5 Table 3 5 Task Management Specifications Item Description Task ID 1 to CFG_MAXTSKID 1023 max Task priority 1 to CFG_MAXTSKPAT 255 max Maximum count of task initiation request 15 Task attribute TA_HLNG The task is written in a high level language TA_ASM The task is written in assembly language TA_ACT The task makes a transition to the READY state after the task has been created
114. task exception processing T E D U sns_tex S Refers to the task exception processing disabled T N E D U L C state ref_tex Refers to the task exception processing state T E D U iref_tex N E D U Notes 1 S Standard profile service calls s Service calls that are not standard profile service calls but are needed in order to use the standard profile function 2 T Can be called from task context N Can be called from non task context E Can be called from dispatch enabled state D Can be called from dispatch disabled state U Can be called from CPU unlocked state L Can be called from CPU locked state C Can be called from CPU exception handler Rev 6 00 109 RENESAS REJ10B0060 0600 Section3 Service Calls Task Exception Specifications The task exception specifications are listed in table 3 19 Table 3 19 Task Exception Specifications Item Description Exception factor 32 bits Status at task initiation e Task exception processing disabled state e No pended exception factors Attribute supported TA_HLNG The task is written in a high level language TA_ASM The task is written in assembly language HI7000 4 HI7700 4 TA_COPO The task uses the DSP HI7000 4 TA_COP1 The task uses the FPU HI7750 4 TA_COP1 The task uses bank 0 in the FPU TA_COP2 The task uses bank 1 in the FPU The task exception routine is initiated as the task context when the following conditions are satisfied e Task exception pr
115. than a multiple of four or tmout lt 2 E_ID p Invalid ID number mbfid lt 0 or mbfid gt CFG_MAXMBFID E_NOEXS k Undefined Message buffer indicated by mbfid does not exist E_CTX k Context error Called from disabled system state E_DLT k Waiting object deleted Target message buffer indicated by mbfid has been deleted during the WAITING state E_TMOUT k Polling failed or timeout E_RLWAI k WAITING state is forcibly cancelled rel_wai service call was called in the WAITING state Function Each service call receives a message from the message buffer specified by parameter mbfid and stores the received message in the area indicated by msg The received message size is returned as the return parameter If there are already messages in the message buffer the task receives the message of the head of the queue the oldest message After the message has been received the free space size of the message buffer will increase by an amount given by the following expression Increase in size msgsz 4 bytes Rev 6 00 172 REJ10B0060 0600 RENESAS Section3 Service Calls If as a result the free space in the message buffer becomes larger than the size of the message to be sent by the task at the head of the send wait queue the message is sent and stored in the message buffer and the task is released from the WAITING state The same will be done for the remaining tasks in the order of the wait queue if the message can be stored
116. that this routine name is fixed void kernel _sysdwn W type ER ercd VW infl VW inf2 Refer to appendix B 2 Information during System Down for details on the parameters passed to the system down routine The system down routine must be created and linked to the kernel When writing a system down routine in C language refer to sample file nnnn_sysdwn c for details Although the system down routine operates under abnormal conditions it cannot use kernel functions such as system calls if the kernel fails error type is negative Do not return from a system down routine When debugging an application program maintain the system down routine state and make the program enter an endless loop and analyze why a system down occurred and takes measures to prevent system downs from occurring Rev 6 00 336 REJ10B0060 0600 RENESAS Section4 Application Program Creation 4 13 Using the DSP in Programs for HI7000 4 and HI7700 4 only 4 13 1 Initializing DSR The initial DSR value depends on the program as shown in table 4 21 Table 4 21 Initial DSR Value Program Initial DSR Value Task without attribute TA_COP0 Undefined Task with attribute TA_COPO 0 Task exception processing routine without attribute TA_COPO Undefined Task exception processing routine with attribute TA_COPO 0 Interrupt handler Undefined CPU exception handler Undefined Time event handler Undefined Initialization routine Und
117. the event flag vwai_ttfl Waits for event occurrence vpol_tfl Polls for event occurrence viwai_tfl Waits for event to occur with timeout Figure 2 3 shows an example of the using task event flags Time Task A Task B Task A event flags 1 velr_ttl 0 2 vwai_ttl lt WAITING gt l INISI SASINI NINI NINS SI NSN I 3 lt READY gt vset_tfi 0 DDD OOOO ISINASAAD A AAAA 4 i ivset_tfl 0 77 Figure 2 3 Example of Using Task Event Flag Rev 6 00 19 RENESAS REJ10B0060 0600 Section2 Kernel Description The bold lines indicate executed processing and the following describes the task event flag operation with respect to time 1 Task A issues vclr_tfl to clear all bits in its task event flag 2 Task A issues vwai_tfl waiting pattern H ffffffff to wait for an event 3 Task B issues vset_tfl set pattern 1 to task A Since this set pattern is included in the waiting pattern specified in task A the WAITING state of task A is cancelled and the task A event flags are cleared to 0 4 Interrupt handler C issues ivset_tfl set pattern 7 to set event flags of the task A In this case however task A does not wait for an event therefore the task event flags are logically ORed with a pattern specified by vset_tfl 2 7 Task Exception Processing Task exception processing is performed when an exception occurs during task execution Task exception processing is performed asynchronously with task process
118. the interrupt level 4 44 x Number of interrupt levels in the system except NMI 1 Size of the stack area used by the NMI interrupt handler calculated as shown in appendixes C 4 and C 5 44 x NMI nest count e HI7750 4 CFG_IRQSTKSZ Size of the largest stack area used by the handler at the interrupt level 4 48 x Number of interrupt levels in the system except NMI 1 Size of the stack area used by the NMI interrupt handler calculated as shown in appendixes C 4 and C 5 48 x NMI nest count When there is no nesting the NMI nest count is 1 C 8 Stack Size Used by a Time Event Handler and Timer Interrupt Routine The size of each time event handler stack and timer interrupt routine _kernel_tmrint stack can be determined from appendixes C 4 and C 5 The size determined by substituting the maximum size of all time event handlers and timer interrupt routine into Table C 7 must be assigned to CFG_TMRSTKSZ When CFG_ACTION is selected calculate under the following conditions e Size obtained in C 4 and C 5 32 e Calls service calls Yes When no time event handler is used and CFG_ACTION is not selected calculate under the following conditions e Size obtained in C 4 and C 5 0 e Calls service calls No Rev 6 00 415 RENESAS REJ10B0060 0600 Appendix CCalculation of Work Area Size Table C 7 Time Event Handler and Timer Interrupt Routine Stack Size
119. those of the def_inh and def_exc service calls They are also the same as those of the vdef_trp service call for HI7000 4 When defining this item on the kernel environment side the def_inh or def_exc service call must be embedded for HI7700 4 or HI7750 4 For the HI7000 4 whether or not the def_inh and vdef_trp service calls are embedded is automatically determined These service calls cannot be selected in the service call selection page 7 Trap Exception Handler Page only for HI7700 4 HI7750 4 1 Maximum trap number CFG_MAXTRPNO L Specify the maximum trap number to be used in the system The maximum number specifiable is 255 2 CPU exception handler definition for TRAPA B Specifiable contents are the same as those of the vdef_trp service call When defining this item on the kernel environment side the vdef_trp service call must be embedded 8 Pre fetch Function Page only for HI7700 4 and HI7750 4 1 Address and range to be pre fetched B Specify the start address and size to be pre fetched when the kernel is in the idle state 9 Initialization Routine Page 1 Initialization routine definition B Specify the initialization routine settings such as the initialization routine address extended information and stack size Rev 6 00 359 RENESAS REJ10B0060 0600 Section5 Configuration Table 5 5 Configurator Setting Items cont 10 Task Page 1
120. to CFG_STSTKID the task indicated by tskid occupies the shared stack and shifts to the READY state If the stack is being used by another task the task indicated by tskid shifts to the WAITING state and is placed in the shared stack wait queue since the stack area cannot be used The wait queue is managed on a first in first out FIFO basis Rev 6 00 81 RENESAS REJ10B0060 0600 Section3 Service Calls When the task is not in the DORMANT state up to 15 task initiation requests from the service calls act_tsk and iact_tsk can be stored 3 4 4 Cancel Task Initiation Request can_act ican_act C Language API ER_UINT actcnt ER_UINT actcnt can_act ID tskid ican_act ID tskid Parameters ID tskid R4 Task ID Return Parameters ER_UINT actcnt RO Number of cached initiation requests positive value or 0 or error code Error Codes E_ID p Invalid ID number tskid lt 0 tskid gt CFG_MAXTSKID or tskid TSK_SELF 0 is specified in a non task context E_NOEXS k Undefined Task indicated by tskid is not created Function The number of initiation requests queued for the task specified by tskid is determined the result is returned as the return parameter and at the same time the initiation requests are all cancelled By specifying tskid TSK_SELF 0 the current task is specified A task in a DORMANT state can also be specified in this case the return parameter is 0 Rev 6 00 82 REJ10B0060 0600 RENESAS
121. to data queue T E D U ifsnd_dtq S N E D U rev_dtq S Receives data from data queue T E U prev_dtq S Polls and receives data from data queue T E D U trev_dtq S Receives data from data queue with timeout function T E U ref_dtq Refers to data queue state T E D U iref_dtq N E D U Notes 1 S Standard profile service calls s Service calls that are not standard profile service calls but are needed in order to use the standard profile function 2 T Can be called from task context N Can be called from non task context E Can be called from dispatch enabled state D Can be called from dispatch disabled state U Can be called from CPU unlocked state L Can be called from CPU locked state C Can be called from CPU exception handler Rev 6 00 136 REJ10B0060 0600 RENESAS Section3 Service Calls Data Queue Specifications The data queue specifications are listed in table 3 30 Table 3 30 Data Queue Specifications Item Description Data queue ID 1 to CFG_MAXDTQID 1023 max One word 32 bits Attribute supported TA_TFIFO Task queue waiting for sending a message is managed on a FIFO basis TA_TPRI Task queue waiting for sending a message is managed on priority Rev 6 00 137 RENESAS REJ10B0060 0600 Section3 Service Calls 3 9 1 Create Data Queue cre_dtq icre_dtq acre_dtq iacre_dtq Assign Data Queue ID Automatically C Language API ER ercd cre_dtq ID dtqid T_CDTQ pk_cdtq ER ercd icre
122. to that stack Table C 9 Timer Initialization Routine Stack Size Stack Size Byte Item HI7000 4 HI7700 4 HI7750 4 Size obtained in C 4 and C 5 Calls service call 140 140 144 CFG_TRACE is selected 24 24 24 CFG_NEWMPL is selected 28 28 28 Addition when the NMI is used a Total Notes 1 Size of the stack area used by the NMI interrupt handler calculated as shown in appendixes C 4 and C 5 8 x NMI nest count When there is no nesting the NMI nest count is 1 2 With the optimization timer driver or the DSP standby control function this value becomes 164 Rev 6 00 418 REJ10B0060 0600 RENESAS Appendix D Timer Driver D 1 Overview A timer driver must be required for the time management functions of the kernel CFG_TIMUSE is selected to be usable Timer drivers are of two types standard timer driver and optimized timer driver e Standard Timer Driver User must create the standard timer driver and link to kernel The HI7000 4 series provide samples for some microcomputer e Optimized Timer Driver The optimized timer driver is supported by only HI7700 4 The optimization timer driver fewer interrupts than the standard timer driver The optimized timer driver is built into the kernel and cannot be created by the user For how to use the optimized timer driver refer to Appendix E Optimized Timer Driver HI7700 4 The following sections explain the specifications of the standard timer driver
123. when the reset vector is defined through the configurator Memory Allocation of the HI7700 4 and the HI7750 4 Allocate the section P_hicpuasm of the CPU initialization routine to H a0000000 reset address 5 13 4 Executing a Build The load module is created by executing a build after adding application files to the project and setting the compiler assembler and optimized linkage editor options To execute a build choose the Build or Build All command from the Build menu as shown in figure 5 14 Rev 6 00 384 REJ10B0060 0600 RENESAS Section5 Configuration 5 14 Build at Separate Linkage Kernel Environment Side cfg Open the sample workspace hios hws and select the project file cfg appropriate to the microcomputer to be used 5 14 1 Adding Files to a Project Table 5 13 lists the source program files to be added to the project The sample project file already contains the files shown in this table Table 5 13 Source Program Files to be Recorded in the Project cfg File Name Description Notes kernel_cfg c Kernel environment side configuration file Mandatory task c Sample task Application files Note These files are in the shnnnn src or shnnnn project src folders 5 14 2 Defining Endian HI7700 4 and HI7750 4 The endian in the supplied sample project is set by selecting it in the build configuration Select the build configuration as shown in figure 5 10 Rev 6 00 385 RENESAS
124. with timeout txxx_yyy e Waiting tasks by dly_tsk service call e Cyclic handlers e Alarm handlers The kernel uses the results to determine whether or not interrupts from the high precision cycle are needed and accordingly enables or disables the corresponding interrupt Interrupts from the low precision cycle are always enabled Although figure E 1 does not show this a further TMU channel is used in monitoring for the overrun handler This timer interrupt is only generated when a task has used the upper limit on the allowed processor time Figure E 2 shows two effects of using the optimized timer driver This function reduces the frequency of timer interrupts leading to the following advantages over the standard timer driver e Quicker transitions to sleep mode lower amounts of CPU time consumed in timer interrupt processing e Less frequent cancellation of sleep mode for the processing of timer interrupts Standard timer driver in use SLEEP instruction Any interrupt Power Time Optimized timer driver in use SLEEP instruction i Power 1 Quicker transitions to Any interrupt a the sleep mode INS Preiod during the timer interrupt processing O Preiod during other than the timer interrupt processing A Period during transitions to sleep mode 2 Less frequent cancel of sleep mode for the timer interrupts Figure E 2 Schematic Illustration of the Optimized Timer Driver s E
125. 0 0600 Section3 Service Calls 3 19 4 Unlock CPU unl_cpu iunl_cpu C Language API ER ercd unl_cpu void ER ercd iunl_cpu void Parameters None Return Parameters ER ercd RO Normal end E_OK Error Codes None Function Each service call unlocks the CPU which was locked by service call loc_cpu or iloc_cpu If the CPU enters the task context dispatch enabled state by the service call the task scheduling is performed When the system makes a transition to the CPU locked state by calling service call iloc_cpu in the interrupt handler service call iunl_cpu must be called to unlock the CPU before returning from the interrupt handler The CPU locked state and dispatch disabled state are managed individually Thus service call unl_cpu or iunl_cpu does not enable the task dispatch by calling service call ena_dsp If service calls unl_cpu and iunl_cpu are called in CPU unlocked state no error will occur but queuing will not be done Rev 6 00 224 REJ10B0060 0600 RENESAS Section3 Service Calls 3 19 5 Disable Dispatch dis_dsp C Language API ER ercd dis_dsp void Parameters None Return Parameters ER ercd RO Normal end E_OK Error Codes None Function Service call dis_dsp disables task dispatch The following describes the dispatch disabled state e Task scheduling is delayed so that a task other than the current task cannot enter the RUNNING state e Interrupts can be accepted e Se
126. 0 0600 Section3 Service Calls 3 5 7 Delay Task dly_tsk C Language API ER ercd dly_tsk RELTIM dlytim Parameters RELTIM dlytim R4 Delayed time Return Parameters ER ercd RO Normal end E_OK or error code Error Codes E_CTX k Context error Called from disabled system state E_RLWAI k WAITING state is forcibly cancelled rel_wai service call was issued in the WAITING state Function The current task is transferred from the RUNNING state to a timed WAITING state and waits until the time specified by dlytim has expired When the time specified by dlytim has elapsed the state of the current task is returned to the READY state The current task is put into a WAITING state even if dlytim 0 is specified If a value larger than 1 is specified for CFG_TICDENO the denominator for time tick cycles the maximum value that can be specified for dlytim is H ffffffff CFG_TICDENO If a value larger than this is specified operation is not guaranteed This service call differs from the service call tslp_tsk in that it terminates normally when execution is delayed by the amount of time specified by dlytim Further even if a service call wup_tsk or iwup_tsk is executed the WAITING state is not cancelled The WAITING state is cancelled before the delay time has elapsed only when a service call rel_wai irel_wai or ter_tsk is called For details on the time watch method refer to section 2 16 4 2 Time Watch Method Rev 6
127. 00 can be specified TIC_NUME and TIC_DENO are output to kernel_macro h The time tick cycle must be specified with the timer driver according to the kernel_macro h information 4 Debugging Function Page 1 Object manipulation functions of debugging CFG_ACTION L extension Check this item when using object manipulation functions Action is displayed in the DX dialog title such as initiating a task When CFG_ACTION is checked please be sure to set up as follows Check CFG_TIMUSE in Time Management Function Page Select cre_cyc service call in Service Call Selection Page Embedding of service call trace function CFG_TRACE L Check this item when using the service call trace function with the debugging extension Refer to section 2 17 2 Service Call Trace Function Rev 6 00 357 RENESAS REJ10B0060 0600 Section5 Configuration Table 5 5 Configurator Setting Items cont 3 Type of service call trace function CFG_TRCTYPE L Either target trace or emulator trace tool trace can be selected Refer to the manual or on line help of the debugging extension for the environment where emulator trace tool trace can be used 4 Buffer size for target trace CFG_TRCBUFSZ Specify the buffer size in bytes that will be used if target trace is selected 5 Service Call Selection Page Select to embed service calls If a service call that has not been embedded is issued the error E_NOSPT
128. 000 gt Memory block D In this new management method member mpfmb is added to the T_CMPF structure which is used to create fixed size memory pool The mpfmb member indicates the address of the management table area The conventional or new management method is chosen by CFG_MPFMANAGE in Fixed size Memory Pool page of the configurator Note that both methods cannot be used simultaneously Related Pages e p 176 Section 3 13 1 Create Fixed Size Memory Pool cre_mpf icre_mpf e p 356 Item No 17 3 in table 5 5 of section 5 4 6 Configurator Settings Rev 6 00 456 REJ10B0060 0600 RENESAS Appendix New Functions of HI7700 4 V2 1 4 Improvement of Variable Size Memory Pool V 2 01 Release 00 Selecting CFG_NEWMPL added to the configurator allows the following improvements 1 The performace to aquaire and release memory blocks In applications that use a large number of memory blocks the performance to aquaire and release memory blocks are faster than when CFG_NEWMPL is not selected 2 Reduced fragmentation of free space Selecting CFG_NEWMPL generally retards the fragmentation of free memory space but the newly supported VTA_UNFRAGMENT attribute further reduces fragmentation Although specifying the VTA_UNFRAGMENT attribute generally helps in reducing fragmentation the degree of fragmentation depends on how the memory pools are used To support the VTA_UNFRAGMENT attribute the following macro has been
129. 0B0060 0600 Section3 Service Calls 2 T Can be called from task context N Can be called from non task context E Can be called from dispatch enabled state D Can be called from dispatch disabled state U Can be called from CPU unlocked state L Can be called from CPU locked state C Can be called from CPU exception handler 3 19 1 Rotate Ready Queue rot_rdq irot_rdq C Language API ER ercd rot_rdq PRI tskpri ER ercd irot_rdq PRI tskpri Parameters PRI tskpri R4 Task priority Return Parameters ER ercd RO Normal end E_OK or error code Error Codes E_PAR p Parameter error tskpri lt 0 tskpri gt CFG_MAXTSKPRI or tskpri TPRI_SELF 0 is specified in a non task context Function Each service call rotates the ready queue of the task priority indicated by parameter tskpri In other words the task at the head of the task priority ready queue is sent to the end of the queue enabling the second task in the ready queue to be executed Specifying tskpri TPRI_SELF 0 rotates the ready queue with the base priority of the current task The base priority is the same as the current priority when the mutex function is not used however the current priority is not the same as the base priority while the mutex is locked Thus the ready queue with current priority including the current task cannot be rotated even when TPRI_SELF is specified Rev 6 00 220 REJ10B0060 0600 RENESAS Section3 Service Calls 3 1
130. 1 SH7641 CMT Peripheral clock Po 25 MHz 7318 SH7318 TMU Peripheral clock Po 27 MHz 7343 SH7343 TMU Peripheral clock P 27 MHz HI7750 4 7750 SH7750 SH7750S TMU Peripheral clock P 50 MHz V 2 02 SH7750R 7751 SH7751 SH7751R TMU Peripheral clock Po 41 6 MHz 7760 SH7760 TMU Peripheral clock P 33 34 MHz 7770 SH7770 TMU Peripheral clock P 50 MHz 7785 SH7785 TMU Peripheral clock P 50 MHz The operation conditions of the sample timer driver are defined in the header files The header files can be modified as required Note however that to change the timer interrupt cycle time the time tick cycle CFG_TINUME and CFG_TICDENO must be changed by the configurator not by changing the header file Rev 6 00 422 REJ10B0060 0600 RENESAS Appendix E Optimized Timer Driver HI7700 4 E 1 Overview The standard timer driver generates timer interrupts in the same cycle as the time precision for service calls CFG_TICNUME CFG_TICDENO ms When the optimized timer driver is used the frequency of interrupts can be reduced while the time precision for service calls is maintained This is expected to have the following effects e The frequency of timer interrupt generation during sleep mode is reduced this leads to improved power consumption e Reducing the frequency of timer interrupts lowers the percentage of CPU time taken up by timer interrupt processing and improves the throughput of the system Alternati
131. 16 4 2 Time Watch Method Rev 6 00 197 RENESAS REJ10B0060 0600 Section3 Service Calls 3 15 2 C Language API Get System Clock get_tim iget_tim ER ercd get_tim SYSTIM p_systim ER ercd iget_tim SYSTIM p_systim Parameters SYSTIM p_systim R4 Return Parameters ER ercd RO SYSTIM p_systim R4 Packet Structure typedef struct systim UH utime UW ltime SYSTIM Error Codes E_PAR p Function Start address of the packet where the current time data is to be returned Normal end E_OK or error code Start address of the packet where the current time data is stored 2 Current time data upper 4 Current time data lower Parameter error p_systim is other than a multiple of four Each service call reads the current system clock and returns it to the area indicated by p_systim Rev 6 00 198 REJ10B0060 0600 RENESAS Section3 Service Calls 3 15 3 Supply Time Tick isig_tim Function Updates the system clock When CFG_TIMUSE is selected the system is configured such that service call isig_tim is executed automatically in cycles equal to CFG_TICDENO CFG_TICNUME ms That is this function is not a service call and so cannot be called from an application When a time tick is supplied the kernel performs the following time related processing 1 System clock update 1 2 Startup of time event handler 3 Timeout processing for tasks in a WAITING state due to
132. 3 Management Method of Fixed Size Memory Pool V 2 00 Release 00 In the previous version the kernel management table for each memory block is allocated in the memory pool area In V 2 the user can also allocate the management table area and can specify the table area address at creation In this case the memory pool area does not include management tables By combining this management method with the new function given in appendix H 2 Specifying Address of Task Stack Fixed Size Memory Pool and Variable Size Memory Pool a memory block can be acquired with a specific offset address as follows for example e Parameters for fixed size memory pool creation Address of fixed size memory pool H 0c000000 Block size H 1000 4 Kbytes Number of blocks 4 In this case one of memory blocks A B C and D shown below is acquired Each memory block is aligned with a 4 Kbyte boundary Address H 0C000000 gt Memory block A H 0C001000 gt Memory block B H 0C002000 gt Memory block C H 0C003000 gt Memory block D In this new management method member mpfmb is added to the T_CMPF structure which is used to create fixed size memory pool The mpfmb member indicates the address of the management table area The conventional or new management method is chosen by CFG_MPFMANAGE in Fixed size Memory Pool page of the configurator Note that both methods cannot be used simultaneou
133. 36 PC SPC at CPU exception 40 SR SSR at CPU exception 44 Stack pointer before gt Stack before CPU exception 48 CPU exception 4 Writing a CPU Exception Handler in C Language Using the DSP To use the DSP in a CPU exception handler refer to section 4 13 Using the DSP in Programs for HI7000 4 and HI7700 4 only 5 Defining a CPU Exception Handler A CPU exception handler can be defined in the following ways e def_exc or idef_exc service call CPU exception handlers other than TRAPA e vdef_trp or ivdef_trp service call CPU exception handlers caused by TRAPA e Defined initially by the configurator Rev 6 00 328 REJ10B0060 0600 RENESAS Section4 Application Program Creation 4 10 Time Event Handlers and Initialization Routine 1 Writing Time Event Handlers and Initialization Routine Time event handlers and initialization routine can be defined as regular C language functions Figure 4 10 shows an example of a cyclic handler an alarm handler and an initialization routine Figure 4 11 shows an example of an overrun handler written in C language These handlers are executed in non task context include kernel h void Handler VP_INT exinf Passes exinf specified at definition as a parameter Handler processing Figure 4 10 Example of a C Language Cyclic Handler Alarm Handler and Initialization Routine include kernel h v
134. 4 Undefined interrupt CPU exception process nnnn_intdwn src kernel_def c and kernel_cfg c Only for HI7700 4 DSP standby control function setting file kernel_def_dspstby_set h Only for HI7700 4 Optimized timer function setting file kernel_def_opttmr_set h Operating Procedure The following describes the normal operating procedure 1 Double click hios hiuser shnnnn nnnn_hcf and initiate the configurator 2 Provide necessary settings for the configurator 3 Save nnnn hcf and generate configuration files The folder to store generated files must be the folder which includes kernel_def c and kernel_cfg c 4 Terminate the configurator 5 Double click sample HEW workspace file shnnnn hws to initiate HEW Then specify the project to be used 6 Provide necessary operations such as adding application files to HEW or setting the C compiler or linkage editor options and execute the build Then load module files are created in the respective directories such as hios hiuser obj Rev 6 00 349 RENESAS REJ10B0060 0600 Section5 Configuration 5 4 Configurator This section describes basic configurator operations and settings For details on configurator operations refer to the configurator online help 5 4 1 Overview The configurator is a tool that is used to set the kernel operating parameters The configurator creates C source files according to the settings The created files and applications are built compi
135. 4 R8to R14 MACH MACL V V Same as before CPU exception GBR 5 R15 V V R15 points to the stack area for the program which generates exception As a CPU exception handler may re enter the CPU exception handler uses the stack used by the previous program A CPU exception handler does not use its own stack 6 PR V v Undefined 7 SH2 DSP DSR RS RE y y Same as before CPU exception MOD AO AOG A1 A1G MO M1 XO X1 YO Y1 8 SH 2A SH2A FPU TBR ki a 9 SH2A FPU FPSCR vV vV Same as before CPU exception 10 SH2A FPU V V Same as before CPU exception FRO to FR11 11 SH2A FPU FPUL vV vV Same as before CPU exception FR12 to FR15 Notes 1 These registers can be used Note that some register contents cannot be guaranteed after service calls For details refer to section 3 2 3 Guarantee of Register Contents after Issuing Service Call 2 When execution is returned from the entry function RTS instruction the contents of these registers must be the same as the value at initiation 3 Depends on CFG_TBR 1 Kernel does not manage The kernel does not operate TBR 2 Only for service call Do not modify TBR 3 Task context When execution is returned from an interrupt handler function RTS instruction the contents of TBR must be the same as the value at initiation The initial value is the same as before CPU exception Rev 6 00 324 REJ10B0060 0600 RENESAS Section4 Application Program Creation Table 4 16 Rul
136. 4A FPSCR The register contents will be guaranteed Rev 6 00 67 RENESAS REJ10B0060 0600 Section3 Service Calls Table 3 3 Guarantee of Register Contents after Issuing Service Call cont Register Register State after Service Call Returned For SH 4 and SH 4A The register contents will not be guaranteed FRO to FR11 DRO to DR10 FVO to FV8 For SH 4 and SH 4A FR12 to FR15 DR12 to DR14 FV12 FPUL The register contents will be guaranteed in the following situation 1 When FR in the FPSCR register 0 e A service call is issued from a task with TA_COP1 attribute or task exception processing routine e A service call is issued in a state mentioned in the note below 2 When FR in the FPSCR register 1 e A service call is issued from a task with TA_COP2 attribute or task exception processing routine e A service call is issued in a state mentioned in the note below For SH 4 and SH 4A XFO to XF15 XDO to XD14 XMTRX The register contents will be guaranteed in the following situation 1 When FR in the FPSCR register 0 e A service call is issued from a task with TA_COP2 attribute or task exception processing routine e A service call is issued in a state mentioned in the note below 2 When FR in the FPSCR register 1 e A service call is issued from a task with TA_COP1 attribute or task exception processing routine e A service call is issued in a state mentioned in the note below
137. 5 Refer To Task Exception Processing Disabled State sns_tex C Language API BOOL state sns_tex void Parameters None Return Parameters BOOL state RO Task exception processing disabled state Error Codes None Function When a task in the RUNNING state is in the task exception processing disabled state TRUE is returned when in the task exception processing enabled state FALSE is returned A task in the RUNNING state is the current task when called from the task context and when called from a non task context is the task which had been run immediately prior to the transition to the non task context When a task is called from a non task context and no task is in the RUNNING state TRUE is returned Tasks for which no task exception processing routines are defined are held in the task exception processing disabled state so that when no task exception processing routine has been defined for a task in the RUNNING state this service call returns TRUE This service call can also be called in the CPU locked state and from the CPU exception handler Rev 6 00 116 REJ10B0060 0600 RENESAS Section3 Service Calls 3 6 6 Refer to Task Exception Processing State ref_tex iref_tex C Language API ER ercd ref_tex ID tskid T_RTEX pk_rtex ER ercd iref_tex ID tskid T_RTEX pk_rtex Parameters ID tskid R4 Task ID T_RTEX pk_rtex R5 Pointer to the packet where the task exception processing state is to be returned
138. 50 4 5 8 HEW Workspace and Projects 5 9 Kernel Libraries 5 9 1 HI7000 4 5 9 2 HI7700 4 5 9 3 HI7750 4 5 10 Section Configuration 5 11 Settings Common to All Projects 5 11 1 CPU Options for the Compiler and Assembler 5 11 2 GBR Option of Compiler Compiler Package V 7 1 or Later 2313 5 11 3 PACK Option and pragma pack of Compiler Compiler Package V 8 or Later 5 11 4 Include Directory for Compiler and Assembler 5 11 5 When SH2A FPU or SH 4 or SH 4A is Used oe 5 11 6 TBR Option of Compiler Compiler Package V 9 or Later 5 12 Build for Whole Linkage mix 5 12 1 Adding Files to a Project 5 12 2 Defining Endian 5 12 3 Setting Optimized Linkage Editor Options 5 12 4 Executing a Buildin 5 13 Build for Separate Linkage Kernel Side def 5 13 1 Adding Files to a Project ccccceseeeeeeeees 5 13 2 Defining Endian HI7700 4 and HI7750 4 5 13 3 Setting Optimized Linkage Editor Options 5 13 4 Executing a Build 5 14 Build at Separate Linkage Kernel Environment Side cfg 5 14 1 Adding Files to a Project 5 14 2 Defining Endian HI7700 4 and HI7750 4 5 14 3 Setting Optimized Linkage Editor Options 5 14 4 Executing a Build 5 15 Application Load Module Creation 0 00 cece esseseeseeseseeseeeeeeseeeeeseeseeeeeeeaees Rev 6 00 vi REJ10B0060 0600 RENESAS Contents Appendix A Service Call List ccsssssssscssssssssssscssscssess
139. 5ff88 0x10 0x1 0x11 SH7300 SH7641 SH7660 SH7710 SH7727 SH7729R Oxffffff88 Not specifiable 0x80 Not specifiable SH7729 Not available SH7318 SH7343 0xa4150030 Not specifiable 0x4000000 Not specifiable Rev 6 00 434 REJ10B0060 0600 RENESAS Appendix D DSP Standby Control HI7700 4 F 5 3 Modifying kernel_sys h Add the following statement near the top of hisys kernel_sys h This will include the contents of the definition file described above ifndef HIOS KERNEL SYS H define HIOS KERNEL SYS H define DSPSTBY lt Added F 6 Kernel Libraries to be Used For the kernel libraries to be used refer to section 5 9 Kernel Libraries F 7 Notes Since the X Y memory uses much power relating the X Y memory with this function has a good effect on the levels of low power consumption However note the following point with regard to DMA transfer When a task A with the TA_COPO attribute specifies the X Y memory as the source or destination of a DMA transfer and then starts the transfer the transfer will not proceed correctly if task execution is switched to a task B that does not have the TA_COPO attribute since the kernel places the X Y memory in module standby mode during the execution of task B This is because access to the X Y memory by the DMA is independent of the operation software while the module standby control of the X Y memory is synchronized with task execution The following measures avert this p
140. 6 REJ10B0060 0600 RENESAS Section3 Service Calls 3 19 7 Refer to Context sns_ctx C Language API BOOL state sns_ctx void Parameters None Return Parameters BOOL state RO Context Function TRUE is returned when service call sns_ctx is called from non task context FALSE is returned when service call sns_ctx is called from task context Service call sns_ctx can be called in the CPU locked state and from the CPU exception handler Rev 6 00 227 RENESAS REJ10B0060 0600 Section3 Service Calls 3 19 8 Refer to CPU Locked State sns_loc C Language API BOOL state sns_loc void Parameters None Return Parameters BOOL state RO CPU locked state Function Service call sns_loc returns TRUE when the CPU is locked Service call sns_loc returns FALSE when the CPU is unlocked Service call sns_loc can be called in the CPU locked state and from the CPU exception handler Rev 6 00 228 REJ10B0060 0600 RENESAS Section3 Service Calls 3 19 9 Refer to Dispatch disabled State sns_dsp C Language API BOOL state sns_dsp void Parameters None Return Parameters BOOL state RO Dispatch disabled state Function Service call sns_dsp returns TRUE when task dispatch is disabled Service call sns_dsp returns FALSE when task dispatch is enabled Service call sns_dsp can be called in the CPU locked state and from the CPU exception handler Rev 6 00 229 RENESAS REJ10B0060 0600 Section3 Servi
141. 7 C 7 1 Stack Size Used by an Interrupt Handler C 7 2 Stack Area Allocation C8 Stack Size Used by a Time Event Handler and Timer Interrupt Routine 0000 415 C9 Initialization Routine Stacks eee cece ceeeeeeeeeeesesaeeaeeaeeae 417 C 10 Timer Initialization Routine Stack oo cece cece cee cceceeseesesaesseseeeseeseseeeaeeaee 418 Appendix D Timer Driver cssssssssssscscssssssssscessssscsscsssssssssceseessssscsssssssesseseee 419 D 1 CDV ELVIS Win sd eE LE EEE EEEE EE Mees ESEE 419 D 2 Standard Timer Drivel iorri dreisar iretsi iea a inir E 419 D 2 1 Installing the Time Management Function ccccsccssseesescseseseneeeeseseseenecssssseneeeensees 419 D22 Sample Timer Driver sssrinin eri anaa a R a RAE EE ERAR EAEE TAS 421 Appendix E Optimized Timer Driver HI7700 4 ssccssssssssssssesssssssssesseees 423 E 1 Overview a E 2 Operation vvccesssieecssvessvvccenrrceanencesstenssavecespvacesses cdadeetentensstaveasbieddeetsdaeuetdenastsenaecsgutoced E 3 Applicable MCU Swsscsssvsceus svasaateavevevensvadesssuateststiteshabeavetanesvsassiasgeaassaseasatensetaas vedatetanes 425 E4 Hardware Initial za On ss sic sisusncissenaticossinsoadecowasntenssdeonegsdvnebieanaeascnesseseseagsnecntseesngentens 425 E5 Differences with the Standard Timer Driver 0 00 cece cee ceeee eee eeeeeeeeeeeeteeteeteeeee 425 E 6 Ways to Include Optimized Timer Driver 426 E 6 1 Overview E 6 2 Creating the kernel_
142. 9 2 Get Task ID in RUNNING State get_tid iget_tid C Language API ER ercd get_tid ID p_tskid ER ercd iget_tid ID p_tskid Parameters ID p_tskid R4 Pointer to the area where the task ID is to be returned Return Parameters ER ercd RO Normal end E_OK or error code ID p_tskid R4 Pointer to the task ID Error Codes E_PAR p Parameter error p_tskid is an odd value Function Each service call gets the task ID in the RUNNING state and returns it to the area indicated by p_tskid If each service call is called from task context the current task ID is returned If each service call is called from non task context the task ID that is being executed is returned If there is no task in the RUNNING state TSK_NONE 0 is returned Service calls get_tid and iget_tid can also be called from the CPU exception handler Rev 6 00 221 RENESAS REJ10B0060 0600 Section3 Service Calls 3 19 3 Lock CPU loc_cpu iloc_cpu C Language API ER ercd loc_cpu void ER ercd iloc_cpu void Parameters None Return Parameters ER ercd RO Normal end E_OK Error Codes None Function Each service call locks the CPU and inhibits interrupts and task dispatches The following describes the CPU locked state e Tasks cannot be scheduled while the CPU is locked e Interrupts having a level equal to or below the kernel interrupt mask level CFG_KNLMSKLVL defined by the configurator are inhibited e Only the following se
143. ACE is not checked by the configurator this service call does not perform any processing This service call is a function original to the HI7000 4 series Rev 6 00 235 RENESAS REJ10B0060 0600 Section3 Service Calls 3 20 Interrupt Management Interrupt Management Service Calls Interrupts are controlled by the service calls listed in table 3 61 Table 3 61 Service Calls for Interrupt Management System State Service Call Description T N E D U L C def_inh Defines interrupt handler T E D U idef_inh N E D U chg_ims Changes interrupt mask T E D U ichg_ims N E D U get_ims Refers to interrupt mask T E D U iget_ims N E D U Notes 1 S Standard profile service calls s Service calls that are not standard profile service calls but are needed in order to use the standard profile function 2 T Can be called from task context N Can be called from non task context E Can be called from dispatch enabled state D Can be called from dispatch disabled state U Can be called from CPU unlocked state L Can be called from CPU locked state C Can be called from CPU exception handler Interrupt Management Specifications The interrupt management specifications are listed in table 3 62 Table 3 62 Interrupt Management Specifications Item Description Interrupt handler number 0 to CPG_MAXVCTNO 511 max HI7000 4 0 to CFG_MAXVCTNO H fe0 max HI7700 4 HI7750 4 Attribute supported T
144. AS REJ10B0060 0600 Section5 Configuration Table 5 9 Section Names Allocation to Section Non Cacheable Name File Name Description Area P_hiknl Kernel library Kernel program Not necessary P_hireset Kernel initialization process Not necessary P_hikni_P2 Part of cache operation Necessary P_hiexpent nnnn_expent src Kernel interrupt or exception entry exit Not necessary kernel_exp sre processing routine P_hiintdwn nnnn_intdwn src Undefined kernel interrupt exception Not necessary kernel_exp src analysis process C_hidef kernel_def c Definition information on the kernel side Not necessary C_hivet CPU vector table Interrupt handler or CPU Not necessary i exception handler definition information C_hitrp CPU exception handler definition Not necessary information for TRAPA C_hibase Service call interface information Not necessary B_hidef Kernel work area Not necessary C_hisysmt kernel_cfg c Configuration information on the kernel Not necessary environment side C_hicfg Configuration information other than Not necessary C_hisysmt on the kernel environment side B_hivet CPU vector table Not necessary B_hiwrk Kernel work area Not necessary B_hicfg Kernel work area Not necessary B_himpl Variable fixed size memory pool area Not necessary B_hidystk Dynamic stack Not necessary B_histstk Static stack Not necessary B_hiirqstk Interrupt handler and time event ha
145. A_HLNG The task is written in a high level language TA_ASM The task is written in assembly language Rev 6 00 236 REJ10B0060 0600 RENESAS Section3 Service Calls 3 20 1 Define Interrupt Handler def_inh idef_inh C Language API ER ercd def_inh INHNO inhno T_DINH pk_dinh ER ercd idef_inh INHNO inhno T_DINH pk_dinh Parameters INHNO inhno R4 Interrupt handler number T_DINH pk_dinh R5 Pointer to the packet where the definition information of interrupt handler is stored Return Parameters ER ercd RO Normal end E_OK or error code Packet Structure typedef struct t_dinh ATR inhatr 0 4 Handler attribute FP inhhdr 4 4 Handler address UINT inhsr 8 4 SR at initiation ignored in the HI7000 4 T_DINH Error Codes E_RSATR p Invalid attribute inhatr is invalid E_PAR p Parameter error pk_dinh is other than a multiple of four or inthdr is an odd value HI7000 4 Invalid number specification inhno 25 or 26 or inhno gt CFG_MAXVCTNO HI7700 4 HI7750 4 Invalid number specification inhno has a value other than a multiple of H 20 inhno H 160 or inhno gt CFG_MAXVCTNO Function The handler for the interrupt handler number specified by inhno is defined as the content specified by pk_dinh The interrupt handler number is for the HI7000 4 the CPU vector number and for the HI7700 4 and HI7750 4 is the CPU exception code in the case of a CPU for which INTEVT2 exists the IN
146. Acquisition and return of memory blocks are faster when a large number of memory blocks are used in the memory pool The VTA_UNFRAGMENT attribute can be used to reduce fragmentation of free space When CFG_NEWMPL is selected note that new members are added to the T CMPL structure in comparison with the conventional method For details refer to section 3 14 1 Create Variable Size Memory Pool The variable size memory pools are controlled by the service calls listed in table 2 15 Rev 6 00 37 RENESAS REJ10B0060 0600 Section2 Kernel Table 2 15 Service Calls for Variable Size Memory Pool Control Service Call Name Function cre_mpl icre_mpl Creates a variable size memory pool acre_mpl iacre_mpl Creates a variable size memory pool automatically assigns ID del_mpl Deletes a variable size memory pool get_mpl Gets a variable size memory block pget_mpl ipget_mpl Gets a variable size memory block polling tget_mpl Gets a variable size memory block with timeout rel_mpl irel_mpl Returns a variable size memory block ref_mpl iref_mpl Refers to the variable size memory pool status A variable size memory pool can also be created by the configurator Figure 2 12 shows an example of using variable size memory pool Rev 6 00 38 REJ10B0060 0600 RENESAS Section2 Kernel dime Task A Task B Variable size memory pool status cre_mpl Empty 1 400 byte
147. Assembly Link Library Standard Library CPU Deb4 gt bible E Category x 7 a 3 a rejects Show entries for Section M source file Address Section a Edit C source file Ox80010000 Chisysm Assembly source fi C hicte Linkage symbol file 6 def l source file B hiwrk C source file Bhim B histstk Linkage symbol file hiirast mix B hitrcbuf source file G source file Options Link Library Assembly source fi efine el cnfetbi000001000 no relink nomessage A i i ist J map nooptimize Liikaga symbol file start C_hisysmt C hicfe P C D 08001 0000 v Cancel T Assembly source fi B hidystk E P F Figure 5 19 Optimized Linkage Editor Section Specifies the allocation addresses of each section Specify the allocation addresses for the sections in the input files according to the target hardware The __kernel_sysmt address the start address of kernel environment information C_hisysmt section must be defined in the kernel load module creation def The defined address and the allocation address of the C_hisysmt section must be the same Basically specify addresses for all sections in the input files The optimized linkage editor automatically places all sections without overt address specifications after the last section in the input files with such a specification The resulting arrangement of sections may not produce
148. B0060 0600 RENESAS Appendix F DSP Standby Control HI7700 4 F 1 Overview This function sets up an relation between hardware modules DSP and X Y memory and the TA_COP0 attribute indicating whether or not a task includes DSP calculation for tasks and task exception processing routines and the kernel automatically places the related hardware modules in the module standby state when tasks or task exception processing routines without TA_COP0 attribute are running figure F 1 As a result this function achieves low power consumption Following can be selected statically as hardware modules related to the TA_COPO attribute e DSP only e X Y memory only e DSP X Y memory Rev 6 00 429 RENESAS REJ10B0060 0600 Appendix D DSP Standby Control HI7700 4 This function also supports the vchg_cop service call which is used to dynamically change the TA_COPO attribute Although it requires that applications be modified using vchg_cop makes it possible to extend the periods over which hardware resources are placed in the module standby state figure F 1 c anes scans SA g with TA_COP0 3 Task B iy without TA_COPO al a gt a Task A 33 95 with TA_COPO0 Sa 5 z Task B gt Q gs5 without TA_COP0 a L_ a 00aaMM 2 gt 02 TTP a vchg_cop DSP in use vchg_cop DSP not in use Q O o Task A 2 2 without TA_COPo L 9 Task B without TA_COPO a e d The DSP is in the module
149. C sets the event flag by issuing iset_flg set pattern 1 In this case there is no task waiting for an event and the event flag is ORed with the pattern specified by iset_flg Rev 6 00 25 RENESAS REJ10B0060 0600 Section2 Kernel 2 10 Data Queue A data queue is used to send or receive 1 word data 4 byte data between tasks High speed data communication can be achieved using a data queue as communication using a data queue copies 1 word data itself In addition pointers can also be specified as data The area of each data queue is allocated in the data queue area CFG_DTQSZ specified through the configurator The data queues are controlled by the service calls listed in table 2 10 Table 2 10 Service Calls for Data Queue Control Service Call Name Function cre_dtq icre_dtq Creates a data queue acre_dtq iacre_dtq Creates a data queue automatically assigns ID del_dtq Deletes a data queue snd_dtq Sends data to a data queue psnd_dtq ipsnd_dtq Sends data to a data queue polling tsnd_dtq Sends data to a data queue with timeout fsnd_dtq ifsnd_dtq Forcibly sends data to a data queue rcv_dtq Receives data from a data queue prev_dtq Receives data from a data queue polling trcv_dtq Receives data from a data queue with timeout ref_dtq iref_dtq Refers to the data queue state Data queues can also be created by the configura
150. Calculation of Work Area Size C 4 Calculation of Stack Size for Each Function C Language Function When a C language function is initiated a stack frame is allocated in the stack area The stack frame is used as a local variable area for the function or as a parameter area for a function call The stack frame size can be determined from the frame size in the object listing output by the compiler An example is shown below extern int h char int double int h char a register int b double c char d d amp a h d b c register int i i d return i kkkkkkkkkkkk OBJECT LISTING 4 kee K KKK FILE NAME m0251 c SCT OFFSET CODE C LABEL INSTRUCTION OPERAND COMMENT P 00000000 _h function h frame size 20 1 00000000 2FE6 MOV L R14 R15 00000002 2FD6 MOV L R13 R15 omitted Stack 0 i Are for the function R4 Frame size 20 bytes 1 Stack frame P gt 2 R5 Parameter area 28 8 bytes 2 Figure C 2 Compile List and Stack Size The stack area size used by the function is obtained by adding 1 and 2 shown above 28 bytes For details on parameters allocated to the parameter area on the stack refer to the SuperH RISC engine C C Compiler User s Manual Rev 6 00 408 REJ10B0060 0600 RENESAS Appendix CCalculation of Work Area Size Assembly Language Function To calculate the stack size examine the stack push and pop in predecrement and pos
151. D T_RMTX pk_rmtx R5 Pointer to the area where the mutex status is to be returned Return Parameters ER ercd RO Normal end E_OK or error code T_RMTX pk_rmtx R5 Pointer to the packet where the mutex status is stored Packet Structure typedef struct t_rmtx ID htskid 0 2 Task ID locking a mutex ID wtskid 2 2 Start task ID of mutex waiting queue T_RMTX Error Codes E_PAR p Parameter error pk_rmtx is other than a multiple of four E_ID p Invalid ID number mtxid lt 0 or mtxid gt CFG_MAXMTXID E_NOEXS k Undefined Mutex indicated by mtxid does not exist Function Service call ref _mtx refers to the state of the mutex Service call ref mtx returns the task ID that locks the mutex htskid and the start task ID of the mutex wait queue wtskid to the area indicated by pk_rmtx If there is no task that locks the target mutex TSK_NONE 0 is returned to the htskid If there is no task waiting for the target mutex TSK_NONE 0 is returned to the wtskid Rev 6 00 163 RENESAS REJ10B0060 0600 Section3 Service Calls 3 12 Extended Synchronization and Communication Message Buffer Message Buffer Service Calls Message Buffers are controlled by the service calls listed in table 3 38 Table 3 38 Service Calls for Message Buffer Control System State Service Call Description T N E D U L C cre_mbf Creates message buffer T E D U icre_mbf N E D U
152. ER ercd del_alm ID almid Parameters ID almid R4 Alarm handler ID Return Parameters ER ercd RO Normal end E_OK or error code Error Codes E_ID p Invalid ID number almid lt 0 or almid gt CFG _MAXALMID E_NOEXS k Undefined Alarm handler specified by almid does not exist E_CTX k Context error Called from disabled system state Function Service call del_alm deletes the alarm handler indicated by parameter almid Rev 6 00 210 REJ10B0060 0600 RENESAS Section3 Service Calls 3 17 3 Start Alarm Handler sta_alm ista_alm C Language API ER ercd sta_alm ID almid RELTIM almtim ER ercd ista_alm ID almid RELTIM almtim Parameters ID almid R4 Alarm handler ID RELTIM almtim R5 Alarm handler initiation time Return Parameters ER ercd RO Normal end E_OK or error code Error Codes E_ID p Invalid ID number almid lt 0 or almid gt CFG _MAXALMID E_NOEXS k Undefined Alarm handler specified by almid does not exist Function The starting time for the alarm handler specified by almid is set to the relative time specified by almtim after the moment at which the service call is called to start operation of the alarm handler If a time is set for an alarm handler already in operation the previous starting time setting is cancelled and the new starting time is set If almtim is set to 0 the alarm handler is started at the next time tick When a value larger than 1 is specified
153. FG_IBNR_ADR The kernel initializes the IBNR value to 0 during initialization vsta_knel 4 When the target MCU does not have register banks If you are using an MCU that does not have register banks i e the processor is not an SH 2A or SH2A FPU select MCU has no register banks NOBANK for CFG_REGBANK Note that the description method of interrupt handlers depends on the CFG_REGBANK setting For details refer to section 4 8 Interrupt Handlers 4 3 Using SH2A FPU SH 4 or SH 4A Be sure to refer to Appendix G Notes on FPU of SH2A FPU SH 4 SH4A even when FPU is not used Rev 6 00 296 REJ10B0060 0600 RENESAS Section4 Application Program Creation 4 4 System Reserve 4 4 1 Reserved Name External definition names beginning with _kernel_ KERNEL_ and hi_ are reserved for the kernel and cannot be used in application programs written in C language 4 4 2 Reserved TRAP Only in HI7000 4 The TRAPA 25 and 26 instructions are used by the HI7000 4 kernel Application programs must not use these instructions 4 5 Tasks 1 Writing a Task in C Language Figure 4 1 shows an example of writing a task as a function written in C language For details refer to the sample file task c Use an ext_tsk or exd_tsk system call to end a task If the task is returned without issuing ext_tsk or exd_tsk ext_tsk is assumed to be issued and the same operation as when ext_tsk is issued is performed include kernel h
154. FG_IRQSTKSZ use the value of the following equation or a larger size e HI7000 4 1 When CFG_DIRECT has been selected Since there are no normal interrupt handlers an interrupt handler stack area is not allocated 2 When CFG_DIRECT has not been selected a When NOBANK NOTUSE or SELECT has been selected for CFG_REGBANK CFG_IRQSTKSZ gt Size of the largest stack area used by the handler at the interrupt level 4 12 x CFG_UPPINTNST 24 x CFG _LOWINTNST 1 20 Size of the stack area used by the NMI interrupt handler calculated as shown in appendixes C 4 and C 5 8 x NMI nest count However when CFG_LOWINTNST lt 1 assume the underlined part to be 0 b When ALL has been selected for CFG_REGBANK CFG_IRQSTKSZ gt Size of the largest stack area used by the handler at the interrupt level 4 8 x CFG_UPPINTNST 16 x CFG LOWINTNST 1 20 Size of the stack area used by the NMI interrupt handler calculated as shown in appendixes C 4 and C 5 8 x NMI nest count However when CFG_LOWINTNST lt 1 assume the underlined part to be 0 If you are using UBC interrupts however the following values must also be added UBC interrupts used as direct interrupts 4 bytes UBC interrupts used as normal interrupts 28 bytes Rev 6 00 414 REJ10B0060 0600 RENESAS Appendix CCalculation of Work Area Size e HI7700 4 CFG_IRQSTKSZ Size of the largest stack area used by the handler at
155. Function only for HI7700 4 The HI7700 4 supports the DSP standby control function whose purpose is low power consumption For details refer to Appendix F DSP Standby Control Rev 6 00 62 REJ10B0060 0600 RENESAS Section 3 Service Calls 3 1 Overview Service calls are classified as shown in table 3 1 Table 3 1 Service Call Classification Classification Description Task management function Initiates and terminates tasks Task synchronization function Suspends and resumes task execution and task event flag Task exception processing function Registers task exception processing routine and requests enables and disables task exception Synchronization and Manages semaphores event flags data queues and communication function mailboxes Extended synchronization and Manages mutexes and message buffers communication function Memory pool management function Allocates memory dynamically Time management function Notifies the time to the kernel sets and references the system clock and defines the timer handler System status management Shifts to the CPU locked state or dispatch disabled state function Interrupt management function Defines the interrupt handler and changes and references the interrupt mask Service call management function Defines and calls the extended service calls System configuration management Defines CPU exception handler and references the function configuration inf
156. Functions FPSCR PR at the End of the pugon pzon Bit Function Remarks Single Specification Single precision 0 Single precision 0 The compiler does disabled not generate any Double Specification Double precision 1 Double precision 1 Object code to disabled change the PR bit No Safe Single precision 0 Single precision 0 specification Aggressive Single precision 0 Undefined Mix Notes 1 The compiler assumes this precision mode in generating code at the top of the function 2 The compiler generates code to select this precision mode at the end of the function 3 Compiler V5 1 does not support this FPSCR option treatment is the same as aggressive 2 FPSCR DN Denormalization mode only in SH 4 and SH 4A Table G 5 Handling of the FPSCR DN Bit by the Compiler Compiler Option Denormalization Mode Assumed by Denormalize Option the Compiler FPSCR DN Bit Remarks OFF A denormalized number is treated as zero 1 The compiler does not generate ON A denormalized number is treated as such 0 ce ara code to change the it Note The compiler assumes this denormalization mode in generating code at the top of the function Rev 6 00 445 RENESAS REJ10B0060 0600 Appendix G Notes on FPU of SH2A FPU SH 4 SH4A 1 FPSCR RM Rounding mode Table G 6 Handling of the FPSCR RM Bits by the Compiler Compiler Option Denormalization Mode Assumed Round Option by the Compiler FPSCR
157. H 3 SH3 DSP SH4AL DSP SH 4 SH 4A There are some microcomputers which can set up by the interrupt controller whether an NMI which is generated in the state of SR BL 1 is accepted immediately or it is suspended until clearing SR BL When it is made a setup detected immediately returning to normal operation of system after NMI interrupt handler is not guaranteed 4 2 6 Nesting the Interrupts SH 3 SH3 DSP SH4AL DSP SH 4 SH 4A When the interrupts are nested for 64 times or more including NMI normal system operation cannot be guaranteed Make sure that no more than 64 interrupts are nested 4 2 7 32 Bit Address Extension Mode SH 4A When using 32 bit address extension mode set up PMB so that behavior of P1 and P2 area becomes the same as 29 bit address mode before kernel initiation 4 2 8 TBR Register SH 2A SH2A FPU How to use the TBR register is specified through CFG_TBR in the configurator 1 Kernel does not manage The kernel does not manage TBR 2 Only for service call The TBR is used only for service calls Service calls are accelerated The TBR is initialized by the kernel If TBR is modified by the application correct system operation cannot be guaranteed The TBR option and pragma tbr of the compiler must not be used 3 Task context Tasks can modify TBR The initial value of TBR at task initiation is undefined The handlers other than tasks must guarantee the TBR value if the handlers modify TBR Rev
158. H4AL DSP ig 0 when attribute TA_COPO is DSR specified or undefined in other cases 9 SH3 DSP SH4AL DSP i Undefined RS RE MOD AO AOG A1 A1G MO M1 XO X1 YO Y1 Notes 1 These registers can be used Note that some register contents cannot be guaranteed after service calls For details refer to section 3 2 3 Guarantee of Register Contents after Issuing Service Call 2 When execution is returned from the entry function RTS instruction the contents of these registers must be the same as the value at initiation 3 DSP CL must be 1 when at least one of CFG_DSP and CFG_CACLOC is checked Except in the CPU locked state IMASK must be 0 MD 1 BL 0 and RB 0 are required 4 Only when the TA_COP0 attribute is specified Rev 6 00 299 RENESAS REJ10B0060 0600 Section4 Application Program Creation Table 4 4 Rules on Using Registers in a Task HI7750 4 End Use Conditions No Registers i a Initial Value 1 PC y Task start address 2 SR V lt H 40000000 3 RO_BANKO to R3_BANKO V Undefined 4 R4_BANKO y Activated by TA_ACT attribute or act_tsk exinf which is specified at task creation Activated by sta_tsk stacd which is specified by sta_tsk 5 R5_BANKO to R7_BANKO V Undefined R8 to R14 MACH MACL GBR 6 R15 V v End address of stack area for the task 7 PR V V Undefined 8 SH 4 SH 4A FPSCR V H 00040001 9 SH 4 SH 4A FPUL i Undefined 10 SH 4 SH 4A FRO_BANKO
159. HI7750 4 V 2 02 HEW Compiler Package Version Used nnnn CPU Core Target Microcomputer at Creation 7750 SH 4 SH7750 SH7750S SH7750R 1 2 6 0C 7751 SH 4 SH7751 SH7751R 1 2 6 0C 7760 SH 4 SH7760 3 0 01 8 00 Release 00 7770 SH 4A SH7770 3 0 01 8 00 Release 00 without extended function 7785 SH 4A with SH7785 4 00 02 9 00 Release 03 extended function The contents of the shnnnn folder are described below Rev 6 00 346 REJ10B0060 0600 RENESAS Section5 Configuration 1 HEW3 or Later Versions The shnnnn folder contains the folders shown in figure 5 4 a shnnnn src mix def cfg Figure 5 4 Folders under the shnnnn Folder HEW3 or Later Versions Sample HEW workspace file shnnnn hws The shnnnn folder contains this workspace file In this workspace the following three projects are registered 1 For whole linkage mix mix hwp 2 For separate linkage kernel side def def hwp 3 For separate linkage kernel environment side cfg cfg hwp b shnnnn src folder This folder contains the following source files Sample task task c Sample timer driver annn_tmrdrv c nnnn_tmrdrv h nnnn_tmrdef h Sample CPU initialization routine nnnn_cpuasm src nnnn_cpuini c Sample system down routine nnnn_sysdwn c Sample configurator information file nnnn hcf and its generated files see table 5 4 Sample section initialization
160. ING gt 5 6 0 1 Figure 2 5 Example of Using Semaphore Description Bold lines represent executed processing and dotted lines represent the region where tasks can exclusively access resources The following describes the semaphore operation with respect to time Task A creates semaphores by cre_sem The initial value is 2 semaphore counter 2 2 Task A issues wai_sem and gets a semaphore decrementing the semaphore count by 1 semaphore counter 1 Task A continues execution Task B issues wai_sem Task C issues wai_sem but cannot get a semaphore because the semaphore counter is 0 and it enters the WAITING state 5 Task A releases a semaphore by issuing sig_sem The released semaphore is allocated to task C and task C is released from the WAITING state 6 Task B releases a semaphore by issuing sig_sem There is no task waiting for a semaphore and so the semaphore counter is incremented by 1 Rev 6 00 23 RENESAS REJ10B0060 0600 Section2 Kernel 2 9 Event Flag An event flag is a bit group corresponding to events One event corresponds to one bit More than one task can wait for a specified bit to be set in an event flag that is tasks can wait until the specified event occurs Table 2 9 shows the service calls for event flag control Table 2 9 Service Calls for Event Flag Control Service Call Name Description cre_flg icre_flg Creates an event flag acre_flg iacre_flg
161. IRL14 BRA CONTINUE MOV L _VecO71_Handler14 R0 Sets the address of IRL14 main process to RO POOL END Figure 4 9 Example of an Assembly Language IRL Direct Interrupt Handler Interface Routine cont e Creating an interrupt handler in assembly language Refer to the above example write a handler that performs the necessary processes after switching to the appropriate stack for the interrupt level and then switches back to the original stack Rev 6 00 322 REJ10B0060 0600 RENESAS Section4 Application Program Creation 4 9 CPU Exception Handler Including TRAPA Instruction Exception If an exception occurs a CPU exception handler is initiated via the entrance and exit process of the kernel 1 Writing a CPU Exception Handler A CPU exception handler including the TRAPA instruction exception can be defined in the same way as normal interrupt handlers For details refer to section 4 8 1 Normal Interrupt Handler Rev 6 00 323 RENESAS REJ10B0060 0600 Section4 Application Program Creation 2 Rules for Using Registers in a CPU Exception Handler Tables 4 15 to 4 17 show rules on using registers for HI7000 4 HI7700 4 and HI7750 4 Table 4 15 Rules on Using Registers in a CPU Exception Handler H1I7000 4 End Use Conditions No Registers sii 7 Initial Value 1 PC V CPU exception handler start address 2 SR v Same as before CPU exception 3 ROtoR7 V Undefined
162. If some other specification is made the following error message will be displayed when kernel_def c and kernel_cfg c is compiled error directive Illegal CFG _TIMINTNO The optimized timer driver uses the following interrupt codes e 0x400 Channel 0 of TMU e 0x420 Channel 1 of TMU e 0x440 Channel 2 of TMU Do not define handlers for these interrupts When however the overrun handler is not in use when the def_ovr service call has not been selected 0x440 channel 2 is not defined bye the optimized timer driver In this case channel 2 is available for user 2 Timer interrupt level CFG_TIMINTLVL Specify same value as the kernel interrupt mask level CFG_KNLMSKLVL If some other specification is made the following error message will be displayed when kernel_cfg c is compiled error directive Illegal CFG _TIMINTLVL 3 Time tick cycle CFG_TICNUME and CFG_TICDENO The time tick cycle is the period of a high precision cycle Rev 6 00 427 RENESAS REJ10B0060 0600 Appendix E Optimized Timer Driver HI7700 4 E 6 4 Modifying kernel_sys h Add the following statement near the top of hisys kernel_sys h This will include the contents of the definition file described above ifndef HIOS KERNEL SYS H define HIOS KERNEL SYS H define OPTTMR lt Added E 7 Kernel Libraries to be Used For the kernel libraries to be used refer to section 5 9 Kernel Libraries Rev 6 00 428 REJ10
163. Invalid ID number mbxid lt 0 or mbxid gt CFG_MAXMBXID E_OBJ k Object status is invalid Mailbox indicated by mbxid already exists E_NOID k No ID available Rev 6 00 147 RENESAS REJ10B0060 0600 Section3 Service Calls Function Service calls cre_mbx and icre_mbx create a mailbox with an ID indicated by mbxid with the contents indicated by pk_cmbx Service calls acre_mbx and iacre_mbx search for an unused mailbox ID and create a mailbox that has this ID with the contents specified by parameter pk_cmbx The created mailbox ID is returned as a return parameter The range for searching for an unused mailbox ID is 1 to CFG_MAXMBXID Parameter mbxatr is specified in the following format See table 3 34 for details mbxatr TA_TFIFO TA_TPRI TA_MFIFO TA_MPRI Table 3 34 Mailbox Attributes mbxatr mbxatr Code Description TA_TFIFO H 00000000 Message receive wait queue is managed on a FIFO basis TA_TPRI H 00000001 Message receive wait queue is managed on priority TA_MFIFO H 00000000 Message queue is managed on a FIFO basis TA_MPRI H 00000002 Message queue is managed on priority When TA_MPRI is specified for mbxatr NULL must be specified for mprihd The message queue header area is created in the area specified by mprihd when a value other than NULL is specified by the pITRON4 0 specification However the kernel does not support a value other than NULL If a value other than NULL is used n
164. KSTKSZ After the task has been created the dynamic stack area size will decrease by an amount given by the following expression Decrease in size stksz 16 bytes The stack area address allocated by application can be specified as stk In this case allocate a stack area for the size specified by stksz and specify the start address of the area The service calls vscr_tsk and ivscr_tsk are functions original to the HI7000 4 series Rev 6 00 79 RENESAS REJ10B0060 0600 Section3 Service Calls 3 4 2 Delete Task del_tsk C Language API ER ercd del_tsk ID tskid Parameters ID tskid R4 Return Parameters ER ercd RO Error Codes Task ID Normal end E_OK or error code E_ID p Invalid ID number tskid lt 0 or tskid gt CFG_MAXTSKID E_NOEXS k Undefined Task indicated by tskid does not exist E_OBJ k Object state is invalid Task indicated by tskid is not in DORMANT state or the current task is specified E_CTX k Context error Function Called from the disabled system state The service call del_tsk deletes the task indicated by the parameter tskid The deleted task makes a transition to the NON EXISTENT state If a dynamic stack is used by the task specified by tskid the stack is returned to the dynamic stack area As a result the free dynamic stack area size increases by an amount given by the following expression Increase in size stksz specified at task creation 16 bytes
165. MO tmout R6 Timeout specification Return Parameters ER ercd RO Normal end E_OK or error code T_MSG ppk_msg R5 Pointer to the area where the start address of the received message is stored Packet Structure lt Mailbox message header gt typedef struct t_msg VP msghead 0 4 Kernel management area T_MSG lt Mailbox message header with priority gt typedef struct t_msg_pri T_MSG msgque 0 4 Message header PRI msgpri 4 2 Message priority T_MSG PRI Error Codes E_PAR p Parameter error ppk_msg is other than a multiple of four or tmout lt 2 E_ID p Invalid ID number mbxid lt 0 or mbxid gt CFG_MAXMBXID E_NOEXS k Undefined Mailbox indicated by mbxid does not exist E_CTX k Context error Called from disabled system state E_DLT k Waiting object deleted Mailbox indicated by mbxid has been deleted in the WAITING state E_TMOUT k Polling failed or timeout E_RLWAI k WAITING state is forcibly cancelled rel_wai service call was called in the WAITING state Rev 6 00 152 REJ10B0060 0600 RENESAS Section3 Service Calls Function Each service call receives a message from the mailbox specified by parameter mbxid Then the start address of the received message is returned to the area indicated by parameter pk_msg With service calls rev_mbx and trcv_mbx if there are no messages in the mailbox the task that called the service call is placed in the wait queue to receive a message With service call
166. MPORT _Vec071_Handler14 Externally references the IRL14 interrupt handler main function IMPORT _Vec071_ Handler15 Externally references the IRL15 interrupt handler main function SECTION B_ hiirgstk DATA ALIGN 4 RES L 128 Defines the interrupt handler stack for IRL15 _Stk15 Assigns symbol _Stk15 to the end address of the IRL15 stack RES L 128 Defines the interrupt handler stack for IRL14 _Stk14 Assigns symbol _Stk14 to the end address of the IRL14 stack Figure 4 9 Example of an Assembly Language IRL Direct Interrupt Handler Interface Routine Rev 6 00 320 REJ10B0060 0600 RENESAS Section4 Application Program Creation CONTINUE SECTION P_ISR CODE ALIGN 4 I_HILEVEL equ H FO gt gt 1 I_BITMASK equ H FO _Vec071 MOV L R0 R15 STC SR RO AND I_BITMASK RO SHLR RO CMP EQ I_HILEVEL RO BF IRL14 IRL15 MOV L Stk15 R0 MOV L R15 RO MOV RO R15 MOV L _VecO71_Handler15 R0 MOV L R1 R MOV L R2 R MOV L R3 R MOV L R4 R15 MOV L R5 R STS L PR R MOV L R6 R15 STS L MACL R15 MOV L R7 R15 STS L MACH R15 JSR RO NOP LDS L R15 MACH MOV L R15 R7 SR bit location of high level gt gt 1 Defines bit mask of SR I field lt Interface routine Saves the contents of RO to the stack of the program that was interrupted Checks the level of the interrupt and determines which stack to switch to and the address fo
167. Maximum task ID CFG_MAXTSKID Maximum task ID using a static stack CFG_STSTKID L Tasks with ID numbers between 1 and CFG_STSTKID use the static stack and tasks with ID numbers between CFG_STSTKID 1 and CFG_MAXTSKID use the dynamic stack The maximum value specifiable for CFG_MAXTSKID is 1023 and that for CFG_STSTKID is CFG_MAXTSKID The following service calls must be embedded corresponding to the CFG_MAXTSKID and CFG_STSTKID settings e When CFG_STSTKID 0 all tasks are set to use the dynamic stack The cre_tsk service call must be embedded e When CFG_MAXTSKID CFG_STSTKID all tasks are set to use the static stack The vscr_tsk service call must be embedded e When CFG_MAXTSKID gt CFG_STSTKID the cre_tsk and vscr_tsk service calls must be embedded 2 Definition of static stack L If a value other than 0 is specified for CFG_STSTKID define the static stack area used by tasks with ID between 1 and CFG_STSTKID 3 Maximum task priority TMAX_TPR1 CFG_MAXTSKPRI L The range of usable task priorities is 1 to CFG_MAXTSKPRI The maximum value specifiable is 255 The same value of CFG_MAXTSKPRI is output to kernel_macro h as TMAX_TPRI 4 Dynamic stack area size CFG_TSKSTKSZ When a task with ID between CFG_STSTKID 1 and CFG_MAXTSKID is created a stack area is allocated within the specified area 5 _ Task creation BA Setting contents are the same as those of the cre_tsk and
168. NG state was forcibly cancelled rel_wai service call was called in the WAITING state Rev 6 00 133 RENESAS REJ10B0060 0600 Section3 Service Calls Function A task that has called one of these service calls waits until the event flag specified by the parameter flgid is set according to the waiting conditions indicated by the parameters waiptn and wfmode Each service call returns the bit pattern of the event flag to the area indicated by flgptn when the wait release condition is satisfied If the attribute of the target event flag is TA_WSGL and another task is waiting for the event flag error code E_ILUSE is returned If the wait release conditions are met before a task calls service call wai_flg pol_flg ipol_flg or twai_flg the service call will be completed immediately If they are not met the task will be sent to the wait queue when the service call wai_flg or twai_flg is called With service call pol_flg or ipol_flg error code E_TMOUT is immediately returned then the task terminates The parameter wfmode is specified in the following format See table 3 28 for details wfmode TWF_ANDW TWF_ORW Table 3 28 Wait Modes wfmode wfmode Code Description TWF_ANDW H 00000000 AND wait TWF_ORW H 00000001 OR wait If TWF_ANDW is specified as wfmode the task waits until all the bits specified by waiptn have been set If TWF_ORW is specified as wfmode the task waits until any one of the bits specified
169. NLMSKLVL and the BL bit in the SR register is 1 Rev 6 00 55 RENESAS REJ10B0060 0600 Section2 Kernel a These calls lock the CPU When CPU is locked interrupts with levels below the kernel interrupt mask level are masked During this period the service calls that can be issued are restricted to those described in 3 2 5 System State and Service Calls loc_cpu iloc_cpu service calls To cancel the CPU locked state issue unl_cpu or iunl_cpu If an interrupt handler CPU exception handler or time event handler locks the CPU the state must be released within the same handler b The IMASK bits in the SR register are changed to the specified value That is interrupts below the specified level are masked When the CPU is locked a chg_ims or ichg_ims call leads to an error with the code E_CTX chg_ims ichg_ims service calls The context state is handled as a non task context while the IMASK bits are changed to a value other than 0 by chg_ims or ichg_ims To cancel the masking of interrupts by these calls call ichg_ims to restore the IMASK bits in the SR register to the value they had before the change However when chg_ims has been called to mask interrupts by setting a value A for the IMASK bits in the task context the IMASK bits in the SR register must be A for ichg_ims to be called to restore the IMASK bits Otherwise correct operation is not guaranteed The following is a bad example Task context SR I
170. Normal end E_OK or error code T_RCYC pk_rcyc R5 Pointer to the packet where the cyclic handler state is stored Packet Structure typedef struct t_reyc STAT cycstat 0 4 Cyclic handler operating state RELTIM lefttim 4 4 Remaining time until the cyclic handler is initiated T_Reyc Error Codes E_PAR p Parameter error pk_rcyc is other than a multiple of four E_ID p Invalid ID number cycid lt 0 or cycid gt CFG _MAXCYCID E_NOEXS k Undefined Cyclic handler specified by cycid does not exist Function Each service call reads the cyclic handler state indicated by cycid and returns the cyclic handler operation state cycstat and the time remaining until the cyclic handler is initiated lefttim to the area indicated by parameter pk_rcyc The target cyclic handler operation state is returned to parameter cycstat Table 3 51 Handler Initiation State cycstat cycstat Code Description TCYC_STP H 00000000 The cyclic handler is not in the operating state TCYC_STA H 00000001 The cyclic handler is in the operating state The relative time until the target cyclic handler is next initiated is returned to parameter lefttim When the target cyclic handler is not initiated lefttim is undefined Rev 6 00 206 REJ10B0060 0600 RENESAS Section3 Service Calls 3 17 Time Management Alarm Handler Alarm Handler Service Calls Alarm handler is controlled by the service calls listed in table 3 52 Table 3 52
171. O tmout R6 Timeout specification Return Parameters ER ercd RO Normal end E_OK or error code UINT p_tflptn R5 Pointer to the area where the bit pattern when releasing the WAITING state is stored Error Codes E_PAR p Parameter error p_tflptn is other than a multiple of four waiptn 0 or tmout lt 2 E_CTX k Context error Called from disabled system state E_TMOUT k Timeout E_RLWAI k WAITING state is forcibly cancelled rel_wai service call was called in the WAITING state Function Each service call waits for any bit of the task event flag specified by waiptn to be set When the wait release condition is satisfied the bit pattern of the task event flag is returned to the area indicated by parameter p_tflptn At the same time the task event flag value is cleared to 0 Each service call immediately terminates if any bit specified by waiptn is already set when a service call is called If no bit is set the task that called service calls vwai_tfl or vtwai_tfl enters the WAITING state With service call vpol_tfl error code E_TMOUT is immediately returned in this case Tasks are released from the WAITING state when any bits specified by waiptn are set by the service call vset_tfl The task event flag value is 0 at task initiation In service call vtwai_tfl the parameter tmout specifies the timeout period Rev 6 00 107 RENESAS REJ10B0060 0600 Section3 Service Calls If a positive value is specified for the
172. ORMANT state the task priority before termination becomes invalid and returns to the initial task priority specified at task creation If the task specified by tskid is in the WAITING state and TA_TPRI is specified for the object attribute the wait queue can be changed by the service calls and as a result the task at the head of the wait queue may be released from the WAITING state If the base priority specified in the parameter tskpri is higher than the upper limit priority of one of the mutexes when the object task locks or waits to lock the mutexes with the TA_CEILING attribute E_ILUSE is returned Rev 6 00 87 2tENESAS REJ10B0060 0600 Section3 Service Calls 3 4 9 Refer to Task Priority get_pri iget_pri C Language API ER ercd get_pri ID tskid PRI p_tskpri ER ercd iget_pri ID tskid PRI p_tskpri Parameters ID tskid R4 Task ID PRI p_tskpri R5 Pointer to the area where the current Return Parameters ER ercd priority of the object task is to be returned RO Normal end E_OK or error code PRI p_tskpri R5 Pointer to the area where the current Error Codes E_PAR p E_ID p E_NOEXS k E_OBJ k Function priority of the object task is stored Parameter error p_tskpri is not even Invalid ID number tskid lt 0 tskid gt CFG_MAXTSKID or tskid TSK_SELF 0 is specified in a non task context Undefined Task specified by tskid does not exist Object status is invalid Task is
173. P p_blk TMO tmout Acquire Fixed Size Memory Block with Timeout 96 rel_mpf ER ercd rel_mpf ID mpfid VP blk Release Fixed Size Memory Block irel_mpf ER ercd irel_mpf ID mpfid VP blk 97 ref_mpf ER ercd ref_mpf ID mpfid T_RMPF pk_rmpf Refer to Fixed Size Memory Pool iref_mpf ER ercd iref_mpf ID mpfid T RMPF pk_rmpf State Variable Size Memory Pool 98 cre_mpl ER ercd cre_mpl ID mplid T CMPL pk_cmpl Create Variable Size Memory Pool icre_mpl ER ercd icre_mpl ID mplid T_ CMPL pk_cmpl 99 acre_mpl ER_ID mplid acre_mpl T_CMPL pk_cmpl Create Variable Size Memory Pool iacre_mp ER_ID mplid iacre_mpl T_CMPL pk_cmpl and Assign Variable Size Memory Pool ID Automatically 100 del_mpl ER ercd del_mpl ID mplid Delete Variable Size Memory Pool 101 get_mpl ER ercd get_mpl ID mplid UINT blksz VP p_blk Acquire Variable Size Memory Block 102 pget_mpl ER ercd pget_mpl ID mplid UINT blksz VP p_blk Poll and Acquire Variable Size ipget_mp ER ercd ipget_mpl ID mplid UINT blksz VP p_blk Memory Block 103 tget_mpl ER ercd tget_mpl ID mplid UINT blksz VP p_blk Acquire Variable Size Memory TMO tmout Block with Timeout 104 rel_mpl ER ercd rel_mpl ID mplid VP blk Release Variable Size Memory irel_mpl ER ercd irel_mpl ID mplid VP blk Block 105 ref_mpl ER ercd ref_mpl ID mplid T_RMPL pk_rmpl Refer to Variable Size Memory iref_mpl ER ercd iref_mpl
174. P0 attribute is specified Rev 6 00 304 REJ10B0060 0600 RENESAS Section4 Application Program Creation Table 4 8 Rules on Using Registers in a Task Exception Processing Routine H17750 4 End Use Conditions No Registers n Initial Value 1 PC V Task exception processing routine start address 2 SR v i H 40000000 3 RO_BANKO to R3_BANKO V Undefined 4 R4_BANKO V Task exception pattern 5 R5_BANKO y Extended information exinf of the task exception processing routine 6 R6_BANKO R7_BANKO R8 V Undefined to R14 MACH MACL GBR 7 R15 V V R15 points to the task s stack area 8 PR v v Undefined 9 SH 4 SH 4A FPSCR V H 00040001 10 SH 4 SH 4A FPUL i Undefined 11 SH 4 SH 4A FRO_BANKO Undefined to FR15_BANKO 12 SH 4 SH 4A FRO_LBANK1 Undefined to FR15_BANK1 Notes 1 These registers can be used Note that some register contents cannot be guaranteed after service calls For details refer to section 3 2 3 Guarantee of Register Contents after Issuing Service Call 2 When execution is returned from the entry function RTS instruction the contents of these registers must be the same as the value at initiation 3 Except in the CPU locked state IMASK must be 0 MD 1 BL 0 RB 0 and FD 0 are required 4 Only when at least one of the TA_COP1 and TA_COP2 attributes is specified Only when the TA_COP1 attribute is specified 6 Only when the TA_COP2 attribute is specifie
175. R ercd def_ovr T_DOVR pk_dovr Parameters T_DOVR pk_dovr R4 Pointer to the packet where the overrun handler definition information is stored Return Parameters ER ercd RO Normal end E_OK or error code Packet Structure typedef struct t_dovr ATR ovratr 0 4 Overrun handler attribute FP ovrhdr 4 4 Overrun handler address T_DOVR Error Codes E_RSATR p Invalid attribute ovratr is invalid E_PAR p Parameter error pk_dovr is other than a multiple of four or ovrhdr is an odd value Function The overrun handler is defined using the content specified by pk_dovr The overrun handler is a time event handler for non task contexts which is started when the processor is used by a task for a time exceeding a preset time Parameter ovratr is specified in the following format See table 3 58 for details ovratr TA_HLNG TA_ASM Table 3 58 Overrun Handler Attributes ovratr ovratr Code Description TA_HLNG H 00000000 The handler is written in a high level language TA_ASM H 00000001 The handler is written in assembly language As ovrhdr the start address of the overrun handler is specified When in service call def_ovr pk_dovr NULL 0 is specified the overrun handler definition is cancelled When an overrun handler has already been defined if this service call is called the preceding definition is cancelled and the new definition takes its place An overrun handler can also be defined statical
176. REJ1 OBOO60 0600 Everywhere you imagine oO gt E N ESAS H 7000 4 Series HI7000 4 V 2 02 HI7700 4 V 2 02 and HI7750 4 V 2 02 User s r Renesas Microcomputer Development Environment System Rev 6 00 RenesasTechnology Revision date Jan 04 2006 www renesas com Keep safety first in your circuit designs Renesas Technology Corp puts the maximum effort into making semiconductor products better and more reliable but there is always the possibility that trouble may occur with them Trouble with semiconductors may lead to personal injury fire or property damage Remember to give due consideration to safety when making your circuit designs with appropriate measures such as i placement of substitutive auxiliary circuits ii use of nonflammable material or iii prevention against any malfunction or mishap Notes regarding these materials These materials are intended as a reference to assist our customers in the selection of the Renesas Technology Corp product best suited to the customer s application they do not convey any license under any intellectual property rights or any other rights belonging to Renesas Technology Corp or a third party Renesas Technology Corp assumes no responsibility for any damage or infringement of any third party s rights originating in the use of any product data diagrams charts programs algorithms or circuit application examples contained in these materials All information
177. REJ10B0060 0600 Section3 Service Calls 3 21 2 Call Service Call cal_svc ical_sve C Language API ER_UINT ercd cal_svc FN fncd ER_UINT ercd ical_svc FN fncd Parameters FN fned R15 Function code of extended service call In above up to four VP_INT type parameters can be substituted If more than four parameters are specified only the first four parameters are passed to the extended service call routine VP_INT parl 4 R15 Parameter 1 VP_INT par2 8 R15 Parameter 2 VP_INT par3 12 R15 Parameter 3 VP_INT par4 16 R15 Parameter 4 Return Parameters ER_UINT ercd RO Return value from service call Error Codes E_RSFN p Reserved function code fnced is invalid or cannot be used Function Each service call executes the extended service call routine corresponding to the function code specified by the parameter fncd Up to four VP_INT type parameters can be specified In the extended service call routine to be called par1 to par4 are stored in R4 to R7 respectively and passed For details refer to section 4 7 Extended Service Call Routines Rev 6 00 244 REJ10B0060 0600 RENESAS Section3 Service Calls 3 22 System Configuration Management System Configuration Management Service Calls System configurations are controlled by the service calls listed in table 3 67 Table 3 67 Service Calls for System Configuration Management System State
178. Round Robin Scheduling with rot_rdq Service call By issuing rot_rdq at specific cycles execution can be switched at specific intervals to a task that has the same priority as the executing task Limitations to Scheduling When the system enters the dispatch disabled state by the dis_dsp service call task scheduling is disabled Task scheduling is enabled when the system enters the dispatch enabled state by the ena_dsp service call When the system enters the CPU locked state by the loc_cpu service call both task scheduling and all interrupts other than kernel management interrupts are disabled Task scheduling and interrupts are enabled when the system enters the CPU unlocked state by the unl_cpu service call Rev 6 00 14 REJ10B0060 0600 RENESAS Section2 Kernel 2 6 5 Task Termination and Deletion Task termination means that a task is finished and can enter the DORMANT or NON EXISTENT state e ext_tsk is issued e exd_tsk is issued e ter_tsk is issued to the target task When a task is terminated and then re initiated or when the number of initiation request queues specified in the act_tsk service call is other than 0 the task starts from the initial state When a task will no longer be used or when re assigning the task ID to another task or the exd_tsk service call is issued and the task is made NON EXISTENT The ID can now be assigned to another task A task must release its resources before execution can be completed
179. SAS REJ10B0060 0600 Section3 Service Calls 3 4 6 Exit Current Task Exit and Delete Current Task ext_tsk exd_tsk C Language API void ext_tsk void void exd_tsk void Parameters None Return Parameters The service calls ext_tsk and exd_tsk do not return to the current task However if the service call ext_tsk or exd_tsk is called without being installed at system creation error code E_RSFN is set in RO and returned In addition the service calls ext_tsk and exd_tsk may generate the following error and in this case control is passed to the system down routine E_CTX k Context error Called from disabled system state Function The service call ext_tsk exits the current task normally After the execution of the service call ext_tsk the current task makes a transition from the RUNNING state to the DORMANT state When initiation request is queued the service call ext_tsk exits the current task and then restarts the task The processing that is performed at task termination is listed in table 3 9 Table 3 9 Processing to be Performed at Task Termination Contents Unlocks the mutex locked by the task Releases upper limit processor time The service call exd_tsk exits the current task normally and deletes it After the execution of the service call exd_tsk the current task makes a transition from the RUNNING state to the NON EXISTENT state Service calls ext_tsk and exd_tsk do not release resources o
180. Section5 Configuration 5 13 3 Setting Optimized Linkage Editor Options 1 Input Category Library files SuperH RISC engine Standard Toolchain Configuration C C Assembly Link Library Standard Library CPU Deb4 gt obj bie z Category Input bd F All Loaded Projects Show entries for HG ofe i source file ln C source file WORKSPDIRDY hilib elf sh4al_dsp knl big H E Assembly source fi WORKSPDIRDY hilib elf shx2_cache_bie lib H E Linkage symbol file S WORKSPDIRDY hilib elf hikn _big lib em source file C source file Assembly source fi Linkage symbol file I7 Use entry point meent k hi cpuasm Auto F source file mix C source file Options Link Library Assembly source fi pent hicpuasm define kernel pon sp 0ACT Lay a A F detine _kernel_man_sp t 1 define _kernel_sysmt Linkage symbol file 080010000 noprelink nomessage list CONFIGDIR C Figure 5 15 Optimized Linkage Editor Input Category Library files Be sure to specify necessary libraries as described in 5 9 Kernel Libraries Also specify application libraries as required Rev 6 00 381 RENESAS REJ10B0060 0600 Section5 Configuration 2 Input Category Defines SuperH RISC engine Standard Toolchain Configuration C C Assembly Link Library Standard Library CPU Deb 4 gt obj bie si Category Input X I F All Load
181. Setting Items cont 3 Time Management Function Page 1 Use of kernel time management function CFG_TIMUSE L When using service calls with time parameters such as tslp_tsk or the cyclic handler check CFG_TIMUSE Atthis time remember to create a timer driver For details refer to Appendix D Timer Driver 2 Timer interrupt number CFG_TIMINTNO L For HI7000 4 specify the timer interrupt vector number For HI7700 4 and HI7750 4 specify INTEVT code 3 Timer interrupt level CFG_TIMINTLVL L CFG_TIMINTLVL is output as TIM_LVL to kernel_macro h The timer interrupt level must be specified with the timer driver according to the information in kernel_macro h When using optimized timer driver in HI7700 4 set CFG_TIMINTLVL as the same value as CFG_KNLMSKLVL 4 Time event handler stack size CFG_TIMRSTKSZ L Specify a size calculated according to the description in Appendix C 8 Stack Size Used by a Time Event Handler 5 Time tick cycle numerator TIC_NUME and CFG_TICNUME L time tick cycle denominator TIC_DENO CFG_TICDENO Time tick cycle time is set to TIC_NUME TIC_DENO ms At least one of TIC_NUME and TIC_DENO must be 1 If a value more than 1 is specified for TIC_DENO the maximum value specifiable for TMO RELTIM or OVRTIM type parameter is limited to specifiable value with each type TIC_DENO A value between 1 and 65535 can be specified for TIC_NUME For TIC_DENO a value between 1 and 1
182. Shared stack allocation WAITING SUSPENDED shared stack double wait state Resumption rsm_tsk frsm_tsk Forcible termination ter_tsk Suspension sus_tsk WAITING shared stack wait state When the shared stack is monopolized act_tsk sta_tsk DORMANT Shared stack is released or unused act_tsk sta_tsk inactive state NON EXISTENT unregistered state RUNNING execution state Figure 2 2 Task State Transitions for the Shared Stack Function 2tENESAS Rev 6 00 17 REJ10B0060 0600 Section2 Kernel 2 6 8 Task Execution Mode In some cases one task may force another task to terminate by issuing ter_tsk before the other task releases the resources it has been using In addition one task may forcibly be terminated at an inappropriate time by issuing the sus_tsk service call To mask requests issued by ter_tsk or sus_tsk service calls use the vchg_tmd service call 2 6 9 Exclusive Control In some cases during execution of one task the task may need to be executed exclusively with another program For example when task A and interrupt handler B refer to and modify the same global variable reference and modification must be exclusive The target program to control exclusivity can be an interrupt handler specific task or any other task Table 2 5 shows the way to ensure that tasks execute exclusively Table 2 5 Exclusive Control Ex
183. T p_ data j ER ercd trev_dtq ID dtqid VP_INT data TMO tmout Parameters ID dtqid R4 Data queue ID VP_INT p data R5 Start address of the area where received data is to be returned lt trcev_dtq gt TMO tmout R6 Timeout specification Return Parameters ER ercd RO Normal end E_OK or error code VP_INT p_data R5 Pointer to the area where received data is stored Error Codes E_PAR p Parameter error p_data is other than a multiple of four or tmout lt 2 E_ID p Invalid ID number dtqid lt 0 or dtqid gt CFG_MAXDTQID E_NOEXS k Undefined Data queue indicated by dtqid does not exist E_CTX k Context error Called from disabled system state E_DLT k Waiting object deleted Target data queue indicated by dtqid has been deleted while waiting E_TMOUT k Polling failed or timeout E_RLWAI k WAITING state is forcibly cancelled rel_wai service call was called in the WAITING state Function Data is received from the data queue specified by dtqid and stored it to the area indicated by parameter p_data If there is data in the data queue the leading data the oldest message is received On receiving data from the data queue the data queue count is decremented by 1 As a result if data can be stored for a task in the send waiting queue data is sent and processed in the order of the wait queue Rev 6 00 143 RENESAS REJ10B0060 0600 Section3 Service Calls If there is no data in the data queue an
184. T returned The queue is managed on a first in first out FIFO basis Parameter tmout of service call tget_mpl specifies the timeout period If a positive value is specified for parameter tmout error code E_TMOUT is returned when the timeout period has passed without the wait release conditions being satisfied If tmout TMO_POL 0 is specified the same operation as for service call pget_mpl will be performed If tmout TMO_FEVR 1 is specified timeout watch is not performed In other words the same operation as for service call get_mpl will be performed If a value larger than 1 is specified for CFG_TICDENO the denominator for time tick cycles the maximum value that can be specified for tmout is H 7fffffff CFG_TICDENO If a value larger than this is specified operation is not guaranteed For detail of time watch method refer to section 2 16 4 2 Time Watch Method Rev 6 00 192 REJ10B0060 0600 RENESAS Section3 Service Calls 3 14 4 Release Variable Size Memory Block rel_mpl irel_mpl C Language API ER ercd rel_mpl ID mplid VP blk ER ercd irel_mpl ID mplid VP blk Parameters ID mplid R4 Variable size memory pool ID VP blk R5 Start address of memory block Return Parameters ER ercd RO Normal end E_OK or error code Error Codes E_PAR p Parameter error blk is other than a multiple of four k blk is other than the memory block start address or blk has already been returned E_ID p Inval
185. TA_COPO0 attribute was specified before the change TA_NULL The TA_COPO0 attribute was not specified before the change When vchg_cop is called from a task the task s TA_COPO attribute after task termination is restored to its state before the task was created When vchg_cop is called from a task exception processing routine the TA_COPO0 attribute of the task exception processing routine is changed but the TA_COPO attribute of the task itself is not changed When execution of the task exception processing routine is completed the routine s TA_COPO attribute is restored to the state it was assigned when the routine was defined When TA_COP0 is specified for the task that does not have the TA_COP0 attribute DSR is initialized to 0 The other DSP registers retain their values Frequently issuing this service call to switch the TA_COPO attribute on and off will increase the overhead of module standby control processing Calling the service call to switch the attribute on and off should be in units of the occurrence of DSP calculation Rev 6 00 432 REJ10B0060 0600 RENESAS Appendix D DSP Standby Control HI7700 4 Note that this service call is specific to the HI7700 4 and is not used for the service call trace function F 5 Ways to Include DSP Standby Control Function F 5 1 Overview This section gives information that is supplementary to the standard configuration procedure For details see section 5 Configuration Table F 2
186. TEVT2 code otherwise the INTEVT code On the HI7000 4 this call cannot be used to define handlers for the interrupt handler numbers 0 to 3 power on reset manual reset If these numbers are specified the call is ignored On the HI7700 4 and HI7750 4 this call cannot be used to define handlers for the interrupt handler numbers 0 and H 20 power on manual reset If these numbers are specified the call is ignored Rev 6 00 237 RENESAS REJ10B0060 0600 Section3 Service Calls The parameter inhatr is specified in the following format See table 3 63 for details inhatr TA_HLNG TA_ASM Table 3 63 Interrupt Handler Attributes inhatr inhatr Code Description TA_HLNG H 00000000 The handler is written in a high level language TA_ASM H 00000001 The handler is written in assembly language VTA_DIRECT H 80000000 Direct interrupt handler HI7000 4 only VTA_REGBANK H 40000000 Normal interrupt handler making use of the register banks HI7000 4 only In the case of the HI7000 4 VTA_DIRECT can be specified to indicate that the handler is to be a direct interrupt handler If you intend to define an interrupt handler with an interrupt level higher than the kernel interrupt mask level CFG_KNLMSKLVL VTA_DIRECT must be specified However the VTA_DIRECT attribute cannot be specified for CPU exceptions or trap interrupt handler numbers When CFG_DIRECT is selected for the configurator it is not possible to def
187. TMO_POL 0 is specified the same operation as for service call pget_mpf will be performed If tmout TMO_FEVR 1 is specified timeout monitoring is not performed In other words the same operation as for service call get_mpf will be performed If a value larger than 1 is specified for CFG_TICDENO the denominator for time tick cycles the maximum value that can be specified for tmout is H 7fffffff CFG_TICDENO If a value larger than this is specified operation is not guaranteed For detail of time watch method refer to section 2 16 4 2 Time Watch Method Rev 6 00 181 RENESAS REJ10B0060 0600 Section3 Service Calls 3 13 4 Release Fixed Size Memory Block rel_mpf irel_mpf C Language API ER ercd rel_mpf ID mpfid VP blk ER ercd irel_mpf ID mpfid VP blk Parameters ID mpfid R4 Fixed size memory pool ID VP blk R5 Start address of memory block Return Parameters ER ercd RO Normal end E_OK or error code Error Codes E_PAR p Parameter error blk is other than a multiple or four k Specifies other than the start address of the memory block or returned blk E_ID p Invalid ID number mpfid lt 0 or mpfid gt CFG_MAXMPFID E_NOEXS k Undefined Fixed size memory pool indicated by mpfid does not exist Function Each service call returns the memory block indicated by blk to the fixed size memory pool indicated by mpfid The start address of the memory block acquired by service call get_mpf
188. UINT clrptn ER ercd ivclr_ tfl ID tskid UINT clrptn Parameters ID tskid R4 Task ID UINT clrptn R5 Bit pattern to clear Return Parameters ER ercd RO Normal end E_OK or error code Error Codes E_ID p Out of ID range tskid lt 0 tskid gt CFG _MAXTSKID or tskid TSK_SELF 0 is specified in a non task context E_NOEXS p Undefined Task indicated by tskid does not exist E_OBJ k Object status is invalid Task specified by tskid is in the DORMANT state Function The task event flag of the task indicated by the parameter tskid are ANDed with the value indicated by parameter clrptn Note that the lower 16 bits of the bit pattern to specify parameter clrptn must be set to H ffff because the corresponding bits of the event flag are reserved for future expansion By specifying tskid TSK_SELF 0 the current task can be specified The service calls vclr_tfl and ivclr_tfl are functions original to the HI7000 4 series Rev 6 00 106 REJ10B0060 0600 RENESAS Section3 Service Calls 3 5 10 Wait Task Event Flag vwai_tfl vpol_tfl vtwai_tfl C Language API ER ercd vwai_tf1 UINT waiptn UINT p_tflptn ER ercd vpol_tfl UINT waiptn UINT p_tflptn ER ercd vtwai_tfl UINT waiptn UINT p_tflptn TMO tmout Parameters UINT waiptn R4 Bit pattern to wait UINT p_tflptn R5 Pointer to the area where the bit pattern when releasing the WAITING state is to be returned lt vtwai_tfl gt TM
189. V IMASK bits Same as before exception MD 1 BL 0 RB 0 FD 0 Other bits Undefined 3 ROtoR3 V Undefined 4 R4 V Cyclic Alarm handler Initialization routine Extended information exinf Overrun handler Target task ID 5 R5 y Cyclic Alarm handler Initialization routine Undefined Overrun handler Extended information exinf for the task 6 R6toR7 V Undefined 7 R8to R14 MACH V v Undefined MACL GBR 8 R15 V V R15 points to appropriate stack area 9 PR V v Undefined 9 SH 4 SH 4A FPSCR V Undefined 10 SH 4 SH 4A FPUL V v Undefined 11 SH 4 SH 4A V V Undefined FRO_BANKO to FR15_BANKO 12 SH 4 SH 4A V V Undefined FRO_BANK1 to FR15_BANK1 RENESAS Rev 6 00 333 REJ10B0060 0600 Section4 Application Program Creation Notes 1 These registers can be used Note that some register contents cannot be guaranteed after service calls For details refer to section 3 2 3 Guarantee of Register Contents after Issuing Service Call 2 When execution is returned from the entry function RTS instruction the contents of these registers must be the same as the value at initiation 3 IMASK bits must not be lower than the value at initiation And IMASK bits must be the same as initial value when execution is returned from the handler MD 1 BL 0 RB 0 and FD O are required 3 Writing Time Event Handlers and Initialization Routine in C Language Using the DSP To use the DSP in time event handlers and the
190. VTA_UNFRAGMENT bytes When CFG_NEWMPL is selected new members mpfmb minblksz and sctnum are added to the T_CMPL structure which is used to create variable size memory pool Member mpfmb indicates the address of the management table area minblksz indicates the minimum block size and sctnum indicates the number of sectors These settings are ignored when the VTA_UNFRAGMENT attribute is not specified Note the use size of stack increases generally when CFG_NEWMPL is selected Related Pages e p 40 Section 2 15 2 Controlling Fragmentation of Free Space e p 186 Section 3 14 1 Create Variable Size Memory Pool cre_mpl icre_mpl e p 363 Item No 18 3 in table 5 5 of section 5 4 6 Configurator Settings e p 405 Appendix C Calculation of Work Area Size Rev 6 00 463 RENESAS REJ10B0060 0600 Appendix J New Functions of HI7750 4 V2 J 5 Macros for Calculating Size V 2 01 Release 00 The following macros are added 1 SIZE mpfsz TSZ_MPF UINT blkent UINT blksz The size of fixed size memory pool area required to store the blkcnt number of blksz byte memory blocks bytes 2 SIZE size VTSZ_MPFMB UINT blkent UINT blksz The size of fixed size memory pool management area required to hold the blkcnt number of blksz byte memory blocks bytes 3 SIZE mplsz TSZ_MPL UINT blkent UINT blksz The size of variable size memory pool area required to hold the blkcnt number of blksz byte memory blocks target byte siz
191. WMPL is selected and VTA_UNFRAGMENT is specified e Allocate a memory pool area to the N byte boundary address and specify that address when creating a memory pool e Specify N for the minimum block size e Specify a multiple of N as the size of every memory block to be acquired 3 When CFG_NEWMPL is not selected 1 Alignement when N 16 Allocate a memory pool area to the 16 byte boundary address and specify that address when creating a memory pool Specify a multiple of 16 as the size of every memory block to be acquired 2 Alignment when N 32 Allocate a memory pool area to the address obtained by 32 byte boundary address 16 by the application and specify that address when creating a memory pool Specify a multiple of N 16 as the size of every memory block to be acquired Rev 6 00 189 RENESAS REJ10B0060 0600 Section3 Service Calls 3 14 2 Delete Variable Size Memory Pool del_mpl C Language API ER ercd del_mpl ID mplid Parameters ID mplid R4 Variable size memory pool ID Return Parameters ER ercd RO Normal end E_OK or error code Error Codes E_ID p Invalid ID number mplid lt 0 or mplid gt CFG_MAXMPLID E_NOEXS k Undefined Variable size memory pool indicated by mplid does not exist E_CTX k Context error Called from disabled system state Function Service call del_mpl deletes the variable size memory pool indicated by mplid No error will occur even if there is a t
192. _WAS is returned to tskstat and the following values are returned Table 3 11 Cause of WAITING State tskwait tskwait Code Description W_SLP H 00000001 Shifted to the WAITING state by slp_tsk or tslp_tsk W_DLY H 00000002 Shifted to the WAITING state by dly_tsk TTW_SEM H 00000004 Shifted to the WAITING state by wai_sem or twai_sem TTW_FLG H 00000008 Shifted to the WAITING state by wai_flg or twai_flg TTW_SDTQ H 00000010 Shifted to the WAITING state by snd_dtq or tsnd_dtq TTW_RDTQ H 00000020 Shifted to the WAITING state by rcv_dtq or trcv_dtq TTW_MBX H 00000040 Shifted to the WAITING state by rcv_mbx or trcv_mbx TTW_MTX H 00000080 Shifted to the WAITING state by loc_mtx or tloc_mtx TTW_SMBF H 00000100 Shifted to the WAITING state by snd_mbf or tsnd_mbf W_RMBF H 00000200 Shifted to the WAITING state by rcv_mbf or trev_mbf W_MPF H 00002000 Shifted to the WAITING state by get_mpf or tget_mpf W_MPL H 00004000 Shifted to the WAITING state by get_mpl or tget_mpl TTW_TFL H 00008000 Shifted to the WAITING state by vwai_tfl or vtwai_ttl wobjid Valid only when TTS_WAI or TTS_WAS is returned to tskstat and the waiting target object ID is returned lefttmo The time until the target task times out is returned Note that when the target task is in the WAITING state according to the service call dly_tsk the value is undefined actcnt The current initiation request queue count is returned
193. _dtq ID dtqid T_CDTQ pk_cdtq ER_ID dtqid acre_dtq T_CDTQ pk_cdtq ER_ID dtqid iacre_dtq T_CDTQ pk_cdtq Parameters lt cre_dtgq icre_dtq gt ID dtqid R4 Data queue ID T_CDTQ pk_cdtq R5 Pointer to the packet where the data queue creation information is stored lt acre_dtq iacre_dtq gt T_CDTQ pk_cdtq R4 Pointer to the packet where the data queue creation information is stored Return Parameters lt cre_dtg icre_dtq gt ER ercd RO Normal end E_OK or error code lt acre_dtq iacre_dtq gt ER_ID dtqid RO Created data queue ID a positive value or error code Packet Structure typedef struct t_cdtq ATR dtgatr 0 4 Data queue attribute UINT dtqent 4 4 Size of data queue area the number of data VP dtq 8 4 Start address of data queue area YT CDTO Error Codes E_NOMEM k Insufficient memory Data queue area cannot be allocated in the memory E_RSATR p Invalid attribute dtqatr is invalid E_PAR p Parameter error pk_cdtq is other than a multiple of four k dtqent x data queue size 4 bytes exceeds 32 bit area E_ID p Invalid ID number dtqid lt 0 or dtqid gt CFG_MAXDTQID E_OBJ k Object status is invalid Data queue indicated by dtqid already exists E_NOID k No ID available Rev 6 00 138 REJ10B0060 0600 RENESAS Section3 Service Calls Function The service calls cre_dtq and icre_dtq create a data queue with the ID specified by dtqid and with the contents specified by pk_cdtq The
194. a_cyc stp_cyc Time Initiation i Initiation i Initiation H yee Initiation cycle cycle at at cycle phase 3 i i X Initiated Initiated y y y Y Y Not initiated Not initiated Cyclic handler Cyclic handler Not initiated l X Il Initiation phase is not stored Figure 2 15 Example of Using Cyclic Handler Description a A cyclic handler without TA_STA attribute specification is created b The cyclic handler is not initiated after cycle time has passed since the cyclic handler operation has not been initiated The cyclic handler operation is initiated by issuing sta_cyc c When the initiation phase is stored as shown in I in figure 2 15 the cyclic handler is initiated based on the initiation cycle after the cyclic handler has been created When the initiation phase is not stored as shown in ID in Figure 2 15 the cyclic handler is initiated based on the initiation cycle after the sta_cyc service call has been issued d The cyclic handler is terminated by issuing the stp_cyc service call e The cyclic handler is not initiated after cycle time has passed since the cyclic handler operation has been terminated Rev 6 00 45 RENESAS REJ10B0060 0600 Section2 Kernel 2 16 2 Alarm Handler The alarm handler is a time event handler that can be initiated once when the specified time has been reached By using the alarm handler processes can be done according to time Alarm handlers ar
195. able 5 11 Source Program Files Added to Project mix File Name Description Notes kernel_def c Kernel side configuration file Mandatory kernel_cfg c Kernel environment side Mandatory configuration file nnnn_sysdwn c System down routine Mandatory nnnn_expent src Interrupt or exception entry exit Mandatory processing routine nnnn_intdwn sre Undefined interrupt detailed Mandatory information acquisition process kernel_exp_src Interrupt or exception processing Mandatory routine nnnn_cpuasm sre nnnn_cpuini c CPU initialization routine Mandatory for executing by reset nnnn_tmrdrv c Standard timer driver When using optimized timer driver in HI7700 4 do not include this task c Sample task Application files Notes 1 These files are in the shnnnn src or shnnnn project src folder 2 Only in the HI7700 4 and HI7750 4 3 Only in the HI7000 4 5 12 2 Defining Endian In the supplied sample project for the microcomputers that support little endian the endian should be selected in the HEW build configuration Select the build configuration as shown in figure 5 10 RENESAS Rev 6 00 375 REJ10B0060 0600 Section5 Configuration 3 mix High performance Embedded W File Edit View Project Build Debug Set joscaa S wee Ile e bibs z abj_big obj itte E h74 x Figure 5 10 Selection of Endian 5 12 3 Setting Optimize
196. ac ivfls_cac C Language API ER ercd vfls_cac VP flsadrl VP flsadr2 ER ercd ivfls_cac VP flsadri VP flsadr2 Parameters VP flsadri1 R4 Flush start address VP flsadr2 R5 Flush end address Return Parameters ER ercd RO Normal end E_OK or error code Error Codes E_PAR p Parameter error flsadri gt flsadr2 Function This service call flushes the operand cache If the addresses from flsadr1 to flsadr2 are cached in the operand cache the contents that have not yet been written to memory are written to memory flsadr1 and flsadr2 must be logical addresses If the address range from flsadr1 to flsadr2 includes one of the following addresses normal system operation cannot be guaranteed e Address corresponding to an physical address in area 7 e Address in P2 or P4 area To specify all cache contents specify flsadr1 H 80000000 and flsadr2 H 9bffffff In the SH 4 the cache line size is 32 bytes five least significant bits of flsadr1 are corrected to Os and five least significant bits of flsadr2 are corrected to 1s This service call can be called before the kernel is initiated This service call can be called even in the exception block state BL 1 in SR Therefore the cache can be flushed irrespective of interrupts or exceptions When this service call has been called when BL 1 in SR clear BL to 0 after returning from the service call processing Rev 6 00 265 RENESAS REJ10B0060 0600 Sect
197. acre_alm Assign Alarm Handler ID Automatically C Language API ER ercd ER ercd ER_ID almid ER_ID almid Parameters lt cre_alm ID icre_alm gt almid T_CALM pk_calm lt acre_alm iacre_alm gt T_CALM pk_calm Return Parameters lt cre_alm ER icre_alm gt ercd lt acre_alm iacre_alm gt ER_ID almid Packet Structure typedef struct ATR VP_INT FP T_CALM Error Codes R4 R5 R4 RO RO t_calm almatr exinf almhdr cre_alm ID almid T_CALM pk_calm icre_alm ID almid T_CALM pk_calm acre_alm T_CALM pk_calm iacre_alm T_CALM pk_calm Alarm handler ID Pointer to the packet where the alarm handler creation information is stored Pointer to the packet where the alarm handler creation information is stored Normal end E_OK or error code Created alarm handler ID a positive value or error code 0 4 Alarm handler attribute 4 4 Extended information 8 4 Alarm handler address E_RSATR p Invalid attribute almatr is invalid E_PAR p Parameter error pk_calm is other than a multiple of four or almhdr is an odd value E_ID p Invalid ID number almid lt 0 or almid gt CFG_MAXALMID E_OBJ k Object status is invalid Alarm handler indicated by almid already exists E_NOID k No ID available Rev 6 00 208 REJ10B0060 0600 RENESAS Section3 Service Calls Function Service calls cre_alm and icre_alm create the alarm handler indi
198. acre_mbf Creates message buffer and assigns message T E D U iacre_mbf buffer ID automatically N E D U del_mbf Deletes message buffer T E D U snd_mbf Sends message to message buffer T E U psnd_mbf Polls and sends message to message buffer T E D U ipsnd_mbf N E D U tsnd_mbf Sends message to message buffer with timeout T E U function rcv_mbf Receives message from message buffer T E U prcv_mbf Polls and receives message from message buffer T E D U trcv_mbf Receives message from message buffer with T E U timeout function ref_mbf Refers to message buffer state T E D U iref_mbf N E D U Notes 1 S Standard profile service calls s Service calls that are not standard profile service calls but are needed in order to use the standard profile function 2 T Can be called from task context N Can be called from non task context E Can be called from dispatch enabled state D Can be called from dispatch disabled state U Can be called from CPU unlocked state L Can be called from CPU locked state C Can be called from CPU exception handler Rev 6 00 164 REJ10B0060 0600 RENESAS Section3 Service Calls Message Buffer Specifications The message buffer specifications are listed in table 3 39 Table 3 39 Message Buffer Specifications Item Description Message buffer ID 1 to CFG_MAXMBFID 1023 max Attribute supported TA_TFIFO Task queue waiting for sending a message is managed on a FIFO basis TA_TPRI Task queue waiting for s
199. agement e Reference to and setting of system clock e Time event handler cyclic handler alarm handler and overrun handler execution control e Task execution control such as timeout and time slicing The kernel uses a counter called the system clock to perform the above functions The unit of time used in the service calls is 1 ms A time tick can be specified as a value other than ms by specifying CFG_TICNUME numerator of time tick cycle and CFG_TICDENO denominator of time tick cycle by the configurator To use the time management function it is necessary to incorporate a timer driver There are two kinds of timer drivers a standard timer driver and an optimization timer driver However an optimization timer driver is the function currently supported only by HI7700 4 For details refer to Appendix D Timer Driver The system clock is controlled by the service calls listed in table 2 17 Note that isig_tim is automatically executed according to the configurator specifications CFG_TIMUSE Table 2 17 Service Calls for System Clock Control Service Call Name Function isig_tim Provides a time tick set_tim iset_tim Sets system clock get_tim iget_tim Refers to system clock Rev 6 00 43 RENESAS REJ10B0060 0600 Section2 Kernel 2 16 1 Cyclic Handler The cyclic handler is a time event handler that can be initiated at a specific cycle time interval after the initiation phase has been passed Cyclic handler
200. agement Method of Fixed Size Memory Pool V 2 01 Release 00 0 455 Improvement of Variable Size Memory Pool V 2 01 Release 00 457 Macros for Calculating Size V 2 01 Release 00 0 0 ceeeeeceeceeseceneeeeeeeeeceeeeeeneeeenees 458 Initial Value of DSR V 2 01 Release 00 ceeeecccccceecceseceseeeeeseeeseeeeeeeeeeeeeseeeensee 458 Initial Value of SR in Task Exception Processing Routine V 2 01 Release OD wcscsecesviacestinvctusedcoatecsusavesesdeatesvaeusdieatodeoteasesusii stents iesnsa E 459 Extension of Maximum Exception Code CFG_MAXVCTNO V 2 01 Release OO wis cviscsasieietiesssrmveracsosties E EAEEREN EEEE NE Er Gentoo maa 459 Handling of TRAPA 16 to 31 V 2 01 Release 00 eee eeeseeeseseeeeesteeeeteneeees 459 Release of Restriction concerning Structure Alignment V 2 01 Release 00 459 ID Name CV2 01 Release QO aeee oriei neei iekea Enan E EEEE EEE ENEE ES 460 Open the file used last time Command for the Configurator V 2 02 Release VO EE E E E POE E N O NE O 460 Appendix J New Functions of HI7750 4 V 2 eseseseseseseseecoeosoeseoesesesesesesososoeoeseseseee FOL J J 2 J 3 J 4 J 5 J 6 J 7 J 8 J 9 J 10 Jl Support of SH 4A with Extended Function V 2 01 Release 00 Specifying Address of Task Stack Fixed Size Memory Pool and Variable Size Memory Pool V 2 01 Release 00 eseecsecceseeeseeeeeceeeeseceeeeeeeeeeeceeeseesaeeeaees 461 Management Method of Fixed Si
201. agmentation in free space The VTA_UNFRAGMENT attribute is suitable for a memory pool from which a large number of small memory blocks are to be acquired When this attribute is specified small blocks are collectively allocated in specialized contiguous areas to leave larger possible contiguous areas Rev 6 00 187 RENESAS REJ10B0060 0600 Section3 Service Calls Only when attribute VTA_UNFRAGMENT is specified mplmb minblksz and sctnum become valid When sctnum is set to a larger value than mplsz minblksz x 32 mplsz minblksz x 32 is assumed For details refer to section 2 15 2 Controlling Fragmentation of Free Space 2 mplsz Parameter mplsz specifies the size of the variable size memory pool to be created Also refer to section 2 15 3 Management of Variable Size Memory Pool The following macro is provided to estimate the approximate size to be specified for mplsz SIZE mplsz TSZ_MPL UINT blkent UINT blksz Approximate size bytes of a variable size memory pool area required to hold the blkcnt number of blksz byte memory blocks This macro calculates the size assuming that the VTA_UNFRAGMENT is not selected The equation for calculating the size depends on whether CFG_NEWMPL is selected 3 mpl Parameter mpl specifies the start address of a free area to be used as a variable size memory pool The kernel allocates an mplsz byte area starting from address mpl as a variable size memory pool When NULL is s
202. ails on stack size calculations refer to Appendix C 7 Interrupt Handler Stacks 3 Only the direct interrupt handler is used only for CFG_DIRECT L HI7000 4 When neither the normal interrupt handler CPU exception handler nor trap exception handler is used this must be checked Rev 6 00 358 REJ10B0060 0600 RENESAS Section5 Configuration Table 5 5 Configurator Setting Items cont 4 Handler definition information is assigned to RAM and CFG_VCTRAM L def_inh def_exc and vdef_trp are embedded Specifies whether the definition information for the interrupt handler CPU exception handler and trap exception handler is assigned to ROM or RAM If it is assigned to ROM the amount of ROM consumption can be smaller def_inh def_exc vdef_trp cannot be used and check for linking with the kernel cannot be cleared when the handler is defined by the configurator 5 Register Bank only for HI7000 4 CFG_REGBANK L When using the register banks in SH 2A check this When using a microcomputer without register banks microcomputers other than SH 2A do not check this For Details refer to section 4 2 9 Register Banks SH 2A SH2A FPU 6 IBNR Register Address only for HI7000 4 CFG_IBNR_ADR L Specify the IBNR register address For Details refer to section 4 2 9 Register Banks SH 2A SH2A FPU 7 Definition of interrupt handler or CPU exception handler B Specifiable contents are the same as
203. an assign an ID number automatically If Auto is selected as an ID number in the object creation dialog box the configurator assigns an ID number automatically 2 kernel_macro h kernel_macro h is included from kernel h Refer to section 4 1 1 Header File 3 System definition files in kernel side kernel_def_main h kernel_def_inidata def kernel_def vct inc kernel_def_main h and kernel_def_inidata def are included from kernel_def c kernel_def_vct inc is generated only in HI7000 4 and is included from nnnn_expent sre and nnnn_intdwn src 4 System definition files in kernel environment side kernel_cfg_main h kernel_cfg_inidata def kernel_cfg_main h and kernel_cfg_inidata def are included from kernel_cfg c Note that the contents of the files differ among the HI7000 4 series If the files are compiled in a different HI7000 4 series environment an error occurs during compilation The following error message is output when a file created by the HI7750 4 configurator is compiled in the HI7000 4 or HI7700 4 environment Unmatch HIOS This file is designed for HI7750 4 Rev 6 00 353 RENESAS REJ10B0060 0600 Section5 Configuration 5 4 5 Separate Linkage 1 Linkage Unit of Setting Items and Kernel Lock Mode All setting items are classified into Kernel side and Kernel environment side The setting items on the kernel side and the setting items on the kernel environment side are separately output to the respec
204. and fpu mix is not specified Unnecessary Unnecessary as compiler option Note This usage is not recommended G 3 3 Called from Non Task Context When floating point calculation is executed the calling programs such as an interrupt handler need to guarantee all FPU registers For details refer to appendix G 2 Non Task Context Normal Interrupt Handler Direct Interrupt Handler CPU Exception Handler Time Event Handler Initialization Routine Rev 6 00 442 REJ10B0060 0600 RENESAS Appendix G Notes on FPU of SH2A FPU SH 4 SH4A G 4 1 Table G 3 shows the FPSCR states on the initiation of tasks and handlers Information for Reference States on the Initiation of Tasks and Handlers RENESAS Table G 3 States on the Initiation of Tasks and Handlers Interruptand CPU Task and Task Time Event Exception Exception Extended Handler and Handler Processing Service Call Initialization Including State at Initiation Routine Routine Routine TRAPA Value of FPSCR H 00040001 Same as Undefined Same as before before the the exception Precision mode Single precision extended occurred FPSCR PR 0 SEVICE gall was issued Denormalization mode Handled as zero FPSCR DN 1 Rounding mode Rounded to zero FPSCR RM B 01 Transfer size mode 32 bits 0 FPSCR SZ FPU register bank Bank 0 0 FPSCR FR Other bits of FPSCR 0 Notes 1 In SH2A FPU DN is always 1 2 Only in SH 4 and SH 4A Re
205. and termination of tasks e Task synchronization including suspension and resumption of tasks and task event flags e Task exception processing functions including the definition request enabling and disabling of task exception processing e Extended inter task synchronization and communication using semaphores event flags data queues and mailboxes e Inter task synchronization and communication using mutexes and message buffers e Memory pool management including control over the allocation and return of memory blocks e Control over timing such as setting and referring to the system clock and controlling the cyclic handler alarm handler and overrun handler e System management e Interrupt management e Service call management including the definition and issue e System configuration management including the definition of CPU exception handlers e Support of DSP and FPU note that the HI7000 4 does not support the FPU in the SH 2E processor e Cache support function only for HI7700 4 and HI7750 4 e Optimized timer driver and DSP standby control function for low power consumption only for HI7700 4 e A compact kernel with optional selection of kernel functions The size of the kernel program and size of its work area are reduced to minimize the ROM and RAM size required by the user system The kernel optimized for the user system can be configured by selecting the kernel functions to be used by the user system e Sample p
206. area size will decrease by the amount given by the following expression Decrease in size mbfsz 16 bytes Rev 6 00 167 RENESAS REJ10B0060 0600 Section3 Service Calls Parameter mbfsz specifies the size of the message buffer to be created This must be a multiple of four and equal to or more than the minimum buffer size 8 bytes When calculating the message buffer size remember that 4 bytes of management area for the kernel is added when one message is stored A message buffer of mbfsz 0 can also be created In this case no message can be stored in the message buffer and the message receiving task completely synchronizes with the message sending task In other words when a service call to send a message is called the task stays in the WAITING state until another task calls a service call to receive a message Similarly when a task calls a service call to receive a message the task stays in the WAITING state until another task calls a service call to send a message Note that for a message buffer with mbfsz 0 there will be no copying via the message buffer Parameter maxmsz specifies the maximum message size that can be received by the created message buffer NULL must be specified for parameter mbf The message buffer is created in the area specified by mbf by the pITRON4 0 specification However the kernel does not support a value other than NULL If a value other than NULL is used normal system operation cannot be guaran
207. ared to 0 and the task is transferred to the task exception processing disabled state If a task exception processing routine has already been defined the previous definition is cancelled and is replaced with the new definition At this time pended exception factors are not cleared and task exception processing is not disabled Rev 6 00 112 REJ10B0060 0600 RENESAS Section3 Service Calls 3 6 2 Request Task Exception Processing ras_tex iras_tex C Language API ER ercd ras_tex ID tskid TEXPTN rasptn ER ercd iras_tex ID tskid TEXPTN rasptn Parameters ID tskid R4 Task ID TEXPTN rasptn R5 Task exception factor of task exception processing to be requested Return Parameters ER ercd RO Normal end E_OK or error code Error Codes E_PAR p Parameter error rasptn 0 E_ID p Out of ID range tskid lt 0 tskid gt CFG_MAXTSKID or tskid TSK_SELF 0 is specified in a non task context E_NOEXS k Undefined Task indicated by tskid does not exist E_OBJ k Object status is invalid Task indicated by tskid is in the DORMANT state or task exception processing routine is not defined Function Requests task exception processing by the task exception factor specified by rasptn for the task specified by tskid That is the pended exception factor for the task is ORed with the value indicated by the parameter rasptn By specifying tskid TSK_SELF 0 the current task can be specified When the condition
208. ask waiting to acquire a memory block in the variable size memory pool area However in that case the task in the WAITING state will be released and error code E_DLT will be returned When the memory pool is allocated in the variable size memory pool that is created with NULL as mpl is deleted the free variable size memory pool area CFG_MPLSZ will increase by an amount given by the following expression Increase in size mplsz specified at creation 16 bytes The kernel will not perform any processing even when a block has already been acquired Rev 6 00 190 REJ10B0060 0600 RENESAS Section3 Service Calls 3 14 3 Get Variable Size Memory Block get_mpl pget_mpl ipget_mpl tget_mpl C Language API get_mpl ID mplid UINT blksz VP p_blk j ER ercd ER ercd ER ercd ER ercd Parameters ID UINT VP lt tget_mp1l gt TMO Return Parameters ER VP Error Codes E_PAR E_ID E_NOEXS E_CTX E_DLT E_TMOUT E_RLWAI pget_mpl ID mplid UINT blksz VP p_blk j ipget_mpl ID mplid UINT blksz VP p_blk tget_mpl ID mplid UINT blksz VP p_blk mplid R4 Variable size memory pool ID blksz R5 Memory block size Number of bytes p_ blk R6 Pointer to the area where the start address of the memory block is to be returned tmout R7 Timeout specification ercd RO Normal end E_OK or error code p_ blk R6 Pointer to the area where the start address of the memory block is stored
209. assigns ID del_mpf Deletes a fixed size memory pool get_mpf Gets a fixed size memory block pget_mpf ipget_mpf Gets a fixed size memory block polling tget_mpf Gets a fixed size memory block with timeout rel_mpf irel_mpf Returns a fixed size memory block ref_mpf iref_mpf Refers to the fixed size memory pool status A fixed size memory pool can also be created by the configurator Figure 2 11 shows an example of using fixed size memory pool Rev 6 00 35 RENESAS REJ10B0060 0600 Section2 Kernel Time M Task A Task B Fixed size memory pool status cre_mpf 1 16 bytes 3 blocks Empty Empty Empty 2 get_mpf Get X X Empty Empty 3 get_mpf Get Y X Y Empty 4 get_mpf Get Z X l Y Z LAI XY YY YOO 5 get_mpf xX TY Zz lt WAITING gt lt READY gt rel_mpf Y xX _wfz 6 Get W Figure 2 11 Example of Using Fixed Size Memory Pool Description Bold lines represent executed process The following describes the fixed size memory pool operation with respect to time 1 Task A issues cre_mpf to create a fixed size memory pool that has three 16 byte memory blocks Task A gets block X by issuing get_mpf Task B gets block Y by issuing get_mpf Task B gets block Z by issuing get_mpf Ot ge E Task A attempts to get a block by issuing get_mpf At this time no memory blocks are available and task A enters the WAITING state 6 Task B
210. ate D Can be called from dispatch disabled state U Can be called from CPU unlocked state L Can be called from CPU locked state C Can be called from CPU exception handler Rev 6 00 255 RENESAS REJ10B0060 0600 Section3 Service Calls 3 23 1 Initialize Cache vini_cac ivini_cac C Language API void vini_cac UW ccr_data UW entnum UW waynum void ivini_cac UW ccr_data UW entnum UW waynum Parameters UW ccr_data R4 Value to be set to the cache control register of the CPU UW entnum R5 Number of cache entries UW waynum R6 Number of cache ways Return Parameters None Error Codes None Function This service call initializes the cache Before using the cache function call this service call The data specified by ccr_data is set to the CCR register The number of entries for each cache way is specified by entnum The number of ways is specified by waynum The parameters entnum and waynum must be set according to CPU specifications and the RAM mode Otherwise normal system operation cannot be guaranteed The following shows supported cache type and required parameters setting in the vini_cac and ivini_cac in the HI7700 4 Cache Typical Parameters Size Microcomputers Condition ccr_data entnum waynum 8 kbytes SH7708 series Internal RAM Specify a value 128 2 SH7709 mode not used according to the Internal RAM MCU s 128 4 mode used specification 16 kbytes SH7706 SH7709S __
211. ated TA_COPO H 00000100 The task uses the DSP HI7000 4 HI7700 4 TA_COP1 H 00000200 The task uses the FPU HI7000 4 The task uses bank 0 in the FPU HI7750 4 TA_COP2 H 00000400 The task uses bank 1 in the FPU HI7750 4 Note The initial value of the FPSCR register is H 00040001 bank 0 When TA_ACT attribute is specified extended information exinf is passed to the task as a parameter By specifying TA_COPn attribute the registers of the selected coprocessor can be saved as task context Note that the TA_COPn attribute is not in the pwITRON4 0 specification exinf The parameter exinf can be widely used by the user for example to set information concerning tasks to be created task Specify the task start address itskpri Specify 1 to CFG_MAXTSKPRI as the task priority at initiation Rev 6 00 78 REJ10B0060 0600 RENESAS Section3 Service Calls stksz Parameter stksz is valid only for service calls cre_tsk icre_tsk acre_tsk and iacre_tsk and specifies the stack size of the task to be created A multiple of four can be specified for the stack size Note that stksz has no meaning to service calls vscr_tsk and ivscr_tsk because each service call creates a task that uses the static stack The parameter stksz is ignored in kernel processing stk stk is effective in cre_tsk icre_tsk acre_tsk and iacre_tsk service calls When NULL is specified as stk the kernel allocates a stack in the dynamic stack area CFG_TS
212. ated in the memory E_RSATR p Invalid attribute mplatr is invalid E_PAR p Parameter error pk_cmpl is other than a multiple of four mplsz is other than a multiple of four mplsz lt TSZ_MPL 1 4 mplsz 2 H 80000000 mpl is other than a multiple of four if mpl is not NULL or while VTA_UNFRAGMENT is selected minblksz 0 sctnum 0 mplsz lt minblksz 32 or mplmb is other than a multiple of four E_ID p Invalid ID number mplid lt 0 or mplid gt CFG_MAXMPLID E_OBJ k Object status is invalid Variable size memory pool indicated by mplid already exists E_NOID k No ID available Function Service calls cre_mpl and icre_mpl create a variable size memory pool with an ID indicated by mplid using the contents specified by pk_cmpl Service calls acre_mpl and iacre_mpl search for an unused variable size memory pool ID and create a variable size memory pool that has this ID with the contents specified by parameter pk_cmpl then returns the ID The range searched for the variable size memory pool ID is 1 to CFG_MAXMPLID 1 mplatr Specify the logical OR of the following values for mplatr a Order of tasks in the queue for waiting for memory block acquisition Only TA_TFIFO can be specified e TA_TFIFO H 00000000 Task queue waiting for memory is managed on a FIFO basis b Management method When CFG_NEWMPL is selected VTA_UNFRAGMENT can be specified e VTA_UNFRAGMENT H 80000000 Sector management reducing fr
213. attribute sent messages are queued in FIFO are specified 2 Task A attempts to receive a message by using rcv_mbx Since no message is stored in the mailbox task A enters the WAITING state 3 Task B sends message X to the mailbox using snd_mbx and stores a message in the mailbox At this time task A is released from the WAITING state and task A receives the address of message X 4 Task B sends message Y to the mailbox using snd_mbx At this time since no tasks are waiting for a message message Y is stored in a message queue 5 Task C sends message Z to the mailbox using snd_mbx In this case message Z is also stored in a massage queue FIFO because the TA_MFIFO attribute has been specified 6 Task A issues rcv_mbx At this time task A receives the address of message Y which is placed at the top of the message queue Rev 6 00 29 RENESAS REJ10B0060 0600 Section2 Kernel 2 12 Mutex A mutex is used to achieve exclusive control by providing a priority ceiling protocol to avoid priority inversion In this protocol the task that acquires a mutex is executed at a priority equal to the ceiling priority specified in the mutex The mutex is controlled by the service calls listed in table 2 12 Table 2 12 Service Call Name Function Service Calls for Mutex Control cre_mtx Creates a mutex acre_mtx Creates a mutex automatically assigns ID del_mtx Deletes a mutex loc_mtx Locks a
214. ay mode the size must not be doubled kernel_cfg_cac_set h is included by kernel_cfg c An example is shown below FRR KKK IKK KKK FR KI KK IIR II RII RTT TRO IIR TRI IO IK KOK Cache size information Please define the specified Cache size in CPU to be used 1 IC SIZE Instruction Cache size Bytes 2 OC_ SIZE Operand Cache size Bytes E e AK e E IR KK KK IK e KR KK KK KK KK KK KK KK e ke RK e e KK e RK RK RK e k KR KR KEK KR KR k k k kk k define IC_SIZE 32768UL define OC_SIZE 32768UL Note that kernel_cfg_cac_set h is stored only in the sample folders for the microcomputers that include SH4AL DSP or SH 4A CPU core the sh7318 and sh7343 folders in HI7700 4 V 2 02 Release 00 and the sh7770 and sh7785 folders in HI7750 4 V 2 02 Release 00 as of writing this manual At this manual creation time they are sh7318 and sh7343 folders of the HI7700 4 and sh7770 and sh7785 folders of the HI7750 4 Similarly kernel_cfg c only in these folders includes kernel_cfg_cac_set h Rev 6 00 364 REJ10B0060 0600 RENESAS Section5 Configuration 5 8 HEW Workspace and Projects Use the following procedure to create load modules with the HEW build function 1 Add the files necessary for creating the load module in a project 2 Specify the options for the compiler assembler and optimized linkage editor 3 Run the Build command This product supplies a sample workspace file shnnnn hws Double clicking this file opens it
215. bia Defa ixl E sh7343 cfe E def ORE Remove Project Unload Project SEE Add Files INS Remove Files Add Folder Version Control Configure View oa Allow Docking Hide Properties A projects I Figure 5 9 Project Selection Rev 6 00 366 REJ10B0060 0600 RENESAS Section5 Configuration 5 9 Kernel Libraries The kernel library is stored in the hilib elf folder and linked in the kernel side at the separate linkage def or whole linkage mix Multiple kernel libraries should be specified with the priority according to the function to be used In the HEW when the kernel library is specified upper of the screen for specifying the library the priority becomes higher see figure 5 11 5 9 1 HI7000 4 Table 5 6 lists the linkage priority of the HI7000 4 kernel library Table 5 6 Linkage Priority of the Kernel Library HI7000 4 CPU Core Linkage Priority SH 1 SH 2 SH 2A without FPU For big endian hiknl lib For little endian hiknl_little lib SH2 DSP 1 dsp_knl lib 2 hiknI lib SH2A FPU 1 fpu_knI lib 2 hiknl lib Following kernel libraries are used for supporting the debugger and usually not used e hiexpand lib and hiexpand_little lib e dsp_expand lib e fpu_expand lib 5 9 2 HI7700 4 Table 5 7 lists the linkage priority of the HI7700 4 kernel library Rev 6 00 367 RENESAS REJ10B0060 0600 Section5 Configurati
216. ble is 1023 When no fixed size memory pool is used specify 0 When a value more than 1 is specified the cre_mpf service call must be embedded 2 _ Fixed size memory pool area size CFG_MPFSZ When a fixed size memory pool is created a fixed size memory pool is allocated with area of the specified size 3 Fixed size Memory Pool Management Method CFG_MPFMANAGE L When this is checked kernel management tables are not located in a memory pool domain Refer to section 2 14 Fixed Size Memory Pool 4 Fixed size memory pool creation BA Specifiable contents are the same as those of the cre_mpf service call 18 Variable Size Memory Pool Page 1 Maximum variable size memory pool ID CFG_MAXMPLID The range of usable variable size memory pool IDs is 1 to CFG_MAXMPLID The maximum value specifiable is 1023 When no variable size memory pool is used specify 0 When a value more than 1 is specified the cre_mpl service call must be embedded Rev 6 00 362 REJ10B0060 0600 RENESAS Section5 Configuration Table 5 5 Configurator Setting Items cont 2 Variable size memory pool area size CFG_MPLSZ When a variable size memory pool is created a variable size memory pool is allocated with area of the specified size 3 Variable size memory pool management method CFG_NEWMPL L When CFG_NEWMPL is not selected the conventional management method in the previous versions HI7000 4 V 2 00 Rel
217. cally assigns task ID del_tsk Deletes task act_tsk iact_tsk Starts task can_act ican_act Cancels start task request sta_tsk ista_tsk Starts task specifies start task code ext_tsk Exits current task exd_tsk Exits current task and deletes it ter_tsk Forcibly terminates a task chg_pri ichg_pri Changes task priority get_pri iget_pri Refers to task priority ref_tsk iref_tsk Refers to task state ref_tst iref_tst Refers to task state simple version vchg_tmd Changes task execution mode Table 2 3 Task Synchronization Service Calls Service Call Description slp_tsk Sleep task tslp_tsk Sleep task with timeout wup_tsk iwup_tsk Wakeup task can_wup ican_wup Cancel wakeup task rel_wai irel_wai Release WAITING state forcibly sus_tsk isus_tsk Suspend task rsm_tsk irsm_tsk Resume task frsm_tsk ifrsm_tsk Resume task forcibly dly_tsk Delay task Rev 6 00 10 REJ10B0060 0600 RENESAS Section2 Kernel 2 6 1 Task State and Transition A task can be in any of the following seven states in the user system NON EXISTENT State A task has not been registered in the kernel and has been in a virtual state DORMANT State A task has been registered in the kernel but has not yet been initiated or has already been terminated READY executable State An executable task is in the queue
218. carefully considering interrupt nestings For details refer to appendix C 7 Interrupt Handler Stacks 6 PR Vo Vy Undefined 7 SH 4 SH 4A FPSCR vV Undefined 8 SH 4 SH 4A FPUL v v Undefined 9 SH 4 SH 4A FRO_BANKO V vV Undefined to FR15_BANKO 10 SH 4 SH 4A FRO_BANK1 V V Undefined to FR15_BANK1 Notes 1 These registers can be used Note that some register contents cannot be guaranteed after service calls For details refer to section 3 2 3 Guarantee of Register Contents after Issuing Service Call 2 When execution is returned from the entry function RTS instruction the contents of these registers must be the same as the value at initiation 3 IMASK bits must not be lower than the current interrupt level MD must be 1 FD must be 0 3 Writing a Normal Interrupt Handler in C Language Using the DSP To use the DSP in an interrupt handler refer to section 4 13 Using the DSP in Programs for HI7000 4 and HI7700 4 only Rev 6 00 310 REJ10B0060 0600 RENESAS Section4 Application Program Creation 4 Using the IRL Interrupt In an IRL interrupt two different interrupt causes are assigned to one vector When using both of these causes the normal interrupt handler must be modified as shown in figure 4 5 include kernel h define I_HILEVEL15 void vec0O71_handler14 void IRL14 interrupt processing void vec0O71_handler15 void IRL14 interrupt processing
219. cated by parameter almid with the contents specified by parameter pk_calm Service calls acre_alm and iacre_alm search for an unused alarm handler ID and define an alarm handler that has the searched ID with the contents specified by parameter pk_calm and return the defined alarm handler ID as a return parameter The range for searching for an unused alarm handler ID is 1 to CRG_MAXALMID The alarm handler is a time event handler for the non task context initiated at the specified time only once Parameter almatr is specified in the following format See table 3 54 for details almatr TA_HLNG TA_ASM Table 3 54 Alarm Handler Attributes almatr almatr Code Description TA_HLNG H 00000000 The handler is written in a high level language TA_ASM H 00000001 The handler is written in assembly language Parameter exinf specifies extended information to be returned as a parameter when initiating the alarm handler Parameter exinf can be widely used by the user for example to set information concerning alarm handlers to be defined Parameter almhdr specifies the start address of the alarm handler The time to initiate the alarm handler is not set immediately after creating the alarm handler The alarm handler is in the stop state The alarm handler can also be created statically by the configurator Rev 6 00 209 RENESAS REJ10B0060 0600 Section3 Service Calls 3 17 2 Delete Alarm Handler del_alm C Language API
220. cd tsnd_mbf ID mbfid VP msg UINT msgsz Send Message to Message Buffer TMO tmout with Timeout 86 rcv_mbf ER_UINT msgsz rcv_mbf ID mbfid VP msg Receive Message from Message Buffer 87 prcv_mbf ER_UINT msgsz prcv_mbf ID mbfid VP msg Poll and Receive Message from Message Buffer 88 trcev_mbf ER_UINT msgsz trcv_mbf ID mbfid VP msg TMO Receive Message from Message tmout Buffer with Timeout 89 ref mbf ER ercd ref _mbf ID mbfid T_RMBF pk_rmbf Refer to Message Buffer State iref_mbf ER ercd iref_mbf ID mbfid T_ RMBF pk_rmbf Rev 6 00 394 REJ10B0060 0600 RENESAS Appendix A Service Call List No Service Call C Language API Function Memory Pool Management Function Fixed Size Memory Pool 90 cre_mpf ER ercd cre_mpf ID mpfid T_ CMPF pk_cmpf Create Fixed Size Memory Pool icre_mpf ER ercd icre_mpf ID mpfid T_ CMPF pk_cmpf 91 acre_mpf ER_ID mpfid acre_mpf T_CMPF pk_cmpf Create Fixed Size Memory Pool iacre_mpf ER_ID mpfid iacre_mpf T_CMPF pk_cmpf and Assign Fixed Size Memory Pool ID Automatically 92 del_mpf ER ercd del_mpf ID mpfid Delete Fixed Size Memory Pool 93 get_mpf ER ercd get_mpf ID mpfid VP p_blk Acquire Fixed Size Memory Block 94 pget_mpf ER ercd pget_mpf ID mpfid VP p_blk Poll and Acquire Fixed size ipget_mpf ER ercd ipget_mpf ID mpfid VP p_blk Memory Block 95 tget_mpf ER ercd tget_mpf ID mpfid V
221. ce Call 2 When execution is returned from the entry function RTS instruction the contents of these registers must be the same as the value at initiation 3 IMASK bits must not be lower than the current interrupt level 4 When the SH 2A or SH2A FPU is used and CFG_REGBANK is selected the end condition is not required 5 Depends on CFG_TBR 1 Kernel does not manage The kernel does not operate TBR 2 Only for service call Do not modify TBR Rev 6 00 308 REJ10B0060 0600 RENESAS Section4 Application Program Creation 3 Task context When execution is returned from an interrupt handler function RTS instruction the contents of TBR must be the same as the value at initiation The initial value is undefined Table 4 10 Rules on Using Registers in a Normal Interrupt Handler H1I7700 4 End Use Conditions No Registers a n Initial Value 1 PC V Interrupt handler start address 2 SR V The value which is specified at the definition 3 RO_BANKO to R7_BANKO V Undefined 4 R8to R14 MACH MACL V V Undefined GBR 5 R15 V V R15 points to the interrupt handler stack area The kernel changes the stack pointer to the interrupt handler stack area at interrupt All interrupt handlers use the same stack area The size of the interrupt handler stack area is defined by CFG_IRQSTKSZ Note that the size of the interrupt handler stack must be calculated carefully considering interrupt nestings For detail
222. ce Calls 3 19 10 Refer to Dispatch Pended State sns_dpn C Language API BOOL state sns_dpn void Parameters None Return Parameters BOOL state RO Dispatch pended state Function Service call sns_dpn returns TRUE when the task dispatch is pended Otherwise service call sns_dpn returns FALSE When the following conditions are satisfied FALSE is returned Otherwise TRUE is returned e Task dispatch is not disabled e The CPU is unlocked e Task or task exception processing routine e An interrupt is not masked by service call chg_ims Service call sns_dpn can be called in the CPU locked state and from the CPU exception handler Rev 6 00 230 REJ10B0060 0600 RENESAS Section3 Service Calls 3 19 11 Start Kernel vsta_knl ivsta_knl C Language API void vsta_kn1 void void ivsta_knl void Assembler API Branches to symbol _ kernel _ reset Parameters None Return Parameters Service call vsta_knl does not return any parameters to the current task Function Service call vsta_knl starts the kernel If the kernel has already been started the multitasking environment up to that point is all nullified This service call can also be called in the CPU locked state and from the CPU exception handler It can also be called before the kernel is started This service call should be called in a state with all interrupts masked SR IMASK 15 In the HI7700 4 and HI7750 4 this servic
223. cify a level when interrupt inside the kernel is masked Debugging Function Service Calls Selection User interrupts above the selected level are accepted without delay however service Interrupt CPU Exception H calls must not be issued in these interrupt handlers Trap Exception Handler Prefetch Function Timer interrupt level CFG_TIMLVL set in time management function view must be een Routine specified below kernel interrupt mask level Semaphore Event Flag Kernel Interrupt Mask Level CFG_KNLMSKLVL Data Queue Mailbox Mutex Message Buffer Fixed size Memory Pool Variable size Memory Pool Cyclic Handler Alarm Handler Overrun Handler Extended Service Call lt For Help press F1 Kernel Interrupt Mask Level Figure 5 7 Configurator Window Rev 6 00 351 RENESAS REJ10B0060 0600 Section5 Configuration 5 4 3 File Operation 1 Configurator Settings File HCF File Configurator parameters and settings can be saved in the HCF file 2 Configuration File Creation When Generate Configuration Files in the Generate menu is selected or Generate button in the toolbar is pressed the dialog box shown in figure 5 8 opens Specify a folder where a configuration file is to be created The configuration file must be generated in a folder containing the kernel_def c or kernel_cfg c Generate configuration files Generate in CAHI7700 4ikernelisamplesish7343 Browse Figure 5 8 Folder
224. clic handler specifications are listed in table 3 49 Table 3 49 Cyclic Handler Specifications Item Description Cyclic handler ID 1 to CFG_MAXCYCID 14 max Attribute supported TA_HLNG The task is written in a high level language TA_ASM The task is written in assembly language TA_STA Starts cyclic handler operation TA_PHS Reserves initiation phase Rev 6 00 200 REJ10B0060 0600 RENESAS Section3 Service Calls 3 16 1 Create Cyclic Handler cre_cyc icre_cyc acre_cyc iacre_cyc Assign Cyclic Handler ID Automatically C Language API ER ercd cre_cyc ID cycid T_CCYC pk_ccyc ER ercd icre_cyc ID cycid T_CCYC pk_ccyc ER_ID cycid acre_cyc T_CCYC pk_ccyc ER_ID cycid iacre_cyc T_CCYC pk_ccyc Parameters lt cre_cyc icre_cyc gt ID cycid R4 Cyclic handler ID T_CCYC pk_ccyc R5 Pointer to the packet where the cyclic handler creation information is stored lt acre_cyc iacre_cyc gt T_CCYC pk_ccyc R4 Pointer to the packet where the cyclic handler creation information is stored Return Parameters lt cre_cyc icre_cyc gt ER ercd RO Normal end E_OK or error code lt acre_cyc iacre_cyc gt HNO cycid RO Created cyclic handler ID number a positive value or error code Packet Structure typedef struct t_ecyc ATR cycatr 0 4 Cyclic handler attribute VP_INT exinf 4 4 Extended information FP cychdr 8 4 Cyclic handler address RELTIM cyctim 12 4 Cyclic handler
225. clusive Control Inhibited Interrupts Task Scheduling Enter the CPU locked state by Equal to or lower thanthe None issuing loc_cpu kernel interrupt mask level CFG_KNLMSKLVL Mask interrupts by issuing Equal to or lower than the None chg_ims service call When the specified mask level chg_ims service call is issued from the task context state the execution becomes the non task context state Enter disabled dispatch state by None None issuing dis_dsp service call Exclusive control by semaphore None The kernel schedules tasks however in tasks using the same semaphore the number of tasks entering the READY state simultaneously is limited to the semaphore initial count value Exclusive control by mutex None The kernel schedules tasks however tasks using the same mutex cannot enter the READY state simultaneously In addition in tasks using the same mutex the task priority inversion will not occur Rev 6 00 18 REJ10B0060 0600 RENESAS Section2 Kernel 2 6 10 Task Event Flags Task event flags are a bit patterns for tasks A task can wait for a specified bit to be set in the task event flag for the current task that is it can wait until the specified event occurs Task event flags are controlled by the service calls listed in table 2 6 Table 2 6 Service Calls for Task Event Flag Control Service Call Name Description vset_tfl ivset_ttl Sets task event flag velrttl ivelr_tfl Clears
226. cre_sem service call must be embedded Semaphore creation BA Specifiable contents are the same as those of the cre_sem service call 12 Event Flag Page 1 Maximum event flag ID CFG_MAXFLGID The range of usable event flag IDs is 1 to CFG_MAXFLGID The maximum value specifiable is 1023 When no event flag is used specify 0 When a value more than 1 is specified the cre_flg service call must be embedded Event flag creation BA Specifiable contents are the same as those of the cre_flg service call 13 Data Queue Page 1 Maximum data queue ID CFG_MAXDTQID The range of usable data queue IDs is 1 to CPG_MAXDTQID The maximum value specifiable is 1023 When no data queue is used specify 0 When a value more than 1 is specified the cre_dtq service call must be embedded 2 Data queue area size CFG_DTQSZ When a data queue is created a data queue is allocated within an area of the specified size 3 Data queue creation BA Specifiable contents are the same as those of the cre_dtq service call 14 Mailbox Page 1 Maximum mailbox ID CFG_MAXMBXID The range of usable mailbox IDs is 1 to CPG_MAXMBXID The maximum value specifiable is 1023 When no mailbox is used specify 0 When a value more than 1 is specified the cre_mbx service call must be embedded 2 Maximum message priority TMAX_MPRI CFG_MAXMSGPRI L The range of usable message pri
227. ction cache HI7750 4 SH 4 Operand cache 7750_cache_ lib SH 4A without Instruction cache and operand cache sh4a_cache_ lib extended function SH 4A with Instruction cache and operand shx2_cache_ lib extended function cache The specifications of the library for SH4AL DSP with extended function shx2_cache_ lib and the library for SH 4A with extended function shx2_cache_ lib are the same and this section explains the specification of them In addition be sure to refer to the following sections e 5 7 When Cache Support Function is Used on SH4AL DSP HI7700 4 or SH 4A HI7750 4 e 5 11 1 CPU Options for the Compiler and Assembler Rev 6 00 277 RENESAS REJ10B0060 0600 Section3 Service Calls Cache Support Service Calls The cache is controlled by the service calls listed in table 3 80 Table 3 80 Service Calls for Cache Support for SH4AL DSP with Extended Function and SH 4A with Extended Function System State Service Call Description T N E D U L C vini_cac Initializes cache T N E D U ivini_cac T N E D U velr_cac Clears instruction operand cache T N E D U ivelr_cac T N E D U vfls_cac Flushes operand cache T N E D U ivfls_cac T N E D U vinv_cac Invalidates instruction operand cache T N E D U ivinv_cac T N E D U Notes 1 S Standard profile service calls s Service calls that are not standard profile service calls but are needed in order to
228. ction 3 4 1 Create Task e p 176 Section 3 13 1 Create Fixed Size Memory Pool cre_mpf icre_mpf e p 186 Section 3 14 1 Create Variable Size Memory Pool cre_mpl icre_mpl J 3 Management Method of Fixed Size Memory Pool V 2 01 Release 00 In the previous version the kernel management table for each memory block is allocated in the memory pool area In V 2 the user can also allocate the management table area and can specify the table area address at creation In this case the memory pool area does not include management tables Rev 6 00 461 RENESAS REJ10B0060 0600 Appendix J New Functions of HI7750 4 V2 By combining this management method with the new function given in appendix J 2 Specifying Address of Task Stack Fixed Size Memory Pool and Variable Size Memory Pool V 2 01 Release 00 a memory block can be acquired with a specific offset address as follows for example e Parameters for fixed size memory pool creation Address of fixed size memory pool H 0c000000 Block size H 1000 4 Kbytes Number of blocks 4 In this case one of memory blocks A B C and D shown below is acquired Each memory block is aligned with a 4 Kbyte boundary Address H 0C000000 gt Memory block A H 0C001000 gt Memory block B H 0C002000 gt Memory block C H 0C003000 gt Memory block D In this new management method member mpfmb is added to the T_CMPF structure
229. ctual timer driver file for SH7708 is 7708_tmrdrv c is used for the file name in the HI7700 4 and HI7750 4 For big endian and little endian big and little are used instead of respectively A variable name beginning with CGF_ is specified for the configurator by the user to use the configurator For details refer to section 5 4 6 Configurator Settings and the configurator on line help Rev 6 00 ii REJ10B0060 0600 ENESAS Contents Section 1 WMtr OCU COON seis cess cc cacctsnc ccsssesseseccvssesaedsconssussseosssvedevesseassedetsvessdovsssesvenseste 1 1 OVET E Wevrscestanicedhascesesnetas nE anek ATE EE Snes erea eraa aene er arie aeara 1 1 2 Features 1 3 Operating Environment 1 4 VEEE OENE LO t ETE A TA AA A TEA AE 1 5 Target Product of This Manual eesisirsesscssissssisssiesssessssseisiesersseseeisstesizei siisii rr iseni 4 Section 2 Kernel E E A E E E 2 1 Overview 2 2 Functions 2 3 Processing Units and Precedence cecceccesseeseeseeceseeeaeeeneceeeaeceneeneeeeeaeeeneeneeeeeeeaeees 6 2 4 System State 2 4 1 Task Context State and Non Task Context State 2 4 2 Dispatch Disabled State Dispatch Enabled State 2 4 3 CPU Locked State CPU Unlocked State 2 5 ODC Si i E EAEE Esi 2 6 2 6 1 Task State and Transition 2 6 2 Task Creation 2 6 3 Task Initiation 2 6 4 Task Scheduling 2 6 5 Task Termination and Deletion 2 6 6 Task Stack 2 6 7 Shared Stack Functi
230. current task can be specified Rev 6 00 117 RENESAS REJ10B0060 0600 Section3 Service Calls 3 7 Synchronization and Communication Semaphore Semaphore Service Calls Semaphores are controlled by the service calls listed in table 3 22 Table 3 22 Service Calls for Event Flag Control System State Service Call Description T N E D U L C cre_sem s Creates semaphore T E D U icre_sem N E D U acre_sem Creates semaphore and assigns semaphore ID automatically T E D U iacre_sem N E D U del_sem Deletes semaphore T E D U sig_sem S Returns semaphore resource T E D U isig sem S N E D U wai sem S Waits on semaphore resource T E U pol_sem S Polls and waits on semaphore resource T E D U ipol_sem N E D U twai_sem S Waits on semaphore resource with timeout function T E U ref_sem Refers to semaphore state T E D U iref_sem N E D U Notes 1 S Standard profile service calls s Service calls that are not standard profile service calls but are needed in order to use the standard profile function 2 T Can be called from task context N Can be called from non task context E Can be called from dispatch enabled state D Can be called from dispatch disabled state U Can be called from CPU unlocked state L Can be called from CPU locked state C Can be called from CPU exception handler Semaphore Specifications The semaphore specifications are listed in table 3 23 Table 3 23 Semaphore Specification
231. d a 3 Defining a Task Exception Processing Routine A task exception processing routine can be defined in the following ways e def tex or idef_tex service call e Defined initially by the configurator Rev 6 00 305 RENESAS REJ10B0060 0600 Section4 Application Program Creation 4 7 Extended Service Call Routines 1 Writing an Extended Service Call Routine An extended service call routine is normally written in C language as shown in figure 4 3 include kernel h ER_UINT Svcrtn VP_INT parl VP_INT par2 Parameters specified by cal_svc are passed to the extended service call routine Extended service call routine return E_OK Passes the return value to the caller Figure 4 3 Example of a C Language Extended Service Call Routine 2 Rules on Using Registers in Extended Service Call Routine An extended service call routine is called by issuing the cal_svc or ical_sve service call in the same way as a normal function call Therefore an extended service call routine can use registers in the same way as normal C language functions For details refer to SuperH RISC engine C C Compiler User s Manual Parameters 1 to 4 specified by cal_svc are stored in the R4 to R7 registers Note that the task issuing cal_svc or ical_sve determines whether or not the DSP and FPU registers can be used in an extended service call routine 3 Defining an Extended Service Call Routine An extended ser
232. d irel_wai ID tskid Parameters ID tskid R4 Task ID Return Parameters ER_UINT ercd RO Normal end E_OK or error code Error Codes E_ID p Invalid ID number tskid lt 0 or tskid gt CFG_MAXTSKID E_NOEXS k Undefined Task indicated by tskid is not created E_OBJ k Object status is invalid Task indicated by tskid is in the DORMANT state or the current task is specified Function When the task specified by tskid is in some kind of WAITING state not including a SUSPENDED state or shared stack WAITING state it is forcibly cancelled E_RLWAI is returned as the error code for the task for which the WAITING state is cancelled by the service call rel_wai or irel_wai If the service calls rel_wai and irel_wai are called for a task in a WAITING SUSPENDED state the task enters the SUSPENDED state Thereafter if the service call rsm_tsk irsm_tsk frsm_tsk or ifrsm_tsk is issued and the SUSPENDED state is cancelled E_RLWAI is returned as the error code for the task To cancel the SUSPENDED state rsm_tsk irsm_tsk frsm_tsk or ifrsm_tsk should be used Note that there is no service call to cancel shared stack WAITING state Rev 6 00 101 RENESAS REJ10B0060 0600 Section3 Service Calls 3 5 5 Suspend Task sus_tsk isus_tsk C Language API ER ercd sus_tsk ID tskid ER ercd isus_tsk ID tskid Parameters ID tskid R4 Task ID Return Parameters ER ercd RO Normal end E_OK or error code Error Codes
233. d the task at the head of the wait queue is released from the WAITING state and the resource is assigned to the task If there are no tasks in the wait queue the semaphore count is incremented by one The maximum semaphore count is maxsem which is specified at semaphore creation Rev 6 00 122 REJ10B0060 0600 RENESAS Section3 Service Calls 3 7 4 Wait on Semaphore wai_sem pol_sem ipol_sem twai_sem C Language API ER ercd wai_sem ID semid ER ercd pol_sem ID semid ER ercd ipol_sem ID semid ER ercd twai_sem ID semid TMO tmout Parameters ID semid R4 Semaphore ID lt twai_sem gt TMO tmout R5 Timeout specification Return Parameters ER ercd RO Normal end E_OK or error code Error Codes E_ PAR p Parameter error tmout lt 2 E_ID p Invalid ID number semid lt 0 or semid gt CFG_MAXSEMID E_NOEXS k Undefined Semaphore indicated by semid does not exist E_CTX k Context error Called from disabled system state E_DLT k Waiting object deleted Target semaphore indicated by semid has been deleted while waiting E_RLWAI k WAITING state is forcibly cancelled rel_wai service call was called in the WAITING state E_TMOUT k Polling failed or timeout Function Each service call acquires one resource from the semaphore specified by semid Each service call decrements the number of resources of the target semaphore by one if the number of resources of the target semaphore is equal to or g
234. d Assign Task ID iacre_tsk ER_ID tskid iacre_tsk T_CTSK pk_ctsk Automatically 4 del_tsk ER ercd del_tsk ID tskid Delete Task 5 act_tsk ER ercd act_tsk ID tskid Initiate Task iact_tsk ER ercd iact_tsk ID tskid 6 can_act ER_UINT actcnt can_act ID tskid Cancel Task Initiation Request ican_act ER_UINT actent ican_act ID tskid X sta_tsk ER ercd sta_tsk ID tskid VP_INT stacd Start Task Start Code Specified ista_tsk ER ercd ista_tsk ID tskid VP_INT stacd 8 ext_tsk void ext_tsk void Exit Current Task 9 exd_tsk void exd_tsk void Exit and Delete Current Task 10 ter_tsk ER ercd ter_tsk ID tskid Terminate Task 11 chg pri ER ercd chg_pri ID tskid PRI tskpri Change Task Priority ichg_pri ER ercd ichg_pri ID tskid PRI tskpri 12 get pri ER ercd get_pri ID tskid PRI p_tskpri Refer to Task Priority iget_pri ER ercd iget_pri ID tskid PRI p_tskpri 13 ref_tsk ER ercd ref_tsk ID tskid T_RTSK pk_rtsk Refer to Task State iref_tsk ER ercd iref_tsk ID tskid T_ RTSK pk_rtsk 14 ref tst ER ercd ref_tst ID tskid T_RTST pk_rtst Refer to Task State simple version iref_tst ER ercd iref_tst ID tskid T_RTST pk_rtst 15 vchg_tmd ER ercd vchg_tmd UINT tmd Change Task Execution Mode RENESAS Rev 6 00 389 REJ10B0060 0600 Appendix A Service Call List No Service C Language API Function Call Task Synchronous Management Function 16 slp_tsk ER ercd
235. d Linkage Editor Options 1 Input Category Library files SuperH RISC engine Standard Toolchain Configuration C C Assembly Link Library Standard Library CPU Deb 4 gt obj bie z Category Input vy E a All Loaded Projects Stow entries fcr cfg i 3 source file cll E C source file CWORKSPDIRO hilib elf sh4al_ dsp knlbig Assembly source file WORKSPDIRDY hilib elf shx2_cache_bie lib E Linkage symbol fi SQWORKSPDIRDY hilib elf hikn _big lib def E C source file C source file Assembly source w Le Up m symbol fi IV Use entry point Prelinker control mix hicpuasm s CSstsS fauto tid source file cpus futo C source file Options Link Library Assembly source file centry hi_cpuasm defines kernel ponp OACI 00000 7 i define _kernel_man_sp l noprelink nomessage Linkage symbol file lists CONFIGDIFINS PROJECTNAME map nooptimize E E it ith E E Figure 5 11 Optimized Linkage Editor Input Category Library files Be sure to specify necessary libraries as described in 5 9 Kernel Libraries Also specify application libraries as required Rev 6 00 376 REJ10B0060 0600 RENESAS Section5 Configuration 2 Input Category Defines SuperH RISC eneine Standard Toolchain Configuration C C Assembly Link Library Standard Library CPU Deb_4 gt obj b
236. d by pk_rver e maker Indicates the manufacturer of this kernel The value is H 0115 which means Renesas e prid Indicates the number to identify the OS or VLSI type as follows HI7000 4 H 0010 HI7700 4 H 000F HI7750 4 H 000E Rev 6 00 252 REJ10B0060 0600 RENESAS Section3 Service Calls spver Indicates the specifications to which the kernel conforms as follows Bits 15 to 12 MAGIC Number to identify the TRON specification series H S uITRON specifications for this kernel Bits 11 to 0 SpecVer Version number of the TRON specification on which the product is based H 400 uITRON version 4 00 00 for this kernel prver Indicates the version number of the kernel Refer to the release note of product appending for the value of prver The prver of each product at this manual creation time is as follows HI7000 4 V 2 02 00 H 0220 HI7700 4 V 2 02 00 H 0220 HI7750 4 V 2 02 00 H 0220 prno Indicates the product management information and the product number The prno 0 to prno 3 values of this kernel are all H 0000 Rev 6 00 253 RENESAS REJ10B0060 0600 Section3 Service Calls 3 23 Cache Support Function HI7700 4 for SH 3 and SH3 DSP This function is supported only for the HI7700 4 and HI7750 4 As for a cache support function libraries differ for every microcomputer table 3 72 And a part of functions and API differ for every library Table 3 72 Library of Cache Sup
237. d cache entry which is dirty is written back to memory This processing is performed in the state of SR BL 1 However whenever it processes one entry this service call restores SR at the time of this call That is interruption may be accepted by SR at the time of this call In the HI7750 4 this service call can be called before the kernel is initiated This service call can be called even in the exception block state BL 1 in SR Therefore the cache can be flushed irrespective of interrupts or exceptions When this service call has been called when BL 1 in SR clear BL to 0 after returning from the service call processing Rev 6 00 274 REJ10B0060 0600 RENESAS Section3 Service Calls 3 25 4 Invalidate Instruction Operand Cache vinv_cac ivinv_cac C Language API ER ercd vinv_cac VP invadrl VP invadr2 MODE mode ER ercd ivinv_cac VP invadrl VP invadr2 MODE mode Parameters VP invadr1 R4 Start address of invalidation VP invadr2 R5 End address of invalidation MODE mode R6 Target cache Return Parameters ER ercd RO Normal end E_OK or error code Error Codes E_PAR p Parameter error invadrl gt invadr2 or mode is invalid E_OBJ k Target cache is disabled Function The service call vinv_cac invalidates the cache It is canceled even if the data which has not been written back to memory is in operand cache The target cache are determined by mode Following either can be specified to be mod
238. d for parameter tmout error code E_TMOUT is returned when the tmout time has passed without the wait release conditions being satisfied If tmout TMO_POL 0 is specified the same operation as for service call psnd_mbf will be performed If tmout TMO_FEVR 1 is specified the same operation as for service call snd_mbf will be performed In other words timeout monitoring is not performed If a value larger than 1 is specified for CFG_TICDENO the denominator for time tick cycles the maximum value that can be specified for tmout is H 7fffffff CFG_TICDENO If a value larger than this is specified operation is not guaranteed For detail of time watch method refer to section 2 16 4 2 Time Watch Method Rev 6 00 171 RENESAS REJ10B0060 0600 Section3 Service Calls 3 12 4 Receive Message from Message Buffer rcv_mbf prev_mbf trev_mbf C Language API ER_UINT msgsz rcv_mbf ID mbfid VP msg ER_UINT msgsz prcv_mbf ID mbfid VP msg ER_UINT msgsz trcv_mbf ID mbfid VP msg TMO tmout Parameters ID mbfid R4 Message buffer ID VP msg R5 Start address of the area where the received message is to be returned lt trcv_mbf gt TMO tmout R6 Timeout specification Return Parameters ER_UINT msgsz RO Size of the received message number of bytes a positive value or error code VP msg R5 Start address of the area where the received message is stored Error Codes E_PAR p Parameter error msg is other
239. d statically by the configurator Rev 6 00 139 RENESAS REJ10B0060 0600 Section3 Service Calls 3 9 2 Delete Data Queue del_dtq C Language API ER ercd del_dtq ID dtqid Parameters ID dtqid R4 Return Parameters ER ercd RO Error Codes Data queue ID Normal end E_OK or error code E_ID p Invalid ID number dtqid lt 0 or dtqid gt CFG_MAXDTQID E_NOEXS k Undefined Data queue indicated by dtqid does not exist E_CTX k Context error Called from disabled system state Function The data queue specified by dtqid is deleted No error occurs even if there is a send waiting task or receive waiting task in the data queue specified by dtqid However the WAITING state of the task is cancelled and an error code E_DLT is returned On deletion the free data queue area size increases by an amount given by the following expression Increase in size dtqcnt specified at creation x 4 16 bytes Rev 6 00 140 REJ10B0060 0600 RENESAS Section3 Service Calls 3 9 3 Send Data to Data Queue snd_dtq psnd_dtq ipsnd_dtq tsnd_dtq fsnd_dtq ifsnd_dtq C Language API snd_dtq ID dtqid VP_INT data psnd_dtq ID dtqid VP_INT data ER ercd ER ercd ER ercd ER ercd ER ercd ER ercd Parameters ID VP_INT lt tsnd_dtq gt TMO ipsnd_dtq ID dtqid VP_INT data tsnd_dtq ID dtqid VP_INT data TMO tmout fsnd_dtq ID dtqid VP_INT data ifsnd_dtq ID dtqid VP_INT da
240. d there exists a data send waiting task such a circumstance can occur only when the data queue area capacity is 0 the data of the task at the head of data send waiting queue is received As a result the WAITING state of the data send waiting task is cancelled If there is no data in the data queue and there are also no data send waiting tasks a service call rcv_dtq or trcv_dtq causes the calling task to be linked to a wait queue to wait for message arrival receive waiting queue In the case of a service call prev_dtq the call returns immediately with an E_TMOUT error The receive waiting queue is managed in FIFO order In the case of the service call trev_dtq tmout specifies the wait time If a positive value is specified for the parameter tmout error code E_TMOUT is returned when the timeout period has passed without the wait release conditions being satisfied If tmout TMO_POL 0 is specified the same operation as for the service call prev_dtq will be performed If tmout TMO_FEVR 1 is specified timeout monitoring is not performed In other words the same operation as for service call rev_dtq will be performed When a value larger than 1 is specified for CFG_TICDENO the denominator for time tick cycles the maximum value that can be specified for tmout is H 7fffffff CFG_TICDENO If a value larger than this is specified operation is not guaranteed For detail of time watch method refer to section 2 16 4 2 Time Watch
241. dicated by mpfid already exists E_NOID k No ID available Function Service calls cre_mpf and icre_mpf create a fixed size memory pool with an ID indicated by mpfid using the contents specified by pk_cmpf Service calls acre_mpf and iacre_mpf search for an unused fixed size memory pool ID and creates a fixed size memory pool that has this ID with the contents specified by parameter pk_cmpf The service calls then return the ID as a return parameter The range to search for an undefined fixed size memory pool ID is 1 to CFG_MAXMPFID The queue order waiting to get a memory block as an attribute is specified by mpfatr in the following format table 3 43 mpfatr TA_TFIFO TA_TPRI Table 3 43 Fixed Size Memory Pool Attributes mpfatr mpfatr Code Description TA_TFIFO H 00000000 Task queue waiting to acquire a memory block is managed on a FIFO basis TA_TPRI H 00000001 Task queue waiting to acquire a memory block is managed by priority Rev 6 00 177 RENESAS REJ10B0060 0600 Section3 Service Calls Parameter blkcnt specifies the total number of memory blocks to be created The size of the memory block to be created is specified by blksz and must be a multiple of four When NULL is specified as mpf kernel allocates memory pool from fixed size memory pool area CFG_MPFSZ After the memory pool has been created the free fixed size memory pool area size will decrease by an amount given by the following expres
242. dler icre_alm ER ercd icre_alm ID almid T_CALM pk_calm 116 acre_alm ER_ID almid acre_alm T_CALM pk_calm Create Alarm Handler and Assign iacre_alm ER_ID almid iacre_alm T_CALM pk_calm Alarm Handler ID Automatically 117 del_alm ER ercd del_alm ID almid Delete Alarm Handler 118 sta_alm ER ercd sta_alm ID almid RELTIM almtim Start Alarm Handler ista_alm ER ercd ista_alm ID almid RELTIM almtim 119 stp_alm ER ercd stp_alm ID almid Stop Alarm Handler istp_alm ER ercd istp_alm ID almid 120 ref_alm ER ercd ref_alm ID almid T_RALM pk_ralm Refer to Alarm Handler State iref_alm ER ercd iref_alm ID almid T RALM pk_ralm Rev 6 00 396 REJ10B0060 0600 RENESAS Appendix A Service Call List No Service C Language API Function Call Overrun Handler 121 def_ovr ER ercd def_ovr T_DOVR pk_dovr Define Overrun Handler 122 sta_ovr ER ercd sta_ovr ID tskid OVRTIM ovrtim ista_ovr ER ercd ista_ovr ID tskid OVRTIM ovrtim Start Overrun Handler Operation 123 stp_ovr ER ercd stp_ovr ID tskid istp_ovr ER ercd istp_ovr ID tskid Stop Overrun Handler Operation 124 ref_ovr ER ercd ref_ovr ID tskid T ROVR pk_rovr iref_ovr ER ercd iref_ovr ID tskid T ROVR pk_rovr Refer to Overrun Handler State System Status Management Function 125 rot_rdq ER ercd rot_rdq PRI tskpri Rotate Ready Queue ir
243. e 4 SIZE mplsz VTSZ_MPLMB UINT sctnum The size of management area for variable size memory pool with the VTA_UNFRAGMENT attribute bytes Related Pages e p 290 Table 4 1 in section 4 1 1 Header File J 6 Initial Value of SR in Task Exception Processing Routine V 2 01 Release 00 or Later The initial value of SR in the task exception processing routine is changed as follows Previous version Same value as in the task before initiation V 2 01 H 40000000 J 7 Extension of Maximum Exception Code CFG_MAXVCTNO V 2 01 Release 00 The maximum exception code that can be specified for CFG_MAXVCTNO through the configurator is extended from Oxfe0 to Ox3fe0 Rev 6 00 464 REJ10B0060 0600 RENESAS Appendix J New Functions of HI7750 4 V2 J 8 Handling of TRAPA 16 to 31 V 2 01 Release 00 Trap exception handlers can be defined for these numbers in V 2 01 J 9 Release of Restriction concerning Structure Alignment V 2 01 Release 00 In the previous version there is a restriction about the pack option and pragma pack of the compiler This restriction is not applied to V 2 01 and the following related note is removed from this user s manual The source program which uses the variable of the structure form defined by the kernel should surely specify pack 4 Moreover do not declare the variable of the structure form defined by the kernel as pragma pack 1 For kernel_def c and kernel_cfg c be sure to speci
244. e e TC_FULL H 00000000 Both instruction cache and operand cache e TC_EXCLUDE_IC H 00000001 Exclude instruction cache only operand cache e TC_EXCLUDE_OC H 00000002 Exclude operand cache only instruction cache invadr1 is omitted to the multiple of 32 and invadr2 is revalued to the multiple 1 of 32 1 Invalidate specified range This service call invalidates the cache entry whose logical address is from invadr1 to invadr2 This service call repeats and executes the following instructions from clradr1 to clradr2 e mode TC_FULL ICBI and OCBI e mode TC_EXCLUDE_IC OCBI e mode TC_EXCLUDE_OC ICBI This processing is performed in the state of SR BL 0 and SR I 15 However whenever it processes one entry this service call restores SR at the time of this call That is interruption may be accepted by SR at the time of this call Rev 6 00 275 RENESAS REJ10B0060 0600 Section3 Service Calls In this service call only the fundamental error check indicated in the error code column is performed on invadr1 and invadr2 For example the following addresses should not be contained e P2 and P4 areas e Address corresponding to a physical address in the control area e Address corresponding to a physical address in X Y memory The processing time of this service call is proportional to the size of the appointed domain 2 Invalidate all If 0 is specified to be invadr1 and H ffffffff is specified to be invadr2 all the e
245. e Create the reset vector in one of the following ways 1 When the user creates a reset vector Create the reset vector as shown in figure 4 12 _INIT_SP EQU H FFFAO0O Defines the initial stack pointer value after a reset usually the last address within the internal RAM SECTION C_ResVec DATA LOCATE 0 lt Specifies C_ResVec as the IMPORT _hi cpuasm reset vector section name and allocates the section to address H O _ResVec DATA L hi_cpuasm _INIT_SP Specifies the program DATA L hi_cpuasm _INIT SP address for vector number 0 END power on reset or vector number 2 manual reset as _hi_cpuasm and the stack pointer as INIT SP Figure 4 12 Example of Creating the Reset Vector HI7000 4 Rev 6 00 335 RENESAS REJ10B0060 0600 Section4 Application Program Creation 2 When defining the CPU initialization routine by the configurator Define the CPU initialization routine address and reset stack pointer as an interrupt handler address for interrupt numbers 0 to 3 respectively by the configurator In addition allocate the C_hivct section which is a vector table section created by the configurator to address H O at linkage 4 11 3 Defining CPU Initialization Routines in HI7700 4 and H17750 4 Allocate the CPU initialization routine to reset vector address H a0000000 at linkage 4 12 System Down Routines The function specifications of the system down routine are defined as follows Note
246. e the task A main routine is resumed Rev 6 00 21 RENESAS REJ10B0060 0600 Section2 Kernel 2 8 Semaphore The elements required for task execution are called resources They include the memory shared between tasks and hardware like I O A semaphore is an object and provides exclusive control and a synchronization function by expressing the existence and the number of resources by a counter In this case tasks must be created in order to separate a region of a task that are to be exclusively accessed using wai_sem and sig_sem service calls Usually the number of resources that can be used is the number of resources initially defined The semaphores are controlled by the service calls listed in table 2 8 Table 2 8 Service Calls for Semaphore Control Service Call Name Function cre_sem icre_sem Creates a semaphore acre_sem iacre_sem Creates a semaphore automatically assigns ID del_sem Deletes a semaphore sig_sem isig_sem Releases a resource wai_sem Acquires a resource pol_sem ipol_sem Polls and gets a resource twai_sem Requests resource allocation with timeout ref_sem iref_sem Refers to the semaphore state Semaphores can also be created by the configurator Figure 2 5 shows an example of using semaphore Rev 6 00 22 REJ10B0060 0600 RENESAS Section2 Kernel Time Task A Task B Task C Semaphore count 2 1 cre_sem 2 2 1 TE A i 1 0 3 well Same 4 wai_sem lt WAIT
247. e Extended Service Call def_svc idef_svc 3 21 2 Call Service Call cal_svec ical_svc 3 22 System Configuration Management ds 3 22 1 Define CPU Exception Handler def_exc idef_exC cccccsssssasssconssienronsscsssniansdasovonsnnerencs 246 3 22 2 Define CPU Exception TRAPA Instruction Exception Handler vdef_trp ivdef_trp 3 22 3 Refer to Configuration Information ref_cfg iref_cfg 3 22 4 Refer to Version Information ref_ver iref_ver 3 23 Cache Support Function HI7700 4 for SH 3 and SH3 DSP 3 23 1 Initialize Cache vini_cac ivini_cac 3 23 2 Clear Cache velr_cac ivclr_cac 3 23 3 Flush Cache vfls_cac ivfls_cac 3 23 4 Invalidate Cache vinv_cac ivinv_cac 3 24 Cache Support Function HI7750 4 for SH 4 3 24 1 Initialize Cache vini_cac ivini_cac Rev 6 00 iv REJ10B0060 0600 RENESAS Contents 3 24 2 Clear Operand Cache velr_cac ivelr_cac 3 24 3 Flush Operand Cache vfls_cac ivfls_cac 3 24 4 Invalidate Operand Cache vinv_cac iVINV_CAC eect cnet eee eeeetseeeteeeeeeetaeeteeees 266 3 25 Cache Support Function HI7700 4 for SH4AL DSP without Extended Function HI7750 4 for SH 4A without Extended Function 3 25 1 Initialize Cache vini_cac ivini C90 seiss 3 25 2 Clear Instruction Operand Cache vclr_cac ivclr_cac 3 25 3 Flush Operand Cache vfls_cac ivfls_cac 3 25 4 Invalidate Instruction Operand Cache vinv_cac ivinv_cac 3 26 Cache Support Function HI7700 4
248. e call can also be called from an exception block state SR BL 1 An application calling this service call must be linked with the kernel Refer to 2 18 1 Resetting the CPU and Initiating the Kernel This service call is a function original to the HI7000 4 series Rev 6 00 231 RENESAS REJ10B0060 0600 Section3 Service Calls 3 19 12 System Down vsys_dwn ivsys_dwn C Language API void vsys_dwn W type ER ercd VW inf1 VW inf2 j void ivsys_dwn W type ER ercd VW infl VW inf2 Parameters W type R4 Error type ER ered R5 Error code VW infi R6 System abnormal information 1 VW inf2 R7 System abnormal information 2 Return Parameters Service call vsys_dwn is not returned Function Service call vsys_dwn passes control to the system down routine A value 1 to H 7fffffff corresponding to the error type must be specified for the parameter type Values below 0 are reserved for future expansion The system down routine is also executed when abnormal operation is detected in the kernel Service call vsys_dwn can be called in the CPU locked state and from the CPU exception handler This service call can be called even in the exception block state SR BL 1 in the HI7700 4 and H17750 4 This service call is a function original to the HI7000 4 series Rev 6 00 232 REJ10B0060 0600 RENESAS Section3 Service Calls 3 19 13 Acquire Trace Information vget_tre ivget_trc C Language API ER ercd vge
249. e controlled by the service calls listed in table 2 19 Table 2 19 Service Calls for Alarm Handler Control Service Call Name Function cre_alm icre_alm Creates an alarm handler acre_alm iacre_alm Creates an alarm handler automatically assigns ID del_alm Deletes an alarm handler sta_alm ista_alm Initiates an alarm handler stp_alm istp_alm Stops an alarm handler ref_alm iref_alm Refers to an alarm handler status The alarm handler can also be created by the configurator Figure 2 16 shows an example of using alarm handler Create an alarm Initiate an alarm Initiate an alarm Stop an alarm handler cre_alm handler sta_alm handler sta_alm handler stp_alm f p e c pf ine Initiation time Initiation time Initiated Alarm handler i Alarm handler is not initiated Figure 2 16 Example of Using Alarm Handler Description a An alarm handler is created b The alarm handler operation is initiated by issuing sta_alm c The alarm handler is initiated after the specified initiation time has passed d If sta_alm is issued by specifying another initiation time the alarm handler starts execution again e Since stp_alm is issued before the initiation time has passed the alarm handler is not initiated Rev 6 00 46 REJ10B0060 0600 RENESAS Section2 Kernel 2 16 3 Overrun Handler The overrun handler is a time event handler
250. e entries of instruction cache are cleared This processing is performed in the state of SR BL 1 2 When mode is TC_FULL or TC_EXCLUDE_IC the OCBP instruction is executed for all entries of the memory mapped operand cache to write back the dirty U 1 entries to memory and invalidates V 0 them During this processing the SR value remains the same as when this function is called When no interrupt should be accepted during this function processing mask interrupts and then call this function In the HI7750 4 this service call can be called before the kernel is initiated This service call can be called even in the exception block state BL 1 in SR Therefore the cache can be cleared irrespective of interrupts or exceptions When this service call has been called when BL 1 in SR clear BL to 0 after returning from the service call processing Rev 6 00 283 RENESAS REJ10B0060 0600 Section3 Service Calls 3 26 3 Flush Operand Cache vfls_cac ivfls_cac C Language API ER ercd vfls_cac VP flsadrl VP flsadr2 ER ercd ivfls_cac VP flsadrl VP flsadr2 Parameters VP flsadri R4 Flush start address VP flsadr2 R5 Flush end address Return Parameters ER ercd RO Normal end E_OK or error code Error Codes E_PAR p Parameter error flsadr1l gt flsadr2 E_OBJ k Operand cache is disabled Function This service call flushes the operand cache That is if the operand cache has data which has not been wri
251. e event flag TA_CLR An event flag is cleared at the time of waiting release Rev 6 00 127 RENESAS REJ10B0060 0600 Section3 Service Calls 3 8 1 Create Event Flag cre_flg icre_flg acre_flg iacre_flg Assign Event Flag ID Automatically C Language API ER ercd cre_flg ID flgid T_CFLG pk_cflg j ER ercd icre_flg ID flgid T_CFLG pk_cflg ER_ID flgid acre_flg T_CFLG pk_cflg ER_ID flgid iacre_flg T_CFLG pk_cflg Parameters lt cre_flg icre_flg gt ID flgid R4 T_CFLG pk_cflg R5 lt acre_flg iacre_flg gt T_CFLG pk_cflg R4 Return Parameters lt cre_flg icre_flg gt ER ercd RO lt acre_flg iacre_flg gt ER_ID flgid RO Packet Structure Event flag ID Pointer to the packet where the event flag creation information is stored Pointer to the packet where the event flag creation information is stored Normal end E_OK or error code Created event flag ID a positive value or error code typedef struct t_cflg ATR flgatr 0 4 Event flag attribute FLGPTN iflgptn 4 4 Initial value of event flag T_CFLG Error Codes E_RSATR p Invalid attribute flgatr is invalid E_PAR p Parameter error pk_cflg is other than a multiple of four E_ID p Invalid ID number flgid lt 0 or flgid gt CFG_MAXFLGID E_OBJ k Object status is invalid Event flag indicated by flgid already exists E_NOID k No ID available Rev 6 00 128 REJ10B0060 0600 RENESAS Sectio
252. e following are called operation is not guaranteed e sns_tex e sns_ctx e sns_loc e sns_dsp e sns_dpn e get_tid iget_tid e ras_tex iras_tex e vsta_knl ivsta_knl e vsys_dwn ivsys_dwn CPU exception handlers can also be defined statically by the configurator In order to define a CPU exception handler for a TRAPA instruction the service call vdef_trp or ivdef_trp should be used instead of the service calls def_exc and idef_exc excsr is a member not defined in the pITRON4 0 specification Rev 6 00 247 RENESAS REJ10B0060 0600 Section3 Service Calls 3 22 2 Define CPU Exception TRAPA Instruction Exception Handler vdef_trp ivdef_trp C Language API ER ercd vdef_trp UINT dtrpno T_DTRP pk_dtrp ER ercd ivdef_trp UINT dtrpno T_DTRP pk_dtrp j Parameters UINT dtrpno R4 Trap number T_DTRP pk_dtrp R5 Pointer to the packet where the CPU exception TRAPA instruction exception handler definition information is stored Return Parameters ER ercd RO Normal end E_OK or error code Packet Structure typedef struct t_dtrp ATR trpatr 0 4 CPU exception TRAPA instruction exception handler attribute FP trphdr 4 4 CPU exception TRAPA instruction exception handler address UINT trpsr 8 4 SR at CPU exception TRAPA instruction exception handler initiation T_DTRP Error Codes E_RSATR p Invalid attribute trpatr is invalid E_PAR p Parameter error pk_dtrp is other than a multiple of four or tr
253. e is managed on priority TA_MFIFO Message queue is managed on a FIFO basis TA_MPRI Message queue is managed on priority Note This value is the same as TMAX_MPRI defined in kernel_macro h Rev 6 00 146 REJ10B0060 0600 RENESAS Section3 Service Calls 3 10 1 Create Mailbox cre_mbx icre_mbx acre_mbx iacre_mbx Assign Mailbox ID Automatically C Language API ER ercd ER ercd ER_ID mbxid ER_ID mbxid Parameters lt cre_mbx ID T_CMBX lt acre_mbx T_CMBX Return Parameters lt cre_mbx ER lt acre_mbx cre_mbx ID mbxid T_CMBX pk_cmbx icre_mbx ID mbxid T_CMBX pk_cmbx acre_mbx T_CMBX pk_cmbx iacre_mbx T_CMBX pk_cmbx icre_mbx gt mbxid R4 Mailbox ID pk_cmbx R5 Pointer to the packet where the mailbox creation information is stored iacre_mbx gt pk_cmbx R4 Pointer to the packet where the mailbox creation information is stored icre_mbx gt ercd RO Normal end E_OK or error code iacre_mbx gt ER_ID mbxid RO Created mailbox ID a positive value or error code Packet Structure typedef struct t_cmbx ATR mbxatr 0 4 Mailbox attribute PRI maxmpri 4 2 Maximum value of message priority VP mprihd 8 4 Start address of message queue header with priority T_CMBX Error Codes E_RSATR p Invalid attribute mbxatr is invalid E_PAR p Parameter error pk_cmbx is other than a multiple of four maxmpri lt 0 or maxmpri gt CFG_MAXMSGPRI E_ID p
254. e task state is stored Packet Structure typedef struct t_rtst STAT tskstat 0 4 Task state STAT tskwait 4 4 Wait cause T_RTST Error Codes E_PAR p Parameter error pk_rtsk is other than a multiple of four E_ID p Invalid ID number tskid lt 0 tskid gt CFG_MAXTSKID or tskid TSK_SELF 0 is specified in a non task context E_NOEXS k Undefined Task indicated by tskid does not exist Function Each service call refers to the state and the case of WAITING state of the task indicated by the parameter tskid and then returns it to the area indicated by parameter pk_rtst By specifying tskid TSK_SELF 0 the current task can be specified The following values are returned to the area indicated by pk_rtst Note that data with an asterisk is invalid when the task is in the DORMANT state If referenced information is related to a function that is not installed the referenced information will be undefined Rev 6 00 93 RENESAS REJ10B0060 0600 Section3 Service Calls tskstat Indicates the current task state The following values are returned Table 3 13 Current Task State tskstat tskstat Code Description TTS_RUN H 00000001 RUNNING state TTS_RDY H 00000002 READY state TTS_WAI H 00000004 WAITING state TTS_SUS H 00000008 SUSPENDED state TTS_WAS H 0000000c WAITING SUSPENDED state TTS_DMT H 00000010 DORMANT state TTS_STK H 40000000 Shared stack WAITING state tskwait
255. e version 6 0C or later project Configurator Windows 98 Windows Millennium Edition Windows Me WindowsNT 4 0 Windows 2000 and Windows XP HI7700 4 Kernel All SuperH microcomputers incorporating SH 3 SH3 DSP or SH4AL DSP Sample program Some SuperH microcomputers incorporating SH 3 SH3 DSP or SH4AL DSP Sample HEW HEW version 1 2 or later SuperH RISC engine C C workspace and compiler package version 6 0C or later project Configurator Windows 98 Windows Millennium Edition Windows Me WindowsNT 4 0 Windows 2000 and Windows XP HI7750 4 Kernel All SuperH microcomputers incorporating SH 4 or SH 4A Sample program Some SuperH microcomputers incorporating SH 4 or SH 4A Sample HEW HEW version 1 2 or later SuperH RISC engine C C workspace and compiler package version 6 0C or later project Configurator Windows 98 Windows Millennium Edition Windows Me WindowsNT 4 0 Windows 2000 and Windows XP 1 4 Installation Refer to release notes attached to the product Rev 6 00 3 RENESAS REJ10B0060 0600 Section1 Introduction 1 5 Target Product of This Manual e HI7000 4 V 2 02 Release 00 or later e HI7700 4 V 2 02 Release 00 or later e HI7750 4 V 2 02 Release 00 or later Rev 6 00 4 REJ10B0060 0600 RENESAS Section 2 Kernel 2 1 Overview The kernel which is the nucleus of the operating system enables realtime multitasking It has three major roles e Resp
256. ease 02 or earlier HI7700 4 V 1 03 Release 02 or earlier and HI7750 4 V 1 1 00 or earlier versions is applied Selecting CFG_NEWMPL improves the following 1 Acquisition and return of memory blocks are faster when a large number of memory blocks are used in the memory pool 2 The VTA_LUNFRAGMENT attribute can be used to reduce fragmentation of free space When CFG_NEWMPL is selected note that new members are added to the T CMPL structure in comparison with the conventional method For details refer to section 3 14 1 Create Variable Size Memory Pool 4 Variable size memory pool creation BA Specifiable contents are the same as those of the cre_mpl service call 19 Cyclic Handler Page 1 Maximum cyclic handler ID CFG_MAXCYCID The range of usable cyclic handler IDs is 1 to CFG_MAXCYCID The maximum value specifiable is 14 When no cyclic handler is used specify 0 When a value more than 1 is specified the cre_cyc service call must be embedded Cyclic handler creation BA Specifiable contents are the same as those of the cre_cyc service call 20 Alarm Handler Page 1 Maximum alarm handler ID CFG_MAXALMID The range of usable alarm handler IDs is 1 to CPG_MAXALMID The maximum value specifiable is 15 When no alarm handler is used specify 0 When a value more than 1 is specified the cre_alm service call must be embedded Alarm handler creation BA Specifiable cont
257. ed Projects cfe Show entries for i i E C source file Defines C source file Datine E Assembly source fi _kernelponsp Address 040100000 Linkage symbol file _kernel_mansp Address 00100000 Remove 5 _kernel_sysmt Address 080010000 source file C source file Assembly source fi Linkage symbol file I Use entry point Prelinker control mix hispuasm auto gt source file hi cpuasm puto C source file Options Link Library C Assembly source fi entry _hi_cpuasm define _kernel_pon_sp A Posen fi taal nace PEAT TNN Aen A j define _kernel_man_sp 04C1 define _kernel_sysmt Linkage symbol file 080010000 noprelink nomessage list GONFIGDIRI S Figure 5 16 Optimized Linkage Editor Input Category Defines The following symbol address is defined e __kernel_sysmt Kernel environment information As this kernel environment information is included in the kernel environment load module cfg the kernel environment information allocation address must therefore be forcibly defined __kernel_sysmt is the start address of the C_hisysmt section in the kernel environment side configuration file kernel_cfg c When creating the kernel environment side load module the C_hisysmt section must be allocated to the address defined here In the sample file 2nnn_cpuasm src for the HI7700 4 and the HI7750 4 the following symbols are externally referred to so define them here
258. ed as an interrupt function by using pragma interrupt statement Specify the following items a sp Switching stack Specify the variable defined in 2 when the stack is switched b tn Return by TRAPA For interrupt handlers with priority levels equal to or lower than the kernel interrupt mask level CFG_KNLMSKLVL tn must be specified For details see table 4 12 c resbank Restore bank register When the SH 2A or SH2A FPU is in use and register banks are used with interrupts resbank must be specified For details see table 4 12 4 Write the interrupt handler as a void type function Rev 6 00 313 RENESAS REJ10B0060 0600 Section4 Application Program Creation Table 4 12 tn and resbank HI7000 4 Usage of Register CFG_REGBANK Banks Interrupt Level tn resbank NOBANK or Higher than None None NOTUSE CFG_KNLMSKLVL Equal to or lower than tn 25 or CFG_KNLMSKLVL tn 26 ALL or SELECT Interrupt Higher than None None sources CFG_KNLMSKLVL with which register Equal to or lower than tn 26 banks are CFG_KNLMSKLVL used Interrupt Higher than None resbank sources CFG_KNLMSKLVL with which z 7 register Equal to or lower than tn 25 banks are CFG_KNLMSKLVL not used Notes 1 Register banks are never used with the NMI and UBC interrupts Register banks are used with all other interrupt sources when ALL has been selected for CFG_REGBANK When SELECT has be
259. eeded the upper limit processor time the overrun handler is terminated In this case the overrun handler is not initiated even if the upper limit processor time has been exceeded Rev 6 00 47 RENESAS REJ10B0060 0600 Section2 Kernel 2 16 4 Notes on Time Management 1 Drawbacks due to the repeated use The following is performed when a timer interrupt occurs System clock is updated All alarm handlers that reached the initiation time are initiated and executed All cyclic handlers that reached the cycle time are initiated and executed ae fF PS The overrun handler is initiated and executed when the total processor time used by the task has reached the specified upper limit processor time e Timeout processing is performed after service calls such as tslp_tsk with timeout function have been issued and the specified timeout time has elapsed The processes from a to e are performed with the timer interrupt level masked Among these processes b c and e may overlap for multiple tasks and handlers In that case the processing time of the kernel becomes very long and results in the following defects e Delay of the response to interrupts e Delay of system clocks To avoid these problems the following steps must be taken e The time event handler processing time must be as short as possible e The time event handler cycle and the timeout value specified by the timeout service call must be set to as large a value a
260. efined Initialize DSR to an appropriate value before starting DSP operation For the initial value refer to the hardware manual of the target processor DSR must be initialized once in each program shown in the above table before DSP operation The following shows an example of DSR initialization in a task include kernel h pragma inline _asm SetDSR Inline assembler function for DSR setting static void SetDSR UW dsr lds r4 dsr void task VP_INT exinf SetDSR 0 Initializes DSR DSP operation Rev 6 00 337 RENESAS REJ10B0060 0600 Section4 Application Program Creation 4 13 2 Using DSP in Handlers To use the DSP in the following programs the contents of the DSP registers must be saved and restored in the process shown in figure 4 13 In addition at compilation the code asmcode option must be specified by the object format specification option Normal interrupt handlers Direct interrupt handlers HI7000 4 CPU exception handlers Time event handlers Initialization routines Timer interrupt routines When using DSP standby control function in HI7700 4 refer to appendix F 3 Module Standby State when Initiating Programs Rev 6 00 338 REJ10B0060 0600 RENESAS Section4 Application Program Creation include kernel h include shdsp h pragma inline _asm SetDSR static void SetDSR UW dsr lds r4 dsr void HandlerMain VP_INT exin
261. el_cfg c CPU vector table HI7000 4 only B_hivet Static stack area B_histstk Dynamic stack area B_hidystk Interrupt handler and time event handler stack B_hiirqstk area Memory pool area B_himpl DX target trace buffer area B_hitrcbuf Memory pool management table B_hicfg DX emulator trace tool trace area B_hitrceml Memory pool management table B_hidef kernel_def c Work area used by application Determined by user Determined by user Note When a fixed size memory pool is created while CFG_MPFMANAGE is selected through the configurator or when a variable size memory pool with the VTA_UNFRAGMENT attribute is created while CFG_NEWMPL is selected through the configurator For the size of each section refer to the compile listing Kernel Work Area Section B_hiwrk B_hidef B_hicfg Used for kernel operation contains the task control block TCB message buffer area and kernel stack area The size of the kernel work area is determined according to object maximum IDs such as CFG_MAXTSKID or CFG_DTQSZ and CFG_MBFSZ CPU Vector Area Section B_hivct The CPU vector table is created in this section when CFG_VCTRAM has been selected Static Stack Area Section B_histstk Static stack area statically defined and allocated by the configurator Dynamic Stack Area Section B_hidystk Task stack area dynamically allocated when a task is created The size of the dynamic stack area is determined according t
262. em is other than a multiple of four maxsem 0 maxsem gt H ffff or isemcnt gt maxsem Invalid ID number semid lt 0 or semid gt CFG MAXSEMID Object status is invalid Semaphore indicated by semid already exists No ID available Rev 6 00 119 RENESAS REJ10B0060 0600 Section3 Service Calls Function Service calls cre_sem and icre_sem create a semaphore with an ID indicated by semid using the contents specified by the parameter pk_csem The service calls acre_sem and iacre_sem search for an unused semaphore ID create a semaphore that has this ID with the contents specified by the parameter pk_csem and return the ID as a return parameter The range for searching for an unused semaphore ID is 1 to CFG_MAXSEMID The parameter sematr is specified in the following format See table 3 24 for details sematr TA_TFIFO TA_TPRI Table 3 24 Event Attributes sematr sematr Code Description TA_TFIFO H 00000000 Task wait queue is managed on a FIFO basis TA_TPRI H 00000001 Task wait queue is managed on priority The parameter isement specifies the initial value of the semaphore to be created It can range from 0 to maxsem The parameter maxsem specifies the maximum number of resources of the semaphore to be created It can range from 1 to 65535 A semaphore can also be created statically by the configurator Rev 6 00 120 REJ10B0060 0600 RENESAS Section3 Service Calls 3 7 2 Delete Semaphore
263. en pk_dinh NULL 0 is specified the definition of inhno is cancelled inhsr is a member not defined in the pITRON4 0 specification Rev 6 00 239 RENESAS REJ10B0060 0600 Section3 Service Calls 3 20 2 Change Interrupt Mask chg_ims ichg_ims C Language API ER ercd chg_ims IMASK imask ER ercd ichg_ims IMASK imask Parameters IMASK imask R4 Interrupt mask value Return Parameters ER ercd RO Normal end E_OK or error code Error Codes E_PAR p Parameter error A value other than SR_IMS00 to SR_IMS15 was specified for imask Function Each service call changes the current interrupt mask to the level specified by imask The imask can be specified as follows e SR_IMSnn H 0000000m Changes interrupt mask level to nn nn Character string indicating two digit decimal number from 0 to 15 00 01 02 15 m nn converted to hexadecimal number Use the service calls when changing the interrupt mask level in the following cases The SR can be directly changed when changing the interrupt mask level in cases other than below 1 When the interrupt mask level is changed from level 0 to a level other than 0 in a task context 2 When the interrupt mask level is returned to 0 after the above case Otherwise normal system operation cannot be guaranteed Note that service calls must not be called while the interrupt mask level is made higher than the kernel interrupt mask level CFG_KNLMSKLVL unless t
264. en selected for CFG_REGBANK register banks are only used with those sources having interrupt levels for which the corresponding CFG_BANKLVL has been selected Otherwise register banks are not used with interrupt sources for which this is not the case 2 The operation is the same in both cases Rev 6 00 314 REJ10B0060 0600 RENESAS Section4 Application Program Creation 2 Rules for Using Registers in a Direct Interrupt Handler Table 4 13 shows rules on using registers in a direct interrupt handler and figure 4 7 shows an example of a direct interrupt handler written in assembly language Table 4 13 Rules for Using Registers in a Direct Interrupt Handler H1I7000 4 End Use Conditions No Registers x Initial Value 1 PC V Interrupt handler start address 2 SR V IMASK Interrupt level Other bits Same as before interrupt 3 ROto R14 MACH V vy MACL GBR Undefined 4 R15 JV V R15 points to the stack area for the interrupted program Interrupts other than NMI When an interrupt occurs the stack used by the task prior to an interrupt must be switched to the interrupt handler specific stack to avoid task stack overflow Otherwise the task stack may overflow Direct interrupt handlers of the same interrupt level can share that stack since such interrupt handlers do not use the stack simultaneously When the stack is shared by direct interrupt handlers of the same interrupt level the stack s
265. ending a message is managed on priority Rev 6 00 165 RENESAS REJ10B0060 0600 Section3 Service Calls 3 12 1 Create Message Buffer cre_mbf icre_mbf acre_mbf iacre_mbf Assign Message Buffer ID Automatically C Language API ER ercd ER ercd ER_ID mbfid ER_ID mbfid cre_mbf ID mbfid T_CMBF pk_cmbf icre_mbf ID mbfid T_CMBF pk_cmbf acre_mbf T_CMBF pk_cmbf iacre_mbf T_CMBF pk_cmbf Parameters lt cre_mbf icre_mbf gt ID mbfid R4 Message buffer ID T_CMBF pk_cmbf R5 Pointer to the packet where the message buffer creation information is stored lt acre_mbf iacre_mbf gt T_CMBF pk_cmbf R4 Pointer to the packet where the message buffer creation information is stored Return Parameters lt cre_mbf icre_mbf gt ER ercd RO Normal end E_OK or error code lt acre_mbf iacre_mbf gt ER_ID mbfid RO Created message buffer ID a positive value or error code Packet Structure typedef struct t_cmbf ATR mbfatr 0 4 Message buffer attribute UINT maxmsz 4 4 Maximum message size Number of bytes SIZE mbfsz 8 4 Message buffer size Number of bytes VP mbf 12 4 Start address of message buffer area T_CMBF Error Codes E_NOMEM k Insufficient memory Message buffer area cannot be allocated in the memory E_RSATR p Invalid attribute mbfatr is invalid E_PAR p Parameter error pk_cmbf is other than a multiple of four mbfsz is other than a multiple of four maxmsz 0 maxmsz 2
266. endix D Timer Driver The following operations are automatically performed by setting the time management function page by the configurator _kernel_tmrini is defined as the kernel initialization routine isig_tim processing module of the kernel is defined as the timer interrupt handler 2 Create a timer driver Here the following two C language functions are created These function names are fixed Timer initialization routine _kernel_tmrini Timer interrupt routine _kernel_tmrint The timer initialization routine is created as an initialization routine For details refer to section 4 10 Time Event Handlers and Initialization Routine In the timer initialization routine initialize the timer counter registers according to the TIC_NUME and TIC_DENO as defined in kernel_macro h and specify timer interrupt level according to TIM_LVL as defined in kernel_macro h When a timer interrupt occurs the isig_tim processing module of the kernel is initiated as an interrupt handler The isig_tim processing module then calls the timer interrupt routine _kernel_tmrint In the timer interrupt routine _kernel_tmrint clear the interrupt factor flag The timer interrupt routine can be defined as a normal C language function as shown in figure D 1 The timer interrupt processing routine operates as a part of the interrupt handler include kernel h void _kernel_ tmrint void Function name is fixed
267. ent Flag with Timeout Rev 6 00 390 REJ10B0060 0600 RENESAS Appendix A Service Call List No Service C Language API Function Call Task Exception Management Function 30 def_tex ER ercd def_tex ID tskid T_DTEX pk_dtex Define Task Exception Processing idef_tex ER ercd idef_tex ID tskid T_DTEX pk_dtex Routine 31 ras_tex ER ercd ras_tex ID tskid TEXPTN rasptn Request Task Exception Processing iras_tex ER ercd iras_tex ID tskid TEXPTN rasptn 32 dis_tex ER ercd dis_tex void Disable Task Exception Processing 33 ena_tex ER ercd ena_tex void Enable Task Exception Processing 34 sns_tex BOOL state sns_tex void Refer to Task Exception Processing Disabled State 35 ref_tex ER ercd ref_tex ID tskid T_RTEX pk_rtex Refer to Task Exception Processing iref_tex ER ercd iref_tex ID tskid T_ RTEX pk_rtex State Synchronization and Communication Function Semaphore 36 cre_sem ER ercd cre_sem ID semid T CSEM pk_csem icre_sem ER ercd icre_sem ID semid T CSEM pk_csem Create Semaphore 37 acre_sem ER_ID semid acre_sem T_CSEM pk_csem iacre_sem ER_ID semid iacre_sem T_CSEM pk_csem Create Semaphore and Assign Semaphore ID Automatically 38 del_sem ER ercd del_sem ID semid Delete Semaphore 39 sig sem ERercd sig_sem ID semid isig_sem ER ercd isig_sem
268. ents are the same as those of the cre_alm service call Refer to the service call description in section 3 21 Overrun Handler Page 1 Overrun handler definition B Specifiable contents are the same as those of the def_ovr service call When defining this item the def_ovr service call must be embedded Rev 6 00 363 RENESAS REJ10B0060 0600 Section5 Configuration Table 5 5 Configurator Setting Items cont 22 Extended Service Call Page 1 Maximum function code of extended service call CFG_MAXSVCCD The range of usable function codes is 1 to CPG_MAXSVCCD The maximum value specifiable is 1023 When no extended service call is used specify 0 When a value more than 1 is specified the def_svc service call must be embedded 2 Extended service call creation B Specifiable contents are the same as those of the def_svc service call 5 5 When Optimized Timer Driver is Used HI7700 4 Refer to Appendix E Optimized Timer Driver HI7700 4 5 6 When DSP Standby Control Function is Used HI7700 4 Refer to Appendix F DSP Standby Control 5 7 When Cache Support Function is Used on SH4AL DSP HI7700 4 or SH 4A HI7750 4 In kernel_cfg_cac_set h define the size of the instruction cache and operand cache built in the target microcomputer When the on chip cache has a 2 way structure specify the actual cache size x 2 When the on chip cache has a 4 way structure and it is used in 2 w
269. eption handler is the same as before CPU exception The initial FPSCR value of the other handlers is undefined When these handlers perform floating point calculation FPSCR must be initialized as shown in G 4 3 Handling by the Compiler at the start of the entry function of these handlers The following explains how to guarantee and initialize the registers Rev 6 00 438 REJ10B0060 0600 RENESAS Appendix G Notes on FPU of SH2A FPU SH 4 SH4A G 2 2 SH 4 SH 4A The HI7750 4 provides the following macros for the above operations These macros are defined in sh4fpu h The code asmcode compiler option must be specified because these macros use in line assemble function 1 void IniFPU_LONEBANK T_FPU_ONEBANK pk_save UW ini_fpscr When only the current FPU register bank is used this macro should be used at the start of the handler function This macro saves the current FPU bank registers to the area pointed by pk_save and initializes FPSCR to ini_fpscr 2 void EndFPU_ONEBANK T_FPU_ONEBANK pk_save When only the current FPU register bank is used this macro should be used at the end of the handler function This macro restores the current FPU bank register contents from the area pointed by pk_save 3 void IniFPU_ALLBANK T_FPU_ALLBANK pk_save UW ini_fpscr When both FPU register banks are used this macro should be used at the top of the handler function This macro saves both FPU bank registers to the area poi
270. er Dependencies Generate Makefile Figure 5 14 Build Execution Rev 6 00 379 RENESAS REJ10B0060 0600 Section5 Configuration 5 13 Build for Separate Linkage Kernel Side def 5 13 1 Adding Files to a Project Table 5 12 lists the source program files to be added to the project The sample project file already contains the files shown in this table Table 5 12 Source Program Files to be Added to the Project def File Name Description Notes kernel_def c Kernel side configuration file Mandatory nnnn_sysdwn c System down routine Mandatory nnnn_expent sre Interrupt or exception entry exit routine Mandatory nnnn_intdwn src Undefined interrupt detailed information Mandatory acquisition process kernel_exp_src Interrupt or exception processing routine Mandatory nnnn_cpuasm src g CPU initialization routine Mandatory for nnnn_cpuini c executing by reset nnnn_tmrdrv c Standard timer driver When using optimized timer driver in HI7700 4 do not include this Application files Notes 1 These files are in the shnnnn src or shnnnn project src folder 2 Only in the HI7700 4 and HI7750 4 3 Only in the HI7000 4 5 13 2 Defining Endian HI7700 4 and H1I7750 4 The endian in the supplied sample project is set by selecting it in the build configuration Select the build configuration as shown in figure 5 10 Rev 6 00 380 REJ10B0060 0600 RENESAS
271. ermined by mode will be cleared In this case this service call is processed as follows 1 When mode is TC_FULL or TC_EXCLUDE_OC it is setting 1 as the ICI bit of a CCR register and all the entries of instruction cache are cleared This processing is performed in the state of SR BL 1 2 When mode is TC_FULL or TC_EXCLUDE_IC all entries of operand cache are cleared after writing back the dirty entry of operand cache to memory This processing is performed in the state of SR BL 1 However whenever it processes one entry this service call restores SR at the time of this call That is interruption may be accepted by SR at the time of this call In the HI7750 4 this service call can be called before the kernel is initiated This service call can be called even in the exception block state BL 1 in SR Therefore the cache can be cleared irrespective of interrupts or exceptions When this service call has been called when BL in SR clear BL to 0 after returning from the service call processing Rev 6 00 272 REJ10B0060 0600 RENESAS Section3 Service Calls 3 25 3 Flush Operand Cache vfls_cac ivfls_cac C Language API ER ercd vfls_cac VP flsadri VP flsadr2 ER ercd ivfls_cac VP flsadri VP flsadr2 Parameters VP flsadri1 R4 Flush start address VP flsadr2 R5 Flush end address Return Parameters ER ercd RO Normal end E_OK or error code Error Codes E_PAR p Parameter error flsadri gt flsadr2
272. ers ID mtxid Return Parameters ER ercd Error Codes E_ID p Invali E_NOEXS k Undefi E_ILUSE k Illega highes E_CTX k Contex Function R4 Mutex ID RO Normal end E_OK or error code d ID mtxid lt 0 mtxid gt CFG_MAXMTXID ned Mutex indicated by mtxid does not exist 1 use of service call Duplicate lock of mutex or t priority is exceeded t error Called from disabled system state The lock for the mutex specified by mtxid is released If there are tasks waiting for the lock for the specified mutex the WAITING state for the task at the head of the mutex wait queue is released and the task whose WAITING state has been released is put into a state which locks the mutex At this time the priority of t mutex If there are no tasks waiting for The simplified priority ceiling protocol he locking task is raised to the ceiling priority of the the mutex the mutex is put into the unlocked state is used for the TA_CEILING attribute of this kernel That is only when all the mutex that are locked by the task are unlocked the present priority of the task is returned to a base priority When the task still locks other mutex after this call the present priority does not change in this service call Rev 6 00 162 REJ10B0060 0600 RENESAS Section3 Service Calls 3 11 5 Refer to Mutex State ref_mtx C Language API ER ercd ref_mtx ID mtxid T_RMTX pk_rmtx Parameters ID mtxid R4 Mutex I
273. ervice Call List No Service Call C Language API Function Extended Synchronization and Communication Function Mutex 72 cre_mtx ER ercd cre_mtx ID mtxid T_CMTX pk_cmtx Create Mutex 73 acre mtx ER_ID mtxid acre_mtx T_CMTX pk_cmtx Create Mutex and Assign Mutex ID Automatically 74 del_mtx ER ercd del_mtx ID mtxid Delete Mutex 75 loc_mtx ER ercd loc_mtx ID mtxid Lock Mutex Resource 76 ploc mtx ER ercd ploc_mtx ID mtxid Poll and Lock Mutex Resource 77 tloc_mtx ER ercd tloc_mtx ID mtxid TMO tmout Lock Mutex Resource with Timeout 78 unl_mtx ER ercd unl_mtx ID mtxid Unlock Mutex Resource 79 ref mtx ER ercd ref _mtx ID mtxid T_RMTX pk_rmtx Refer to Mutex State Message Buffer 80 cre_mbf ER ercd cre_mbf ID mbfid T_CMBF pk_cmbf Create Message Buffer icre_mbf ER ercd icre_mbf ID mbfid T_CMBF pk_cmbf 81 acre_mbf ER_ID mbfid acre_mbf T_CMBF pk_cmbf Create Message Buffer and Assign iacre_mbf ER_ID mbfid iacre_mbf T_CMBF pk_cmbf Message Buffer ID Automatically 82 del_mbf ER ercd del_mbf ID mbfid Delete Message Buffer 83 snd_mbf ER ercd snd_mbf ID mbfid VP msg UINT msgsz Send Message to Message Buffer 84 psnd_mbf ER ercd psnd_mbf ID mbfid VP msg UINT msgsz Poll and Send Message to ipsnd_mbf ER ercd ipsnd_mbf ID mbfid VP msg UINT msgsz Message Buffer 85 tsnd_mbf ER er
274. ervice call releases a task from the WAITING state after the task was assigned to the WAITING state by calling the service call slp_tsk or tslp_tsk If the target task did not enter the WAITING state by calling the service call slp_tsk or tslp_tsk up to 15 requests to wake up a task can be stored By specifying tskid TSK_SELF 0 the current task can be specified Rev 6 00 99 RENESAS REJ10B0060 0600 Section3 Service Calls 3 5 3 Cancel Wakeup Task can_wup ican_wup C Language API ER_UINT wupent can_wup ID tskid ER_UINT wupent ican_wup ID tskid Parameters ID tskid R4 Task ID Return Parameters ER_UINT wupcent RO Number of queued task wake up requests 0 or a positive value or error code Error Codes E_ID p Out of ID range tskid lt 0 tskid gt CFG _MAXTSKID or tskid TSK_SELF 0 is specified in a non task context E_NOEXS k Undefined Task indicated by tskid is not created E_OBJ k Object status is invalid Task indicated by tskid is in the DORMANT state Function Each service call calculates the number of wake up requests queued for the task specified by tskid then returns the result as a return parameter and invalidate all of those requests By specifying tskid TSK_SELF 0 the current task can be specified Rev 6 00 100 REJ10B0060 0600 RENESAS Section3 Service Calls 3 5 4 Release WAITING State Forcibly rel_wai irel_wai C Language API ER ercd rel_wai ID tskid ER erc
275. es on Using Registers in a CPU Exception Handler H1I7700 4 No Registers End Use Conditions 1 2 Initial Value 1 PC V CPU exception handler start address 2 SR V i IMASK bits Same as before exception Other bits The value which is specified at the definition 3 RO_BANKO to R7_BANKO V Undefined 4 R8to R14 MACH MACL V Same as before CPU exception GBR 5 R15 V V R15 points to the stack area for the program which generates exception As a CPU exception handler may re enter the CPU exception handler uses the stack used by the previous program A CPU exception handler does not use its own stack PR V V Undefined SH3 DSP SH4AL DSP V V Same as before CPU exception DSR RS RE MOD AO AOG A1 A1G MO M1 XO X1 YO Y1 Notes 1 These registers can be used Note that some register contents cannot be guaranteed after service calls For details refer to section 3 2 3 Guarantee of Register Contents after Issuing Service Call 2 When execution is returned from the entry function RTS instruction the contents of these registers must be the same as the value at initiation 3 DSP CL must be 1 when at least one of CFG_DSP and CFG_CACLOC is checked MD must be 1 Rev 6 00 325 RENESAS REJ10B0060 0600 Section4 Application Program Creation Table 4 17 Rules on Using Registers in a CPU Exception Handler H1I7750 4 End Use Conditions No Re
276. esenes T Eh D Appendix B Error List cssssssssssssscsscsssssscsssssscescesscsscsscsssssssescessesssssssessessessseeee AOL B 1 Service Call Error Code List vecsie nenene eeir eio Eo ran eao ra iani 401 B 2 Information during System Down cece cee cee cee ceeeeeeeeseeseeseeseeteeeeeseeeeeted 402 B 3 Error during Comping ss svccsevccsvacccsssecesvanscasssceasnsseassuseovanceoveetssnsivedsestssseissssevteare es 403 B 3 1 Error when Files are for a Different HI7000 4 Series 403 B 3 2 Errors to Do with the Optimized Timer Driver HI7700 4 403 C 1 C 2 C3 C4 C5 C 6 B 3 3 Errors to Do with the DSP Standby Control Function HI7700 4 Appendix C Calculation of Work Area Size 0405 Work ALC aS cc secccotscccsancccorncccatneccensncecvansisviwesndentissiwesexentsssrsesnsputessasednstbesssanesnsntessenves 405 Stack TYPES isise oai T E ASEE ER EE EAR 406 Stack Size Calculation Procedure serccseiiecvciicciesiccisdinritiseses iseis sieis 407 Calculation of Stack Size for Each Function sssesesessesesesessrsnersrsrsnernrernrnersrsrnene 408 Stack Size Considering Programming Nesting 409 Task Stacks visseovssssencsvsoussssossevsoscsssovdscssncsteved C 6 1 Stack Size Used by Each Task A C62 Stack Area ACquisitiOnscscsac cccuastiiestinsegcen tttecneesbienssdiangastesseroeosadeanssadongasccsscesesssaacesteess Interrupt Handler Stacks icme satire ne e Eaa O vae EAE EEEE VEEL EEEE EEEE ES SETENE SiE C
277. esult only when all mutexes locking the task are removed the task priority is returned to base priority The task locked by the deleted mutex is not notified that the mutex has been deleted If an attempt is later made to release the mutex lock an error is returned Rev 6 00 159 RENESAS REJ10B0060 0600 Section3 Service Calls 3 11 3 Lock Mutex loc_mtx ploc_mtx tloc_mtx C Language API ER ercd loc_mtx ID mtxid ER ercd ploc_mtx ID mtxid ER ercd tloc_mtx ID mtxid TMO tmout Parameters ID mtxid R4 Mutex ID lt tloc_mtx gt TMO tmout R5 Timeout specification Return Parameters ER ercd RO Normal end E_OK or error code Error Codes E_PAR p Parameter error tmout lt 2 E_ID p Invalid ID mtxid lt 0 mtxid gt CFG _MAXMTXID E_NOEXS k Undefined Mutex indicated by mtxid does not exist E_ILUSE k Illegal use of service call The mutex specified by mtxid is already locked by the calling task or the base priority of the calling task is less than the ceiling priority of the target mutex E_CTX k Context error Called from disabled system state E_DLT k Waiting object deleted Mutex indicated by mtxid has been deleted in the WAITING state E_RLWAI k The WAITING state was forcibly cancelled rel_wai service call was called in the WAITING state E_TMOUT k Polling failed or timeout Function Service calls loc_mtx ploc_mtx and tloc_mtx lock the mutex specified by parameter
278. eue ID ID maxmbxid 10 2 Maximum mailbox ID ID maxmtxid 12 2 Maximum mutex ID ID maxmbfid 14 2 Maximum message buffer ID ID maxmplid 16 2 Maximum variable size memory pool ID ID maxmpfid 18 2 Maximum fixed size memory pool ID ID maxcycid 20 2 Maximum cyclic handler ID ID maxalmid 22 2 Maximum alarm handler ID ID maxs_fncd 24 4 Maximum function code of extended service call T_RCFG Error Codes E_PAR p Parameter error pk_rcfg is other than a multiple of four Function Each service call returns the system configuration information to the area indicated by pk_rcfg The following parameters are returned to the packet specified by pk_rcfg table 3 71 The name enclosed in parentheses is the corresponding items to be set in the configurator Rev 6 00 250 REJ10B0060 0600 RENESAS Section3 Service Calls Table 3 71 Parameter to Return to Packet Specified by pk_rcfg Parameter Description maxtskid Returns the maximum task ID CFG_MAXTSKID ststkid Returns the maximum task ID CFG_STSTKID using static stack maxsemid Returns the maximum semaphore ID CFG_MAXSEMID maxflgid Returns the maximum event flag ID CFG_MAXFLGID maxdtqid Returns the maximum data queue ID CFG_MAXDTQID maxmbxid Returns the maximum mailbox ID CFG_MAXMBXID maxmixid Returns the maximum mutex ID CFG_MAXMTXID maxmbfid Returns the maximum message buffer ID CFG_MAXMBFID maxmplid Returns the maximum va
279. ext that differs from the above description However in special cases for example when a service call that shifts to the WAITING state is called from non task context an E_CTX error is returned 2 Dispatch disabled enabled State All service calls can be called from dispatch enabled state Some service calls that shift to WAITING state cannot be called from dispatch disabled state When those service calls are called from dispatch disabled state an E_CTX error is returned 3 CPU locked unlocked State All service calls can be called from the CPU unlocked state Service calls that can be called from the CPU locked state are listed below Normal system operation cannot be guaranteed when service calls other than these are called from the CPU locked state When service calls that shift to the WAITING state are called an E_CTX error is returned ext_tsk exd_tsk sns_tex loc_cpu iloc_cpu unl_cpu iunl_cpu sns_ctx sns_loc sns_dsp sns_dpn vsta_knl ivsta_knl vsys_dwn ivsys_dwn Rev 6 00 70 REJ10B0060 0600 RENESAS Section3 Service Calls 4 CPU Exception Handler Service calls that can be called from the CPU exception handler are listed below Normal system operation cannot be guaranteed when service calls other than these are called from the CPU exception handler When service calls that shift to the WAITING state are called an E_CTX error is returned sns_tex sns_c
280. f Handler processing void Handler VP_INT exinf T_DSP area IniDSP amp area SetDSR 0 HandlerMain exinf EndDSP amp area Includes header file shdsp h Inline assembler function for DSR setting Handler main routine lt In the handler start function writes only the process shown in this figure Writes the handler main process in HandlerMain Defines the area to save the contents of the DSP registers Saves the contents of the DSP registers Initializes DSR Calls HandlerMain which performs the main process Restores the contents of the DSP registers Figure 4 13 Example of a C Language Handler Using the DSP RENESAS Rev 6 00 339 REJ10B0060 0600 Section4 Application Program Creation Rev 6 00 340 REJ10B0060 0600 RENESAS Section 5 Configuration 5 1 Read First Before creating a system please read and fully understand this section The following tools are used for practical configuration e The configurator that comes with this product e HEW The description in this section is provided on the assumption that the user has already mastered HEW For information about HEW refer to the HEW manual or online help For information about the configurator operation refer to section 5 4 Configurator or online help 5 1 1 Whole Linkage and Separate Linkage To create load modules for the system the following operations are necessary
281. f a kernel load module is called the kernel side A load module with the kernel data portion called the kernel environment load module is created by linking kernel_cfg c which is a part of the configurator output file The linkage unit of a kernel environment load module is called the kernel environment side Separate linkage makes it possible to change some configuration parameters such as the maximum number of tasks CFG_MAXTSKID and to re create a kernel environment load module without changing a kernel load module even after the kernel load module is in ROM Application files can be included in a kernel load module a kernel environment load module or in an independent application load module Figure 5 2 shows the flow for creating a load module using separate linkage Rev 6 00 342 REJ10B0060 0600 RENESAS Section5 Configuration Separate linkage kernel side project Supplied library kernel_def c Kernel load module Separate linkage kernel environment side project 7n_ctg kernel_cfg c Kernel environment load module Application file Application load module Notes 1 Application files specified for the kernel side by the configurator are also required Application files specified for the kernel environment side by the configurator are also required Figure 5 2 Separate Load Module Creation Rev 6 00 343 RENESAS REJ10B0060 0600 Section5 Configuration 5 2 Folder St
282. fer for every library Table 3 74 Library of Cache Support Functions Kernel CPU Target Cache Library HI7700 4 SH 3 SH3 DSP Mixed instruction data 7708_cache_ lib SH4AL DSP without Instruction cache and operand cache sh4al_cache_ lib extended function SH4AL DSP with Instruction cache and operand cache shx2_cache_ lib extended function HI7750 4 SH 4 Operand cache 7750_cache_ lib SH 4A without Instruction cache and operand cache sh4a_cache_ lib extended function SH 4A with Instruction cache and operand cache shx2_cache_ lib extended function This section explains for SH 4 7750_cache_ lib Rev 6 00 261 RENESAS REJ10B0060 0600 Section3 Service Calls Cache Support Service Calls The cache is controlled by the service calls listed in table 3 75 Table 3 75 Service Calls for Cache Support for SH 4 System State Service Call Description T N E D U L C vini_cac Initializes cache T N E D U ivini_cac T N E D U velr_cac Clears operand cache T N E D U ivelr_cac T N E D U vils_cac Flushes operand cache T N E D U ivfls_cac T N E D U vinv_cac Invalidates operand cache T N E D U ivinv_cac T N E D U Notes 1 S Standard profile service calls s Service calls that are not standard profile service calls but are needed in order to use the standard profile function T Can be called from task context N Can be called from non ta
283. ffects Rev 6 00 424 REJ10B0060 0600 RENESAS Appendix E Optimized Timer Driver HI7700 4 E 3 Applicable MCUs The optimized timer driver uses TMU with build in MCU However the optimization timer driver might not be able to be used even in case of MCU with built in TMU At the time of writing the optimized timer driver can only be run with the following MCUs SH7630 SH7290 SH7294 SH7300 SH7660 SH7318 SH7343 For the latest information refer to the release notes on individual products E 4 Hardware Initialization The following processing is carried out to initialize the optimized timer driver when the kernel is started up 1 Cancels the module standby state of TMU 2 Initializes channels 0 1 and 2 3 Sets the interrupt levels of channels 0 1 and 2 for the interrupt controller However when the def_ovr service call has not been selected in the configurator settings for channel 2 in the above 2 and 3 are not made Note that the optimized timer driver does not place the TMU in the module standby state E 5 Differences with the Standard Timer Driver Table E 1 shows the differences between the standard and optimized timer drivers Table E 1 Time precision of service calls Standard Timer Driver CFG_TICNUME CFG_TICDENO ms Differences between the Standard and Optimized timer Drivers Optimized Timer Driver As at left however the time precision of the overrun handler
284. for CFG_TICDENO the denominator for time tick cycles the maximum value that can be specified for almtim is H ffffffff CFG_TICDENO If a value larger than this is specified operation is not guaranteed For detail of time watch method refer to section 2 16 4 2 Time Watch Method Rev 6 00 211 RENESAS REJ10B0060 0600 Section3 Service Calls 3 17 4 Stop Alarm Handler stp_alm istp_alm C Language API ER ercd stp_alm ID almid ER ercd istp_alm ID almid j Parameters ID almid R4 Alarm handler ID Return Parameters ER ercd RO Normal end E_OK or error code Error Codes E_ID p Invalid ID number almid lt 0 or almid gt CFG_MAXALMID E_NOEXS k Undefined Alarm handler specified by almid does not exist Function Each service call releases the alarm handler initiation time indicated by parameter almid and stops alarm handler operation Rev 6 00 212 REJ10B0060 0600 RENESAS Section3 Service Calls 3 17 5 Refer to Alarm Handler State ref_alm iref_alm C Language API ER ercd ref_alm ID almid T_RALM pk_ralm ER ercd iref_alm ID almid T_RALM pk_ralm Parameters ID almid R4 Alarm handler ID T_RALM pk_ralm R5 Pointer to the packet where the alarm handler state is to be returned Return Parameters ER ercd RO Normal end E_OK or error code T_RALM pk_ralm R5 Pointer to the packet where the alarm handler state is stored Packet Structure typedef struct t_ralm STAT almstat
285. for SH 4A without extended function 157 vini_cac ER vini_cac ATR cacatr Initialize Cache ivini_cac ER ivini_cac ATR cacatr 158 vclr_cac ER ercd velr_cac VP clradr1 VP clradr2 MODE mode Clear Instruction Operand Cache ivelr_cac ER ercd ivclr_cac VP clradr1 VP clradr2 MODE mode 159 vfls_cac ER ercd vfls_cac VP flsadr1 VP flsadr2 Flush Operand Cache ivfls_cac ER ercd ivfls_cac VP flsadr1 VP flsadr2 160 vinv_cac ER ercd vinv_cac VP invadr1 VP invadr2 MODE mode Invalidate Instruction Operand Cache ivinv_cac ER ercd ivinv_cac VP invadr1 VP invadr2 MODE mode Cache Support Function HI7700 4 for SH4AL DSP with extended function HI7750 4 for SH 4A with extended function 161 vini_cac ER vini_cac ATR cacatr Initialize Cache ivini_cac ER ivini_cac ATR cacatr 162 velr_cac ER ercd velr_cac VP clradr1 VP clradr2 MODE mode Clear Instruction Operand Cache ivelr_cac ER ercd ivclr_cac VP clradr1 VP clradr2 MODE mode 163 vfls_cac ER ercd vfls_cac VP flsadr1 VP flsadr2 Flush Operand Cache ivfls_cac ER ercd ivfls_cac VP flsadr1 VP flsadr2 164 vinv_cac ER ercd vinv_cac VP invadr1 VP invadr2 MODE mode Invalidate Instruction Operand ivinv_cac ER ercd ivinv_cac VP invadr1 VP invadr2 MODE Cache mode DSP Standby Control Function HI7700 4 165 vchg_cop ER_UINT oldatr vchg_cop ATR newat
286. for an unused mutex ID and creates a mutex having that ID and with the contents specified by pk_cmtx and returns the ID as a return parameter The range for searching for an unused mutex ID is from 1 to CFG_MAXMTXID As the mtxatr attribute only the ceiling priority protocol TA_CEILING can be specified mtxatr TA_CEILING Table 3 37 Mutex Attribute mtxatr mtxatr Code Description TA_CEILING H 00000003 Ceiling priority protocol ceilpri specifies the ceiling priority for the mutex to be created The range of values which can be specified is 1 to CFG_MAXTSKPRI A mutex can also be created statically by the configurator Rev 6 00 158 REJ10B0060 0600 RENESAS Section3 Service Calls 3 11 2 Delete Mutex del_mtx C Language API ER ercd del_mtx ID mtxid Parameters ID mtxid R4 Mutex ID Return Parameters ER ercd RO Normal end E_OK or error code Error Codes E_ID p Invalid ID number mtxid lt 0 or mtxid gt CFG_MAXMTXID E_NOEXS k Undefined Mutex indicated by mtxid does not exist E_CTX k Context error Called from disabled system state Function Service call del_mtx deletes the mutex specified by parameter mtxid No error occurs even when there is a lock waiting task for the mutex specified by mtxid but the WAITING state of the task is cancelled and E_DLT is returned as an error code When the target mutex is locked the lock for the task locked by the mutex is cancelled As a r
287. formace to aquaire and release memory blocks In applications that use a large number of memory blocks the performance to aquaire and release memory blocks are faster than when CFG_NEWMPL is not selected 2 Reduced fragmentation of free space Selecting CFG_NEWMPL generally retards the fragmentation of free memory space but the newly supported VTA_UNFRAGMENT attribute further reduces fragmentation Although specifying the VTA_UNFRAGMENT attribute generally helps in reducing fragmentation the degree of fragmentation depends on how the memory pools are used To support the VTA_UNFRAGMENT attribute the following macro has been added SIZE mplsz VTSZ_MPLMB UINT sctnum Size of the management area for variable size memory pool with attribute VTA_UNFRAGMENT bytes Rev 6 00 451 RENESAS REJ10B0060 0600 Appendix H New Functions of HI7000 4 V2 When CFG_NEWMPL is selected new members mpfmb minblksz and sctnum are added to the T_CMPL structure which is used to create variable size memory pool Member mpfmb indicates the address of the management table area minblksz indicates the minimum block size and sctnum indicates the number of sectors These settings are ignored when the VTA_UNFRAGMENT attribute is not specified Note the use size of stack increases generally when CFG_NEWMPL is selected Related Pages e p 40 Section 2 15 2 Controlling Fragmentation of Free Space e p 186 Section 3 14 1 Create Variable Size Memory Pool
288. fy pack 4 Moreover do not declare the variable of the structure form defined by the kernel as pragma pack 1 For kernel_def c and kernel_cfg c be sure to specify pack 4 as an option of the compiler H 14 Open the file used last time Command for the Configurator V 2 02 Release 00 A new Options menu has been added to the menu bar and contains an Open the file used last time item If you select this item the configurator will automatically open the last file to be used whenever it starts up Rev 6 00 453 RENESAS REJ10B0060 0600 Appendix H New Functions of HI7000 4 V2 Rev 6 00 454 REJ10B0060 0600 RENESAS Appendix I New Functions of HI7700 4 V 2 I 1 Support of SH4AL DSP with Extended Function V 2 01 Release 00 The cache support library shx2_cache_ lib for the SH4AL DSP with extended function is added I 2 Specifying Address of Task Stack Fixed Size Memory Pool and Variable Size Memory Pool V 2 01 Release 00 In the previous version it was not possible to specify the addresses of task stacks fixed size memory pools and variable size memory pools at the time of creation of these objects These areas were always allocated to respective specific areas managed by the kernel In V 2 the user can also allocate each area and can specify the address at each object creation Thereby the user can allocate each stack or memory pool area to an arbitrary memory address according to the purpose
289. fy pack 4 as an option of the compiler J 10 ID Name V 2 01 Release 00 In the previous version ID names can be specified only when ID numbers are automatically assigned In V 2 ID names can be specified to all objects Table J 1 shows the additional functions in V 2 about ID names Table J 1 Additional Functions about ID Names Kernel Environment Side Kernel Side kernel_id_sys h kernel_id h Automatic Automatic ID Number ID Number Version Assignment Specify ID Name Assignment Specify ID Name Previous version Impossible Impossible Possible Possible only for specifying Auto as ID Number V 2 01 or later Possible Possible Related Pages e p 292 Section 4 1 1 3 Header Files for ID Name e p 353 Section 5 4 4 1 kernel_id h kernel_id_sys h J 11 Open the file used last time Command for the Configurator V 2 02 Release 00 A new Options menu has been added to the menu bar and contains an Open the file used last time item If you select this item the configurator will automatically open the last file to be used whenever it starts up Rev 6 00 465 RENESAS REJ10B0060 0600 Appendix J New Functions of HI7750 4 V2 Rev 6 00 466 REJ10B0060 0600 RENESAS Renesas Microcomputer Development Environment System User s Manual HI7000 4 Series HI7000 4 V 2 02 HI7700 4 V 2 02 and HI7750 4 V 2 02 Publication Date Rev 6 00 January 4 2006 Published by Sales Strategic Planning Div Re
290. g rel_mpl At this time the total available memory blocks is more than 256 bytes however there is not 256 bytes of contiguous memory in the memory pool so task A remains the WAITING state 8 Task B returns 32 byte memory block Y by issuing rel_mpl At this time since there is more than 256 bytes of contiguous memory in the memory pool task A is released from the WAITING state and 256 byte memory block W is assigned to task A 2 15 2 Controlling Fragmentation of Free Space Repeated acquisition and release of memory blocks in a variable sized memory pool causes fragmentation of the available memory area When the memory area is fragmented even if the total amount of free space is sufficient for a required memory block the non contiguity of the available areas means that a large memory block cannot be acquired figure 2 13 Free space In use Free space In use In use Free space In use Figure 2 13 Fragmentation of Free Space Selecting CFG_NEWMPL on the Variable Size Memory Pool page of the configurator slightly reduces the degree of fragmentation Specify the VTA_UNFRAGMENT attribute for variable size memory pools to further reduce fragmentation Although specification of the VTA_UNFRAGMENT attribute generally helps in reducing fragmentation the degree of fragmentation will depend on how variable size memory pools are used When CFG_NEWMPL is selected parameters minimum block size number of sectors and mana
291. ge 14 Initial definition of alarm handlers in the alarm handler page 4 15 Initial definition of overrun handlers in the overrun handler page 16 Initial definition of extended service calls in the extended service call page B 3 Error during Compiling B 3 1 Error when Files are for a Different HI7000 4 Series If kernel_cfg c and kernel_def c are compiled using the file created by the configurator in a different HI7000 4 series environment the following message is displayed during compiling The underlined part shows the target OS for the file created by the configurator Unmatch HIOS This file is designed for HI7750 4 B 3 2 Errors to Do with the Optimized Timer Driver HI7700 4 The definition file kernel_def_opttmr_set h for the optimized timer driver and setting in the Time management function page in the configurator are checked for the errors shown in table B 3 when kernel_def c and kernel_cfg c are compiled Rev 6 00 403 RENESAS REJ10B0060 0600 Appendix B Error List Table B 3 Errors of the Optimized Timer Driver Error Message Meaning error directive Illegal CFG_TIMUSE error directive Illegal hi_longticrate CFG_TIMUSE is not checked in the configurator Check CFG_TIMUSE Illegal hi_longticrate setting Specify hi_longticrate as an integer constant in the 2 to Oxff range error directive Illegal hi_pclock Illegal hi_pclock setting Specify an integer constan
292. gement table address for the VTA_UNFRAGMENT attribute are added to the T CMPL structure which is specified at the time of variable size memory pool creation When the VTA_UNFRAGMENT attribute is specified the sector management method is applied to the variable size memory pools This method reduces fragmentation when a large number of small blocks and some large blocks are allocated in a large memory pool Rev 6 00 40 REJ10B0060 0600 RENESAS Section2 Kernel In this method up to minimum block size x 8 bytes is handled as a small block size The size of each block acquisition request is rounded up as shown in table 2 16 When a small block is requested the kernel allocates a sector consisting of blocks each of which has the rounded request size The sector size is always minblksz x 32 This means that the number of blocks in a sector depends on the requested size Table 2 16 Small Block Control Size after Acquisition Request Size blksz Rounding Number of Blocks in a Sector 0 lt blksz lt minblksz minblksz 32 minblksz lt blksz lt minblksz x 2 minblksz x 2 16 minblksz x 2 lt blksz lt minblksz x 4 minblksz x 4 8 minblksz x 4 lt blksz lt minblksz x 8 minblksz x 8 4 Note blksz Requested size minblksz Minimum block size Then the kernel assigns one of the memory blocks in the sector as the requested block The remaining blocks in the sector are reserved for later requests for memory bloc
293. get_mpf iref_mpf icre_mpl iacre_mpl ipget_mpl iref_mpl iset_tim iget_tim icre_cyc iacre_cyc ista_cyc istp_cyc iref_cyc iacre_alm iacre_alm ista_alm istp_alm iref_alm ista_ovr istp_ovr iref_ovr idef_inh ichg_ims iget_ims idef_svc ical_svc idef_exc iref_cfg iref_ver Rev 6 00 72 REJ10B0060 0600 RENESAS Section3 Service Calls 3 3 Service Call Description Form Service calls are described in details as shown below in this section Section Brief function description Service call name e C language API Service call calling format e Parameter P P t Regist Meani f yee Pargpgier Register Manian Assembler API is also described only for service calls that are not in accordance with section 3 2 2 Assembly Language API 4 Register R4 R5 indicate registers e Return Parameter R15 4 R15 indicate stack Type Parameter Register Meaning of 4 R15 indicates the contents of name parameter address R15 4 e Return Code Error Code I Error Code Type Note when the conditions Mnemonic Type Meaning of which cause p type errors occurred in the configuration which does not check CFG_PARCHK the system operation is not guaranteed And the cases of p type errors are not detected when k type errors are detected k indicates an error that is always detected p indicates an error that is detected only when the kernel with parameter check f
294. gisters s a Initial Value 1 PC V CPU exception handler start address 2 SR V IMASK bits Same as before exception Other bits The value which is specified at the definition 3 RO_BANKO to R7_BANKO V Undefined 4 R8to R14 MACH MACL y y Same as before CPU exception GBR 5 R15 V V R15 points to the stack area for the program which generates exception As a CPU exception handler may re enter the CPU exception handler uses the stack used by the previous program A CPU exception handler does not use its own stack 6 PR V v Undefined 7 SH 4 SH 4A FPSCR V Same as before CPU exception 8 SH 4 SH 4A FPUL V V Same as before CPU exception 9 SH 4 SH 4A FRO_BANKO V vV Same as before CPU exception to FR15_BANKO 10 SH 4 SH 4A FRO_BANK1 V V Same as before CPU exception to FR15_BANK1 Notes 1 These registers can be used Note that some register contents cannot be guaranteed after service calls For details refer to section 3 2 3 Guarantee of Register Contents after Issuing Service Call 2 When execution is returned from the entry function RTS instruction the contents of these registers must be the same as the value at initiation 3 MD must be 1 FD must be 0 Rev 6 00 326 REJ10B0060 0600 RENESAS Section4 Application Program Creation 3 Contents of Stack at Initiation When a CPU exception occurs the kernel saves the register contents in the stack When execution is returned from a CPU exception handler the ke
295. he configurator is extended from Oxfe0 to Ox3fe0 1 9 Handling of TRAPA 16 to 31 V 2 01 Release 00 Trap exception handlers can be defined for these numbers in V 2 01 1 10 Release of Restriction concerning Structure Alignment V 2 01 Release 00 In the previous version there is a restriction about the pack option and pragma pack of the compiler This restriction is not applied to V 2 01 and the following related note is removed from this user s manual The source program which uses the variable of the structure form defined by the kernel should surely specify pack 4 Moreover do not declare the variable of the structure form defined by the kernel as pragma pack 1 For kernel_def c and kernel_cfg c be sure to specify pack 4 as an option of the compiler Rev 6 00 459 RENESAS REJ10B0060 0600 Appendix New Functions of HI7700 4 V2 1 11 ID Name V 2 01 Release 00 In the previous version ID names can be specified only when ID numbers are automatically assigned In V 2 ID names can be specified to all objects Table I 1 shows the additional functions in V 2 about ID names Table I 1 Additional Functions about ID Names Kernel Environment Side Kernel Side kernel_id_sys h kernel_id h Automatic Automatic ID Number ID Number Version Assignment Specify ID Name Assignment Specify ID Name Previous version Impossible Impossible Possible Possible only for specifying Auto as ID Number V
296. he folders shown in figure 5 5 shnnnn project src Figure 5 5 Folders under the shnnnn Folder HEW1 2 a Sample HEW workspace file shnnnn hws The shnnnn folder contains this workspace file In this workspace the following three projects are registered 1 For whole linkage project mix hwp 2 For separate linkage kernel side project def hwp 3 For separate linkage kernel environment side project cfg hwp b shnnnn project folder This folder contains the three project files that are registered in shnnnn hws Under this folder a folder is prepared for each project to store object files to be generated through the respective project Rev 6 00 348 REJ10B0060 0600 RENESAS Section5 Configuration c shnnnn project src folder This folder contains the following source files 5 3 Sample task task c Sample timer driver annn_tmrdrv c nnnn_tmrdrv h nnnn_tmrdef h Sample CPU initialization routine anmn_cpuasm src nnnn_cpuini c Sample system down routine nnnn_sysdwn c Sample configurator information file nnnn hcf and its generated files see Table 5 4 Sample section initialization process nnnn_sct src nnnn_inisct c These files are not used in the state at shipment Only for HI7000 4 Interrupt CPU exception process kernel_exp src Only for HI7700 4 and HI7750 4 Interrupt CPU exception entry process nnnn_expent src Only for HI7700 4 and HI7750
297. his service call is used to lower the interrupt mask level to a level equal to or below the kernel interrupt mask level Otherwise normal system operation cannot be guaranteed If an interrupt is masked from the task context the task is regarded as the non task context until the interrupt mask level is returned to 0 For information of SR register see section 4 2 1 SR Register Rev 6 00 240 REJ10B0060 0600 RENESAS Section3 Service Calls Start address of the interrupt mask level Normal end E_OK or 3 20 3 Refer to Interrupt Mask get_ims iget_ims C Language API ER ercd get_ims IMASK p_imask ER ercd iget_ims IMASK p_imask Parameters IMASK p_imask R4 returned Return Parameters ER ercd RO IMASK p_imask R4 Error Codes E_PAR p four Function Start address of the interrupt mask level area where the is to be error code area where the is stored Parameter error p_imask is other than a multiple or Each service call refers to the interrupt mask bits MASK bits of the current CPU status register SR and returns the interrupt mask level to the area indicated by p_imask The value to be returned to p_imask has the same format as the parameter imask used by the service call chg_ims RENESAS Rev 6 00 241 REJ10B0060 0600 Section3 Service Calls 3 21 Service Call Management Service Call Management Service Calls Service call is controlled by the service
298. ication DMA transfer Initializing the Cache Before using the cache support function vini_cac or ivini_cac must be executed vini_cac and ivini_cac can be called before kernel initiation Rev 6 00 61 RENESAS REJ10B0060 0600 Section2 Kernel 2 21 Kernel Idling When there is no executable task the kernel enters the endless loop after handling the pre fetch function described later and waits for an interrupt To use the low power consumption mode of the CPU the lowest priority task is normally used for transition to that mode 2 22 Pre fetch Function only for HI7700 4 and HI7750 4 The pre fetch function allows an interrupt that occurs after the idle state to response quickly When the kernel enters the idle state the pre fetch function executes the PREF instruction cache pre fetch instruction The area pre fetched by the PREF instruction is specified by the configurator Since the PREF instruction supported by the SH 3 and SH3 DSP uses the instruction data mixed cache either program area or data area can be specified by the configurator Since the PREF instruction supported by the SH4AL DSP SH 4 and SH 4A uses operand cache only data area can be specified by the configurator 2 23 Optimized Timer Driver only for HI7700 4 The HI7700 4 supports the optimized timer driver function whose purpose is low power consumption For details refer to Appendix E Optimized Timer Driver HI7700 4 2 24 DSP Standby Control
299. id ID number mplid lt 0 or mplid gt CFG_MAXMPLID E_NOEXS k Undefined Variable size memory pool indicated by mplid does not exist Function Each service call returns the memory block specified by blk to the variable size memory pool specified by mplid The start address of the memory block acquired by service call get_mpl pget_mpl ipget_mpl or tget_mp must be specified as parameter blk After the memory block has been returned the size of the variable size memory pool free space will increase For details refer to section 2 15 3 Management of Variable Size Memory Pool When the target variable size memory pool has a contiguous memory block requested by the task at the head of the memory block acquisition wait queue the memory block is assigned to that task as a result the task is released from the WAITING state The same process will be done for the remaining tasks in the order of the wait queue if the remaining memory pool size still has enough contiguous memory blocks available Rev 6 00 193 RENESAS REJ10B0060 0600 Section3 Service Calls 3 14 5 Refer to Variable Size Memory Pool State ref_mpl iref_mpl C Language API ER ercd ref_mpl ID mplid T_RMPL pk_rmp1 ER ercd iref_mpl ID mplid T_RMPL pk_rmp1l Parameters ID mplid R4 Variable size memory pool ID T_RMPL pk_rmpl R5 Pointer to the packet where the variable size memory pool state is to be returned Return Parameters ER ercd
300. ied in a non task context Undefined Task indicated by tskid does not exist The task exception processing routine indicated by tskid is defined as specified by pk_dtex By specifying tskid TSK_SELF 0 the current task can be specified The parameter texatr is specified in the following format See table 3 20 for details texatr TA_HLNG TA_ASM TA_COPO TA_COP1 TA_COP2 Rev 6 00 111 RENESAS REJ10B0060 0600 Section3 Service Calls Table 3 20 Task Exception Routine Attribute texatr texatr Code Description TA_HLNG H 00000000 The task is written in a high level language TA_ASM H 00000001 The task is written in assembly language TA_COPO H 00000100 The task uses the DSP HI7000 4 HI7700 4 TA_COP1 H 00000200 Uses the FPU HI7000 4 Uses bank 0 in the FPU HI7750 4 TA_COP2 H 00000400 Uses bank 1 in the FPU HI7750 4 Note The initial value of the FPSCR register is H 00040001 bank 0 Through specification of a TA_COPn attribute the relevant coprocessor registers are also saved as the context of the task exception processing routine Note that the TA_COPn attribute is not in the pITRON4 0 specifications texrtn specifies the start address of the task exception processing routine When in a service call def_tex or idef_tex pk_dtex NULL 0 is specified the definition of the task exception processing routine for tskid is cancelled At this time the task pended exception factor is cle
301. ig zl Category Input F ey All Loaded Projects Show entries for res a 9 C source fi ei e E C source file Define Assembly source file _kernelpon sp Address 0AC100000 E Linkage symbol file _kernel_mansp Address 0AC100000 det C source file C source file E Assembly source file Linkage symbol file IV Use entry point Prelinker control mix hi _cpuasm Auto C source file gee E C source file Options Link Library H E Assembly source file ene his a Reiley ferns pons Te 00000 a lefine _kernel_man_sp noprelink nomessage Gi Linkage symbol file list CONFIGDIRI S PROJECTNAME map nooptimize Figure 5 12 Optimized Linkage Editor Input Category Defines In the sample file nnnn_cpuasm src for the HI7700 4 and the HI7750 4 the following symbols are externally referred to so define them here e __kernel_pon_sp Initial stack pointer used for power on reset e _ kernel_man_sp Initial stack pointer used for manual reset Rev 6 00 377 RENESAS REJ10B0060 0600 Section5 Configuration 3 Section Category SuperH RISC eneine Standard Toolchain Configuration C C Assembly Link Library Standard Library CPU Deb_4 gt Bi bi nes Category All Loaded Projects Show entries for Section X re cte E source file Address Section a Edit G source file xi P hiexpent_ Assembly source fi XBO00T000 C hiba
302. ine vo Gale Issue an extended is Extended service call cal_svc e service call To task d Figure 2 19 Example of Extended SVC Handler Description a Defines an extended service call b Issues the service call cal_svc to call the defined extended service call routine c Initiates the extended service call routine by the service call cal_svc issued by a task d Returns the extended service call routine to the caller Rev 6 00 59 RENESAS REJ10B0060 0600 Section2 Kernel In an extended service call routine the task execution mode of the task which calls the extended service call routine is retained If the task calling the extended service call routine does not mask the task termination request ter_tsk or suspension request sus_tsk these requests can also be accepted immediately in the extended service call routine 2 20 Cache Support only for HI7700 4 and HI7750 4 This function is used when it is necessary to establish coherence between the memory and cache such as when transferring the memory contents of an application to the cache DMA transfer The cache support is controlled by service calls listed in table 2 26 Table 2 26 Service Calls for Cache Support Control Service Call Name Function vini_cac ivini_cac Initializes cache velr_cac ivclr_cac Clears the cache vfls_cac ivfls_cac Flushes the cache vinv_cac ivinv_cac Invalidates the cache
303. ine handlers without the VTA_DIRECT attribute If this is attempted the HI7000 4 returns the error E_ RSATR VTA_REGBANK is valid with the HI7000 4 Furthermore the selected CPU core must be the SH 2A or SH2A FPU and SELECT must have been selected for CFG_REGBANK on the Interrupt CPU Exception Handler page in the configurator When all of these conditions hold specify VTA_REGBANK when defining normal interrupt handlers for interrupts with which the register banks are to be used In other cases the specification of VTA_REGBANK has no meaning If VTA_DIRECT has already been specified the specification of VTA_REGBANK is superfluous and is simply ignored Be sure to specify VTA_REGBANK whenever you define a normal interrupt handler for an interrupt with priority level xx for which the corresponding CFG_BANKLVLxx xx is a value from 01 to 15 which indicates an interrupt level checkbox is marked When you define a normal interrupt handler for an interrupt with priority level xx for which CFG_BANKLV Lxx has not been marked do not specify VTA_REGBANK Specification of VTA_REGBANK only has meaning when the interrupt handler number is 14 64 or a higher number This is simply the range of interrupt handler numbers for which register banks can be used and does not apply to the NMI or UBC interrupts The specification of VTA_REGBANK for an interrupt handler number outside this range has no meaning and is simply ignored Rev 6 00 238 REJ10B0060
304. ing and is similar to the function generally called signal Task exception processing is controlled by the service calls listed in table 2 7 Table 2 7 Service Calls for Task Exception Processing Service Call Name def_tex idef_tex Function Defines a task exception processing routine ras_tex iras_tex Requests task exception processing dis_tex Disables task exception processing ena_tex Enables task exception processing sns_tex Refers to the task exception disable state ref_tex iref_tex Refers to the task exception processing state Rev 6 00 20 REJ10B0060 0600 RENESAS Section2 Kernel Task exception processing routines can also be defined by the configurator Figure 2 4 shows an example of task exception processing Enable task A exception a ena_tex disable task exception d Figure 2 4 Example of Task Exception Processing Description Letters indicate the order of operation a Task A enables a task exception b An exception exception factor 00000101 is requested from task A via the ras_tex service call during task A execution c When task A is scheduled to execute task exception processing is initiated before the task A main routine is executed During task exception processing the task enters the task exception processing disabled state and the task exception source is cleared d After returning from the task exception processing routin
305. initiation cycle RELTIM cycphs 16 4 Cyclic handler initiation phase Tuceve Error Codes E_RSATR p Invalid attribute cycatr is invalid E_PAR p Parameter error pk_ccyc is other than a multiple of four cyctim 0 cycphs gt cyctim or cychdr is an odd address E_ID p Invalid ID number cycid lt 0 or cycid gt CFG_MAXCYCID E_OBJ k Object status is invalid Cyclic handler indicated by cycid already exists E_NOID k No ID available Rev 6 00 201 RENESAS REJ10B0060 0600 Section3 Service Calls Function Service calls cre_cyc and icre_cyc create the cyclic handler indicated by parameter cycid with the contents specified by parameter pk_ccyc Service calls acre_cyc and iacre_cyc search for an unused cyclic handler ID and define a cyclic handler that has the searched ID with the contents specified by parameter pk_ccyc and return the defined cyclic handler ID as a return parameter The range for searching for an unused cyclic handler specification number is 1 to CRG_MAXCYCID The cyclic handler is a time event handler for the non task context initiated by the time interval Parameter cycatr is specified in the following format See table 3 50 for details cycatr TA_HLNG TA_ASM TA_STA TA_PHS Table 3 50 Cyclic Handler Attributes cycatr cycatr Code Description TA_HLNG H 00000000 The handler is written in a high level language TA_ASM H 00000001 The handler is written in assembly lang
306. ion Handler Including TRAPA Instruction Exception 0 ee 323 4 10 Time Event Handlers and Initialization Routine 4 11 CPU Initialization Routines eee 4 11 1 Creating CPU Initialization Routines in C language 4 11 2 Defining CPU Initialization Routines in HI7000 4 4 11 3 Defining CPU Initialization Routines in HI7700 4 and HI7750 4 4 12 System Down Routines 4 13 Using the DSP in Programs for HI7000 4 and HI7700 4 only 4 13 1 Initializing DSR 4 13 2 Using DSP in Handlers Rev 6 00 v RENESAS REJ10B0060 0600 Contents Section 5 COMMQULAGON cescescesscciisssessscssssiccssesssssiaassosssssesssssssbscosseasossesssassessceseee OO 5 1 Read First 5 1 1 Whole Linkage and Separate Linkage 5 2 Folder Structure 5 2 1 hihead Folder 5 2 2 hisys Folder 5 2 3 hilib Folder 5 2 4 knl Folder 3 25 samples shnnnn Folder 5 3 Operating Procedure wisissscscscesssssntcassessescarveaecdveastvcaseadensencscseddesieisasseatatvasvsssevasesbeasens 5 4 Configurator 5 4 1 Overview 5 4 2 Configurator Construction 5 4 3 File Operation 5 4 4 Configuration Files 5 4 5 Separate Linkage 5 4 6 Configurator Settings 5 5 When Optimized Timer Driver is Used HI7700 4 0 ececcececeeeeeeeeeeeeeeeeeeeeeeee 364 5 6 When DSP Standby Control Function is Used HI7700 4 ecceseeceeeeeeseeeeeeenees 364 5 7 When Cache Support Function is Used on SH4AL DSP HI7700 4 or SH 4A HI77
307. ion3 Service Calls 3 24 4 Invalidate Operand Cache vinv_cac ivinv_cac C Language API ER ercd vinv_cac VP invadrl VP invadr2 ER ercd ivinv_cac VP invadrl VP invadr2 Parameters VP invadrl R4 Start address of invalidation VP invadr2 R5 End address of invalidation Return Parameters ER ercd RO Normal end E_OK or error code Error Codes E_PAR p Parameter error invadrl gt invadr2 Function This service call invalidates the operand cache Keep in mind that the contents are canceled even if there is data which is not written back to the memory yet in the cache If the addresses from invadr1 to invadr2 are cached in the operand cache the contents are invalidated even if the contents have not yet been written to memory invadr1 and invadr2 must be logical addresses If the address range from invadr1 to invadr2 includes one of the following addresses normal system operation cannot be guaranteed e Address corresponding to an physical address in area 7 e Address in P2 or P4 area To specify all cache contents specify invadr1 H 80000000 and invadr2 H 9bffffff In the SH 4 the cache line size is 32 bytes five least significant bits of invadr are corrected to Os and five least significant bits of invadr2 are corrected to 1s This service call can be called before the kernel is initiated This service call can be called even in the exception block state BL 1 in SR Therefore the cache can be
308. iref_sem ID semid T_RSEM pk_rsem Parameters ID semid R4 Semaphore ID T_RSEM pk_rsem R5 Pointer to the area where the semaphore state is to be returned Return Parameters ER ercd RO Normal end E_OK or error code T_RSEM pk_rsem R5 Pointer to the area where the semaphore state is stored Packet Structure typedef struct t_rsem ID wtskid 0 2 Wait task ID UINT semcnt 4 4 Current semaphore count value T_RSEM Error Codes E_PAR p Parameter error pk_rsem is other than a multiple of four E_ID p Invalid ID number semid lt 0 or semid gt CFG_MAXSEMID E_NOEXS k Undefined Semaphore indicated by semid does not exist Function Each service call refers to the state of the semaphore indicated by the parameter semid Each service call returns the task ID at the head of the semaphore wait queue wtskid and the current semaphore count semcnt to the area specified by the parameter pk_rsem If there is no task waiting for a semaphore TSK_NONE 0 is returned as a wait task ID Rev 6 00 125 RENESAS REJ10B0060 0600 Section3 Service Calls 3 8 Synchronization and Communication Event Flag Event Flag Service Calls Event flags are controlled by the service calls listed in table 3 25 Table 3 25 Service Calls for Event Flag Control System State Service Call Description T N E D U L C cre_flg s Creates event flag T E D U icre_flg N E D U acre_flg Creates even
309. is higher than task A and task A cannot enter the RUNNING state In other words while task C locks a mutex task C continues execution even if the initial task priority of task A is higher than task C Task C unlocks the mutex by issuing unl_mtx At this time the priority of task C returns to the initial priority and task A enters the RUNNING state Task A issues loc_mtx to push its priority up to the ceiling priority specified in the mutex Task A issues unl_mtx to return its priority to the initial priority Task B issues loc_mtx to push its priority up to the ceiling priority specified in the mutex Task B issues unl_mtx to return its priority to the initial priority Rev 6 00 31 RENESAS REJ10B0060 0600 Section2 Kernel 2 13 Message Buffer A message buffer is used to send and receive data messages between tasks Since a message itself is copied and transferred in communication using a message buffer the message area becomes available immediately after the message has been sent regardless of whether a task has received the message or not The area of each message buffer is allocated in the message buffer area CFG_MBFSZ specified through the configurator The message buffers are controlled by the service calls listed in table 2 13 Table 2 13 Service Calls for Message Buffer Control Service Call Name Function cre_mbf icre_mbf Creates a message buffer acre_mbf iacre_mbf Creates a message buffer automa
310. is returned Note that there is no selectable item of the service call beginning with i Selecting the service call without i means that the service call beginning with corresponding i has been automatically selected When each object is used be sure to select the service call see the table below that generates and defines the object Object Service call Object Service call Task dynamic stack used cre_tsk Message buffer cre_mbf Task static stack used vscr_tsk Fixed size memory pool cre_mpf Task exception processing def_tex Variable size memory pool __cre_mpl routine Cyclic handler cre_cyc Semaphore cre_sem Alarm handler cre_alm Eventflag cre_fig Overrun handler def_ovr Data queue cre_dtg Extended service call def_svc In addition with the service call selection page vchg_cop service call of the HI7700 4 cannot be chosen but is automatically incorporated by incorporating DSP standby control function For details refer to Appendix F DSP Standby Control HI7700 4 6 Interrupt Handler CPU Exception Handler Page 1 Maximum interrupt number CFG_MAXVCTNO L Specify the maximum number of interrupts or exception factors used in the system For HI7000 4 specify the processor vector number For HI7700 4 and HI7750 4 specify the processor interrupt or exception code The maximum allowed value is 511 for HI7000 4 and 0x3fe0 for HI7700 4 and HI7750 4 2 Interrupt handler stack size CFG_IRQSTKSZ For det
311. is revalued to the multiple 1 of 32 1 Clear specified range This service call clears the cache entry whose logical address is from clradr1 to clradr2 If operand cache is contained in target before canceling a dirty entry it is written back to memory This service call repeats and executes the following instructions from clradr1 to clradr2 e mode TC_FULL ICBI and OCBP e mode TC_EXCLUDE_IC OCBI e mode TC_EXCLUDE_OC ICBI During this processing the SR value remains the same as when this function is called When no interrupt should be accepted during this function processing mask interrupts and then call this function Rev 6 00 282 REJ10B0060 0600 RENESAS Section3 Service Calls In this service call only the fundamental error check indicated in the error code column is performed on clradr and clradr2 For example the following addresses should not be contained e P2 and P4 areas e Address corresponding to a physical address in the control area e Address corresponding to a physical address in X Y memory The processing time of this service call is proportional to the size of the appointed domain 2 Clear all If 0 is specified to be clradr1 and H ffffffff is specified to be clradr2 all the entries of the target cache determined by mode will be cleared In this case this service call is processed as follows 1 When mode is TC_FULL or TC_EXCLUDE_OC it is setting 1 as the ICI bit of a CCR register and all th
312. is waiting for CPU resource allocation because another higher priority task is currently running RUNNING State The task is currently running The kernel puts the READY task with the highest priority in the RUNNING state WAITING State A task issues a service call such as tslp_tsk to put itself to sleep when it can no longer continue execution The task is released awakened from the WAITING sleep state when the service call wup_tsk is issued and it then makes the transition to the READY state SUSPENDED State A task has been suspended by another task by sus_tsk WAITING SUSPENDED State This state is a combination of the WAITING state and SUSPENDED state Rev 6 00 11 RENESAS REJ10B0060 0600 Section2 Kernel Figure 2 1 shows the task state transition diagram CPU allocation READY executable state Suspension sus_tsk Resumption Initiation act_tsk sta_tsk Suspension sus_tsk WAITING SUSPENDED double wait state rsm_tsk frsm_t RUNNING execution state Waiting for CPU allocation Wait release WAITING wait state Resumption rsm_tsk frsm_tsk Wait Forcible termination Wait ter_tsk release Forcible termination ter_tsk SUSPENDED forcible wait state tsk Forcible termination ter_tsk DORMANT inactive state Forcible termination Exit ext_tsk
313. it box was necessary because a fixed IBNR address of H fffe080e was assumed in previous versions of the kernel Since the IBNR of some processors is allocated to different addresses the previous fixed setting did not allow usage of the register banks in these processors Related Pages e p 296 Section 4 2 9 Register Banks SH 2A SH2A FPU e p 307 Section 4 8 Interrupt Handlers e p 359 Item No 6 5 and 6 6 in table 5 5 of section 5 4 6 Configurator Settings H 2 Specifying Address of Task Stack Fixed Size Memory Pool and Variable Size Memory Pool V 2 00 Release 00 In the previous version it was not possible to specify the addresses of task stacks fixed size memory pools and variable size memory pools at the time of creation of these objects These areas were always allocated to respective specific areas managed by the kernel In V 2 the user can also allocate each area and can specify the address at each object creation Thereby the user can allocate each task stack or memory pool area to an arbitrary memory address according to the purpose of use For example only a specific task uses a stack in the high speed on chip RAM Related Pages e p 13 Section 2 6 2 Task Creation e p 76 Section 3 4 1 Create Task e p 176 Section 3 13 1 Create Fixed Size Memory Pool p 186 Section 3 14 1 Create Variable Size Memory Pool e Rev 6 00 448 REJ10B0060 0600 RENESAS Appendix H New Functions of HI7000 4 V2 H
314. itiation SIZE stksz 16 4 Task stack size VP stk 20 4 Start address of task stack area T_CTSK Rev 6 00 76 REJ10B0060 0600 RENESAS Section3 Service Calls Error Codes E_NOMEM k Insufficient memory Task stack area cannot be allocated in the memory E_RSATR p Invalid attribute tskatr is invalid E_PAR p Parameter error pk_ctsk is other than a multiple of four task is an odd address stksz is other than a multiple of four stksz 0 stksz 2 H 80000000 itskpri lt 0 itskpri gt CFG_MAXTSKPRI or stk is other than a multiple of four if stk is not NULL E_ID p Invalid ID number tskid lt 0 tskid gt CFG_MAXTSKID cre_tsk or icre_tsk tskid lt CFG_STSTKID cre_tsk or icre_tsk or tskid gt CFG_STSTKID vscre_tsk or ivscre_tsk E_OBJ k The object state is invalid The task specified by tskid is not in the DORMANT state or the current task is specified E_NOID k No ID available Function The service calls cre_tsk icre_tsk acre_tsk and iacre_tsk create tasks that use dynamic stacks and service calls vscr_tsk and ivscr_tsk create tasks that use static stacks The created tasks make a transition to the DORMANT state when the TA_ACT attribute is not specified or to the READY state when the TA_ACT attribute is specified The processing that is performed at task creation is listed in table 3 6 Table 3 6 Processing to be Performed at Task Creation Contents Clears the number of task initiatio
315. itor reports the following warning message example in case C section does not exist L1100 W Cannot find C specified in option start The default settings for example sometimes produce such warnings if the application files do not have P C D B or R sections because these sections are not used in the linked application object but these warnings in no way affect use of the resulting load module Rev 6 00 378 REJ10B0060 0600 RENESAS Section5 Configuration Memory Allocation of the HI7000 4 The vector table C_hivct section must be specified Be sure to allocate the C_hivct section to address 0 when the reset vector is defined through the configurator Memory Allocation of the HI7700 4 and the HI7750 4 Allocate the section P_hicpuasm of the CPU initialization routine to H a0000000 reset address 5 12 4 Executing a Build The load module is created by executing a build after adding application files to the project and setting the compiler assembler and optimized linkage editor options To execute a build choose the Build or Build All command from the Build menu as shown in figure 5 14 63 mix High performance Embedded Workshop Eile Edit View Project ERIE Debug Setup Tools Window Help F7 Build All Build Multiple Update All Dependencies E 7343_cpu 2 7343 sys Build Phases E 7343_tmre R a 2 kernel cfi Build Configurations kernel_de 7 B taske Linkage Ord
316. ize can be determined by substituting the size obtained from appendix C 5 above into table C 6 The stack size for the NMI interrupt handler must be calculated by using the item no 1 in table C 6 This value is used in the calculation in appendixes C 6 to C 9 Table C 6 Interrupt Handler Stack Size Stack Size Byte HI7000 4 HI7700 4 HI7750 4 Direct Normal Interrupt Interrupt Item Handler Handler Size obtained in C 4 and C 5 Calls service call 168 168 168 172 CFG_TRACE is selected 24 24 24 24 CFG_NEWMPL is selected 28 28 28 28 Addition considering nested interrupts i Added value when the NMI is used g Total Note 1 uppintnst The nest count of direct interrupts that are higher than CFG_KNLMSKLVL and the interrupt level lowintnst The nest count of interrupts that are lower than or equal to CFG_KNLMSKLVL and higher than the interrupt level 1 When NOBANK NOTUSE or SELECT has been selected for CPG_REGBANK 1 1 When CFG_DIRECT has been selected 12 x uppintnst 20 x lowintnst 1 2 When CFG_DIRECT has not been selected 12 x uppintnst 24 x lowintnst 20 However when lowintnst is 0 assume the underlined part to be 0 2 When ALL has been selected for CFG_REGBANK 8 x uppintnst 16 x lowintnst If you are using UBC interrupts however the following values must also be added UBC interrupts used as direct interrupts 4 bytes UBC interrupts used as normal interrupts
317. ize must be defined considering the largest stack size used among the direct interrupt handlers The direct interrupt handler can use 4 bytes of stack used by the previous task In case of NMI Since the NMI interrupt handler has the possibility to re enter the stack must not be switched Since the NMI interrupt handler uses the stack at the point of the NMI occurrence the stack size to be used by the NMI interrupt handler must be added to the stacks for the tasks and the interrupt handler 5 PR vo v Undefined 6 SH2 DSP DSR RS vV V RE MOD AO AOG A1 A1G MO M1 XO X1 YO Y1 Undefined Rev 6 00 315 RENESAS REJ10B0060 0600 Section4 Application Program Creation Table 4 13 Rules for Using Registers in a Direct Interrupt Handler cont End Use Conditions No Registers i Initial Value 7 SH 2A SH2A FPU TBR 8 SH2A FPU FPSCR vV V Undefined FPUL FRO to FR15 Notes 1 These registers can be used Note that some register contents cannot be guaranteed after service calls For details refer to section 3 2 3 Guarantee of Register Contents after Issuing Service Call When execution is returned from the entry function RTE or TRAPA instruction the contents of these registers must be the same as the value at initiation IMASK bits must not be lower than the current interrupt level In the case of the SH 2A or SH2A FPU processors the end condition is not necessary when
318. izing sections For details refer to the SuperH RISC engine C C Compiler User s Manual Then vsta_knl or ivsta_knl is called to initiate the kernel When the kernel is initiated control does not return to the caller of vsta_knl and ivsta_knl The following is performed by vsta_knl and ivsta_knl a All interrupts are disabled SR IMASK 15 in the HI7000 4 or SR BL 1 in the HI7700 4 and HI7750 4 b The VBR is initialized c SR BL is cleared to 0 and SR IMASK is set to 15 in the HI7700 4 and HI7750 4 d The kernel work area is initialized e SR IMASK is set to the kernel interrupt mask level In the HI7700 4 and HI7750 4 SR BL is cleared at this time f The initial defined objects specified in the configurator are created Rev 6 00 53 RENESAS REJ10B0060 0600 Section2 Kernel The system initialization routine specified in the configurator is called o g h The multitasking environment is entered All initial tasks are executed The program which issues the vsta_knl or ivsta_knl service call must normally be linked with the kernel Note however that since the address of vsta_knl and ivsta_knl service call is equal to the start address of P_hireset section vsta_knl can be issued only by specifying the P_hireset section start address without kernel linkage For details on creating a CPU initialization routine refer to section 4 11 CPU Initialization Routines 2 18 2 Interrupt Handlers ad Overvie
319. k Used before Kernel Initiation The stacks used by programs executed before kernel initiation such as the CPU initialization routine are not managed by the kernel Therefore the user can use the desired area for the stack In the HI7000 4 the stack pointer at power on reset must be set in the reset vector In the HI7700 4 and HI7750 4 it must be defined at the beginning of the CPU initialization routine For a microcomputer having built in RAM allocate the stack at reset to the built in RAM Fora microcomputer without built in RAM the stack the user system RAM may not be accessed during reset depending on the bus state controller BSC status immediately after reset In this case do not run programs that use stacks and do not generate any interrupts or exceptions until the memory becomes accessible by changing the BSC settings This is because register data is stored in the stack when interrupts or exceptions occur C3 Stack Size Calculation Procedure Use the stack size calculation procedure shown in figure C 1 to define the appropriate sizes in the corresponding definition parts Calculate the stack size for each function Section C 4 Determine the stack size by considering the Section C 5 program nesting Determine the task and handler stack size and assign the results to the corresponding items Sections SOE 2 Figure C 1 Stack Size Calculation Procedure Rev 6 00 407 RENESAS REJ10B0060 0600 Appendix C
320. ks with this size or a smaller size In this manner small blocks are allocated contiguously so that a larger free space is left available Figure 2 14 shows an example of a variable size memory pool when the minimum block size is 32 First a 32 byte memory block is requested Sector A with 32 x 32 1024 bytes is allocated and 32 byte area A 1 in the sector is assigned for the requested block figure 2 14 1 When a 16 byte memory block is then requested 32 byte area A 2 in sector A is assigned figure 2 14 2 Next a 36 byte memory block is requested Since the size of each block in sector A is 32 bytes no block in sector A can be assigned for this request To respond to this request new sector B is allocated for 16 blocks x 64 bytes the requested size 36 is rounded up to a multiple of the minimum block size 1024 bytes and 64 byte area B 1 is assigned for the requested block figure 2 14 3 Rev 6 00 41 RENESAS REJ10B0060 0600 Section2 Kernel Sector A Sector B 1 2 3 Figure 2 14 Example of Variable Size Memory Pool If the maximum number of sectors have already been used or contiguous free space is not sufficient to create a new sector the requested size of the memory block is allocated without creating a sector In this case free space may be fragmented If contiguous free space is not sufficient for the requested size the memory block is allocated in a sector for a large
321. le creation cfg The defined address and the allocation address of the C_hibase section must be the same Basically specify addresses for all sections in the input files The optimized linkage editor automatically places all sections without overt address specifications after the last section in the input files with such a specification The resulting arrangement of sections may not produce the order expected and the program may not work properly In this case the optimized linkage editor reports the following warning message example in case P_Task1 section is not specified L1120 W Section address is not assigned to P_Taski Specifying a section name that does not actually appear in the input files also produces a warning message but the optimized linkage editor continues linking In this case the optimized linkage editor reports the following warning message example in case C section does not exist L1100 W Cannot find C specified in option Start The default settings for example sometimes produce such warnings if the application files do not have P C D B or R sections because these sections are not used in the linked application object but these warnings in no way affect use of the resulting load module Rev 6 00 383 RENESAS REJ10B0060 0600 Section5 Configuration Memory Allocation of the HI7000 4 The vector table C_hivct section must be specified Be sure to allocate the C_hivct section to address 0
322. led and linked into a system load module Figure 5 6 shows the position of the configurator in the system configuration User operation input Configurator Header file Project definition file HEW project i annn _mix etc itron h kernel h Application including sample program annn _imrdrv c etc epnjouy a uomuyaa ll Output incus Configuration file Build kernel_def c kernel_cfg c C o o J Load module pnj ul Il Configuration file Shaded parts indicate configurator output files Figure 5 6 Position of Configurator in System Configuration Rev 6 00 350 REJ10B0060 0600 RENESAS Section5 Configuration 5 4 2 Configurator Construction Figure 5 7 shows the configurator window The configurator window consists of a list window of configuration information input parts on the left side and a configuration information input window on the right side Input data in the configuration information input window and execute the Configuration File Creation command with the menu or the tool button The configuration files are then created HIOS Configurator HI 700 4 untitled File View Generate Help D El n New Open Save Generate Help HI 700 4Confieuration informa Kernel Execution Condition Kernel Extention Function Time Management Functior Spe
323. led before the kernel is initiated This service call can be called even in the exception block state BL 1 in SR Rev 6 00 279 RENESAS REJ10B0060 0600 Section3 Service Calls Table 3 81 Cache Attribute CCR and RAMCR Attribute Value Description Setting TCAC_IC_ENABLE H 00000100 When Enable instruction CCR ICE 1 specify cache When not Disable instruction CCR ICE 0 specify cache TCAC_OC_ENABLE H 00000001 When Enable operand cache CCR OCE 1 specify When not Disable operand cache CCR OCE 0 specify TCAC_IC_2WAY H 00800000 When 2 way instruction cache RAMCR IC2W 1 specify When not 4 way instruction cache RAMCR IC2W 0 specify TCAC_OC_2WAY H 00400000 When 2 way operand cache RAMCR OC2W specify 1 When not 4 way operand cache RAMCR OC2W specify 0 TCAC_P1_CB H 00000004 When Writing mode for P1 CCR CB 1 specify area is write back mode When not Writing mode for P1 CCR CB 0 specify area is write through mode TCAC_PO_WT H 00000002 When Writing mode for PO UO CCR WT 1 specify area is write through mode When not Writing mode for PO UO CCR WT 0 specify area is write back mode TCAC_IC_WPD H 00200000 When Does not predict the CCR ICWPD 1 specify instruction cache way When not Predicts the instruction CCR ICWPD 0 specify cache way TCAC_L2_ENABLE H 00010000 When Enable secondary RAMCR L2E 1 specify cache When not Disable secondary RAMCR L2E 0 specify cache
324. lradr2 ER ercd ivclr_cac VP clradrl VP clradr2 Parameters VP clradri R4 Start address VP clradr2 R5 End address Return Parameters ER ercd RO Normal end E_OK or error code Error Codes E_PAR p Parameter error clradrl gt clradr2 Function This service call clears the operand cache If the addresses from clradr1 to clradr2 are cached in the operand cache the cache contents are invalidated The contents that have not yet been written to memory are written to memory clradr1 and clradr2 must be logical addresses If the address range from clradr1 to clradr2 includes one of the following normal system operation cannot be guaranteed e Address corresponding to an physical address in area 7 e Address in P2 or P4 area To specify all cache contents specify clradr1 H 80000000 and clradr2 H 9bffffff In the SH 4 the cache line size is 32 bytes five least significant bits of clradr1 are corrected to Os and five least significant bits of clradr2 are corrected to Is This service call can be called before the kernel is initiated This service call can be called even in the exception block state BL 1 in SR Therefore the cache can be cleared irrespective of interrupts or exceptions When this service call has been called when BL 1 in SR clear BL to 0 after returning from the service call processing Rev 6 00 264 REJ10B0060 0600 RENESAS Section3 Service Calls 3 24 3 Flush Operand Cache vfls_c
325. ls listed in table 3 35 Table 3 35 Service Calls for Mutex Control System State Service Call Description T N E D U L C cre_mtx Creates mutex T E D U acre_mtx Creates mutex and assigns mutex ID T E D U automatically del_mtx Deletes mutex T E D U loc_mtx Locks mutex T E U ploc_mtx Polls and locks mutex T E D U tloc_mtx Locks mutex with timeout function T E U unl_mtx Unlocks mutex T E D U ref_mtx Refers to mutex state T E D U Notes 1 S Standard profile service calls s Service calls that are not standard profile service calls but are needed in order to use the standard profile function 2 T Can be called from task context N Can be called from non task context E Can be called from dispatch enabled state D Can be called from dispatch disabled state U Can be called from CPU unlocked state L Can be called from CPU locked state C Can be called from CPU exception handler Mutex Specifications The mutex specifications are listed in table 3 36 Table 3 36 Mutex Specifications Item Description Mutex ID 1 to CFG_MAXMTXID 1023 max Attribute supported TA_CEILING Ceiling priority protocol Note When the TA_CEILING attribute is specified the mutex is managed by simplified priority control rule Under this rule the management which changes the task s current priority to higher value is always operated but the management which changes the task s priority to lower value is not opera
326. ly by the configurator Rev 6 00 215 RENESAS REJ10B0060 0600 Section3 Service Calls 3 18 2 Start Overrun Handler sta_ovr ista_ovr C Language API ER ercd sta_ovr ID tskid OVRTIM ovrtim ER ercd ista_ovr ID tskid OVRTIM ovrtim Parameters ID tskid R4 Task ID OVRTIM ovrtim R5 Upper processor time limit Return Parameters ER ercd RO Normal end E_OK or error code Error Codes E_ID p Invalid ID number tskid lt 0 tskid gt CFG _MAXTSKID or tskid TSK_SELF 0 is specified in a non task context E_NOEXS k Undefined Task specified by tskid does not exist E_OBJ k Object status is invalid Overrun handler has not been defined Function Overrun handler operation begins for the task specified by tskid By specifying tskid TSK_SELF 0 the current task can be specified The upper processor time limit for the task is set to the time specified by ovrtim and the processor time used is cleared to 0 If upper processor time has been already specified for the task indicated by tskid the upper processor time limit previously specified is cancelled and the new processor time limit is set When the processor time used exceeds the upper processor time limit the overrun handler is started When a value larger than 1 is specified for CFG_TICDENO the denominator for time tick cycles the maximum value that can be specified for ovrtim is H ffffffff CFG_TICDENO If a value larger than this is specified
327. m CPU exception handler Task Synchronization Specifications The task synchronization specifications are listed in table 3 17 Table 3 17 Task Synchronization Specifications Item Description Maximum number of task wake up request 15 count Maximum number of task suspend request 15 nesting Number of task event flag bits 32 bits lower 16 bits are reserved for future expansion Initial value of task event flag Initialized as 0 at task initiation Wait condition of task event flag Waits for a logical OR Rev 6 00 97 RENESAS REJ10B0060 0600 Section3 Service Calls 3 5 1 Sleep Task slp_tsk tslp_tsk C Language API ER ercd slp_tsk void ER ercd tslp_tsk TMO tmout Parameters lt tslp_tsk gt TMO tmout R4 Timeout specification Return Parameters ER ercd RO Normal end E_OK or error code Error Codes E_PAR p Parameter error tmout lt 2 E_CTX k Context error Called from disabled system state E_TMOUT k Timeout E_RLWAI k WAITING state is forcibly cancelled rel_wai service call was issued in the WAITING state Function Each service call shifts the current task to the wake up WAITING state However if wake up requests are queued for the current task the wake up request count is decremented by one and task execution continues The WAITING state is cancelled by the service calls wup_tsk and iwup_tsk The parameter tmout specified by service call tslp_tsk specifies the time
328. mal end E_OK or error code T_ROVR pk_rovr R5 Pointer to the packet where the overrun handler state is stored Packet Structure typedef struct t_rovr STAT ovrstat 0 4 Overrun handler operation state OVRTIM leftotm 4 4 Remaining processor time T_ROVR Error Codes E_PAR p Parameter error pk_rovr is other than a multiple of four E_ID p Invalid ID number tskid lt 0 tskid gt CFG _MAXTSKID or tskid TSK_SELF 0 is specified in a non task context E_NOEXS k Undefined Task specified by tskid does not exist E_OBJ k Object status is invalid Overrun handler has not been defined Function The state of the overrun handler for the task specified by tskid is referenced and the state of operation of the overrun handler ovrstat and the remaining processor time leftotm are returned to the area specified by pk_rovr By specifying tskid TSK_SELF 0 the current task can be specified As the operating state of the overrun handler the upper processor time limit setting is returned as ovrstat Table 3 59 Handler Activation State ovrstat ovrstat Code Description TOVR_STP H 00000000 No upper processor time limit is set TOVR_STA H 00000001 An upper processor time limit is set Rev 6 00 218 REJ10B0060 0600 RENESAS Section3 Service Calls The processor time remaining until the overrun handler is started due to the target task is returned as leftotm If no upper processor time limit is set for
329. memory block in the fixed size memory pool area indicated by mpfid However in that case the task in the WAITING state will be released and error code E_DLT will be returned When the memory pool allocated in the fixed size memory pool that is created with NULL as mpf is deleted the free fixed size memory pool area CFG_MPFSZ will increase by an amount given by the following expression 1 CFG_MPFMANAGE is not checked Increase in size blksz specified at creation 4 bytes x blkcnt 16 bytes 2 CFG_MPFMANAGE is checked Increase in size blksz specified at creation x blkcnt 16 bytes The kernel will not perform any processing even when a block has already been acquired Rev 6 00 179 RENESAS REJ10B0060 0600 Section3 Service Calls 3 13 3 Get Fixed Size Memory Block get_mpf pget_mpf ipget_mpf tget_mpf C Language API ER ercd ER ercd ER ercd get_mpf ID mpfid VP p_blk j pget_mpf ID mpfid VP p_blk j ipget_mpf ID mpfid VP p_blk j ER ercd tget_mpf ID mpfid VP p_blk TMO tmout Parameters ID VP lt tget_mpf gt TMO Return Parameters ER VP Error Codes mpfid R4 Fixed size memory pool ID p_ blk R5 Pointer to the area where the start address of the memory block is to be returned tmout R6 Timeout specification ercd RO Normal end E_OK or error code p_ blk R5 Start address of the area where the start address of the memory block is stored E_PAR p Parameter
330. message by preparing the 48 byte memory and issuing rcv_mbf Task A is placed in the WAITING state since there are no messages in the message buffer Task B sends a 16 byte message X by issuing snd_mbf At this time task A is released from the WAITING state and message X is copied to the memory prepared by task A Task A receives message size 16 as the return parameter Task B sends a 48 byte message Y by issuing snd_mbf At this time since there are no tasks waiting for a message message Y is copied to the message buffer In this case the kernel uses 4 byte message buffer area to copy message Y to the message buffer however this is not indicated in figure 2 10 Rev 6 00 33 RENESAS REJ10B0060 0600 Section2 Kernel 5 Task B attempts to send 32 byte message Z by issuing snd_mbf At this time since the message buffer is not large enough to store message Z task B is placed in the WAITING state 6 Task A prepares the 48 byte memory and issues rcv_mbf to receive a message 48 byte message Y stored in the message buffer is copied to the memory prepared by task A Task A receives message size 48 as the return parameter At this time since the message buffer has sufficient space to store message Z task B is released from the WAITING state and message Z is copied to the message buffer Rev 6 00 34 REJ10B0060 0600 RENESAS Section2 Kernel 2 14 Fixed Size Memory Pool A task can acquire and use a fixed size memory block who
331. method configuring the system using the configurator Appendixes List of service call function codes error references user and kernel work area calculations timer drivers optional functions of HI7700 4 optimized timer driver and DSP standby control function note on FPU and modified functions in the new version of the product The other relevant manuals are listed below e Release Notes provided for the product e Manuals provided for the SuperH RISC engine C C compiler package e The hardware manual and programming manual of the SuperH microcomputer in use Renesas Technology Homepage Various support information is available on the Renesas Technology homepage http www renesas com en tools Rev 6 00 i RENESAS REJ10B0060 0600 Preface Abbreviations of products Product Name Description HI7000 4 series Abbreviation of HI7000 4 HI7700 4 and HI7750 4 DX Abbreviation of Debugging Extension HEW Abbreviation of High performance Embedded Workshop which is an integrated development tool Symbols used in this manual have the following meanings H and D nnnn 22 CFG_MAXTSKID For hexadecimal integers prefix H is attached For decimal integers prefix H is attached If no prefix is attached a decimal integer is assumed Bold faced italic nnnn is the CPU name used for the sample file name Example The timer driver file name is nnnn_tmrdrv c in this manual but the a
332. mutex ploc_mtx Locks a mutex polling tloc_mtx Locks a mutex with timeout unl_mtx Unlocks a mutex ref_mtx Refers to the mutex status Mutexes can also be created by the configurator Figure 2 9 shows an example of using mutex x rad rad Higher A Upper limit priority y RUNNING kal RUNNING RUNNING E E RUNNING S 3 gt gt a gt Task A wia TING READY Aunnine E RUNNING WAITING e Priority E runna Task B a READY RUNNING Runne 5 RUNNING 2 f Sy Lowery Task c RUNNING RUNNING g READY t f f f f it 2 3 4 5 6 7 Time Figure 2 9 Example of Using Mutex Rev 6 00 30 REJ10B0060 0600 RENESAS Section2 Kernel Description In figure 2 9 the priorities of tasks A B and C are defined as task A highest and task C lowest Note that the ceiling priority specified by the mutex is specified as higher than the priority of the task that locks the mutex The following describes the mutex operation with respect to time 1 Fe p Task C locks a mutex by issuing loc_mtx At this time the priority of task C is pushed up to the ceiling priority specified by the mutex Task A enters the READY state while task C is executed at a priority equal to the ceiling priority specified by the mutex Although the priority of task A is higher than that of task C at initial specification task C now locks a mutex to be executed at the ceiling priority which
333. n in table 2 24 Rev 6 00 54 REJ10B0060 0600 RENESAS Section2 Kernel Table 2 24 Normal Interrupt Handler and Direct Interrupt Handler Item Normal Interrupt Handler Direct Interrupt Handler Initiation method when an Initiated via kernel interrupt Initiated without kernel intervention interrupt occurs processing a direct interrupt handler is defined by a CPU interrupt vector Service call issuing Service calls for non task context are used Note however that an method interrupt handler with level higher than CFG_KNLMSKLVL must not issue a service call Interrupt level An interrupt with level higher than CFG_KNLMSKLVL must be defined as a direct interrupt handler Definition method def_inh or idef_inh service call Defined by the configurator 3 Register banks SH 2A SH2A FPU Refer to section 4 2 9 Register Banks SH 2A SH2A FPU 2 18 3 Disabling Interrupts Interrupts are prohibited in one of the following four ways a loc_cpu iloc_cpu service calls Change the IMASK bits in the SR register to the kernel interrupt mask level b chg_ims ichg_ims service calls Change IMASK bits in the SR register c Change IMASK bits in the SR register without a service call d Change BL bit in the SR register without a service call SH 3 SH3 DSP SH4AL DSP SH 4 SH 4A Do not issue service calls when the level set by the IMASK bits in the SR register is higher than the kernel interrupt mask level CFG_K
334. n not 4 way instruction cache RAMCR IC2W 0 specify TCAC_OC_2WAY H 00400000 When 2 way operand cache RAMCR OC2W specify 1 When not 4 way operand cache RAMCR OC2W specify 0 TCAC_P1_CB H 00000004_ When Writing mode for P1 CCR CB 1 specify area is write back mode When not Writing mode for P1 CCR CB 0 specify area is write through mode TCAC_PO_WT H 00000002 When Writing mode for PO UO CCR WT 1 specify area is write through mode When not Writing mode for PO UO CCR WT 0 specify area is write back mode Rev 6 00 270 REJ10B0060 0600 RENESAS Section3 Service Calls 3 25 2 Clear Instruction Operand Cache velr_cac ivelr_cac C Language API ER ercd vclr_cac VP clradrl VP clradr2 MODE mode ER ercd ivclr_cac VP clradrl VP clradr2 MODE mode Parameters VP clradr1 R4 Start address VP clradr2 R5 End address MODE mode R6 Target cache Return Parameters ER ercd RO Normal end E_OK or error code Error Codes E_PAR p Parameter error clradrl gt clradr2 or mode is invalid E_OBJ k Target cache is disabled Function This service call clears the cache That is the cache contents are invalidated If the operand cache has data which has not been written to memory the data is written back to memory The target cache are determined by mode Following either can be specified to be mode e TC_FULL H 00000000 Both instruction cache and operand cache e TC_EXCLUDE_IC H 00000001 Exclude instruction cache onl
335. n request queues Sets the state for which the task exception routine is not defined Sets the state for which the upper limit processor time is not specified Assigns the stack for cre_tsk and acre_tsk Rev 6 00 77 RENESAS REJ10B0060 0600 Section3 Service Calls The following describes the meaning of the parameters tskid The service calls vscr_tsk and ivscr_tsk create tasks that use static stacks 1 to CFG_STSTKID can be specified for tskid The service calls cre_tsk and icre_tsk create tasks that use dynamic stacks CFG_STSTKID 1 to CFG_MAXTSKID can be specified for tskid The service calls acre_tsk and iacre_tsk detect an undefined task ID and create a task for the task ID with the contents specified by pk_ctsk and return the ID as a return parameter The service calls acre_tsk and iacre_tsk create tasks that use dynamic stacks The task ID range to be detected is CFG_STSTKID 1 to CFG_MAXTSKID tskatr The parameter tskatr specifies the coprocessor and language in which the task was written in the following format See table 3 7 for details tskatr TA_HLNG TA_ASM TA_ACT TA_COPO TA_COP1 TA_COP Table 3 7 Task Attributes tskatr tskatr Code Description TA_HLNG H 00000000 The task is written in a high level language TA_ASM H 00000001 The task is written in assembly language TA_ACT H 00000002 The task makes a transition to the READY state after the task has been cre
336. n3 Service Calls Function The service calls cre_flg and icre_flg create an event flag with an ID indicated by flgid with the contents indicated by pk_cflg The service calls acre_flg and iacre_flg search for an unused event flag ID and create an event flag that has this ID with the contents specified by the parameter pk_cflg The created event flag ID is returned as a return parameter The range for searching for an unused event flag ID is 1 to CFG_MAXFLGID The parameter flgatr is specified in the following format See table 3 27 for details flgatr TA_TFIFO TA_TPRI TA_WSGL TA_WMUL TA_CLR Table 3 27 Event Flag Attribute flgatr figatr Code Description TA_TFIFO H 00000000 Task wait queue is managed on a FIFO basis TA_TPRI H 00000001 Task wait queue is managed on priority TA_WSGL H 00000000 Does not permit multiple tasks to wait for the event flag TA_WMUL H 00000002 Permits multiple tasks to wait for the event flag TA_CLR H 00000004 Clears event flag at the time of waiting release If TA_WSGL attribute is specified for flgatr only one task can wait for the created event flag In this case the event flag performs the same operation when either attribute TA_TFIFO or TA_TPRI is specified On the other hand multiple tasks can enter the WAITING state when the TA_WMUL attribute is specified If TA_CLR attribute is specified for flgatr all bits of the event flag bit pattern are cleared when the wait
337. nagement Function 140 def_inh ER ercd def_inh INHNO inhno T_DINH pk_dinh Define Interrupt Handler idef_inh ER ercd idef_inh INHNO inhno T_DINH pk_dinh 141 chg_ims ER ercd chg_ims IMASK imask Change Interrupt Mask ichg_ims ER ercd ichg_ims IMASK imask 142 get_ims ER ercd get_ims IMASK p_imask Refer to Interrupt Mask igetims ER ercd iget_ims IMASK p_imask Service Call Management Function 143 def_svc ER ercd def_svc FN fncd T_DSVC pk_dsvc Define Extended Service call idef_svc ER ercd idef_svc FN fned T_DSVC pk_dsvc Routine 144 cal_svc ER_UINT ercd cal_sve FN fncd Extended Service call ical_svc ER_UINT ercd cal_sve FN fncd Rev 6 00 398 REJ10B0060 0600 RENESAS Appendix A Service Call List No Service C Language API Function Call System Configuration Management Function 145 def_exc ER ercd def_exc EXCNO excno T_DEXC pk_dexc Define CPU Exception Handler idef_exc ER ercd idef_exc EXCNO excno T_DEXC pk_dexc 146 vdef_trp ER ercd vdef_trp UINT dtrono T_ DTRP pk_dtrp Define CPU Exception TRAPA ivdef_trp ER ercd ivdef_trp UINT dtrpno T_DTRP pk_dtrp Instruction Exception Handler 147 ref_cfg ER ercd ref_cfg T_RCFG pk_rcfg Refer to Configuration iref_cfg ER ercd iref_cfg T_RCFG pk_refg Information 148 ref_ver ER ercd ref_ver T_RVER pk_rver
338. nation can also be acquired In addition the vget_tre and ivget_tre service calls allow the user to acquire trace information on all timing Trace Information Storage Area Trace information can be stored either in the target memory of debugger such as E6000 emulator or simulator The former is called target trace and the latter is called emulator trace or tool trace Although the environment where emulator trace can be used is limited there is the feature of hardly needing the domain for service call trace on a target memory Refer to the manual or online help of the debugging extension for the environment where emulator trace tool trace can be used Preparation for Service Call Trace Function The service call trace function is specified in the debugging function page of the configurator At linkage sections for trace such as B_hitrcbuf for target trace and B_hitrceml for emulator trace must be assigned to the appropriate addresses Rev 6 00 50 REJ10B0060 0600 RENESAS Section2 Kernel Note on Service Call Trace Function The following must be noted when using the service call trace function a Degradation of performance When the service call trace function is used the performance of the kernel is degraded a little Service call information not traced Service calls for non task context such as ixxx_yyy are all acquired as service calls for task context such as Xxx_yyy Following service calls cannot be traced
339. nd macros defined in the above header files Note however that the above header files include some constants and macros that are not described in section 3 These are listed in table 4 1 For details refer to the description on header files Rev 6 00 289 RENESAS REJ10B0060 0600 Section4 Application Program Creation Table 4 1 Constants and Macros File Name Macro and Constants Description kernel h TMIN_TPRI Minimum task priority value always 1 TMIN_MPRI Minimum message priority value always 1 TKERNEL_MAKER Kernel manufacturer code This value is the same as maker which is returned by ref_ver service call TKERNEL_PRID Kernel ID This value is the same as prid which is returned by ref_ver service call TKERNEL_SPVER ITRON specification version number This value is the same as spver which is returned by ref_ver service call TKERNEL_PRVER Kernel version number This value is the same as prver which is returned by ref_ver service call TMAX_ACTCNT Maximum number of task initiation request queues always 15 TMAX_WUPCNT Maximum number of task wake up request queues always 15 TMAX_SUSCNT Maximum number of nestings for task forced wait request always 15 TBIT_TEXPTN Number of task exception factor bits always 32 TBIT_FLGPTN Number of event flag bits always 32 SIZE mpfsz TSZ_MPF UNIT blkent UNIT blksz The size of fixed size memory
340. ndler Not necessary stack B_hitrceml DX emulator trace tool trace area Not necessary B_hitrcbuf DX target trace buffer Not necessary P_hisysdwn _nnnn_sysdwn c Sample system down routine Not necessary P_hicpuasm nnnn_cpuasm src Sample CPU initialization routine 8 P_hicpuini nnnn_cpuini c Sample CPU initialization subroutine Not necessary P_hitmrdrv nnnn_tmrdrv c Sample timer driver Not necessary Determined Applications by the user Notes 1 See section 5 9 Kernel Libraries 2 Only in the HI7700 4 and HI7750 4 3 Only in the HI7000 4 4 Only for sh4al_cache_ lib and shx2_cache_ lib in the HI7700 4 and sh4a_cache_ lib and shx2_cache_ lib in the HI7750 4 5 When the fixed size memory pool is created while CFG_MPFMANAGE is selected through the configurator or when the variable size memory pool with the VTA_UNFRAGMENT is created while CFG_NEWMPL is selected 6 Only when CFG_VCTRANM is selected and the OS is the HI7000 4 Rev 6 00 372 REJ10B0060 0600 RENESAS Section5 Configuration 7 Allocate the section to address 0 when the reset vector is specified through the configurator in the HI7000 4 Also refer to section 4 11 2 Defining CPU Initialization Routines in HI7000 4 8 Allocate the area to the CPU reset vector address H a0000000 in the P2 area in the HI7700 4 and HI7750 4 5 11 Settings Common to All Projects 5 11 1 CPU Options for the Compiler and Assembler
341. ned 11 SH2A FPU FPSCR s H 00040001 12 SH2A FPU FPUL i Undefined FRO to FR15 Notes 1 These registers can be used Note that some register contents cannot be guaranteed ha after service calls For details refer to section 3 2 3 Guarantee of Register Contents after Issuing Service Call When execution is returned from the entry function RTS instruction the contents of these registers must be the same as the value at initiation Except in the CPU locked state IMASK must be 0 Only when the TA_COP0 attribute is specified Depends on CFG_TBR 1 Kernel does not manage The kernel does not operate TBR 2 Only for service call Do not modify TBR 3 Task context Usable Only when the TA_COP1 attribute is specified Rev 6 00 298 REJ10B0060 0600 RENESAS Section4 Application Program Creation Table 4 3 Rules on Using Registers in a Task HI7700 4 End Use Conditions No Registers n i Initial Value 1 PC V Task start address 2 SR V i Either CFG_DSP or CFG_CACLOC is checked H 40001000 Neither CFG_DSP nor CFG_CACLOC is checked H 40000000 3 RO_BANKO to R3_BANKO y Undefined 4 R4_BANKO y Activated by TA_ACT attribute or act_tsk exinf which is specified at task creation Activated by sta_tsk stacd which is specified by sta_tsk 5 R5_BANKO to R7_BANKO V Undefined R8 to R14 MACH MACL GBR 6 R15 V V End address of stack area for the task 7 PR V V Undefined 8 SH3 DSP S
342. nel does not control cache lock Application program should control cache lock 1 Microcomputer which has LE Lock enable bit in the cache control register 2 CCR2 In the microcomputers of this type cache lock function is effective when CCR2 LE bit is 1 The control of cache lock enable and disable is done by CCR LE bit 2 Microcomputer which does not have LE Lock enable bit in the cache control register 2 CCR2 In the microcomputers of this type cache lock function is effective when SR DSP or SR CL bit is 1 To maintain cache lock state SR DSP or SR CL bit is always 1 It is necessary to do the following for that a Checks CFG_DSP or CFG_CACLOC in the configurator As a result the SR DSP or SR CL bit when the task starts and kernel executes becomes 1 b For all interrupt handlers and CPU exception handlers including TRAPA the DSP or CL bit of the Handler SR which is specified at definition must be 1 c Application program must not clear SR DSP or SR CL bit If these operations are not satisfied SR DSP or SR CL may be cleared It means that cache lock state is canceled Rev 6 00 294 REJ10B0060 0600 RENESAS Section4 Application Program Creation 4 2 3 VBR Register The VBR register is initialized at kernel initiation Application programs must not change the VBR 4 2 4 MMU SH 3 SH3 DSP SH4AL DSP SH 4 SH 4A The kernel does not control the MMU 4 2 5 Acceptance of NMI while SR BL 1 S
343. nesas Technology Corp Edited by Customer Support Department Global Strategic Communication Div Renesas Solutions Corp 2006 Renesas Technology Corp All rights reserved Printed in Japan Renesas Tech nology Corp Sales Strategic Planning Div Nippon Bldg 2 6 2 Ohte machi Chiyoda ku Tokyo 100 0004 Japan 2CENESAS RENESAS SALES OFFICES Refer to http www renesas com en network for the latest and detailed information http www renesas com Renesas Technology America Inc 450 Holger Way San Jose CA 95134 1368 U S A Tel lt 1 gt 408 382 7500 Fax lt 1 gt 408 382 7501 Renesas Technology Europe Limited Dukes Meadow Millboard Road Bourne End Buckinghamshire SL8 5FH U K Tel lt 44 gt 1628 585 100 Fax lt 44 gt 1628 585 900 Renesas Technology Shanghai Co Lid Unit 205 AZIA Center No 133 Yincheng Rd n Pudong District Shanghai 200120 China Tel lt 86 gt 21 5877 1818 Fax lt 86 gt 21 6887 7898 Renesas Technology Hong Kong Lid 7th Floor North Tower World Finance Centre Harbour City 1 Canton Road Tsimshatsui Kowloon Hong Kong Tel lt 852 gt 2265 6688 Fax lt 852 gt 2730 6071 Renesas Technology Taiwan Co Ltd 10th Floor No 99 Fushing North Road Taipei Taiwan Tel lt 886 gt 2 2715 2888 Fax lt 886 gt 2 2713 2999 Renesas Technology Singapore Pte Lid 1 Harbour Front Avenue 06 10 Keppel Bay Tower Singapore 098632 Tel lt 65 gt 6213 0200 Fa
344. ng of trpsr has no meaning and is simply ignored The actual value of SR on startup is determined by the CPU exception processing When pk_dtrp NULL 0 is specified the definition of dtrpno is cancelled Service calls which can be called from a CPU exception TRAPA instruction exception handler are limited to the following service calls If calls other than the following are called normal system operation is not guaranteed e sns_tex e sns_ctx e sns_loc e sns_dsp e sns_dpn e get_tid iget_tid e ras_tex iras_tex e vsta_knl ivsta_knl e vsys_dwn ivsys_dwn CPU exception TRAPA instruction exception handlers can also be defined statically by the configurator The service calls vdef_trp and ivdef_trp are functions original to the HI7000 4 series Rev 6 00 249 RENESAS REJ10B0060 0600 Section3 Service Calls 3 22 3 Refer to Configuration Information ref_cfg iref_cfg C Language API ER ercd ref_cfg T_RCFG pk_rcfg Parameters T_RCFG pk_rcfg R4 Pointer to the packet where the configuration information is to be returned Return Parameters ER ercd RO Normal end E_OK or error code T_RCFG pk_rcfg R4 Pointer to the packet where the configuration information is stored Packet Structure typedef struct t_rcfg ID maxtskid 0 2 Maximum task ID ID ststkid 2 2 Maximum ID of task using static stack ID maxsemid 4 2 Maximum semaphore ID ID maxflgid 6 2 Maximum event flag ID ID maxdtqid 8 2 Maximum data qu
345. ng the DSP in Programs for HI7000 4 and HI7700 4 only 4 Defining a Direct Interrupt Handler A direct interrupt handler can be defined in either of the following ways e By making a def_inh or idef_inh service call e By specification in the configurator Rev 6 00 318 REJ10B0060 0600 RENESAS Section4 Application Program Creation 5 Using the IRL Interrupt In an IRL interrupt two different interrupt causes are assigned to one vector When using both of these causes the direct interrupt handler must be modified as shown in figure 4 8 e Creating an interrupt handler in C language Create the main process as a normal C function as shown in figure 4 8 In assembly language create the interface routine which calls the C function when an interrupt occurs as shown in figure 4 9 When defining interrupt handlers by the configurator specify the interface routine address as the interrupt handler address Rev 6 00 319 RENESAS REJ10B0060 0600 Section4 Application Program Creation include kernel h void vec071_handler14 void Describes the program as a usual void type function IRL14 interrupt processing void vec0O71_handler15 void Describes the program as a usual void type function IRL15 interrupt processing Figure 4 8 Example of a C Language IRL Direct Interrupt Handler Main Processing Routine EXPORT _Vec071 Externally defines the interface routine I
346. ng to receive or send a message TSK_NONE 0 is returned as a wait task ID Rev 6 00 174 REJ10B0060 0600 RENESAS Section3 Service Calls 3 13 Memory Pool Management Fixed Size Memory Pool Fixed Size Memory Pool Service Calls Fixed size memory pools are controlled by the service calls listed in table 3 41 Table 3 41 Service Calls for Fixed Size Memory Pool Control System State Service Call Description T N E D U L C cre_mpf s Creates fixed size memory pool T E D U icre_mpf N E D U acre_mpf Creates fixed size memory pool and assigns fixed size T E D U iacre_mpft memory pool ID automatically N E D U del_mpf Deletes fixed size memory pool T E D U get_mpf S Acquires fixed size memory block T E U pget_mpf S Polls and acquires fixed size memory block T E D U ipget_mpf N E D U tget_mpf S Acquires fixed size memory block with timeout function T E U rel_mpf S Returns fixed size memory block T E D U irel_mpf N E D U ref_mpf Refers to fixed size memory pool state T E D U iref_mpf N E D U Notes 1 S Standard profile service calls s Service calls that are not standard profile service calls but are needed in order to use the standard profile function 2 T Can be called from task context N Can be called from non task context E Can be called from dispatch enabled state D Can be called from dispatch disabled state U Can be called from CPU unlocked state L Can be called from CPU locked
347. nloaded from the TRON association homepage http www assoc tron org 4 The copyright of the ITRON specification belongs to the TRON association 5 Microsoft Windows 98 Microsoft Windows Millennium Edition Windows Me operating system Microsoft Windows NT operating system Microsoft Windows 2000 operating system and Microsoft Windows XP operating system are registered trademarks of Microsoft Corporation in the United States and or other countries 6 SuperH is a trademark of Renesas Technology Corp 7 All other product names are trademarks or registered trademarks of the respective holders Rev 6 00 REJ10B0060 0600 RENESAS Preface This manual describes how to configure systems using the HI7000 4 HI7700 4 and HI7750 4 hereinafter collectively referred to as the HI7000 4 series embedded realtime multitasking operating systems based on uITRON4 0 specifications Please read this manual and the related manuals listed below before using the HI7000 4 series to fully understand the operating system This user s manual contains the following five sections and appendixes Section 1 Introduction to HI7000 4 series general description of HI7000 4 series systems Section 2 Kernel overview of HI7000 4 series kernel functions Section 3 System calls overview of HI7000 4 series kernel system calls Section4 Applications creating applications in C using sample programs Section 5 System configuration
348. not caused Rev 6 00 245 RENESAS REJ10B0060 0600 Section3 Service Calls 3 22 1 Define CPU Exception Handler def_exc idef_exc C Language API ER ercd def_exc EXCNO excno T_DEXC pk_dexc ER ercd idef_exc EXCNO excno T_DEXC pk_dexc Parameters EXCNO excno R4 CPU exception handler number T_DEXC pk_dexc R5 Start address of the definition information of CPU exception handler Return Parameters ER ercd RO Normal end E_OK or error code Packet Structure typedef struct t_dexc ATR excatr 0 4 Handler attribute FP exchdr 4 4 Handler address UINT excsr 8 4 SR at initiation ignored in HI7000 4 T_DEXC Error Codes E_RSATR p Invalid attribute excatr is invalid E_PAR p Parameter error pk_dexc is other than a multiple of four or exchdr is an odd value HI7000 4 Invalid number specification excno 25 or 26 or excno gt CFG_MAXVCTNO HI7700 4 HI7750 4 Invalid number specification excno is other than a multiple of H 20 excno H 160 or excno gt CFG _MAXVCTNO Function The handler for the CPU exception handler number specified by excno is defined as the content specified by pk_dexc The CPU exception handler number is for the HI7000 4 the CPU vector number and for the HI7700 4 and H17750 4 the CPU exception code EXPEVT code For the HI7700 4 and HI7750 4 CPU exception handlers cannot be defined for exception codes for which the EXPEVT code is other than a multi
349. nted by pk_save and initializes FPSCR to ini_fpscr 4 void EndFPU_ALLBANK T_FPU_ALLBANK pk_save When both FPU register banks are used this macro should be used at the end of the handler function This macro restores both FPU bank register contents from the area pointed by pk_save Figure G 2 shows an example of interrupt handler to initialize FPSCR and guarantee FPU registers Rev 6 00 439 RENESAS REJ10B0060 0600 Appendix G Notes on FPU of SH2A FPU SH 4 SH4A include lt sh4fpu h gt Include sh4fpu h define INI_FPSCR 0x00040001 FR 0 PR 0 DN 1 SZ 0 RM B 01 void HandlerMain void Handler main routine Handler processing void Handler void Handler entry function T_FPU_ONEBANK area For saving FPU registers IniFPU_ONEBANK amp area INI_FPSCR Save FPU registers and initialize FPSCR HandlerMain Call HandlerMain which performs main processing EndFPU_ONEBANK amp area Restore FPU registers Figure G 2 Example of Interrupt Handler to Initialize FPSCR and Guarantee FPU Registers SH 4 SH 4A Rev 6 00 440 REJ10B0060 0600 RENESAS Appendix G Notes on FPU of SH2A FPU SH 4 SH4A G 2 3 SH2A FPU The HI7000 4 provides the following macros for the above operations These macros are defined in sh2fapu h The code asmcode compiler option must be specified because these macros use in line assemble function 1 v
350. ntries of the target cache determined by mode will be invalidated In this case this service call operates the following bits of the CCR register according to mode This processing is performed in the state of SR BL 1 e mode TC_FULL Writes 1 to ICI bit and OCI bit e mode TC_EXCLUDE_IC Writes 1 to OCI bit e mode TC_EXCLUDE_OC Writes 1 to ICI bit In the HI7750 4 this service call can be called before the kernel is initiated This service call can be called even in the exception block state BL 1 in SR Therefore the cache can be invalidated irrespective of interrupts or exceptions When this service call has been called when BL 1 in SR clear BL to 0 after returning from the service call processing Rev 6 00 276 REJ10B0060 0600 RENESAS Section3 Service Calls 3 26 Cache Support Function HI7700 4 for SH4AL DSP with Extended Function HI7750 4 for SH 4A with Extended Function This function is supported only for the HI7700 4 and HI7750 4 As for a cache support function libraries differ for every microcomputer table 3 79 And a part of functions and API differ for every library Table 3 79 Library of Cache Support Function Kernel CPU Target Cache Library HI7700 4 SH 3 SH3 DSP Mixed instruction data 7708_cache_ lib SH4AL DSP without Instruction cache and operand cache sh4al_cache_ lib extended function SH4AL DSP with Instruction cache and operand shx2_cache_ lib extended fun
351. o CFG_TSKSTKSZ Rev 6 00 405 RENESAS REJ10B0060 0600 Appendix CCalculation of Work Area Size Interrupt Handler and Time Event Handler Stack Area Section B_hiirgstk Area used by interrupt handlers and time event handlers The size of the interrupt handler and time event handler stack area is determined according to CFG_IRQSTKSZ and CFG_TMRSTKSZ respectively Memory Pool Area Section B_himpl Area for variable size and fixed size memory pools The size of the memory pool area is determined according to CFG_MPLSZ and CFG_MPFSZ DX Trace Buffer Area Section B_hitrcbuf This area is allocated when the target trace is set to CFG_TRCTYPE The size is fixed to CFG_TRCBUFSZ bytes DX Emulator Trace Tool Trace Area Section B_hitrceml This area is allocated when emulator trace tool trace is specified through CFG_TRCTYPE The size is fixed to 14 bytes Work Area Used by Application Area for variables used by applications C 2 Stack Types Each task or handler requires its own contiguous stack area If a stack overflows the system will operate incorrectly Therefore the user must determine the stack size required for each task or handler execution and allocate enough area for each task or handler by referring to the following description Task Stack An independent stack used by each task ID The kernel switches task stacks at task scheduling A task exception processing routine also uses the stack used by the same task Ta
352. o include all application files in a whole load module kernel load module or kernel environment load module In this case no application load module is required To create a new load module with applications alone see the details of the procedure for adding a new project into the sample workspace hios hws or creating a new workspace as given in the HEW User s Manual or online help Please note the following points for linkage 1 Definition of __kernel cnfgtbl address The following symbol address must be defined e _ kernel cnfgtbl Service call interface data As this service call interface data is included in the kernel load module mix or def the service call interface data allocation address must therefore be forcibly defined __kernel_cnfgtbl is the start address of the C_hibase section in the kernel side configuration file kernel_def c Rev 6 00 388 REJ10B0060 0600 RENESAS No Service Call Appendix A Service Call List C Language API Function Task Management Function 1 cre_tsk ER ercd cre_tsk ID tskid T_ CTSK pk_ctsk Create Task Using Dynamic Stack icre_tsk ER ercd icre_tsk ID tskid T CTSK pk_ctsk 2 vscr_tsk ER ercd vscr_tsk ID tskid T_CTSK pk_ctsk Create Task Using Static Stack ivscr_tsk ER ercd ivscr_tsk ID tskid T CTSK pk_ctsk 3 acre_tsk ER_ID tskid acre_tsk T_CTSK pk_ctsk Create Task an
353. o the following operations a Checks CFG_DSP in the configurator As a result the SR DSP bit when the task starts becomes 1 b Interrupt handlers and CPU exception handlers If the handler has DSP operation the DSP bit of the SR specified in the following operations must be 1 e def_inh idef_inh def_exc idef_exc vdef_trp ivdef_trp e Definition of interrupt handlers and CPU exception handlers including TRAPA in the configurator However refer to section 4 2 2 Cache Lock Function SH 3 SH3 DSP if using cache lock function of SH 3 and SH3 DSP Rev 6 00 293 RENESAS REJ10B0060 0600 Section4 Application Program Creation 6 SR CL Bit Cache lock bit SH 3 When using cache lock function on the microcomputer which has CL bit in the SR register refer to section 4 2 2 Cache Lock Function SH 3 SH3 DSP 7 SR FD FPU disable bit SH 4 and SH 4A The SR FD bit must not be set in the application programs In other words the FPU disable exception of SH 4 cannot be used The FD bit of the SR register must always be cleared to 0 in the following cases e def_inh idef_inh def_exc idef_exc vdef_trp ivdef_trp e Definition of interrupt handlers and CPU exception handlers including TRAPA in the configurator For further information refer to Appendix G Notes on FPU of SH2A FPU SH 4 SH4A 4 2 2 Cache Lock Function SH 3 SH3 DSP When using cache lock function do the following operations Note the ker
354. ocessing enabled state e Pended exception factor is not 0 e Task is in the RUNNING state e Non task context or the CPU exception handler is not executed When the task returns from the task exception processing routine the processing that is performed before the task exception processing routine was initiated is continued At this time the task enters the task exception enabled state When the pended exception factor is not 0 the task exception processing routine is initiated again Rev 6 00 110 REJ10B0060 0600 RENESAS Section3 Service Calls 3 6 1 Define Task Exception Processing Routine def_tex idef_tex C Language API ER ercd ER ercd Parameters ID T_DTEX Return Parameters ER Packet Structure typedef T_DTEX Error Codes E_RSATR E_PAR E_NOEXS Function def_tex ID tskid T_DTEX pk_dtex idef_tex ID tskid T_DTEX pk_dtex ATR tskid R4 Task ID pk_dtex R5 Pointer to the packet where task exception processing routine definition information is stored ercd RO Normal end E_OK or error code struct t_dtex texatr 0 4 Task exception processing routine attribute texrtn 4 4 Task exception processing routine FP p p p k initiation address Reserved attribute texatr is invalid Parameter error pk_dtex is other than a multiple of four or texrtn is an odd value Out of ID range tskid lt 0 tskid gt CFG_MAXTSKID or tskid TSK_SELF 0 is specif
355. odule that is not linked When this extended service call is issued the corresponding extended service call routine is called Each processing unit is processed with the following precedence 1 Interrupt handlers time event handlers and CPU exception handlers 2 Dispatcher part of kernel processing 3 Tasks The dispatcher is a kernel processing that switches a task to be executed The precedence of an interrupt handler becomes higher when an interrupt level is higher The precedence of a time event handler is the same as a timer interrupt level CFG_TIMINTLVL The precedence of a CPU exception handler is higher than that of the processing where the CPU exception occurred and of the dispatcher The precedence of a CPU exception handler is also lower than that of other processings which have the higher precedence than those where the CPU exception occurred The precedence between tasks depends on the priority of these tasks The precedence of an extended service call routine is higher than that of the processing where the extended service call was called The precedence of an extended service call routine is also lower than that of other processings which have the higher precedence than those where the extended service call was called Rev 6 00 6 REJ10B0060 0600 RENESAS Section2 Kernel The precedence of a task s exception processing routine is higher than that of the task and lower than that of other higher level tasks
356. of an interrupt handler In addition it should always be used in combination with ivend_int An error does not result if it is called from code other than an interrupt handler but in such cases there is the possibility that the debugging extension trace display may be illegal If CFG_TRACE is not checked by the configurator this service call does not perform any processing This service call is a function original to the HI7000 4 series Rev 6 00 234 REJ10B0060 0600 RENESAS Section3 Service Calls 3 19 15 Acquire End of Interrupt Handler as Trace Information ivend_int C Language API ER ercd ivend_int UINT dintno Parameters UINT dintno R4 Interrupt handler number Return Parameters ER ercd RO Normal end E_OK Error Codes None Function The end of processing of the interrupt handler for the interrupt handler number specified by dintno is traced The interrupt handler number is for the HI7000 4 the CPU vector number and for the HI7700 4 and HI7750 4 is the CPU exception code in the case of a CPU for which INTEVT2 exists the INTEVT2 code otherwise the INTEVT code This service call should be called at the end of an interrupt handler In addition it should always be used in combination with ivbgn_int An error does not result if it is called from code other than an interrupt handler but in such cases there is the possibility that the debugging extension trace display may be illegal If CFG_TR
357. of variable size memory pool area required to hold the blkcnt number of blksz byte memory blocks target byte size 4 SIZE mplsz VTSZ_MPLMB UINT sctnum The size of management area for variable size memory pool with the VTA_UNFRAGMENT attribute bytes Related Pages e p 290 Table 4 1 in section 4 1 1 Header File 1 6 Initial Value of DSR V 2 01 Release 00 The initial value of DSR in the task with the TA_COPO0 attribute and its task exception processing routine is changed from an undefined value to 0 Note that this change also applies to V 1 03 Release 02 When the TA_COP0 specification is switched from off to on through the vchg_cop service call the kernel does not initialize DSR in the previous version but in V 2 01 the kernel initializes it to 0 Related Pages e p 337 Section 4 13 Using the DSP in Programs for HI7000 4 and H17700 4 only Rev 6 00 458 REJ10B0060 0600 RENESAS Appendix New Functions of HI7700 4 V2 1 7 Initial Value of SR in Task Exception Processing Routine V 2 01 Release 00 The initial value of SR in the task exception processing routine is changed as follows Previous version Same value as in the task before initiation V 2 01 H 40001000 when either CFG_DSP or CFG_CACLOC is selected or H 40000000 when neither of them is selected 1 8 Extension of Maximum Exception Code CFG_MAXVCTNO V 2 01 Release 00 The maximum exception code that can be specified for CFG_LMAXVCTNO through t
358. ogram Table F 1 Module Standby State at Initiating Programs Program Module Standby State Task With TA_COPO Non standby Without TA_COPO Standby Task exception processing routine With TA_COPO Non standby Without TA_COPO Standby Expanded service call routine Same state as before the call Interrupt handler Undefined CPU exception handler Undefined Time event handler Undefined Initialization routine Undefined When the kernel is idling i e there is no executable task a module associated with the TA_COP0 attribute enters the standby state Rev 6 00 431 RENESAS REJ10B0060 0600 Appendix D DSP Standby Control HI7700 4 F 4 Service Call for Changing the TA_COP0 Attribute vchg_cop C Language API ER_UINT oldatr vchg_cop ATR newatr Parameters ATR newatr R4 Attribute after changing Return Parameters ER_UINT oldatr RO Attribute before changing 0 or a positive value or error code Error Codes E_RSATR p Invalid attribute newatr is invalid E_CTX k Context error Called from non task context Function When this call is issue the TA_COPO attribute of the calling task is changed as newatr Either of the following values can be specified for newatr newatr TA COPO TA NULL TA_COPO H 00000100 DSP is used TA_NULL H 00000000 DSP is not used The value returned is oldatr whether or not a TA_COP0 attribute was specified before this service call was issued TA_COPO The
359. oid IniFPU VT_FPU pk_save UW ini_fpscr This macro should be used at the start of the handler function This macro saves FPU registers including FPSCR to the area pointed by pk_save and initializes FPSCR to ini_fpscr 2 void EndFPU VT_FPU pk_save This macro should be used at the end of the handler function This macro restores FPU registers including FPSCR from the area pointed by pk_save Refer to figure G 2 for an example of interrupt handle The interrupt handler for the SH2A FPU differs from the example in figure G 2 only in the header file name and macro name G3 Extended Service Call Routine The compiler handles issuing of extended service calls as calling of functions G 3 1 Compiler Options The compiler handles issuing of extended service calls as calling of functions Therefore the same settings should be made for the following compiler options between an extended service call routine and its caller fpu option fpscr option denormalize option round option When these options are different between the caller and the extended service call routine note the following 1 Initialize FPSCR At initiation FPSCR FR bits FPU register bank of SH 4 and SH 4A are the same as before an extended service call and other FPSCR bits are determined by compiler options When floating point calculation is executed in an extended service call routine it is necessary to initialize FPSCR at the start of the entry function of the e
360. oid Overhdr ID tskid VP_INT exinf Passes tskid indicating the initiation factor and exinf for the task Handler processing Figure 4 11 Example of a C Language Overrun Handler 2 Rules for Using Registers in Time Event Handlers and Initialization Routine Tables 4 18 to 4 20 show rules on using registers for HI7000 4 HI7700 4 and HI7750 4 Rev 6 00 329 RENESAS REJ10B0060 0600 Section4 Application Program Creation Table 4 18 Rules for Using Registers in Time Event Handler and Initialization Routine H17000 4 End Use Conditions No Registers Initial Value 1 PC vV Handler Routine start address 2 SR v m IMASK Time event handler Timer interrupt level CFG_TIMINTLVL Initialization routine Kernel interrupt mask level CFG_KNLMSKLVL Other bits Undefined 3 ROtoR3 V Undefined 4 R4 y Cyclic Alarm handler Initialization routine Extended information exinf Overrun handler Target task ID 5 R5 Vy Cyclic Alarm handler Initialization routine Undefined Overrun handler Extended information exinf for the task 6 R6toR7 V Undefined 7 R8to R14 MACH V V Undefined MACL GBR 8 R15 V V R15 points to appropriate stack area 9 PR V V Undefined 10 SH2 DSP DSR RS V V Undefined RE MOD AO A0G A1 A1G MO M1 XO X1 YO Y1 11 SH 2A SH2A FPU lt ol TBR 12 SH2A FPU FPSCR V V Undefined 13 SH2A FPU V V Undefined FRO to FR11 14 SH2A FPU
361. on Task processing ext_tsk Figure G 1 Example of Initialization of FPSCR in a Task Rev 6 00 437 RENESAS REJ10B0060 0600 Appendix G Notes on FPU of SH2A FPU SH 4 SH4A G 1 2 Attributes TA_COP1 and TA_COP2 Specify attributes TA_COP1 and TA_COP2 as described in table G 1 Table G 1 Specifying Attributes TA_COP1 and TA_COP2 Case SH2A FPU SH 4 SH 4A Matrix calculation both FPU register banks used TA_COP1 TA_COP2 Normal floating point calculation only FPU registerbankO TA_COP1 TA_COP1 is used No floating point calculation and fpu mix is specified as TA_COP1 Unnecessary compiler option No floating point calculation and fpu mix is not specified Unnecessary Unnecessary as compiler option Note This usage is not recommended G 2 Non Task Context Normal Interrupt Handler Direct Interrupt Handler CPU Exception Handler Time Event Handler Initialization Routine G 2 1 Overview 1 Guarantee FPU Registers When floating point calculation is executed these handlers need to guarantee all FPU registers 2 Guarantee FPSCR When fpu mix and fpscr aggressive are specified as compiler options in SH2A FPU these handlers must guarantee the FPSCR register even if these handlers do not perform floating point calculation When using SH 4 or SH 4A these handlers do not have to guarantee the FPSCR register 3 Initialize FPSCR The initial FPSCR value of CPU exc
362. on Table 5 7 DSP Standby CPU Core Control Function Optimized timer Driver Function Linkage Priority of the Kernel Library H1I7700 4 Linkage Priority SH 3 Cannot be used Unused 1 7708_cache_ lib 2 hiknl_ lib Used 1 opttmr_ lib 2 7708_cache_ lib 3 hiknl_ lib SH3 DSP Unused Unused 1 dsp_knl_ lib 2 7708_cache_ lib 3 hiknl_ lib Used 1 dsp_knl_ lib 2 opttmr_ lib 3 7708_cache_ lib 4 hiknl_ lib Used Unused 1 dspstby_ lib 2 dsp_knl_ lib 3 7708_cache_ lib 4 hiknl_ lib Used 1 dspstby_ lib 2 dsp_knl_ lib 3 opttmr_ lib 5 hiknl_ lib SH4AL Unused DSP without extended function Unused 1 sh4al_dsp_knl_ lib 2 sh4al_cache_ lib 3 hiknl_ lib Used 1 sh4al_dsp_knl_ lib 2 sh4al_opttmr_ lib 4 hiknl_ lib Used Unused 1 sh4al_dspstby_ lib 2 sh4al_dsp_knl_ lib 3 sh4al_cache_ lib 4 hiknl_ lib Used 1 sh4al_dspstby_ lib 2 sh4al_dsp_knl_ lib 3 sh4al_opttmr_ lib 4 sh4al_cache_ lib 5 hiknl_ lib 4 7708_cache_ lib 3 sh4al_cache_ lib Rev 6 00 368 REJ10B0060 0600 RENESAS Section5 Configuration
363. on 2 6 8 Task Execution Mode 2 6 9 Exclusive Control 2 6 10 Task Event Flags 2 7 Task Exception Processing 2 8 Semaphore wiscsscsc cei evccaivs cess cuvcsvebessasseestarcscsaivessasesiseteltvesseiset sds stiucsasseddebvsesvesscieviaceonnvedels 2 9 Event Flag 2 10 Data Queue 2 11 Mailbox 2 12 2 13 Message Buffer 2 14 Fixed Size Memory Pool sisccscissisacssceaceevaveasvasesvevesavanecesvavsdevsoaatepaceveatadscasasssvnsaneassates 2 15 Variable Size Memory Pool 2 15 1 Overview 2 15 2 Controlling Fragmentation of Free Space 2 15 3 Management of Variable Size Memory Pool 2 16 Time Management 2 16 1 Cyclic Handler 2 16 2 Alarm Handler 2 16 3 Overrun Handlet 2 16 4 Notes on Time Management 2 17 System State Management 2 17 1 System Down 2 17 2 Service Call Trace Function Rev 6 00 i RENESAS REJ10B0060 0600 Contents 2 18 2 18 1 Resetting the CPU and Initiating the Kernel 2 18 2 Interrupt Handlers 2 18 3 Disabling Interrupts 2 18 4 Kernel Interrupt Mask Level CFG_ KNLMSKLVL 2 18 5 CPU Exception 2 19 2 20 2 21 2 22 2 23 2 24 Section 3 3 1 3 2 3 2 1 C Language API 3 2 2 Assembly Language API 3 23 Guarantee of Register Contents after Issuing Service Call 3 2 4 Return Value of Service Call and Error Code 3 2 5 System State and Service Calls 0cccee 3 2 6 Service Calls not in the npITRON4 0 Specification 3 3 3 4 3 4 1 Crea
364. on Processing Routine def_tex idef_tex e p 373 Section 5 11 1 CPU Options for the Compiler and Assembler e p 437 Appendix G Notes on FPU of SH2A FPU SH 4 SH4A H 1 2 TBR Register V 2 00 Release 00 As the usage of TBR register one of the following three can be chosen 1 Kernel does not manage 2 Only for service call 3 Task context This is chosen by CFG_TBR in the Kernel Execution Condition page of configurator Related Pages e p 295 Section 4 2 8 TBR Register SH 2A SH2A FPU e p 356 Item No 1 4 in table 5 5 of section 5 4 6 Configurator Settings e p 373 Section 5 11 1 CPU Options for the Compiler and Assembler Rev 6 00 447 RENESAS REJ10B0060 0600 Appendix H New Functions of HI7000 4 V2 H 1 3 Register Banks V 2 00 Release 00 V 2 01 Release 00 and V 2 02 Release 00 In V 2 00 Release 00 the CFG_REGBANK checkbox was included allowing selection of whether or not to use register banks with all interrupts other than the NMI and UBC interrupts In V 2 02 Release 00 the CFG_REGBANK checkbox was replaced by a combo box extending the above capability by allowing the user to select whether or not to use register banks with interrupts at each of the individual interrupt priority levels Moreover in V 2 01 Release 00 the CFG_IBNR_ADR edit box was added to the Interrupt Handler CPU Exception Handler page of the configurator allowing selection of the IBNR address for the register banks This ed
365. on handlers Note 1 Inthe HI7700 4 TA_COPO attribute can be set or cleared by vchg_cop service call This additional size is necessary when TA_COPO attribute is set by vchg_cop 2 With the optimization timer driver or the DSP standby control function it becomes 168 Rev 6 00 409 RENESAS REJ10B0060 0600 Appendix CCalculation of Work Area Size An example of calculation is shown below for the HI7700 4 where the stack size considering programming nesting is added The program nesting shown in figure C 3 is used as an example task_a sub1 sub2 sub3 ___ gt texrtn 7 Uses 16 bytes task_b sub4 Figure C 3 Programming Nesting The stack size of each function is assumed as follows Table C 3 Stack Size of Each Function Function Size Byte Note task_a 56 Start function of task A No TA_COP0 attribute included task_b 40 Start function of task B No TA_COP0 attribute included sub1 88 task_a subroutine sub2 8 task_a subroutine sub3 24 Common subroutine sub4 12 task_b subroutine texrtn 172 16 188 Start function of task exception processing routine No TA_COPO attribute included CFG_NEWMPL is not selected The stack sizes of tasks A and B considering the calling path are shown in table C 4 Table C 4 Task Size Considering Calling Path Task Calling Path Task Size Byte Task A task_a lt 56 bytes gt sub1 lt 88 bytes gt 144 task_a lt 56
366. onse to events Recognizes events generated asynchronously and immediately executes a task to process the event e Task scheduling Schedules task execution on a priority basis e Service call execution Accepts various requests for processing service calls from tasks and performs the appropriate processing 2 2 Functions An application program can issue service calls to almost any kernel function Task Management When a task is executed the CPU is allocated to the task The kernel controls the order of CPU allocation and of the start and end of tasks Multiple tasks can share one stack by using the shared stack function Task Synchronization Management Performs basic synchronous processing for tasks such as suspension of task execution resumption and task event flag processing Synchronization and Communication Management Uses event flags semaphores data queues and mailboxes for inter task synchronization and communication Extended Synchronization and Communication Management Uses mutex and message buffers for inter task synchronization and communication Memory Pool Management Manages unused memory in the user system as a memory pool A task dynamically acquires blocks from or returns them to the memory pool The size of the memory pool can be fixed or variable Time Management Manages time related information for the system and monitors task execution times for control purposes System State Management Perform
367. operation is not guaranteed If 0 is specified for ovrtim the overrun handler is started on the first time tick after the task begins to use the processor For detail of time watch method refer to section 2 16 4 2 Time Watch Method Rev 6 00 216 REJ10B0060 0600 RENESAS Section3 Service Calls 3 18 3 Stop Overrun Handler Operation stp_ovr istp_ovr C Language API ER ercd stp_ovr ID tskid ER ercd istp_ovr ID tskid Parameters ID tskid R4 Task ID Return Parameters ER ercd RO Normal end E_OK or error code Error Codes E_ID p Invalid ID number tskid lt 0 tskid gt CFG_MAXTSKID or tskid TSK_SELF 0 is specified in a non task context E_NOEXS k Undefined Task specified by tskid does not exist E_OBJ k Object status is invalid Overrun handler has not been defined Function Each service call releases the upper processor time limit for the task indicated by parameter tskid and stops overrun handler operation By specifying tskid TSK_SELF 0 the current task can be specified Rev 6 00 217 RENESAS REJ10B0060 0600 Section3 Service Calls 3 18 4 Refer to Overrun Handler State ref_ovr iref_ovr C Language API ER ercd ref_ovr ID tskid T_ROVR pk_rovr ER ercd iref_ovr ID tskid T_ROVR pk_rovr Parameters ID tskid R4 Task ID T_ROVR pk_rovr R5 Pointer to the packet where the overrun handler state is to be returned Return Parameters ER ercd RO Nor
368. or Calculating Size V 2 00 Release 00 sseneeseseeeeeeeseeresresrreerrerrerrereees 450 H 6 Extension of Maximum Vector Number V 2 00 Release 00 o on 450 H 7 ID Name V 2 00 Release QO eh ssscecasecdtavecessns vesstestes sesesavesieadobsas Meeta let ccasshseesanctdervsess 451 H 8 Support of Little Endian in SH 2 V 2 00 Release 01 00 451 H9 Improvement of Variable Size Memory Pool V 2 01 Release 00 eee 451 H 10 Initial Value of DSR V 2 01 Release 00 0 0 eeccesceecseceessecesteeeseecnseeeceseeeeeeeeseees 452 H 11 Initial Value of SR in Task Exception Processing Routine V 2 01 Release QO sssaccssactaciacisscessavinevsiseecsaiccandiciesasscvsianasddasicaaacdesdeversdbseiaiaees H 12 Handling of Vector Numbers 16 to 31 V 2 01 Release 00 H 13 Lifting of Restriction concerning Structure Alignment V 2 01 Release 00 453 H 14 Open the file used last time Command for the Configurator V 2 02 Release QO EEE E T T TNE ETS 453 Appendix I New Functions of HI7700 4 V 2 esesesesesereeerseossesesososoecesnsesesee eseseesesee 455 Ll Support of SH4AL DSP with Extended Function V 2 01 Release 00 455 Rev 6 00 viii REJ10B0060 0600 RENESAS Contents 12 13 14 L5 1 6 1 7 1 8 19 1 10 Ll 1 12 Specifying Address of Task Stack Fixed Size Memory Pool and Variable Size Memory Pool V 2 01 Release 00 esseseesesseesessessessererresesresieresrrrsersrisrrsresres 455 Man
369. orities is 1 to CFG_MAXMSGPRI The same value of CFG_MAXMSGPR1 is output to kernel_macro h as TMAX_MPRI 3 Mailbox creation BA Specifiable contents are the same as those of the cre_mbx service call Rev 6 00 361 RENESAS REJ10B0060 0600 Section5 Configuration Table 5 5 Configurator Setting Items cont 15 Mutex Page 1 Maximum mutex ID CFG_MAXMTXID The range of usable mutex IDs is 1 to CFG_MAXMTXID The maximum value specifiable is 1023 When no mutex is used specify 0 When a value more than 1 is specified the cre_mtx service call must be embedded Mutex creation BA Specifiable contents are the same as those of the cre_mtx service call 16 Message Buffer Page 1 Maximum message buffer ID CFG_MAXMBFID The range of usable message buffer IDs is 1 to CPG_MAXMBFID The maximum value specifiable is 1023 When no message buffer is used specify 0 When a value more than 1 is specified the cre_mbf service call must be embedded 2 Message buffer area size CFG_MBFSZ When a message buffer is created a message buffer is allocated with area of the specified size 3 Message buffer creation BA Specifiable contents are the same as those of the cre_mbf service call 17 Fixed Size Memory Pool Page 1 Maximum fixed size memory pool ID CFG_MAXMPFID The range of usable fixed size memory pool IDs is 1 to CFG_MAXMPFID The maximum value specifia
370. ormal system operation cannot be guaranteed If TA_MPRI is not specified mprihd does not have any meaning and is simply ignored A mailbox can also be created statically by the configurator Rev 6 00 148 REJ10B0060 0600 RENESAS Section3 Service Calls 3 10 2 Delete Mailbox del_mbx C Language API ER ercd del_mbx ID mbxid Parameters ID mbxid R4 Mailbox ID Return Parameters ER ercd RO Normal end E_OK or error code Error Codes E_ID p Invalid ID number mbxid lt 0 or mbxid gt CFG_MAXMBXID E_NOEXS k Undefined Mailbox indicated by mbxid does not exist E_CTX k Context error Called from disabled system state Function Service call del_mbx deletes the mailbox indicated by parameter mbxid No error will occur even if there is a task waiting for a message in the mailbox indicated by mbxid However in that case the task in the WAITING state will be released and error code E_DLT will be returned If there is a message in the mailbox no error will occur but the kernel will not perform any processing for the message area For example the kernel will not automatically return the message area to the memory pool when a memory block acquired from the memory pool is used for a message Rev 6 00 149 RENESAS REJ10B0060 0600 Section3 Service Calls 3 10 3 Send Message to Mailbox snd_mbx isnd_mbx C Language API ER ercd snd_mbx ID mbxid T_MSG pk_msg ER ercd isnd_mbx ID mbxid T_MSG pk_msg
371. ormation Cache support function Flushes clears and invalidates cache HI7700 4 and HI7750 4 Rev 6 00 63 RENESAS REJ10B0060 0600 Section3 Service Calls 3 2 Service Call Interface Service calls can be called from programs written in C or assembly language This section describes how to issue service calls 3 2 1 C Language API 1 Header File Header file kernel h must be included kernel h can be found in the hihead folder For details on the header file refer to section 4 1 Header Files 2 Calling Form All service calls are described in the following C language function call format include kernel h YE nas A ercd act_tsk 1 Rev 6 00 64 REJ10B0060 0600 RENESAS Section3 Service Calls 3 Basic Data Type The basic data type defined in the HI7000 4 series are shown in the table 3 2 Table 3 2 Basic Data Type No DataType Meaning No DataType Meaning 1 B 8 bit signed integer 21 PRI 16 bit signed integer 2 H 16 bit signed integer 22 SIZE 32 bit unsigned integer 3 Ww 32 bit signed integer 23 TMO 32 bit signed integer 4 UB 8 bit unsigned integer 24 RELTIM 32 bit unsigned integer 5 UH 16 bit unsigned integer 25 SYSTIM A structure which contains the following members 6 UW 32 bit unsigned integer Upper 16 bit unsigned integer 7 VB 8 bit signed integer Lower 32 bit unsigned integer 8 VH 16 bit signed integer
372. ot_rdq ER ercd irot_rdq PRI tskpri 126 get tid ER ercd get_tid ID p_tskid Refer to Task ID in RUNNING iget_tid ER ercd iget_tid ID p_tskid State 127 loc_cpu ER ercd loc_cpu void Lock CPU iloc_cpu ER ercd iloc_cpu void 128 unl_cpu ER ercd unl_cpu void Unlock CPU iunl_cpu ER ercd iunl_cpu void 129 dis_dsp ER ercd dis_dsp void Disable Dispatch 130 ena_dsp ER ercd ena_dsp void Enable Dispatch 131 sns_ctx BOOL state sns_ctx void Refer to Context 132 sns_loc BOOL state sns_loc void Refer to CPU Locked State 133 sns_dsp BOOL state sns_dsp void Refer to Dispatch Disabled State 134 sns_dpn BOOL state sns_dpn void Refer to Dispatch Pended State RENESAS Rev 6 00 397 REJ10B0060 0600 Appendix A Service Call List No Service C Language API Function Call 135 vsta_knl void vsta_knl void Start Kernel ivsta_knl void ivsta_knl void 136 vsys_dwn void vsys_dwn W type ER ercd VW inf1 VW inf2 Terminate System ivsys_dwn_ void ivsys_dwn W type ER ercd VW inf1 VW inf2 137 vget_tre ER ercd vget_trc VW paral VW para2 VW para3 VW Acquire Trace Information para4 ivget_trc ER ercd ivget_trc VW para1 VW para2 VW para3 VW para4 138 ivbgn_int ER ercd ivbgn_int UINT dintno Acquire Start of Interrupt Handler as Trace Information 139 ivend_int ER ercd ivend_int UINT dintno Acquire End of Interrupt Handler as Trace Information Interrupt Ma
373. ote The 7750_cache_ lib library is not dedicated for the SH7750 it is used for all SH 4 series Rev 6 00 370 REJ10B0060 0600 RENESAS Section5 Configuration 5 10 Section Configuration The allocation address of each module is determined at the time of linkage regardless of the linkage methods A module is allocated in section units The sections are described here Table 5 9 lists the section names for the supplied files included with the product The first letter in a section name gives the section attribute P Attribute Program sections which can be located in a ROM C Attribute Constant sections which can be located in a ROM B Attribute Non initialized data sections which must be located in a RAM D and R Attribute D attribute is an initialized data section which can be located in a ROM When locating a D attribute section in a ROM the contents of the section must be copied to a RAM before executing the program so as to enable the contents to be treated as variables To be specific the following procedures are required e Create an R attribute section with the same size as the D attribute section by using the ROM support function provided by the optimized linkage editor Allocate the R attribute section toa RAM e Create a program for copying the contents of the D attribute section to the R attribute section and execute it at program initiation usually a CPU initialization subroutine Rev 6 00 371 RENES
374. out period If a positive value is specified for parameter tmout the WAITING state is released and error code E_TMOUT is returned when the tmout period has passed without the wait release conditions being satisfied If tmout TMO_POL 0 is specified the task continues execution by decrementing the wake up request count by one if the count is a positive value If the wake up request count is 0 error code E_TMOUT is returned If tmout TMO_FEVR 1 is specified the same operation as for service call slp_tsk will be performed In other words timeout will not be monitored If a value larger than 1 is specified for CFG_TICDENO the denominator for time tick cycles the maximum value that can be specified for tmout is H 7fffffff CFG_TICDENO If a value larger than this is specified operation is not guaranteed Rev 6 00 98 REJ10B0060 0600 RENESAS Section3 Service Calls 3 5 2 Wakeup Task wup_tsk iwup_tsk C Language API ER ercd wup_tsk ID tskid ER ercd iwup_tsk ID tskid Parameters ID tskid R4 Task ID Return Parameters ER ercd RO Normal end E_OK or error code Error Codes E_ID p Invalid ID number tskid lt 0 tskid gt CFG _MAXTSKID or tskid TSK_SELF 0 is specified in a non task context E_NOEXS k Undefined Task indicated by tskid does not exist E_OBJ k Object status is invalid Task indicated by tskid is in the DORMANT state E_QOVR k Queuing overflow wupcnt gt 15 Function Each s
375. pecified as mpl the kernel allocates an mplsz byte area from the variable size memory pool area CFG_MPLSZ After the memory pool has been created the free variable size memory pool area will decrease by an amount given by the following expression Decrease in size mplsz 16 4 mplmb mplmb is a member not defined in the pITRON4 0 specification Parameter mplmb is only valid when VTA_UNFRAGMENT is specified it is ignored in other cases Allocate an area for the size calculated by the following macro and specify the start address of the area as mplmb VTSZ_MPLMB maximum sector number Rev 6 00 188 REJ10B0060 0600 RENESAS Section3 Service Calls 5 minblksz and sctnum These are parameters not defined in the pITRON4 0 specification These parameters are valid only when VTA_UNFRAGMENT is specified For details refer to the above description of attribute VTA_UNFRAGMENT Variable size memory pools can also be created statically by the configurator Supplement The standard alignment size for the address of a memory block is 4 To specify an address with the cache line size 16 or 32 allocate the area as follows N means the alignment size 1 When CFG_NEWMPL is selected and VTA_UNFRAGMENT is not specified e Allocate a memory pool area to the N byte boundary address and specify that address when creating a memory pool e Specify a multiple of N as the size of every memory block to be acquired 2 When CFG_NE
376. phdr is an odd address HI7000 4 Invalid number specification trpno 25 or 26 or trpno gt CFG_MAXVCTNO HI7700 4 HI7750 4 Invalid number specification trpno gt CFG _MAXTRPNO Function Each service call defines a CPU exception TRAPA instruction exception handler for the trap number indicated by dtrpno with the contents specified by pk_dtrp The parameter trpatr is specified in the following format See table 3 70 for details trpatr TA_HLNG TA_ASM Rev 6 00 248 REJ10B0060 0600 RENESAS Section3 Service Calls Table 3 70 CPU Exception TRAPA Instruction Exception Handler Attributes trpatr trpatr Code Description TA_HLNG H 00000000 The trap routine is written in a high level language TA_ASM H 00000001 The trap routine is written in assembly language The start address of the CPU exception TRAPA instruction exception handler is specified by trphdr For the HI7700 4 and HI7750 4 the value of the status register SR when initiating the CPU exception handler must be specified in trpsr trpsr is specified using the same bit position as the SR configuration For information of SR register see section 4 2 1 SR Register and section 4 2 2 Cache Lock Function SH 3 SH3 DSP On actual CPU exception handler initiation SR is as follows e Interrupt mask bit Same as before the exception occurred e Bits other than the CPU exception mask bit As specified by trpsr In the HI7000 4 the setti
377. ple of H 20 Operation is not guaranteed for exceptions which occur with codes other than multiples of H 20 such as TLB exceptions due to SH3 DSP repeat loops exception codes H 070 and H 0D0 The parameter excatr is specified in the following format See table 3 69 for details excatr TA_HLNG TA_ASM Rev 6 00 246 REJ10B0060 0600 RENESAS Section3 Service Calls Table 3 69 CPU Exception Handler Attributes excatr excatr Code Description TA_HLNG H 00000000 The handler is written in a high level language TA_ASM H 00000001 The handler is written in assembly language On the HI7700 4 and HI7750 4 excsr sets the value of the status register SR when initiating the interrupt handler excsr is specified using the same bit position as the SR configuration For information of SR register see section 4 2 1 SR Register and section 4 2 2 Cache Lock Function SH 3 SH3 DSP On actual interrupt handler initiation SR is as follows e Interrupt mask bit Same as before the exception occurred e Bits other than the CPU exception mask bit As specified by excsr In the HI7000 4 the setting of excsr has no meaning and is simply ignored The actual value of SR on startup is determined by the CPU interrupt processing When pk_dexc NULL 0 is specified the definition of excno is cancelled Service calls which can be called from a CPU exception handler are limited to the following service calls If calls other than th
378. pool area required to store the blkcnt number of blksz byte memory blocks bytes SIZE size VTSZ_MPFMB UNIT blkent UNIT blksz The size of fixed size memory pool management area required to store the blkcnt number of blksz byte memory blocks bytes SIZE mplsz TSZ_MPL UNIT bikent UNIT blksz The size of variable size memory pool area required to store the blkcnt number of blksz byte memory blocks bytes SIZE mplsz VTSZ_MPLMB UNIT sctnum x2 The size of variable size memory pool management area with the VTA_UNFRAGMENT attribute bytes TMAX_MAXSEM Maximum number of resources in the semaphore always 65535 Rev 6 00 290 REJ10B0060 0600 RENESAS Section4 Application Program Creation Table 4 1 File Name Constants and Macros cont Macro and Constants Description kernel_macro h TIC_NUME Numerator of time tick cycle TIC_DENO Denominator of time tick cycle TMAX_TPRI Highest task priority TMAX_MPRI Highest message priority VTCFG_TBR Indicates CFG_TBR 0 Kernel does not manage 1 Only for service call 2 Task context VTCFG_REGBANK Indicates the CFG_REGBANK setting 0 Register bank is not used NOTUSE 1 Register bank is used except NMI and UBC ALL 2 You select level to beused register bank SELECT 3 MCU has no register banks NOBANK VTCFG_BANKLVLnn nn a value from 01 to 15 Indicates whether or
379. port Functions Kernel CPU Target Cache Library HI7700 4 SH 3 SH3 DSP Mixed instruction data 7708_cache_ lib SH4AL DSP without Instruction cache and operand cache sh4al_cache_ lib extended function SH4AL DSP with Instruction cache and operand cache shx2_cache_ lib extended function HI7750 4 SH 4 Operand cache 7750_cache_ lib SH 4A without Instruction cache and operand cache sh4a_cache_ lib extended function SH 4A with Instruction cache and operand cache shx2_cache_ lib extended function This section explains for SH 3 and SH3 DSP 7708_cache_ lib Rev 6 00 254 REJ10B0060 0600 RENESAS Section3 Service Calls Cache Support Service Calls The cache is controlled by the service calls listed in table 3 73 Table 3 73 Service Calls for Cache Support for SH 3 and SH3 DSP System State Service Call Description T N E D U L C vini_cac Initializes cache T N E D U ivini_cac T N E D U velr_cac Clears cache T N E D U ivelr_cac T N E D U vils_cac Flushes cache T N E D U ivfls_cac T N E D U vinv_cac Invalidates cache T N E D U ivinv_cac T N E D U Notes 1 S Standard profile service calls s Service calls that are not standard profile service calls but are needed in order to use the standard profile function T Can be called from task context N Can be called from non task context E Can be called from dispatch enabled st
380. pragma noregsave Task lt pragma noregsave can be used because the task function does not need to guarantee register contents void Task VP_INT exinf lt When a task is initiated by TA_ACT attribute or act_tsk passes exinf specified at task creation as a parameter when a task is initiated by sta_tsk passes stacd specified by sta_tsk as a parameter task processing ext_tsk lt Uses an ext_tsk or exd_tsk service call to end a task lt Calls ext_tsk automatically at the end of a task function Figure 4 1 Example of a C Language Task Rev 6 00 297 RENESAS REJ10B0060 0600 Section4 Application Program Creation 2 Rules on Using Registers Tables 4 2 to 4 4 show rules on using registers for HI7000 4 HI7700 4 and HI7750 4 Table 4 2 Rules on Using Registers in a Task H1I7000 4 End Use Conditions No Registers sai 7 Initial Value 1 PC vV Task start address 2 SR v i H 00000000 3 ROtoR3 V Undefined 4 R4 y Activated by TA_ACT attribute or act_tsk exinf which is specified at task creation Activated by sta_tsk stacd which is specified by sta_tsk 5 R5 to R14 MACH MACL V Undefined GBR R15 V V End address of stack area for the task PR V v Undefined 8 SH2 DSP DSR ai 0 when attribute TA_COPO is specified or undefined in other cases 9 SH2 DSP RS RE MOD Undefined AO AOG A1 A1G MO M1 XO X1 YO Y1 10 SH 2A SH2A FPU TBR 7 Undefi
381. r Change TA_COP0 attribute Rev 6 00 400 REJ10B0060 0600 RENESAS B 1 Service Call Error Code List Table B 1 Service Call Error Code List Appendix B Error List Error Code Error Mnemonic Error Code Check Type Error Contents 1 E_OK H 00000000 D O k Normal end 2 E_NOSPT H fffffff7 D 9 p Unsupported function function is undefined 3 E_RSFN H fffffff6 D 10 p No service call is included E_RSATR H fffffff5 D 11 p Reserved attribute invalid attribute 5 E_PAR H ffffffef D 17 p k Parameter error 6 E_ID H ffffffee D 18 p Invalid ID number 7 E_CTX H ffffffe7 D 25 k Context error 8 E_ILUSE H ffffffe4 D 28 k Illegal use of service call 9 E_NOMEM H ffffffdf D 33 k Insufficient memory 10 E_NOID H ffffffde D 34 k No ID available 11 E OBJ H ffffffd7 D 41 k Object state is invalid 12 E_NOEXS H ffffffd6 D 42 k Object does not exist 13 E_QOVR H ffffffd5 D 43 k Queuing or nest overflow 14 E_RLWAI H ffffffcf D 49 k WAITING state is forcibly cancelled 15 E TMOUT H ffffffce D 50 k Polling failed or timeout 16 E DLT H ffffffcd D 51 k Waiting object deleted Note p is an error that is checked when the parameter checking function CFG_PARCHk is selected by the setup file k is an error that is always checked Rev 6 00 401 RENESAS REJ10B0060 0600 Appendix B Error List B 2 Information d
382. r CFG_REGBANK 1 1 When CFG_DIRECT has been selected 12 x CFG_UPPINTNST 20 x CFG_LOWINTNST 1 2 When CFG_DIRECT has not been selected 12 x CFG_UPPINTNST 24 x CFG_LOWINTNST 20 However when CFG_LOWINTNST is 0 assume the underlined part to be 0 2 When ALL has been selected for CFG_REGBANK 8 x CFG_UPPINTNST 16 x CFG_LOWINTNST If you are using UBC interrupts however the following values must also be added UBC interrupts used as direct interrupts 4 bytes UBC interrupts used as normal interrupts 28 bytes 2 Size of the stack area used by the NMI interrupt handler calculated as shown in appendixes C 4 and C 5 8 x NMI nest count When there is no nesting the NMI nest count is 1 3 In the HI7700 4 TA_COPO attribute can be set or cleared by vchg_cop service call This additional size is necessary when TA_COP0 attribute is set by vchg_cop 4 With the optimization timer driver or the DSP standby control function it becomes 208 C 6 2 Stack Area Acquisition The dynamic stack area can be automatically allocated by specifying a size in CFG_TSKSTKSZ by the configurator For CFG_TSKSTKSZ use the value of the following equation or a larger size CFG_TSKSTKSZ Stack use size of the task which uses dynamic stack 16 28 Rev 6 00 412 REJ10B0060 0600 RENESAS Appendix CCalculation of Work Area Size C 7 Interrupt Handler Stacks C 7 1 Stack Size Used by an Interrupt Handler The interrupt handler stack s
383. r block size When all blocks in a sector are released the sector itself is also released When a large block is requested larger than minblksz x 8 the kernel always allocates a block for the requested size without creating a sector 2 15 3 Management of Variable Size Memory Pool The kernel creates a management table in a variable size memory pool to manage the allocated memory blocks When determining the variable size memory pool note that the variable size memory pool area is used for the kernel management table area as well as the memory block area to be acquired by the application 1 When CFG_NEWMPL is not selected The kernel creates a 16 byte management table when a memory block is acquired This management table is released when the memory block is returned 2 When CFG_NEWMPL is selected When the VTA_UNFRAGMENT attribute is specified the kernel creates a 32 byte management table at creation of a sector This management table is released when the sector is released The kernel also creates a 32 byte management table when a memory block is allocated outside of a sector while the VTA_UNFRAGMENT attribute is specified or when a memory block is allocated while the VTA_UNFRAGMENT attribute is not specified This management table is released when the memory block is returned Rev 6 00 42 REJ10B0060 0600 RENESAS Section2 Kernel 2 16 Time Management The kernel provides the following functions related to time man
384. r can be specified to be mode e TC_FULL H 00000000 Both instruction cache and operand cache e TC_EXCLUDE_IC H 00000001 Exclude instruction cache only operand cache TC_EXCLUDE_OC H 00000002 Exclude operand cache only instruction cache invadr1 is omitted to the multiple of 32 and invadr2 is revalued to the multiple 1 of 32 1 Invalidate specified range This service call invalidates the cache entry whose logical address is from invadr1 to invadr2 This service call repeats and executes the following instructions from clradr1 to clradr2 e mode TC_FULL ICBI and OCBI e mode TC_EXCLUDE_IC OCBI e mode TC_EXCLUDE_OC ICBI During this processing the SR value remains the same as when this function is called When no interrupt should be accepted during this function processing mask interrupts and then call this function Rev 6 00 286 REJ10B0060 0600 RENESAS Section3 Service Calls In this service call only the fundamental error check indicated in the error code column is performed on invadr1 and invadr2 For example the following addresses should not be contained e P2 and P4 areas e Address corresponding to a physical address in the control area e Address corresponding to a physical address in X Y memory The processing time of this service call is proportional to the size of the appointed domain 2 Invalidate all If 0 is specified to be invadr and H ffffffff is specified to be invadr2 all the entries of
385. r is started each time the start cycle has passed based on the timing at which the service calls are called If the cyclic handler specified by cycid is in the operating state and TA_PHS is not specified as its attribute the next timing of initiation is set after the service call is called If the cyclic handler specified by cycid is in the operating state and TA_PHS is specified as its attribute the next timing of initiation is not set Rev 6 00 204 REJ10B0060 0600 RENESAS Section3 Service Calls 3 16 4 Stop Cyclic Handler stp_cyc istp_cyc C Language API ER ercd stp_cyc ID cycid ER ercd Parameters ID Return Parameters ER Error Codes E_ID p E_NOEXS k Function istp_cyc ID cycid cycid R4 Cyclic handler ID ercd RO Normal end E_OK or error code Invalid ID number cycid lt 0 or cycid gt CFG_MAXCYCID Undefined Cyclic handler specified by cycid does not exist Each service call causes the cyclic handler indicated by parameter cycid to enter the not operating state Rev 6 00 205 RENESAS REJ10B0060 0600 Section3 Service Calls 3 16 5 Refer to Cyclic Handler State ref_cyc iref_cyc C Language API ER ercd ref_cyc ID cycid T_RCYC pk_rcyc ER ercd iref_cyc ID cycid T_RCYC pk_rcyc Parameters TD cycid R4 Cyclic handler ID T_RCYC pk_rcyc R5 Pointer to the packet where the cyclic handler state is to be returned Return Parameters ER ercd RO
386. r the main process Process for IRL15 Saves the address pointed to by the stack pointer to the stack of IRL15 Switches from the stack pointer to the stack for IRL15 Sets the address of IRL15 main process to RO Saves the contents of the registers used by the main process according to the C language function calling rules When the handler uses the DSP the contents of the DSP registers must be saved Calls the main process Restores the contents of the registers Figure 4 9 Example of an Assembly Language IRL Direct Interrupt Handler Interface Routine cont RENESAS Rev 6 00 321 REJ10B0060 0600 Section4 Application Program Creation LDS L R15 MACH MOV L R15 R6 LDS L R15 PR MOV L R15 R5 MOV L R15 R4 MOV L R15 R3 MOV L R15 R2 MOV L R15 R1 MOV L R15 R15 Restores the address pointed to by the stack pointer MOV L R15 R0 Restores the contents of RO TRAPA D 25 lt An interrupt handler with a level equal to or lower than the kernel interrupt mask level completes execution with TRAPA 25 RTE lt An interrupt handler with a NOP level higher than the kernel interrupt mask level completes execution with RTE IRL14 Process for IRL14 MOV L Stk14 RO0 Saves the address pointed to by the stack pointer to the stack of IRL14 MOV L R15 RO MOV RO R15 Switches from the stack pointer to the stack for
387. reater than 1 and the task calling the service call continues execution If no resources exist the task calling the service call wai_sem or twai_sem shifts to the WAITING state and with service call pol_sem or ipol_sem error code E_TMOUT is immediately returned The wait queue is managed according to the attribute specified at creation The parameter tmout specified by service call twai_sem specifies the timeout period If a positive value is specified for the parameter tmout error code E_ TMOUT is returned when the tmout period has passed without the wait release conditions being satisfied If tmout TMO_POL 0 is specified the same operation as for the service call pol_sem will be performed If tmout TMO_FEVR 1 is specified the timeout monitoring is not performed In this case the same operation as for the service call wai_sem will be performed Rev 6 00 123 RENESAS REJ10B0060 0600 Section3 Service Calls If a value larger than 1 is specified for CFG_TICDENO the denominator for time tick cycles the maximum value that can be specified for tmout is H 7fffffff CFG_TICDENO If a value larger than this is specified operation is not guaranteed For detail of time watch method refer to section 2 16 4 2 Time Watch Method Rev 6 00 124 REJ10B0060 0600 RENESAS Section3 Service Calls 3 7 5 Refer to Semaphore State ref_sem iref_sem C Language API ER ercd ref_sem ID semid T_RSEM pk_rsem ER ercd
388. ref_flg 3 9 Synchronization and Communication Data Queue 3 9 1 Create Data Queue 3 9 2 Delete Data Queue del 20 ss sasessenvensssacenssvsnsinsossdisatonenonndusentsssnvlsssnstasnvsneanadsonisesusssnctonsn 3 9 3 Send Data to Data Queue snd_dtq psnd_dtq ipsnd_dtq tsnd_dtq fsnd_dtq ifsnd_dtq 3 9 4 Receive Data from Data Queue rcv_dtq prcev_dtq trev_dtq 3 9 5 Refer to Data Queue State ref_dtq iref_dtq 3 10 Synchronization and Communication Mailbox 3 10 1 Create Mailbox 3 10 2 Delete Mailbox del_mbx 3 10 3 Send Message to Mailbox snd_mbx isnd_mbx 3 10 4 Receive Message from Mailbox rcv_mbx prev_mbx iprev_mbx trcv_mbx 3 10 5 Refer to Mailbox State ref_mbx iref_mbx 3 11 Synchronization and Communication Mutex 3 11 1 Create Mutex cre_mtx acre_mtx Assign Mutex ID 3 11 2 Delete Mutex del_mtx eec cc eeseeeeseeeseeeneees 3 11 3 Lock Mutex loc_mtx ploc_mtx tloc_mtx 3 11 4 Unlock Mutex unl_mtx 3 11 5 Refer to Mutex State ref_mtx 3 12 Extended Synchronization and Communication Message Buffer 3 12 1 Create Message Buffer 3 12 2 Delete Message Buffer del_mbf 3 12 3 Send Message to Message Buffer snd mbf psnd mbf ipsnd_mbf tsnd_mbf 3 12 4 Receive Message from Message Buffer rcv_mbf prev_mbf trcev_mbf 3 12 5 Refer to Message Buffer State ref_mbf iref_mbf 3 13 Memory Pool Management Fixed Size Memory Pool 3 13 1 Create Fixed Size Memory Pool
389. returns block Y by issuing rel_mpf At this time task A is released from the WAITING state and the released block Y is allocated to task A Rev 6 00 36 REJ10B0060 0600 RENESAS Section2 Kernel 2 15 Variable Size Memory Pool 2 15 1 Overview A task can acquire a variable size memory block from the variable size memory pool Although the variable size memory pool is more flexible than fixed size memory pool the overhead is large when acquiring or releasing variable size memory block Also in a variable size memory pool there is a possibility of fragmentation This means that even if there is enough total space to acquire a variable size memory block it cannot be acquired if the area is not contiguous The area of each memory pool is allocated in the variable size memory pool area CFG_MPLSZ specified through the configurator An area allocated by the application can also be used as a variable size memory pool In this case the address of a memory pool area must be specified at creation The user can choose either of the following management methods through the configurator CFG_NEWMPL 1 Conventional method CFG_NEWMPL not selected This method is compatible with the following previous versions HI7000 4 V 2 00 Release 02 or earlier HI7700 4 V 1 03 Release 02 or earlier HI7750 4 V 1 1 00 or earlier 2 New method CFG_NEWMPL selected This method has the following advantages over the conventional method
390. riable size memory pool ID CFG_MAXMPLID maxmpfid Returns the maximum fixed size memory pool ID CFG_MAXMPFID maxcycid Returns the maximum cyclic handler ID CFG_MAXCYCID maxalmid Returns the maximum alarm handler ID CFG_MAXALMID maxs_fned Returns the maximum extended SVC function code CFG_MAXSVCCD Note that the value of CFG_MAXCYCID 1 is returned to the maxcycid when CFG_ACTION is checked All members of the T_RCFG structure are not defined in the pITRON4 0 specification Rev 6 00 251 RENESAS REJ10B0060 0600 Section3 Service Calls 3 22 4 Refer to Version Information ref_ver iref_ver C Language API ER ercd ref_ver T_RVER pk_rver ER ercd iref_ver T_RVER pk_rver Parameters T_RVER pk_rver R4 Pointer to the packet where version information is to be returned Return Parameters ER ercd RO Normal end E_OK or error code T_RVER pk_rver R4 Pointer to the packet where version information is stored Packet Structure typedef struct t_rver UH maker 0 2 Manufacturer UH prid 2 2 Identification number UH spver 4 2 Specification version UH prver 6 2 Product version UH prno 4 8 8 Product management information T_RVER Error Codes E_PAR p Parameter error pk_rver is an odd value Function Each service call reads information on the version of the kernel currently in use and returns it to the area indicated by pk_rver The following information is returned to the packet indicate
391. rnel restores these register contents from the stack a b HI7000 4 Stack pointer R15 gt Stack pointer before gt CPU exception HI7700 4 Stack pointer R15 gt Stack pointer before gt CPU exception R7 at CPU exception R6 at CPU exception R5 at CPU exception R4 at CPU exception R3 at CPU exception R2 at CPU exception R1 at CPU exception RO at CPU exception PR at CPU exception PC at CPU exception SR at CPU exception Stack before CPU exception R7_BANKO at CPU exception R6_BANKO at CPU exception R5_BANKO at CPU exception R4_BANKO at CPU exception R3_BANKO at CPU exception R2_BANKO at CPU exception R1_BANKO at CPU exception RO_BANKO at CPU exception PR at CPU exception PC SPC at CPU exception SR SSR at CPU exception Stack before CPU exception 4 8 12 16 20 24 28 32 36 40 44 4 8 12 16 20 24 28 32 36 40 44 RENESAS Rev 6 00 327 REJ10B0060 0600 Section4 Application Program Creation c HI7750 4 Stack pointer R15 gt R7_BANKO at CPU exception 0 R6_BANKO at CPU exception 4 R5_BANKO at CPU exception 8 R4_BANKO at CPU exception 12 R3_BANKO at CPU exception 16 R2_BANKO at CPU exception 20 R1_BANKO at CPU exception 24 RO_BANKO at CPU exception 28 PR at CPU exception 32 FPSCR at CPU exception
392. roblem 1 Not applying the module standby control function to the X Y memory 2 Not using DMA transfer with the X Y memory 3 Not switching tasks until the completion of the DMA transfer Rev 6 00 435 RENESAS REJ10B0060 0600 Appendix D DSP Standby Control HI7700 4 Rev 6 00 436 REJ10B0060 0600 RENESAS Appendix G Notes on FPU of SH2A FPU SH 4 SH4A G 1 Task and Task Exception Processing Routine G 1 1 Initialization of FPSCR The initial value of FPSCR of a task and a task exception processing routine is shown below e SH 4 SH 4A H 00040001 FR 0 SZ 0 PR 0 DN 1 RM B 01 e SH2A FPU TA_COP1 is specified H 00040001 SZ 0 PR 0 DN 1 RM B 01 TA_COP1 is not specified Undefined When floating point calculation is executed and when one of the following compiler options is specified it is necessary to initialize FPSCR at the start of the entry function of the task and of the task exception processing routine e fpu double e denormalize on e round nearest Figure G 1 shows an example for initialization of FPSCR under the following conditions cpu sh4a fpu double denormalize on round nearest include lt machine h gt Included to use intrinsic function set_fpscr define INI_FPSCR 0x00080000 FR 0 PR 1 DN 0 SZ 0 RM B 00 pragma noregsave Task void Task VP_INT exinf set_fpscr INI_FPSCR Sets FPSCR at the start of functi
393. rograms The following sample source programs are provided By modifying the programs as required the user system can easily be created and customized for the user Rev 6 00 1 RENESAS REJ10B0060 0600 Section1 Introduction System down routine Timer driver for on chip timers of SuperH microcomputer series CPU initialization routine Section initialization and definition file e Configurator The configurator is supported to ease kernel configuration e Debugging extension option The debugging extension which adds a multitasking debugging function to HEW3 or later versions of HEW is prepared The debugging extension supports the following functions e Refer to the status of objects such as a task e Operate to objects such as starting task or set event flag e Display service call history The debugging extension can be downloaded free of charge from our homepage Rev 6 00 2 REJ10B0060 0600 RENESAS Section1 Introduction 1 3 Operating Environment The operating environment is shown in table 1 1 Table 1 1 Operating Environment Product Name Files Included Operating Environment HI7000 4 Kernel All SuperH microcomputers incorporating SH 1 SH 2 SH2 DSP SH 2A or SH2A FPU Sample program Some SuperH microcomputers incorporating SH 1 SH 2 SH2 DSP SH 2A or SH2A FPU Sample HEW HEW version 1 2 or later SuperH RISC engine C C workspace and compiler packag
394. rs ER ercd RO Normal end E_OK or error code Error Codes E_ID p Invalid ID number tskid lt 0 or tskid gt CFG_MAXTSKID E_NOEXS k Undefined Task indicated by tskid does not exist E_OBJ k Object state is invalid Task indicated by tskid is in the DORMANT state E_ILUSE k Illegal use of service call The current task is specified as the object task E_CTX k Context error Called from disabled system state Function The service call ter_tsk forces a task specified by tskid to terminate The terminated task enters the DORMANT state At this time the processing shown in table 3 9 is performed When the initiation request is queued the processing to be performed during task initiation is performed and the target task enters the READY state A request from a task to force another task to terminate is delayed in the following cases e Ifthe task specified by tskid is masking requests from other tasks to force tasks to terminate by calling service call vchg_tmd The service call ter_tsk does not release resources other than the mutexes such as semaphores and memory blocks acquired before the task is terminated Therefore the user must call service calls to release resources before calling the service call ter_tsk If the task specified by tskid shares the stack with other tasks the task at the head of the stack wait queue is removed and released from the WAITING state At this time the processing to be performed d
395. ructure The kernel files are installed in the kernel folder under the installation folder which is specified by the installer program as shown in figure 5 3 hihead hisys hilib elf samples shnnnn knl Figure 5 3 Folders under the kernel Folder 5 2 1 hihead Folder This folder contains header files e g itron h or kernel h which are used in application 5 2 2 hisys Folder This folder contains system definition files which are used to compile configuration files The files in this folder must not be modified 5 2 3 hilib Folder This folder contains the folder which contains kernel library files The hilib elf folder contains ELF format kernel library files Refer to the release notes for the compiler version used at library creation 5 2 4 knl Folder This folder is provided only under the license with kernel source code Refer to the release notes attached to the product for details 5 2 5 samples shnnnn Folder This folder contains sample files for microcomputer corresponding to nnnn This folder also contains the HEW workspace file for load module creation Rev 6 00 344 REJ10B0060 0600 RENESAS Section5 Configuration Tables 5 1 to 5 3 show relationship between nnnn and microcomputer in the HI7000 4 V 2 02 HI7700 4 V 2 02 and HI7750 4 V 2 02 respectively For the latest information refer to the release notes attached to the product Table 5
396. rvice calls can be called from the CPU locked state The system operation cannot be guaranteed when a service call other than the following is called ext_tsk exd_tsk sns_tex loc_cpu iloc_cpu unl_cpu iunl_cpu sns_ctx sns_loc sns_dsp sns_dpn vsta_knl ivsta_knl vsys_dwn ivsys_dwn When the following service calls are called in the CPU locked state the system returns to the CPU unlocked state unl_cpu or iunl_cpu ext_tsk or exd_tsk Rev 6 00 222 REJ10B0060 0600 RENESAS Section3 Service Calls The transition between CPU Locked state and CPU unlocked state is occurred only when loc_cpu iloc_cpu unl_cpu iunl_cpu ext_tsk or exd_tsk service call is called An interrupt handler which level is equal or lower than the kernel interrupt mask level CFG_KNLMSKLVL time event handler initialization routine and task exception routine must unlock the CPU at termination If the CPU is locked at termination normal system operation cannot be guaranteed Note the CPU at the start of these handlers is unlocked If the CPU exception handler changes CPU locked unlocked state the handler must return to former state If the handler does not return to former state normal system operation cannot be guaranteed If service calls loc_cpu and iloc_cpu are called while the CPU is locked no error will occur In this case queuing will not be done Rev 6 00 223 RENESAS REJ10B006
397. rvice calls to shift a task to the WAITING state cannot be called When the following service calls are called while task dispatch is disabled the system returns to the task dispatch enabled state e ena dsp e ext_tsk or exd_tsk The transition between dispatch disabled state and dispatch enabled state is occurred only when dis_dsp ena_dsp ext_tsk or exd_tsk service call is called If the CPU exception handler changes dispatch disabled enabled state the handler must return to former state If the handler does not return to former state normal system operation cannot be guaranteed When task dispatch is disabled the task state is undefined Therefore if the current task refers to its state by calling service call ref_tsk the returned state is not always the RUNNING state An error will not occur when service call dis_dsp is called while the task dispatch is disabled however queuing will not be done Rev 6 00 225 RENESAS REJ10B0060 0600 Section3 Service Calls 3 19 6 Enable Dispatch ena_dsp C Language API ER ercd ena_dsp void Parameters None Return Parameters ER ercd RO Normal end E_OK Error Codes None Function Service call ena_dsp enables task dispatch disabled by service call dis_dsp Task scheduling is then performed after the service call An error will not occur when service call ena_dsp is called during task dispatch enabled state however queuing will not be done Rev 6 00 22
398. s Item Description Semaphore ID 1 to CFG_MAXSEMID 1023 max Maximum semaphore count 65535 Attribute supported TA_TFIFO Task wait queue is managed on a FIFO basis TA_TPRI Task wait queue is managed on priority Rev 6 00 118 REJ10B0060 0600 RENESAS Section3 Service Calls 3 7 1 Create Semaphore cre_sem icre_sem acre_sem iacre_sem Assign Semaphore ID Automatically C Language API ER ercd cre_sem ID semid T_CSEM pk_csem ER ercd icre_sem ID semid T_CSEM pk_csem ER_ID semid acre_sem T_CSEM pk_csem ER_ID semid iacre_sem T_CSEM pk_csem Parameters lt cre_sem icre_sem gt ID T_CSEM semid R4 Semaphore ID pk_csem R5 Pointer to the packet where semaphore creation information is stored lt acre_sem iacre_sem gt T_CSEM Return Parameters pk_csem R4 Pointer to the packet where semaphore creation information is stored lt cre_sem icre_sem gt ER ercd RO Normal end E_OK or error code lt acre_sem iacre_sem gt ER_ID Packet Structure typedef struct ATR UINT UINT T_CSEM Error Codes E_RSATR p E_PAR p E_ID p E_OBJ k E_NOID k semid RO ID of created semaphore a positive value or error code t_csem sematr 0 4 Semaphore attribute isemcnt 4 4 Initial value of semaphore resource count maxsem 8 4 Maximum number of semaphore resources Invalid attribute sematr is invalid Parameter error pk_cs
399. s LDA LOO get_mpl 192 bytes X Empty 2 Get X i get_mpl 32 bytes 3 Get Y X Y Empty 4 get_mpl 96 bytes X ly Z Get Z Empty DPA A gt ARADRDDARARDmnnre _ 5 get_mpl 256 bytes X I Z Emi lt WAITING gt mpty 6 i rel_mpl X Empty ly Z Empty 4 rel_mpl Z Empty Y Empty 8 lt READY gt rel_mpl Y W Empty Get W Figure 2 12 Example of Using Variable Size Memory Pool Description Bold lines represent executed process The following describes the variable size memory pool operation with respect to time 1 Task A creates a 400 byte variable size memory pool by issuing cre_mpl 2 Task B acquires 192 byte memory block X by issuing get_mpl At this time the kernel uses 16 bytes in the memory pool This is not indicated in figure 2 12 3 Task B also acquires 32 byte memory block Y by issuing get_mpl 4 Task B also acquires 96 byte memory block Z by issuing get_mpl 5 Task A attempts to acquire a 256 byte memory block by issuing get_mpl However the available memory block is insufficient to assign a 256 byte memory block to task A so task A enters the WAITING state 6 Task B returns 192 byte memory block X by issuing rel_mpl At this time since there is not 256 bytes of contiguous memory in the memory pool task A remains in the WAITING state Rev 6 00 39 RENESAS REJ10B0060 0600 Section2 Kernel 7 Task B returns 96 byte memory block Z by issuin
400. s prcv_mbx and iprcv_mbx if there are no messages in the mailbox error code E_TMOUT is returned immediately The wait queue is managed according to the attributes specified at creation Parameter tmout specified by service call trcev_mbx specifies the timeout period If a positive value is specified for parameter tmout error code E_TMOUT is returned when the timeout period has passed without the wait release conditions being satisfied If tmout TMO_POL 0 is specified the same operation as for service call prev_mbx will be performed If tmout TMO_FEVR 1 is specified timeout monitoring is not performed In other words the same operation as for service call rev_mbx will be performed If a value larger than 1 is specified for CFG_TICDENO the denominator for time tick cycles the maximum value that can be specified for tmout is H 7fffffff CFG_TICDENO If a value larger than this is specified operation is not guaranteed For detail of time watch method refer to section 2 16 4 2 Time Watch Method Rev 6 00 153 RENESAS REJ10B0060 0600 Section3 Service Calls 3 10 5 Refer to Mailbox State ref_mbx iref_mbx C Language API ER ercd ref_mbx ID mbxid T_RMBX pk_rmbx ER ercd iref_mbx ID mbxid T_RMBX pk_rmbx Parameters ID mbxid T_RMBX pk_rmbx Return Parameters ER ercd T_RMBX pk_rmbx Packet Structure 1 T_RMBX typedef struct t_rmbx ID wtskid T_MSG pk_msg T_RMBX 2 T_MSG
401. s refer to appendix C 7 Interrupt Handler Stacks 6 PR y V Undefined 7 SH3 DSP SH4AL DSP y V Undefined DSR RS RE MOD AO AOG A1 A1G MO M1 XO X1 YO Y1 Notes 1 These registers can be used Note that some register contents cannot be guaranteed after service calls For details refer to section 3 2 3 Guarantee of Register Contents after Issuing Service Call 2 When execution is returned from the entry function RTS instruction the contents of these registers must be the same as the value at initiation 3 IMASK bits must not be lower than the current interrupt level DSP CL must be 1 when at least one of CFG_DSP and CFG_CACLOC is checked MD must be 1 Rev 6 00 309 RENESAS REJ10B0060 0600 Section4 Application Program Creation Table 4 11 Rules on Using Registers in a Normal Interrupt Handler H1I7750 4 End Use Conditions No Registers id Initial Value 1 PC V Interrupt handler start address 2 SR V b The value which is specified at the definition 3 RO_BANKO to R7_BANKO V Undefined 4 R8 to R14 MACH MACL V V Undefined GBR 5 R15 V vV R15 points to the interrupt handler stack area The kernel changes the stack pointer to the interrupt handler stack area at interrupt All interrupt handlers use the same stack area The size of the interrupt handler stack area is defined by CFG_IRQSTKSZ Note that the size of the interrupt handler stack must be calculated
402. s and receives the message start address it is fast regardless of the message size The mailboxes are controlled by the service calls listed in table 2 11 Table 2 11 Service Calls for Mailbox Control Service Call Name Function cre_mbx icre_mbx Creates a mailbox acre_mbx iacre_mbx Creates a mailbox automatically assigns ID del_mbx Deletes a mailbox snd_mbx isnd_mbx Sends a message to a mailbox rcv_mbx Receives a message from a mailbox prcv_mbx iprcv_mbx Receives a message from a mailbox polling trcv_mbx Receives a message from a mailbox with timeout ref_mbx iref_mbx Refers to the mailbox status Figure 2 8 shows an example of using mailbox Rev 6 00 28 REJ10B0060 0600 RENESAS Section2 Kernel Time Mailbox status Task A Task B Task Task queue Send waiting to message receive queue None None cre_mbx i 2 b i LWAITING gt Task Al None rwomeeenrnrrrrererrrrrraroawv lt READY gt snd_mbx X i None None Receive X i 4 j snd_mbx Y None Y LLDLDDDOWI OWI OOOO OO 5 i i snd_mbx Z Y HZ 6 rcv_mbx i Z Receive Y Figure 2 8 Example of Using Mailbox Description Bold lines represent executed processing The following describes the mailbox operation with respect to time 1 Task A issues cre_mbx to create a mailbox At this time the TA_TFIFO attribute tasks waiting to receive are queued in FIFO and the TA_MFIFO
403. s are controlled by the service calls listed in table 2 18 Table 2 18 Service Calls for Cyclic Handler Control Service Call Name Function cre_cyc icre_cyc Creates a cyclic handler acre_cyc iacre_cyc Creates a cyclic handler automatically assigns ID del_cyc Deletes a cyclic handler sta_cyc ista_cyc Initiates a cyclic handler stp_cyc istp_cyc Stops a cyclic handler ref_cyc iref_cyc Refers to a cyclic handler status The cyclic handler can also be created by the configurator There are two methods to initiate the cyclic handler storing the initiation phase and not storing the initiation phase In storing the initiation phase the cyclic handler is initiated based on the timing when the cyclic handler is created In not storing the initiation phase the cyclic handler is initiated based on the timing when the cyclic handler is started Figure 2 15 shows an example of using cyclic handler Rev 6 00 44 REJ10B0060 0600 RENESAS Section2 Kernel Create a cyclic handler Initiate a cyclic handler Stop a cyclic handler cre_cyc sta_cyc stp_cyc a 0 e d Time initialen Initiation i Initiation i Initiation i Initiation phase cycle e Initiated Initiateay y y Not initiated Not initiated Cyclic handler Cyclic handler Not initiated I Initiation phase is stored Create a cyclic handler Initiate a cyclic handler Stop a cyclic handler cre_cyc st
404. s calculated by follow expression T sec 1 PCLOCK x DIV x N PCLOCK Hz Frequency which is supplied to the timer module DIV Divided ratio by setting of the timer module register N The number of timer clock counts which expires the period T In general the following expressions consist to count the timer module n when n is set to the counter register of the timer module For the sample timer drivers each sign in the above expression is made to correspond as follows n N 1 The sample timer drivers which are provided by the HI7000 4 series calculate n according to the above calculation method and set to register of the timer module T CFG_TICNUME CFG_TICDENO ms PCLOCK PCLOCK which is defined in the nnnn_tmrdef h Hz DIV In the HI7000 4 DIV which is defined in the nnnn_tmrdrv c In the HI7700 4 and HI7750 4 the DIV is selected automatically in order to PCLOCK n The above expression is defined in COUNTER in the nnnn_tmrdrv c Note that when the calculated value as COUNTER is larger than the counter register size the period is illegal Do confirm this And when the calculated value as COUNTER is not integer the value is rolled to integer In this case the period at run time is shorter than expected period CFG_TICNUME CFG_TICDENO Table D 1 shows sample timer driver files provided by each product at this manual creation time and the clock source of the
405. s for starting task exception processing routine are satisfied the task exception processing routine is initiated The service calls can also be called from the CPU exception handler Rev 6 00 113 RENESAS REJ10B0060 0600 Section3 Service Calls 3 6 3 Disable Task Exception Processing dis_tex C Language API ER ercd dis_tex void Parameters None Return Parameters ER ercd RO Normal end E_OK or error code Error Codes E_OBJ k Object status is invalid Task exception processing routine is not defined on the current task E_CTX k Context error Called from disabled system state Function The current task is transferred to the task exception processing disabled state Rev 6 00 114 REJ10B0060 0600 RENESAS Section3 Service Calls 3 6 4 Enable Task Exception Processing ena_tex C Language API ER ercd ena_tex void Parameters None Return Parameters ER ercd RO Normal end E_OK or error code Error Codes E_OBJ k Object status is invalid Task exception processing routine is not defined on the current task E_CTX k Context error Called from disabled system state Function The current task is transferred to the task exception enabled state When conditions for starting the task exception processing routine are satisfied through this service call the task exception processing routine is initiated Rev 6 00 115 RENESAS REJ10B0060 0600 Section3 Service Calls 3 6
406. s or exceptions When this service call has been called when BL 1 in SR clear BL to 0 after returning from the service call processing Rev 6 00 259 RENESAS REJ10B0060 0600 Section3 Service Calls 3 23 4 Invalidate Cache vinv_cac ivinv_cac C Language API ER ercd vinv_cac void ER ercd ivinv_cac void Parameters None Return Parameters ER ercd RO Normal end E_OK or error code Error Codes None Function This service call invalidates the cache Keep in mind that the contents are canceled even if there is data which is not written back to the memory yet in the cache This service call sets the cache flush bit CF in the cache control register CCR to 1 to invalidate all cached contents If this service call is called before calling the service call vini_cac or ivini_cac the normal system operation cannot be guaranteed This service call can be called even in the exception block state BL 1 in SR Therefore the cache can be invalidated irrespective of interrupts or exceptions When this service call has been called when BL 1 in SR clear BL to 0 after returning from the service call processing Rev 6 00 260 REJ10B0060 0600 RENESAS Section3 Service Calls 3 24 Cache Support Function HI7750 4 for SH 4 This function is supported only for the HI7700 4 and HI7750 4 As for a cache support function libraries differ for every microcomputer table 3 74 And a part of functions and API dif
407. s possible If the cycle time of a cyclic handler is 1 ms and the handler s processing time takes longer than 1 ms that cyclic handler will be executed forever and the system will hang 2 Time Watch Method Time parameters specified in service calls are specified using relative time For example if the relative time is specified as 1 ms the corresponding event processing is initiated at the time tick when ms has elapsed since the service call was issued If the relative time is specified as 0 ms the corresponding event processing is initiated at the first time tick after the service call is issued The system clock can be changed by issuing the set_tim service call Note however that the system clock for an event to which a time management request is issued before the set_tim service call is not affected Rev 6 00 48 REJ10B0060 0600 RENESAS Section2 Kernel 2 17 System State Management The service calls listed in table 2 21 can be used to control system state Table 2 21 Service Calls for System State Management Service Call Name Function rot_rdq irot_rdq Rotates ready queue get_tid iget_tid Refers to the task ID loc_cpu iloc_cpu Enters CPU locked state unl_cpu iunl_cpu Releases CPU locked state dis_dsp Disables dispatch ena_dsp Enables dispatch sns_ctx Refers to the context sns_loc Refers to the CPU locked state sns_dsp Refers to the dispatch disable state
408. s specified Rev 6 00 303 RENESAS REJ10B0060 0600 Section4 Application Program Creation Table 4 7 Rules on Using Registers in a Task Exception Processing Routine H17700 4 End Use Conditions No Registers zi Initial Value 1 PC V Task exception processing routine start address 2 SR V ii H 40001000 when either CFG_DSP or CFG_CACLOC is selected or H 40000000 when neither of them is selected 3 RO_BANKO to R3_BANKO V Undefined 4 R4_BANKO V Task exception pattern 5 R5_BANKO vV Extended information exinf of the task exception processing routine 6 R6_BANKO R7_BANKO R8 V Undefined to R14 MACH MACL GBR R15 V vV R15 points to the task s stack area PR v V Undefined SH3 DSP SH4AL DSP i 0 when attribute TA_COPO is DSR specified or undefined in other cases 10 SH3 DSP SH4AL DSP e Undefined RS RE MOD AO AOG A1 A1G MO M1 XO X1 YO Y1 Notes 1 These registers can be used Note that some register contents cannot be guaranteed after service calls For details refer to section 3 2 3 Guarantee of Register Contents after Issuing Service Call 2 When execution is returned from the entry function RTS instruction the contents of these registers must be the same as the value at initiation 3 DSP CL must be 1 when at least one of CFG_DSP and CFG_CACLOC is checked Except in the CPU locked state IMASK must be 0 MD 1 BL 0 and RB 0 are required 4 Only when the TA_CO
409. s system state management functions such as modifying or referencing the context or system states Interrupt Management Initiates the appropriate interrupt handlers in response to external interrupts The interrupt handler performs appropriate interrupt processing and notifies tasks of interrupts Service Call Management Defines or calls an extended service call Rev 6 00 5 RENESAS REJ10B0060 0600 Section2 Kernel System Configuration Management Performs system configuration management functions such as defining the CPU exception handlers and reading the kernel version number DSP FPU Support Supports the DSP and FPU in its multitasking environment Each task can use special registers to execute DSP FPU instructions 2 3 Processing Units and Precedence An application program is executed in the following processing units Task A task is a unit controlled by multitasking Task Exception Processing Routine A task exception processing routine is executed when a task exception processing is requested by a task in the ras_tex service call Interrupt Handler An interrupt handler is executed when an interrupt occurs CPU Exception Handler A CPU exception handler is executed when a CPU exception occurs Time Event Handler Cyclic Handler Alarm Handler and Overrun Handler A time event handler is executed when a specified cycle or time has been reached Extended Service Call An extended service call is used to call a m
410. se Linkage symbol file ces det f C hitrp source file Phiknl C source file G hidef E Assembly source fi C hisysmt E Linkage symbol fi Hee aa F hiintdwn source file C source file Options Link Library Assembly source fi centry hcpuasm define kernel pon spi pol 00000 A i i eftnme _kernel_man_sp l noprelink nomessage Liikaga symbol lists CONFIGDIFNS PROJECTNAMES map nooptimize Carce D D Figure 5 13 Optimized Linkage Editor Section Specifies the allocation addresses of each section Specify the allocation addresses for the sections in the input files according to the target hardware Basically specify addresses for all sections in the input files The optimized linkage editor automatically places all sections without overt address specifications after the last section in the input files with such a specification The resulting arrangement of sections may not produce the order expected and the program may not work properly In this case the optimized linkage editor reports the following warning message example in case P_Task1 section is not specified L1120 W Section address is not assigned to P_Task1 Specifying a section name that does not actually appear in the input files also produces a warning message but the optimized linkage editor continues linking In this case the optimized linkage ed
411. se fixed size is determined for each memory pool from the fixed size memory pool The size can be specified when the memory pool is created The area of each memory pool is allocated in the fixed size memory pool area CFG_MPFSZ specified through the configurator An area allocated by the application can also be used as a fixed size memory pool In this case the address of a memory pool area must be specified at creation The user can choose either of the following management methods through the configurator CFG_MPFMANAGE 1 Conventional method CFG_MPFMANAGE not selected The kernel places the kernel management tables adjacent to the memory blocks in the memory pool This method is compatible with the previous versions HI7000 4 V 1 0 05 or earlier HI7700 4 V 1 03 Release 02 or earlier and HI7750 4 V 1 1 00 or earlier versions 2 Extended method CFG_MPFMANAGE selected The kernel places the kernel management tables outside of the memory pool In this method the application must specify the address of the management tables at creation of the fixed size memory pool The application must allocate the area for management tables The fixed size memory pools are controlled by the service calls listed in table 2 14 Table 2 14 Service Calls for Fixed Size Memory Pool Control Service Call Name Function cre_mpf icre_mpf Creates a fixed size memory pool acre_mpf iacre_mpf Creates a fixed size memory pool automatically
412. section 2 16 4 2 Time Watch Method Rev 6 00 173 RENESAS REJ10B0060 0600 Section3 Service Calls 3 12 5 Refer to Message Buffer State ref_mbf iref_mbf C Language API ER ercd ref_mbf ID mbfid T_RMBF pk_rmbf ER ercd iref_mbf ID mbfid T_RMBF pk_rmbf Parameters ID mbfid R4 Message buffer ID T_RMBF pk_rmbf R5 Pointer to the packet where the message buffer state is to be returned Return Parameters ER ercd RO Normal end E_OK or error code T_RMBF pk_rmbf R5 Pointer to the packet where the message buffer state is stored Packet Structure typedef struct t_xrmbf ID stskid 0 2 Start task ID of the queue waiting to send a message ID rtskid 2 2 Start task ID of the queue waiting to receive a message UINT smsgcnt 4 4 Number of messages in message buffer SIZE fmbfsz 8 4 Size of free buffer Number of bytes T_RMBF Error Codes E_PAR p Parameter error pk_rmbf is other than a multiple of four E_ID p Invalid ID number mbfid lt 0 or mbfid gt CFG_MAXMBFID E_NOEXS k Undefined Message buffer indicated by mbfid does not exist Function Each service call refers to the state of the message buffer indicated by parameter mbfid and returns the task ID of the task waiting to send a message stskid task waiting to receive a message rtskid the size of the next message to be received smsgcnt and the available free buffer size fmbfsz to the area indicated by pk_rmbf If no task is waiti
413. service calls acre_dtq and iacre_dtq search for an unused data queue ID and create a data queue with that ID and with the contents specified by pk_cdtq and return the ID as a return parameter The range for searches for unused data queue IDs is from 1 to CFG_MAXDTQID The attribute dtqatr is specified in the following format See table 3 31 for details dtqatr TA_TFIFO TA_TPRI Table 3 31 Data Queue Attributes dtqatr dtqatr Code Description TA_TFIFO H 00000000 Task queue waiting for sending a message is managed on a FIFO basis TA_TPRI H 00000001 Task queue waiting for sending a message is managed on priority Data queue receive waiting queues are managed in FIFO order Further data sent to a data queue is also managed in FIFO order in the data queue without priority dtqcent specifies the number of data items stored in the data queue area It is also possible to specify a value of 0 for dtqcnt in this case data send tasks and data receive tasks are completely synchronized Data queues are allocated from the data queue area CFG_DTQSZ specified by the configurator On successful creation of a data queue the free data queue area size will decrease by an amount given by the following expression Decrease in size dtqcnt x 4 16 bytes dtq is for future expansion in this kernel NULL must be specified If a value other than NULL is used normal system operation cannot be guaranteed Data queues can also be create
414. service calls with a timeout such as tslp_tsk In order to use kernel functions related to time the timer driver must be included For details refer to Appendix D Timer Driver Rev 6 00 199 RENESAS REJ10B0060 0600 Section3 Service Calls 3 16 Time Management Cyclic Handler Cyclic Handler Service Calls Cyclic handler is controlled by the service calls listed in table 3 48 Table 3 48 Service Calls for Cyclic Handler System State Service Call Description T N E D U L C cre_cyc s Creates cyclic handler T E D U icre_cyc N E D U acre_cyc Creates cyclic handler and assigns cyclic handler T E D U iacre_cyc ID automatically N E D U del_cyc Deletes cyclic handler T E D U sta_cyc S Starts cyclic handler operation T E D U ista_cyc N E D U stp_cyc S Stops cyclic handler operation T E D U istp_cyc N E D U ref_cyc Refers to the cyclic handler state T E D U iref_cyc N E D U Notes 1 S Standard profile service calls s Service calls that are not standard profile service calls but are needed in order to use the standard profile function 2 T Can be called from task context N Can be called from non task context E Can be called from dispatch enabled state D Can be called from dispatch disabled state U Can be called from CPU unlocked state L Can be called from CPU locked state C Can be called from CPU exception handler Cyclic Handler Specifications The cy
415. sgsz ER ercd ipsnd_mbf ID mbfid VP msg UINT msgsz ER ercd tsnd_mbf ID mbfid VP msg UINT msgsz TMO tmout Parameters ID mbfid R4 Message buffer ID VP msg R5 Start address of the message to send UINT msgsz R6 Size of the message to send number of bytes lt tsnd_mbf gt TMO tmout R7 Timeout specification Return Parameters ER ercd RO Normal end E_OK or error code Error Codes E_PAR p Parameter error msg is other than a multiple of four msgsz 0 or tmout lt 2 k msgsz gt maxmsz E_ID p Invalid ID number mbfid lt 0 or mbfid gt CFG_MAXMBFID E_NOEXS k Undefined Message buffer indicated by mbfid does not exist E_CTX k Context error Called from disabled system state E_DLT k Waiting object deleted Message buffer indicated by mbfid has been deleted during the WAITING state E_TMOUT k Polling failed or timeout E_RLWAI k WAITING state is forcibly cancelled rel_wai service call was called in the WAITING state Note maxmsz Maximum message size specified at message buffer creation Function Each service call sends a message specified by msg to the message buffer specified by mbfid The message size is specified by parameter msgsz If there are no tasks waiting to send a message but there is a task waiting to receive a message the message sent by the service call is not placed in the message buffer Instead the message is passed to the task at the head of the receive wait queue releasing the ta
416. shows the procedures which must be followed to include the DSP standby control function Table F 2 Including the DSP Standby Control Function DSP Standby Control DSP Standby Control Item Function not Included Function Included Creation of a definition file Not needed Needed F 5 2 Modifying kernel_sys h Not needed Needed F 5 3 Note that no item specifically determines whether or not the vchg_cop service call is available Whenever the DSP standby control function is included the vchg_cop service call is included F 5 2 Creating the kernel_def_dspstby_set h Definition File The following information is defined in kernel_def_dspstby_set h e hi_cop_stby_adr Address of the module standby control register e hi_cop_stby_bit Bit locations of the module standby control register When the kernel executes a task or exception processing routine with the TA_COPO attribute the bits indicated by hi_cop_stby_bit which is indicated within an 8 bit unit SH3 DSP or 32 bit SH4AL DSP of the address hi_cop_stby_adr are set to 0 A module specified by hi_cop_stby_bit is thus placed in the non standby state On the other hand when the kernel executes a task or exception processing routine without the TA_COPO attribute the bits indicated by hi_cop_stby_bit which is indicated within an 8 bit unit SH3 DSP or 32 bit SH4AL DSP of the address hi_cop_stby_adr are set to 1 A module specified by hi_cop_stby_bit will be placed in the standby s
417. sing Registers in a Normal Interrupt Handler Tables 4 9 to 4 11 show rules on using registers for HI7000 4 HI7700 4 and HI7750 4 Rev 6 00 307 RENESAS REJ10B0060 0600 Section4 Application Program Creation Table 4 9 Rules on Using Registers in a Normal Interrupt Handler H1I7000 4 End Use Conditions No Registers i Initial Value 1 PC V Interrupt handler start address 2 SR V ai IMASK Interrupt level Other bits Same as before interrupt 3 ROtoR7 v Undefined 4 R8toR14 MACH MACL V yin Undefined GBR 5 R15 V V R15 points to the interrupt handler stack area The kernel changes the stack pointer to the interrupt handler stack area at interrupt All interrupt handlers use the same stack area The size of the interrupt handler stack area is defined by CFG_IRQSTKSZ Note that the size of the interrupt handler stack must be calculated carefully considering interrupt nestings For details refer to appendix C 7 Interrupt Handler Stacks 6 PR v V Undefined 7 SH2 DSP DSR RS RE V V Undefined MOD AO AOG A1 A1G MO M1 XO X1 YO Y1 8 SH 2A SH2A FPU TBR i a 9 SH2A FPU FPSCR V V Undefined 10 SH2A FPU v V Undefined FRO to FR11 11 SH2A FPU FPUL vV V Undefined FR12 to FR15 Notes 1 These registers can be used Note that some register contents cannot be guaranteed after service calls For details refer to section 3 2 3 Guarantee of Register Contents after Issuing Servi
418. sion 1 CFG_MPFMANAGE is not checked Decrease in size blksz 4 bytes x blkcnt 16 bytes 2 CFG_MPFMANAGE is checked Decrease in size blksz x blkcnt 16 bytes The memory pool area address allocated by application can be specified as mpf In this case allocate the memory pool area which size is calculated by TSZ_MPF blkcnt blksz and specify the address as mpf Note the definition of TSZ_MPF is depend on CFG_MPFMANAGE If the CRG_MPFMANAGE is checked the address for kernel management tables must be specified as mpfmb In this case allocate the area which size is calculated by VTSZ_MPFMB blkcnt blksz and specify the address as mpfmb mpfmb is a member not specified in the pITRON4 0 specification Fixed size memory pools can also be created statically by the configurator Rev 6 00 178 REJ10B0060 0600 RENESAS Section3 Service Calls 3 13 2 Delete Fixed Size Memory Pool del_mpf C Language API ER ercd del_mpf ID mpfid Parameters ID mpfid R4 Fixed size memory pool ID Return Parameters ER ercd RO Normal end E_OK or error code Error Codes E_ID p Invalid ID number mpfid lt 0 or mpfid gt CFG_MAXMPFID E_NOEXS k Undefined Fixed size memory pool indicated by mpfid does not exist E_CTX k Context error Called from disabled system state Function Service call del_mpf deletes the fixed size memory pool indicated by mpfid No error will occur even if there is a task waiting to acquire a
419. sk stacks are classified into static stacks and dynamic stacks In addition the stack area that is allocated by application can be used The task stack is switched by the kernel Accordingly the stack must not be switched by the task Interrupt Handler Stack When a normal interrupt occurs the stack is switched to the one dedicated to the interrupt handler by the kernel Accordingly the stack must not be switched by the interrupt handler When a direct interrupt of the HI7000 4 occurs the stack must be allocated and switched by the interrupt handler Unless it is switched the interrupt handler uses the stack of the task that was executed before the interrupt occurred Therefore the task stack may overflow When the HI7000 4 is used the NMI must be defined as the direct interrupt handler However the NMI has the possibility of re entry so stack switching must not be performed by the NMI interrupt handler Stacks for tasks and handlers must be reserved considering the size used by the NMI interrupt handler since the stack before the NMI occurrence is used by the NMI interrupt handler The time event handler uses the interrupt handler stack The stack must not be switched by the time event handler Rev 6 00 406 REJ10B0060 0600 RENESAS Appendix CCalculation of Work Area Size Kernel Stack Stack used by the kernel It is also used by the initialization routine The stack must not be switched in the initialization routine Stac
420. sk Force Task to Resume rsm_tsk irsm_tsk frsm_tsk ifrsm _tsk 3 5 7 Delay Task dly_tsk 3 5 8 Set Task Event Flag vset_tfl ivset_tfl 3 5 9 Clear Task Event Flag velr_tfl ivclr_tfl 3 5 10 Wait Task Event Flag vwai_tfl vpol_tfl vtwai_tfl 3 6 3 6 1 Define Task Exception Processing Routine def_tex idef_tex 3 6 2 Request Task Exception Processing ras_tex iras_tex 3 6 3 Disable Task Exception Processing dis_tex 3 6 4 Enable Task Exception Processing ena_tex 3 6 5 Refer To Task Exception Processing Disabled State sns_tex Task Synchronization Task Exception Processing Functions Rev 6 00 REJ10B0060 0600 RENESAS Contents 3 6 6 Refer to Task Exception Processing State ref_tex iref_teX eee eee 117 3 7 Synchronization and Communication Semaphore 3 7 1 Create Semaphore IT 2 Delete Semaphore del_sem 3 1 3 Returns Semaphore Resource sig_sem isig_ sem 3 7 4 Wait on Semaphore wai_sem pol_sem ipol_sem twai_sem Zra Refer to Semaphore State ref_sem iref_sem 3 8 Synchronization and Communication Event Flag 3 8 1 Create Event Flag 3 8 2 Delete Event Flag del_flg 3 8 3 Set Event Flag set_flg iset_flg 3 8 4 Clear Event Flag clr_flg iclr_flg 3 8 5 Wait for Event Flag Setting wai_flg pol_flg ipol_flg twai_flg 133 3 8 6 Refer to Event Flag State ref_flg i
421. sk context E Can be called from dispatch enabled state D Can be called from dispatch disabled state U Can be called from CPU unlocked state L Can be called from CPU locked state C Can be called from CPU exception handler Rev 6 00 262 REJ10B0060 0600 RENESAS Section3 Service Calls 3 24 1 Initialize Cache vini_cac ivini_cac C Language API void vini_cac UW ccr_data void ivini_cac UW ccr_data Parameters UW ccr_data R4 Value to be set to the cache control register of the CPU Return Parameters None Error Codes None Function This service call initializes the cache Before using the cache function call this service call The data specified by ccr_data is set to the CCR register If the usage of these service calls is mistaken coherence between the cache and the memory might not be maintained When the contents of the cache may not have been written back to the memory and you need to be sure that they have been written back make the vfls_cac or ivfls_cac service call to flush the cache before issuing this service call Specify a value for ccr_data such that the CCR CF bit becomes 1 This service call can be called before the kernel is initiated This service call can be called even in the exception block state BL 1 in SR Rev 6 00 263 RENESAS REJ10B0060 0600 Section3 Service Calls 3 24 2 Clear Operand Cache velr_cac ivelr_cac C Language API ER ercd vclr_cac VP clradrl VP c
422. sk from the WAITING state Rev 6 00 170 REJ10B0060 0600 RENESAS Section3 Service Calls If there are already tasks waiting to send a message to the message buffer the task that called service call snd_mbf or tsnd_mbf is placed in the queue to wait for free space in the message buffer With service calls psnd_mbf and ipsnd_mbf error code E_ TMOUT is immediately returned The wait queue is managed according to the attribute specified at task creation If there are no tasks waiting to send or receive a message the message sent from a task is stored in the message buffer After the message has been stored in the message buffer the size of the message buffer free space will decrease by an amount given by the following expression Decrease in size msgsz 4 bytes However if the free space in the message buffer is less than the above size including when the buffer size is 0 the task that called the service call is placed in the queue to wait for message buffer free space ipsnd_mbf can also be issued from a non task context Since the priority of a non task context is higher than that of a task when the target message buffer has TA_TPRI attribute and the buffer has enough free size for required size msgsz 4 the specified message is copied to the buffer even if there exists a task that has been waiting to be transmitted In service call tsnd_mbf parameter tmout specifies the timeout time If a positive value is specifie
423. slp_tsk void Sleep Task 17 tslp_tsk ER ercd tslp_tsk TMO tmout Sleep Task with Timeout 18 wup_tsk ER ercd wup_tsk ID tskid iwup_tsk ER ercd iwup_tsk ID tskid Wakeup Task 19 can_wup ER UINT wupcnt can_wup ID tskid ican_wup ER UINT wupcnt ican_wup ID tskid Cancel Wakeup Task 20 rel_wai ER ercd rel_wai ID tskid irel_wai ER ercd irel_wai ID tskid Release WAITING State Forcibly 21 sus_tsk ER ercd sus_tsk ID tskid isus_tsk ER ercd isus_tsk ID tskid Shift to SUSPENDED State 22 rsm_tsk ER ercd rsm_tsk ID tskid irsm_tsk ER ercd irsm_tsk ID tskid Resume Task from SUSPENDED State 23 frsm_tsk ER ercd frsm_tsk ID tskid ifrsm_tsk ER ercd ifrsm_tsk ID tskid Resume Task from SUSPENDED State Forcibly 24 dly_tsk ER ercd dly_tsk RELTIM dlytim Delay Task 25 vset_tfl ER ercd vset_tfl ID tskid UINT setptn ivset_ttl ER ercd ivset_tfl ID tskid UINT setptn Set Task Event Flag 26 velr_tfl ER ercd velr_tfl ID tskid UINT clrptn ivelr_ttl ER ercd ivelr_tfl ID tskid UINT clrptn Clear Task Event Flag 27 vwai_tfl ER ercd vwai_tfl UINT waiptn UINT p_tflptn Wait Task Event Flag 28 vpol_tfl ER ercd vpol_tfl UINT waiptn UINT p_tflptn Poll and Wait Task Event Flag 29 vtwai_tfl ER ercd vtwai_tfl UINT waiptn UINT p_tflptn TMO tmout Wait Task Ev
424. sly Related Pages e p 176 Section 3 13 1 Create Fixed Size Memory Pool e p 356 Item No 17 3 in table 5 5 of section 5 4 6 Configurator Settings Rev 6 00 449 RENESAS REJ10B0060 0600 Appendix H New Functions of HI7000 4 V2 H 4 Direct Interrupt Handler V 2 00 Release 00 and V 2 02 Release 00 In the previous version V1 issuing of service calls by direct interrupt handlers was forbidden In V 2 00 Release 00 direct interrupt handlers can issue service calls Note that the direct interrupt handler which level is higher than the kernel interrupt mask level CFG_KNLMSKLVL must not call a service call This specification is the same as the previous version In V 2 02 Release 00 it is also possible to define a direct interrupt handler by issuing a def_inh or idef_inh service call H 5 Macros for Calculating Size V 2 00 Release 00 The following macros are added 1 SIZE mpfsz TSZ_MPF UINT blkent UINT blksz The size of fixed size memory pool area required to hold the blkcnt number of blksz byte memory blocks bytes 2 SIZE size VTSZ_MPFMB UINT blkcent UINT blksz The size of fixed size memory pool management area required to hold the blkcnt number of blksz byte memory blocks bytes 3 SIZE mplsz TSZ_MPL UINT blkent UINT blksz The size of variable size memory pool area required to hold the blkcnt number of blksz byte memory blocks target byte size Related Pages e p 290 Table 4 1 in sec
425. ssembly language kernel inc includes itron inc kernel inc can be found in the hihead folder Rev 6 00 292 REJ10B0060 0600 RENESAS Section4 Application Program Creation 4 2 Handling the CPU Resources 4 2 1 SR Register 1 SR IMASK bits Interrupt Mask Bit Refer to section 0 Disabling Interrupts 2 SR MD Bit Processing mode bit SH 3 SH3 DSP SH4AL DSP SH 4 SH 4A Application program must not clear MD bit The MD bit of the SR specified in the following operations must be 1 e def_inh idef_inh def_exc idef_exc vdef_trp ivdef_trp e Definition of interrupt handlers and CPU exception handlers including TRAPA in the configurator 3 SR RB Bit Register bank bit SH 3 SH3 DSP SH4AL DSP SH 4 SH 4A Application programs must not change bank registers And application programs must not set SR RB bit to 1 The RB bit of the SR specified in the following operations must be 1 e def_inh idef_inh def_exc idef_exc vdef_trp ivdef_trp e Definition of interrupt handlers and CPU exception handlers including TRAPA in the configurator 4 SR BL Bit Exception block bit SH 3 SH3 DSP SH4AL DSP SH 4 SH 4A In the exception block state service calls must not be issued unless the specific condition is specified When using this bit to disable interrupts refer to section 0 Disabling Interrupts 5 SR DSP Bit DSP operation mode bit SH3 DSP SH4AL DSP When using SH3 DSP or SH4AL DSP d
426. st be 0 when sending a message To send a message to a mailbox that has the TA_MPRI attribute the message must be created in RAM and must have the T MSG_PRI structure at the head of the message as shown in figure 3 5 The contents of T MSG must be 0 when sending a message Rev 6 00 150 REJ10B0060 0600 RENESAS Section3 Service Calls Note that the T_MSG area is used by the kernel therefore the area must not be modified after message transfer If this area is modified normal system operation cannot be guaranteed typedef T_MSG struct user msg t_msg T_MSG structure B data 8 USER_MSG Example of user message data structure Figure 3 4 Example of a Message Form typedef struct user msg T_MSG_PRI t_msg T_MSG structure K B data 8 Example of user message data structure USER_MSG Figure 3 5 Example of a Message Form with Priority Rev 6 00 151 RENESAS REJ10B0060 0600 Section3 Service Calls 3 10 4 Receive Message from Mailbox rev_mbx prev_mbx iprcv_mbx trev_mbx C Language API ER ercd rcv_mbx ID mbxid T_MSG ppk_msg ER ercd prcv_mbx ID mbxid T_MSG ppk_msg ER ercd iprcev_mbx ID mbxid T_MSG ppk_msg ER ercd trcv_mbx ID mbxid T_MSG ppk_msg TMO tmout Parameters ID mbxid R4 Mailbox ID T_MSG ppk_msg R5 Pointer to the area where the start address of the received message is to be returned lt trcev_mbx gt T
427. standby state L The DSP is not in the module standby state The DSP is not in the module standby state and the DSP is in calculation the hardware module i e the DSP is actually being accessed Figure F 1 Examples of Module Standby Operation Rev 6 00 430 REJ10B0060 0600 RENESAS Appendix D DSP Standby Control HI7700 4 F 2 Applicable MCUs This function is only usable with MCUs that include a DSP X Y memory or both and at least one of the units has a module standby function At the time of writing this specification applies to the following MCUs SH7727 SH7729R SH7290 SH7294 SH7300 SH7641 SH7660 SH7710 SH7318 SH7343 F 3 Module Standby State when Initiating Programs When processing of a program is initiated and the DSP standby control function has been included the operation of the modules with which the TA_COP0 attribute has been related DSP or X Y memory will be affected in different ways according to the type of program and whether or not the TA_COP0 attribute has been set for that program We recommended that handlers i e programs of those types for which Undefined are indicated in table F 1 be created such that they do not access modules associated with the TA_COPO attribute If such a module is to be used have the program bring the module out of the standby state after saving the module s standby state information on the program side and return the module to the standby state before leaving the pr
428. state C Can be called from CPU exception handler Fixed Size Memory Pool Specifications The fixed size memory pool specifications are listed in table 3 42 Table 3 42 Fixed Size Memory Pool Specifications Item Description Fixed size memory pool ID 1 to CFG_MAXMPFID 1023 max Attribute supported TA_TFIFO Task wait queue is managed on a FIFO basis TA_TPRI Task wait queue is managed on priority Management method Whether to place kernel management information in the memory pool can be chosen with CFG_MPFMANAGE in the configurator Rev 6 00 175 RENESAS REJ10B0060 0600 Section3 Service Calls 3 13 1 Create Fixed Size Memory Pool cre_mpf icre_mpf acre_mpf iacre_mpf Assign Memory Pool ID Automatically C Language API ER ercd cre_mpf ID mpfid T_CMPF pk_cmpf ER ercd icre_mpf ID mpfid T_CMPF pk_cmpf ER_ID mpfid acre_mpf T_CMPF pk_cmpf ER_ID mpfid iacre_mpf T_CMPF pk_cmpf Parameters lt cre_mpf icre_mpf gt ID mpfid T_CMPF pk_cmpf lt acre_mpf iacre_mpf gt T_CMPF pk_cmpf Return Parameters lt cre_mpf icre_mpf gt ER ercd lt acre_mpf iacre_mpf gt ER_ID mpfid Packet Structure 1 CFG_MPFMANAGE is not checked typedef struct t_cmpf ATR mpfatr UINT blkent UINT blksz VP mpf T_CMPF 2 CFG_MPFMANAGE is checked typedef struct t_cmpf ATR mpfatr UINT blkent UINT blksz R4 R5 R4 RO RO 0 4 8 12 0
429. t System State Service Call Description T N E D U L C set_tim S Sets system clock T E D U iset_tim N E D U get_tim S Gets system clock T E D U iget_tim N E D U isig_tim S Supplies time tick Automatically executed according to CFG_TIMUSE check Notes 1 S Standard profile service calls s Service calls that are not standard profile service calls but are needed in order to use the standard profile function 2 T Can be called from task context N Can be called from non task context E Can be called from dispatch enabled state D Can be called from dispatch disabled state U Can be called from CPU unlocked state L Can be called from CPU locked state C Can be called from CPU exception handler System Clock Management Specifications The system clock management specifications are listed in table 3 47 Table 3 47 System Clock Management Specifications Item Description System clock value Unsigned 48 bits System clock unit 1ms System clock update cycle CFG_TICNUME CFG_TICDENO ms System clock initial value at initialization H 000000000000 Note The values of TIC_NUME and TIC_DENO defined in kernel_macro h are same as the values of CFG_TICNUME and CFG_TICDENO respectively Rev 6 00 195 RENESAS REJ10B0060 0600 Section3 Service Calls The system clock is expressed as 48 bit unsigned integer value by using the data type SYSTIM The maximum value of the s
430. t other than 0 for hi_pclock error directive Illegal CFG_TIMINTNO error directive illegal CFG_TIMINTLVL Illegal CFG_TIMINTNO setting Specify 0x400 Illegal CFG_TIMINTLVL setting Specify the value same as kernel interrupt mask level CFG_KNLMSKLVL Note this error is not detected when kernel_def c is compiled B 3 3 Errors to Do with the DSP Standby Control Function H1I7700 4 The definition file kernel_def_dspstby_set h for the DSP standby control function is checked for the errors shown in table B 4 when kernel_def c and kernel_cfg c are compiled Table B 4 Error of the DSP Standby Control Function Error Message error directive Illegal hi_cop_stby_adr Meaning Illegal hi_cop_stby_adr setting Specify hi_cop_stby_adr as a non zero integer constant error directive Illegal hi_cop_stby_bit Illegal hi_cop_stby_bit setting Specify hi_cop_stby_bit as an integer constant in the 1 to Oxff range when using SH3 DSP Specify hi_cop_stby_bit as an integer constant in the 1 to Oxffffffff range when using SH4AL DSP Rev 6 00 404 REJ10B0060 0600 RENESAS Appendix C Calculation of Work Area Size C 1 Work Areas To facilitate memory allocation a section is assigned for each work area as listed in table C 1 Allocate these sections to suitable addresses at linkage Table C 1 Work Areas Work Area Section Name File Defining Sections Kernel work area B_hiwrk kern
431. t flag and assigns event flag ID automatically T E D U iacre_flg N E D U del_fig Deletes event flag T E D U set_flg S Sets event flag T E D U iset_flg S N E D U clr_flg S Clears event flag T E D U iclr_flg N E D U wai_flg S Waits for event flag T E U pol_fig S Polls and waits for event flag T E D U ipol_flg S N E D U twai_flg S Waits for event flag with timeout function T E U ref _flg Refers to event flag state T E D U iref_flg N E D U Notes 1 S Standard profile service calls s Service calls that are not standard profile service calls but are needed in order to use the standard profile function T Can be called from task context N Can be called from non task context E Can be called from dispatch enabled state D Can be called from dispatch disabled state U Can be called from CPU unlocked state L Can be called from CPU locked state C Can be called from CPU exception handler Rev 6 00 126 REJ10B0060 0600 RENESAS Section3 Service Calls Event Flag Specifications The event flag specifications are listed in table 3 26 Table 3 26 Event Flag Specifications Item Description Event flag ID 1 to CFG_MAXFLGID 1023 max Maximum flag pattern size 32 bits Attribute supported TA_TFIFO Task wait queue is managed on a FIFO basis TA_TPRI Task wait queue is managed on priority TA_WSGL Does not permit multiple tasks to wait for the event flag TA_WMUL Permits multiple tasks to wait for th
432. t_trc VW paral VW para2 VW para3 VW para4 j ER ercd ivget_trc VW paral VW para2 VW para3 VW para4 Parameters VW paral R4 Parameter 1 VW para2 R5 Parameter 2 VW para3 R6 Parameter 3 VW para4 R7 Parameter 4 Return Parameters ER ercd RO Normal end E_OK Error Codes None Function A trace of information required by the user is obtained The parameters paral to para4 can be used freely by the user to distinguish the information to be acquired The acquired trace information can be shown by using a debugging extension DX If CFG_TRACE is not checked by the configurator this service call does not perform any processing This service call is a function original to the HI7000 4 series Rev 6 00 233 RENESAS REJ10B0060 0600 Section3 Service Calls 3 19 14 Acquire Start of Interrupt Handler as Trace Information ivbgn_int C Language API ER ercd ivbgn_int UINT dintno Parameters UINT dintno R4 Interrupt handler number Return Parameters ER ercd RO Normal end E_OK Error Codes None Function The beginning of processing of the interrupt handler for the interrupt handler number specified by dintno is traced The interrupt handler number is for the HI7000 4 the CPU vector number and for the HI7700 4 and HI7750 4 is the CPU exception code in the case of a CPU for which INTEVT2 exists the INTEVT2 code otherwise the INTEVT code This service call should be called at the beginning
433. ta dtqid data tmout Return Parameters ER Error Codes E_PAR EID E_ILUSE E_NOEXS E_CTX E_DLT E_TMOUT E_RLWAI ercd R4 Data Queue ID R5 Data sent to data queue R6 Timeout specification RO Normal end E_OK or error code Parameter error tmout lt 2 Invalid ID number dtqid lt 0 or dtqid gt CFG_MAXDTQID Illegal use of service call fsnd_dtg ifsnd_dtq is issued for the data queue which dtqcnt is 0 Undefined Data queue indicated by dtqid does not exist Context error Called from disabled system state Waiting object deleted Target data queue indicated by dtqid has been deleted while waiting Polling failed or timeout WAITING state is forcibly cancelled rel_wai service call was called in the WAITING state Rev 6 00 141 RENESAS REJ10B0060 0600 Section3 Service Calls Function The data specified by the parameter data 4 bytes is sent to the data queue specified by dtqid In addition when the data queue generated by dtqent 0 is specified fsnd_dtq and ifsnd_dtq service call generates E_ILUSE error 1 When the waiting task for reception exists in the target data queue The data is passed to the head task of receiving queuing and the waiting state of the task is canceled 2 When the waiting task for reception does not exist in the target data queue a When the data queue is not full The data specified is stored to the end of the data queue The counts of the da
434. ta queue is incremented b When the data queue is full i snd_dtq tsnd_dtq ii S The calling task is connected with queuing for waiting for the empty domain of data queue In the case of a service call tsnd_dtq the wait time is specified to tmout If a positive value is specified for the parameter tmout error code E_TMOUT is returned when the timeout period has passed without the wait release conditions being satisfied If tmout TMO_POL 0 is specified the same operation as for the service call psnd_dtq will be performed If tmout TMO_FEVR 1 is specified timeout monitoring is not performed In other words the same operation as for service call snd_dtq will be performed When a value larger than is specified for CFG_TICDENO the denominator for time tick cycles the maximum value that can be specified for tmout is H 7fffffff CFG_TICDENO If a value larger than this is specified operation is not guaranteed For detail of time watch method refer to section 2 16 4 2 Time Watch Method psnd_dtq ipsnd_dtq This call returns immediately with E_TMOUT error iii fsnd_dtq ifsnd_dtq The data is stored in the end of data queue after the data of the head of data queue is deleted Rev 6 00 142 REJ10B0060 0600 RENESAS Section3 Service Calls 3 9 4 Receive Data from Data Queue rev_dtq prev_dtgq trev_dtq C Language API ER ercd rcev_dtq ID dtqid VP_INT p data ER ercd prev_dtq ID dtqid VP_IN
435. ta_ovr N E D U stp_ovr Stops overrun handler operation T E D U istp_ovr N E D U ref_ovr Refers to overrun handler state T E D U iref_ovr N E D U Notes 1 S Standard profile service calls s Service calls that are not standard profile service calls but are needed in order to use the standard profile function 2 T Can be called from task context N Can be called from non task context E Can be called from dispatch enabled state D Can be called from dispatch disabled state U Can be called from CPU unlocked state L Can be called from CPU locked state C Can be called from CPU exception handler Only one overrun handler can be defined in the system The overrun handler is a time event handler The processor time used by the task includes the execution times of a task the service calls called by the task and the interrupt handler that is initiated during execution of the task Used processor time is not counted while the task is not in the RUNNING state Overrun Handler Specifications The overrun handler specifications are listed in table 3 57 Table 3 57 Overrun Handler Specifications Item Description Processor time unit OVRTIM Same as system clock 1 ms Attribute supported TA_HLNG The task is written in a high level language TA_ASM The task is written in assembly language Rev 6 00 214 REJ10B0060 0600 RENESAS Section3 Service Calls 3 18 1 Define Overrun Handler def_ovr C Language API E
436. tack or stack allocated by application If CFG_STSTKID is specified as 0 no static stack is used If CFG_STSTKID and CFG_MAXTSKID are specified as the same value all tasks use the static stack 2 6 7 Shared Stack Function More than one task can share one static stack This reduces the total stack area The shared stack function is not defined in the pITRON4 0 specification Shared stack and static stack assignment is defined by the configurator However only one task in a task group that shares a stack can be executed at a time When multiple tasks are initiated and share a stack the task that was initiated first uses the stack first The remaining tasks enter the shared stack wait state Tasks in the shared stack wait state are managed as a first in first out FIFO queue regardless of their priority Tasks are sent to the shared stack wait queue in the order in which they were initiated A shared stack is released from the task when the task becomes DORMANT When tasks are waiting for the shared stack the task at the head of the wait queue will use the stack and enters the READY state Figure 2 2 shows the task state transitions for the shared stack function Rev 6 00 16 REJ10B0060 0600 RENESAS Section2 Kernel READY executable state A Tes Ly Shared stack allocation WAITING SUSPENDED WAITING wait state double wait state SUSPENDED forcible wait state
437. tances in which human life is potentially at stake Please contact Renesas Technology Corp or an authorized Renesas Technology Corp product distributor when considering the use of a product contained herein for any specific purposes such as apparatus or systems for transportation vehicular medical aerospace nuclear or undersea repeater use The prior written approval of Renesas Technology Corp is necessary to reprint or reproduce in whole or in part these materials If these products or technologies are subject to the Japanese export control restrictions they must be exported under a license from the Japanese government and cannot be imported into a country other than the approved destination Any diversion or reexport contrary to the export control laws and regulations of Japan and or the country of destination is prohibited Please contact Renesas Technology Corp for further details on these materials or the products contained therein Rev 6 00 RENESAS REJ10B0060 0600 1 TRON is an acronym of The Realtime Operating system Nucleus ITRON is an acronym of the Industrial TRON and ITRON is an acronym of the Micro Industrial TRON 2 TRON ITRON and ITRON are the names of computer specifications and do not indicate a specific group of the commodity or the commodity 3 The uITRON4 0 specification is open realtime kernel specification defined by the TRON association The specification of hITRON4 0 can be dow
438. task context Task scheduling Refer to sections 2 4 2 and 2 4 3 Does not occur The following processing is executed in non task context e Interrupt handler e CPU exception handler e Time event handler cyclic handler alarm handler and overrun handler e A part where the interrupt mask is changed to a value other than 0 by the chg_ims service call Note that extended service calls initiated in the above processing state are also executed in non task context 2 4 2 Dispatch Disabled State Dispatch Enabled State The system is placed in either dispatch disabled state or dispatch enabled state In dispatch disabled state task scheduling is not allowed and service calls that place a task in the WAITING state cannot be used Issuing the dis_dsp service call during task execution changes the system state to dispatch disabled state Issuing the ena_dsp service call will return the system state to the dispatch enabled state Issuing the sns_dsp service call will check whether the system state is in dispatch disabled state or not Rev 6 00 8 REJ10B0060 0600 RENESAS Section2 Kernel 2 4 3 CPU Locked State CPU Unlocked State The system is placed in either CPU locked state or CPU Unlocked state In CPU locked state interrupts and task scheduling are not allowed Note however that interrupts with interrupt mask levels higher than that specified in the kernel mask level CFG_KNLMSKLVL in configuration are allowed In this state
439. tate The kernel_def_dspstby_set h is included from kernel_def c and kernel_cfg c Rev 6 00 433 RENESAS REJ10B0060 0600 Appendix D DSP Standby Control HI7700 4 1 hi_cop_stby_adr Format define hi_cop_stby_adr lt setting value gt Specify as a non zero integer constant the address of the register that controls the module standby state of the DSP or X Y memory If some other specification is made the following error message will be displayed when kernel_def c and kernel_cfg c is compiled error directive Illegal hi_cop_stby adr 1 hi_cop_stby_bit Format define hi_cop_stby_bit lt setting value gt Specify the bit which corresponds to the module to be controlled by this function in the register specified by hi_cop_stby_adr with the integer constant The ranges 1 to Oxff for SH3 DSP or 1 to Oxffffffff SH4AL DSP can be specified If some other range is specified the following error message will be displayed when kernel_def c and kernel_cfg c is compiled error directive Illegal hi_cop_stby bit This specification determines the hardware modules that are associated with the TA_COPO attribute Table F 3 shows the detailed values for specification with those SH3 DSP MCUs to which this function was applicable at the time of writing Table F 3 Value to be Specified for Each MCUs hi_cop_stby_bit X Y Memory DSP X Y MCU hi_cop_stby_adr DSP Only Only Memory SH7290 SH7294 0xa41
440. te Task Interrupt Management and System Configuration Management Service Call Management Cache Support only for HI7700 4 and HI7750 4 o cececec cece cece cece ce eeeeeeeeeee 60 Kernel Idling Pre fetch Function only for HI7700 4 and HI7750 4 Optimized Timer Driver only for HI7700 4 oo eee c cece tee ceeteeceeeeeeeeeeeees DSP Standby Control Function only for HI7700 4 Service Calls se scsevisscccctecdsccussbescedsscdssstsosssstscsssssvadesesdsensssvasesetsosssssesesseeegs OO Overview Service Call Interface Service Call Description Form Task Management 3 4 2 Delete Task del_tsk 3 4 3 Initiate Task act_tsk iact_tsk 3 4 4 Cancel Task Initiation Request can_act ican_act 3 4 5 Start Task Start Code Specified sta_tsk ista_tsk 3 4 6 Exit Current Task Exit and Delete Current Task ext_tsk exd_tsk 3 4 7 Terminate Task ter_tsk 3 4 8 Change Task Priority chg_pri ichg_pri 3 4 9 Refer to Task Priority get_pri iget_pri 3 4 10 Refer to Task State ref_tsk iref_tsk 3 4 11 Refer to Task State Simple Version ref_tst iref tst 3 4 12 Change Task Execution Mode vchg_tmd 3 5 3 9 1 Sleep Task slp_tsk ts p_ts 3 5 2 Wakeup Task wup_tsk iwup_t tsk 3 53 Cancel Wakeup Task can_wup ican _Wup 3 5 4 Release WAITING State Forcibly rel_wai irel wai lt lt 3 5 5 Suspend Task sus_tsk isus_tsk 3 5 6 Resume Ta
441. ted only when the task releases all of mutexes Rev 6 00 156 REJ10B0060 0600 RENESAS Section3 Service Calls 3 11 1 Create Mutex cre_mtx acre_mtx Assign Mutex ID Automatically C Language API ER ercd cre_mtx T_CMTX pk_cmtx ER_ID mtxid acre_mtx T_CMTX pk_cmtx Parameters lt cre_mtx gt ID mtxid R4 Mutex ID T_CMTX pk_cmtx R5 Pointer to the packet where the mutex lt acre_mtx gt creation information is stored T_CMTX pk_cmtx R4 Pointer to the packet where the mutex Return Parameters lt cre_mtx gt creation information is stored ER ercd RO Normal end E_OK or error code lt acre_mtx gt ER_ID mtxid RO Created mutex ID a positive value or Packet Structure typedef struct ATR PRI T_CMTX Error Codes E_RSATR p E_PAR p E_ID p E_OBJ k E_NOID k error code t_cmtx mtxatr 0 4 Mutex attribute ceilpri 4 2 Ceiling priority of mutex Invalid attribute mtxatr is invalid Parameter error pk_cmtx is other than a multiple of four ceilpri lt 0 ceilpri gt CFG_MAXTSKPRI Invalid ID number mtxid lt 0 or mtxid gt CFG_MAXMTXID Object status is invalid Mutex indicated by mtxid already exists No ID available Rev 6 00 157 RENESAS REJ10B0060 0600 Section3 Service Calls Function Service call cre_mtx creates a mutex that has the ID specified by mtxid and with the contents specified by pk_cmtx Service call acre_mtx searches
442. teed A message buffer can also be created statically by the configurator Rev 6 00 168 REJ10B0060 0600 RENESAS Section3 Service Calls 3 12 2 Delete Message Buffer del_mbf C Language API ER ercd del_mbf ID mbfid Parameters ID mbfid R4 Message buffer ID Return Parameters ER ercd RO Normal end E_OK or error code Error Codes E_ID p Invalid ID number mbfid lt 0 or mbfid gt CFG_MAXMBFID E_NOEXS k Undefined Message buffer indicated by mbfid does not exist E_CTX k Context error Called from disabled system state Function Service call del_mbf deletes the message buffer indicated by parameter mbfid No error will occur even if there is a task waiting for receiving or sending a message in the message buffer indicated by mbfid However in that case the task in the WAITING state will be released and error code E_DLT will be returned In addition if there is a message in the message buffer no error will occur but all stored messages will be deleted The size of the free message buffer area will increase by an amount given by the following expression after a message buffer is deleted Increase in size mbfsz defined at creation 16 bytes Rev 6 00 169 RENESAS REJ10B0060 0600 Section3 Service Calls 3 12 3 Send Message to Message Buffer snd_mbf psnd_mbf ipsnd_mbf tsnd_mbf C Language API ER ercd snd mbf ID mbfid VP msg UINT msgsz ER ercd psnd_mbf ID mbfid VP msg UINT m
443. tended information exinf Overrun handler Target task ID 5 R5 y Cyclic Alarm handler Initialization routine Undefined Overrun handler Extended information exinf for the task 6 R6toR7 V Undefined 7 R8to R14 MACH V V Undefined MACL GBR 8 R15 V V R15 points to appropriate stack area 9 PR V V Undefined 10 SH3 DSP SH4AL DSP V V Undefined DSR RS RE MOD AO AOG A1 A1G MO M1 XO X1 YO Y1 RENESAS Rev 6 00 331 REJ10B0060 0600 Section4 Application Program Creation Notes 1 These registers can be used Note that some register contents cannot be guaranteed after service calls For details refer to section 3 2 3 Guarantee of Register Contents after Issuing Service Call 2 When execution is returned from the entry function RTS instruction the contents of these registers must be the same as the value at initiation 3 IMASK bits must not be lower than the value at initiation And IMASK bits must be the same as initial value when execution is returned from the handler DSP CL must be 1 when at least one of CFG_DSP and CFG_CACLOC is checked MD 1 BL 0 and RB 0 are required Rev 6 00 332 REJ10B0060 0600 RENESAS Section4 Application Program Creation Table 4 20 Rules for Using Registers in Time Event Handlers and Initialization Routine HI7750 4 End Use Conditions No Registers a a Initial Value 1 PC V CPU exception handler start address 2 SR
444. ter task execution resumes Delayed requests to suspend a task can be cancelled by calling service call rsm_tsk irsm_tsk frsm_tsk or ifrsm_tsk Therefore tasks are suspended when there are one or more delayed suspend requests Rev 6 00 102 REJ10B0060 0600 RENESAS Section3 Service Calls 3 5 6 Resume Task Force Task to Resume rsm_tsk irsm_tsk frsm_tsk ifrsm_tsk C Language API ER ercd ER ercd ER ercd ER ercd Parameters ID Return Parameters ER Error Codes EID E_NOEXS E_OBJ Function rsm_tsk ID tskid irsm_tsk ID tskid frsm_tsk ID tskid ifrsm_tsk ID tskid R4 Task ID RO Normal end E_OK or error code Invalid ID number tskid lt 0 or tskid gt CFG_MAXTSKID Undefined Task indicated by tskid does not exist Object status is invalid Task indicated by tskid is not in the SUSPENDED state task is in the DORMANT state or the current task is specified Each service call releases the task specified by parameter tskid from the SUSPENDED state Service calls rsm_tsk and irsm_tsk decrement by one the number of nested requests to suspend and release the task from the SUSPENDED state when the number of the nested requests becomes 0 Service calls frsm_tsk and ifrsm_tsk modify the number of nested requests to 0 and release the task from the SUSPENDED state When the task is in the WAITING SUSPENDED state the task is shifted to the WAITING state Rev 6 00 103 RENESAS REJ10B006
445. that of the dispatcher task switching cannot be performed during the CPU exception processing In CPU exception handler processing system states such as task execution mode remain at the same state as when the exception occurred The CPU exception handler operates using the context at the time of the exception occurrence Note that the CPU exception handler can call only the following service calls e sns_ctx e sns_loc e sns_dsp e sns_dpn e sns_tex e get_tid iget_tid e ras_tex iras_tex e vsta_knl ivsta_knl e vsys_dwn ivsys_dwn Rev 6 00 58 REJ10B0060 0600 RENESAS Section2 Kernel 2 19 Service Call Management A service call processing routine can be created and defined in the kernel as an extended service call routine If a process common to the system is created as an extended service call routine the handler can be called without linking to the processing routine Extended service calls are controlled by the service calls listed in table 2 25 Table 2 25 Service Calls for Extended Service Call Control Service Call Name Function def_svc idef_svc Defines an extended service call cal_sve ical_svc Issues an extended service call Figure 2 19 shows an example of an extended service call routine seed Kernel o Extended service Define an extended Maximum function code call routine service call routine CFG_MAXSVCCD def_svc Execute an extended service call rout
446. that is initiated when the specified time has been exceeded Only one overrun handler can be defined in a single system The overrun handler is controlled by the service calls listed in table 2 20 Table 2 20 Service Calls for Overrun Handler Control Service Call Name Function def_ovr Defines an overrun handler sta_ovr ista_ovr Initiates an overrun handler stp_ovr istp_ovr Stops an overrun handler ref_ovr iref_ovr Refers to an overrun handler status The overrun handler can also be created by the configurator Figure 2 17 shows an example of using overrun handler Define an Initiate an Initiate an Stop an overrun handler overrun handler overrun handler overrun handler def_ovr sta_ovr sta_ovr stp_ovr eee Time Upper limit H Upper limit processor time _ _ processor time Start execution y An overrun handler is not initiated Overrun handler J Figure 2 17 Example of Using Overrun Handler Description a An overrun handler is defined b The upper limit processor time for the task is specified by the sta_ovr service call The overrun handler is initiated at this point c If a total processor time used by the task exceeds the upper limit processor time the overrun handler is initiated d If the upper limit processor time is modified by the sta_ovr service call the overrun handler is initiated again e If stp_ovr is issued before the total processor time has exc
447. the order expected and the program may not work properly In this case the optimized linkage editor reports the following warning message example in case P_Task1 section is not specified L1120 W Section address is not assigned to P_Taski Specifying a section name that does not actually appear in the input files also produces a warning message but the optimized linkage editor continues linking In this case the optimized linkage editor reports the following warning message example in case C section does not exist L1100 W Cannot find C specified in option Start The default settings for example sometimes produce such warnings if the application files do not have P C D B or R sections because these sections are not used in the linked application object but these warnings in no way affect use of the resulting load module Rev 6 00 387 RENESAS REJ10B0060 0600 Section5 Configuration 5 14 4 Executing a Build The load module is created by executing a build after adding application files to the project and setting the compiler assembler and optimized linkage editor options To execute a build choose the Build or Build All command from the Build menu as shown in figure 5 14 5 15 Application Load Module Creation Application files that are specified in the configurator and that do not have external application names such as task symbols can independently create a load module Conversely it is possible t
448. the target cache determined by mode will be invalidated In this case this service call operates the following bits of the CCR register according to mode This processing is performed in the state of SR BL 1 e mode TC_FULL Writes 1 to ICI bit and OCI bit e mode TC_EXCLUDE_IC Writes 1 to OCI bit e mode TC_EXCLUDE_OC Writes 1 to ICI bit In the HI7750 4 this service call can be called before the kernel is initiated This service call can be called even in the exception block state BL 1 in SR Therefore the cache can be invalidated irrespective of interrupts or exceptions When this service call has been called when BL 1 in SR clear BL to 0 after returning from the service call processing Rev 6 00 287 RENESAS REJ10B0060 0600 Section3 Service Calls Rev 6 00 288 REJ10B0060 0600 RENESAS Section 4 Application Program Creation 4 1 Header Files 4 1 1 Header Files for C C Language 1 itron h itron h is a header file where the common ITRON specification definitions are described for C C language This file can be found in the hihead folder 2 kernel h and kernel_macro h kernel h is a header file where the yITRON4 0 kernel specification definitions are described for C C language kernel h includes itron h and kernel_macro h that is output from the configurator kernel h can be found in the hihead folder Section 3 Service Calls describes the service calls by using the data types constants a
449. the task 1 When TA_ACT attribute is specified at task creation and when the task is started by act_tsk service call The extended information exinf which is specified at task creation is passed to the task 2 When the task is started by sta_tsk service call The task start code stacd which is specified by sta_tsk service call is passed to the task Rev 6 00 13 RENESAS REJ10B0060 0600 Section2 Kernel 2 6 4 Task Scheduling Scheduling For each task a task priority is assigned to determine the priority of processing A smaller value indicates a higher priority level and level 1 is the highest priority The kernel selects the highest priority task from the READY tasks and puts it in the RUNNING state The same priority can be assigned for multiple tasks When there are multiple READY tasks with the highest priority the kernel selects the first task that became READY and puts it in the RUNNING state To implement this behavior the kernel has ready queues which are READY task queues waiting for execution While execution is in a non task context no task is executed until the non task context processing is completed Round Robin Scheduling The kernel also supports round robin scheduling where the CPU allocates equal time to tasks with a given priority by rotating the ready queue at specific intervals The round robin scheduling can be achieved by issuing the rot_rdq service call that manipulates the ready queues e
450. the task the value of leftotm is undefined 3 19 System State Management System State Management Service Calls System state is controlled by the service calls listed in table 3 60 Table 3 60 Service Calls for System State Management System State Service Call Description T N E D U L C rot_rdq S Rotates ready queue T E D U irot_rdq S N E D U get_tid S Refers to task ID in RUNNING state T E D U C iget_tid S N E D U C loc_cpu S Locks CPU T E D U L iloc_cpu S N E D U L unl_cpu S Unlocks CPU T E D U L iunl_cpu S N E D U L dis_dsp S Disables task dispatch T E D U ena_dsp S Enables task dispatch T E D U sns_ctx S Refers to task context T N E D U L C sns_loc S Refers to CPU locked state T N E D U L C sns_dsp S Refers to dispatch disabled state T N E D U L C sns_dpn S Refers to dispatch pended state T N E D U L C vsta_knl s Starts kernel T N E D U L C ivsta_knl s T N E D U L C vsys_dwn s Terminates the system T N E D U L C ivsys_dwn s T N E D U L C vget_trc Acquires trace T E D U ivget_tre N E D U ivbgn_int Acquires start of interrupt handler to trace N E D U ivend_int Acquires end of interrupt handler to trace N E D U Notes 1 S Standard profile service calls s Service calls that are not standard profile service calls but are needed in order to use the standard profile function Rev 6 00 219 RENESAS REJ1
451. ther than mutexes such as semaphores and memory blocks acquired before the task is exited Therefore the user must call service calls to release resources before exiting the task Rev 6 00 84 REJ10B0060 0600 RENESAS Section3 Service Calls If the task that issues the service calls ext_tsk and exd_tsk shares the stack with other tasks the task at the head of the stack wait queue is removed and WAITING state is cancelled At this time the processing to be performed during task initiation table 3 8 is performed for the task that is removed from the stack wait queue and the task makes a transition to the READY state If a dynamic stack is used by the task that called the service call exd_tsk the stack is returned to the dynamic stack area As a result the free dynamic stack area size increases by an amount given by the following expression Increase in size stksz which is specified at creation 16 bytes Service calls ext_tsk and exd_tsk can be called while task dispatch is disabled or the CPU is locked After either of the service calls is called the dispatch disabled state or CPU locked state is cancelled Note that when the task returns from the start function the same operation as for service call ext_tsk will be performed Rev 6 00 85 RENESAS REJ10B0060 0600 Section3 Service Calls 3 4 7 Terminate Task ter_tsk C Language API ER ercd ter_tsk ID tskid Parameters ID tskid R4 Task ID Return Paramete
452. tically assigns ID del_mbf Deletes a message buffer snd_mbf Sends a message to a message buffer psnd_mbf ipsnd_mbf Sends a message to a message buffer polling tsnd_mbf Sends a message to a message buffer with timeout rcv_mbf Receives a message from a message buffer prcv_mbf Receives a message from a message buffer polling trcv_mbf Receives a message from a message buffer with timeout ref_mbf iref_mbf Refers to the message buffer status Message buffers can also be created by the configurator Figure 2 10 shows an example of using message buffer Rev 6 00 32 REJ10B0060 0600 RENESAS Section2 Kernel Time Task A Task B Message buffer status 1 cre_mbf 64 bytes Empty rcv_mbf 2 lt WAITING gt PW APO LPI OF OL OT TF OOP OT 3 lt READY gt Receive X snd_mbf X 16 bytes Empty PDA SANESI A ONL OAT Vel ODP S A 3 snd_mbf Y 48 bytes Y Empty 5 i snd_mbf Z 32 bytes lt WAITING gt Y Empty LONI VOL VA VI OP A OT A 6 rcv_mbf z i READY gt Receive Y i Z Empty Figure 2 10 Example of Using Message Buffer Description Bold lines represent executed processing The following describes the message buffer operation with respect to time 1 Task A creates a 64 byte message buffer which deals the message where the maximum size is 48 bytes by issuing cre_mbf Task A receives a
453. timer modules assumed by the sample timer driver For more detail refer to the contents of the header file Rev 6 00 421 RENESAS REJ10B0060 0600 Appendix D Timer Driver Table D 1 Sample Timer Driver Files and Clock Sources Target Microcomputers and Assumed Timer Module Clock Product nnnn Internal Timer Modules Source HI7000 4 7011 SH7011 SH7018 CMT System clock 20 MHz V 2 02 703x SH7020 SH7021 SH7032 ITU System clock b 20 MHz SH7034 704x SH7040 SH7041 SH7042 CMT System clock 28 MHz SH7043 SH7044 SH7045 SH7014 SH7016 SH7017 7046 SH7046 SH7047 SH7048 CMT System clock 40 MHz SH7049 SH7144 SH7145 SH7148 7050 SH7050 SH7051 CMT System clock 20 MHz 7052 SH7052 SH7053 SH7054 CMT Peripheral clock 20 MHz 7065 SH7065 CMT Peripheral clock Po 30 MHz 7604 SH7604 FRT System clock 28 7 MHz 7615 SH7615 SH7616 FRT Peripheral clock P 30 MHz 7618 SH7618 CMT Peripheral clock P 12 5 MHz 72060 SH72060 CMT Peripheral clock P 24 MHz HI7700 4 7707 SH7707 TMU Peripheral clock Pd 30 MHz V 2 02 7708 SH7708 SH7708R TMU Peripheral clock Po 15 MHz SH7708S 7709 SH7709 TMU Peripheral clock P 30 MHz 7709a SH7709A SH7709S TMU Peripheral clock Po 33 34 MHz SH7706 7729 SH7729 SH7729R SH7727 TMU Peripheral clock Po 33 34 MHz 7290 SH7290 SH7294 SH7300 TMU Peripheral clock Po 19 8 MHz 764
454. tincrement register indirect addressing mode instructions used in the program When parameters are pushed onto the stack at function call the area size for the parameters must be added to the stack size C 5 Stack Size Considering Programming Nesting A stack size considering programming nesting is calculated with the following program start functions as a base point e Tasks e Interrupt handlers e Time event handlers e Initialization routine Programming nesting includes all functions that are called from these start functions and the following program calls e Extended service call routine e Task exception processing routine e CPU exception handlers containing TRAPA instruction exception handlers Calculate the total value of the stack sizes used by each function and determined according to appendix C 4 Calculation of Stack Size for Each Function above for each nesting case When the task exception processing routine or CPU exception handlers containing TRAPA instruction exception handlers is nested add the value shown in table C 2 for each nesting Table C 2 Additional Stack Size of the Call Routine and the Handlers Additional Size Byte Item HI7000 4 HI7700 4 HI7750 4 Task exception processing routine 172 172 2 180 TA_COPO attribute 56 56 included 1 TA_COP1 attribute 72 64 included TA_COP2 attribute 64 included CPU exception handlers containing TRAPA 44 44 48 instruction excepti
455. tion 5 11 3 PACK Option and pragma pack of Compiler Compiler Package V 8 or Later The structure parameters to be passed to the kernel must be aligned with the same boundary alignment value as that for the members To achieve this pragma pack 4 is specified in the definition of the structure type in the standard header files itron h and kernel h 5 11 4 Include Directory for Compiler and Assembler As the standard header files are stored in the hihead folder specify the hihead folder as the include directory for usual operation For kernel_def c and kernel_cfg c specify the hisys folder as the include directory 5 11 5 When SH2A FPU or SH 4 or SH 4A is Used Appendix G Notes on FPU of SH2A FPU SH 4 SH4A also has the description about a compiler option When you do not use an FPU function please be sure to refer this 5 11 6 TBR Option of Compiler Compiler Package V 9 or Later The TBR option is only for SH 2A and SH2A FPU When Only for service call is chosen as CFG_TBR the kernel initializes the TBR register The application must not modify TBR For this reason the TBR option and pragma tbr must not be used Rev 6 00 374 REJ10B0060 0600 RENESAS Section5 Configuration 5 12 Build for Whole Linkage mix 5 12 1 Adding Files to a Project Table 5 11 lists the source program sample files to be added to the project The sample project file already contains the files shown in this table T
456. tion 4 1 1 Header File H 6 Extension of Maximum Vector Number V 2 00 Release 00 The maximum vector number that can be specified for CFG_MAXVCTNO through the configurator is extended from 255 to 511 Related Pages e p 236 Table 3 62 in section 3 20 Interrupt Management e p 245 Table 3 68 in section 3 22 System Configuration Management Rev 6 00 450 REJ10B0060 0600 RENESAS Appendix H New Functions of HI7000 4 V2 H 7 ID Name V 2 00 Release 00 In the previous version ID names can be specified only when ID numbers are automatically assigned In V 2 ID names can be specified to all objects Table H 1 shows the additional functions in V 2 about ID names Table H 1 Additional Functions about ID Names Kernel Environment Side Kernel Side kernel_id_sys h kernel_id h Automatic Automatic ID Number ID Number Version Assignment SpecifyIDName Assignment Specify ID Name Previous version Impossible Impossible Possible Possible only for specifying Auto as ID Number V 2 00 or later Possible Possible Related Pages e p 292 Section 4 1 1 3 Header Files for ID Name e p 353 Section 5 4 4 1 kernel_id h kernel_id_sys h H 8 Support of Little Endian in SH 2 V 2 00 Release 01 V 2 00 Release 01 supports the little endian mode in the SH 2 H 9 Improvement of Variable Size Memory Pool V 2 01 Release 00 Selecting CFG_NEWMPL added to the configurator allows the following improvements 1 The per
457. tive files refer to table 5 4 In separate linkage kernel environment load modules are usually modified alone without modifying kernel load modules For this operation the configurator provides the kernel lock mode In this mode editing of the parameters that are to be expanded in a kernel side output file is limited and no kernel side file is output To enter kernel lock mode put a check mark in Generate gt Kernel Lock Mode Whether each item is on the kernel side or kernel environment side can be checked by specifying the kernel lock mode but for details refer to the help information of the configurator In addition for generation of objects such as tasks the kernel side or kernel environment side can be assigned and checked as follows e All object creation dialog boxes have the Link with Kernel Library check box If this box is checked the object is on the kernel side e The object that is marked by a flag icon in the object page is on the kernel side In an object creation dialog box when specifying the symbol of applications such as the address of a task the symbol instance must be included in the suitable linkage unit kernel side or kernel environment side 2 kernel_id h The application on the kernel side must not include kernel_id h because kernel_id h is a file on the kernel environment side Rev 6 00 354 REJ10B0060 0600 RENESAS Section5 Configuration 5 4 6 Configurator Settings Most config
458. tor Figure 2 7 shows an example of using a data queue Rev 6 00 26 REJ10B0060 0600 RENESAS Section2 Kernel Time Task A Task C Data queue status 1 cre_dtq gt Bg z 2 snd_dtq X i aE gt 3 ipsnd_dtq Y gt ine LLL EINE NINE NISS N 4 snd_dtq Z ybx gt lt WAITING gt DININI AINAN IANA INNAN IANA IAIN AIAN ININA ASA lt READY gt i gt gt 5 rcv_dtq Receive X Figure 2 7 Example of Using Data Queue Description Bold lines represent executed processing The following describes the data queue operation with respect to time 1 Task A issues cre_dtq to create a data queue with a size of two words 2 Task A sends data X by issuing snd_dtq Data X is copied to the data queue and task A continues execution 3 Interrupt handler B sends data Y by issuing ipsnd_dtq 4 Task A attempts to send data Z At this time since there is no empty entry in the data queue task A enters the WAITING state 5 Task C receives data from a data queue by issuing rcv_dtq Task C gets data X which is initially copied At this time since one entry in the data queue is released data Z which task A has attempted to send is copied to a data queue and task A is released from the WAITING state Rev 6 00 27 RENESAS REJ10B0060 0600 Section2 Kernel 2 11 Mailbox A mailbox is used to send or receive message data between tasks Since the communication using a mailbox send
459. tskid 0 2 Wait task ID FLGPTN flgptn 4 4 Event flag bit pattern T_RFLG Error Codes E_PAR p Parameter error pk_rflg is other than a multiple of four E_ID p Invalid ID number flgid lt 0 or flgid gt CFG_MAXFLGID E_NOEXS k Undefined Event flag indicated by flgid does not exist Function Each service call refers to the state of the event flag indicated by the parameter flgid Each service call returns the task ID at the head of the event flag wait queue wtskid and the current event flag bit pattern flgptn to the area specified by the parameter pk_rflg If there is no task waiting for the specified event flag TSK_NONE 0 is returned as a wait task ID Rev 6 00 135 RENESAS REJ10B0060 0600 Section3 Service Calls 3 9 Synchronization and Communication Data Queue Data Queue Service Calls Data queues are controlled by the service calls listed in table 3 29 Table 3 29 Service Calls for Data Queue Control System State Service Call Description T N E D U L C cre_dtq s Creates data queue T E D U icre_dtq N E D U acre_dtq Creates data queue and assigns data queue ID automatically T E D U iacre_dtq N E D U del_dtq Deletes data queue T E D U snd_dtq S Sends data to data queue T E U psnd_dtq S Polls and sends data to data queue T E D U ipsnd_dtq S N E D U tsnd_dtq S Sends data to data queue with timeout function T E U fsnd_dtq S Forcibly sends data
460. tten to memory the data is written back to memory flsadr1 is omitted to the multiple of 32 and flsadr2 is revalued to the multiple 1 of 32 1 Flush specified range This service call flushes the entries corresponding to the logical address range from flsadr1 to flsadr2 in the operand cache that is when the specified entries have not been written to memory the entries are copied back to memory This service call repeats execution of the OCBWB instruction for the range from flsadr1 to flsadr2 During this processing the SR value remains the same as when this function is called When no interrupt should be accepted during this function processing mask interrupts and then call this function In this service call only the fundamental error check indicated in the error code column is performed on flsadr1 and flsadr2 For example the following addresses should not be contained e P2 and P4 areas e Address corresponding to a physical address in the control area e Address corresponding to a physical address in X Y memory The processing time of this service call is proportional to the size of the appointed domain Rev 6 00 284 REJ10B0060 0600 RENESAS Section3 Service Calls 2 Flush all If 0 is specified to be flsadr1 and H ffffffff is specified to be flsadr2 all the entries of the operand cache will be cleared In this case this service call is processed as follows e The OCBP instruction is executed for all entries of the
461. tx sns_loc sns_dsp sns_dpn get_tid iget_tid ras_tex iras_tex vsta_knl ivsta_knl vsys_dwn ivsys_dwn 5 Before Kernel Activation The following service calls can be called even before kernel activation vsta_knl service call vsta_knl ivsta_knl vsys_dwn ivsys_dwn vini_cac ivini_cac HI7700 4 vclr_cac ivelr_cac HI7700 4 vfls_cac ivfls_cac HI7700 4 vinv_cac ivinv_cac Rev 6 00 71 RENESAS REJ10B0060 0600 Section3 Service Calls 3 2 6 Service Calls not in the pyITRON4 0 Specification Service calls whose name start with v or iv such as vscr_tsk and ivbgn_int are service calls that are not defined in the pITRON4 0 specification The following ixxx_yyy format service calls starting with i are not defined in the ulTRON4 0 specification They are provided to enable the xxx_yyy format service calls corresponding to the following service calls to be issued in a non task context because the xxx_yyy format service calls are defined to be issued only in a task context in the pITRON4 0 specification icre_tsk iacre_tsk ista_tsk ichg_pri iget_pri iref_tsk iref_tst isus_tsk irsm_tsk frsm_tsk idef_tex iref_tex icre_sem iacre_sem ipol_sem iref_sem icre_flg iacre_flg iclr_flg ipol_flg iref_flg icre_dtq iacre_dtq iref_dtq icre_mbx iacre_mbx isnd_mbx iprcv_mbx iref_mbx icre_mbf iacre_mbf ipsnd_mbf iref_mbf icre_mpf iacre_mpf ip
462. uage TA_STA H 00000002 Starts the cyclic handler operation TA_PHS H 00000004 Reserves initiation phase When TA_STA is specified the cyclic handler is set to the operating state after it is created When TA_STA is not specified the cyclic handler does not operate until service calls sta_cyc or ista_cyc is called When TA_PHS is specified the initiation phase of the cyclic handler is kept before activating the cyclic handler and the next time to initiate the handler is determined When TA_PHS is not specified the next time to initiate the cyclic handler is determined based on the time that service calls sta_cyc or ista_cyc is called Parameter exinf specifies the extended information to be passed as a parameter when initiating the cyclic handler Parameter exinf can be widely used by the user for example to set information concerning cyclic handlers to be defined Parameter cychdr specifies the start address of the cyclic handler Parameter cyctim specifies the handler initiation state Parameter cycphs specifies the handler initiation phase If a value larger than 1 is specified for CFG_TICDENO the denominator for time tick cycles the maximum value that can be specified for cyctim and cycphs is H 7fffffff CFG_TICDENO If a value larger than this is specified operation is not guaranteed For detail of time watch method refer to section 2 16 4 2 Time Watch Method Rev 6 00 202 REJ10B0060 0600 RENESAS Section3 Service Calls
463. unction s Packet Siruatire CFG_PARCHKk is installed Packet state described as below when used by a service call typedef struct t_rsem ID wtskid 0 2 Wait task ID UINT sement 4 4 Current semaphore count T_RSEM Naf SSS Description of the t ji Description of member structure in C language Offset from the Member size beginning of a packet e Description of Attribute The following symbols are used for description of attribute A indicates specification of A can be omitted A B indicates selection of A or B Figure 3 3 Service Call Description Form Rev 6 00 73 RENESAS REJ10B0060 0600 Section3 Service Calls 3 4 Task Management Task Management Service Calls Tasks are managed by the service calls listed in table 3 4 Table 3 4 Service Calls for Task Management System State Service Call Description T N E D U L C cre_tsk s Creates task using dynamic stack T E D U icre_tsk N E D U vscr_tsk s Creates task using static stack T E D U ivscr_tsk N E D U acre_tsk Creates task and assigns task ID automatically T E D U iacre_tsk N E D U del_tsk Deletes task T E D U act_tsk S Initiates task T E D U iact_tsk S N E D U can_act S Cancels task initiation request T E D U ican_act N E D U sta_tsk Initiates task and specifies start code T E D U ista_tsk N E D U ext_tsk S Exits current
464. urator settings influence kernel operation These settings are named with the prefix CFG_ and these names are displayed on the configurator screen and also used in this manual However note that some settings do not have names Table 5 5 lists the settings The following letters are used in this table L Kernel side items Cannot be changed in the kernel lock mode B Can be set either for the kernel side or the kernel environment side by Link with Kernel Library check box BA Can be set either for the kernel side or the kernel environment side by Link with Kernel Library check box and an ID name can be specified If the kernel environment side is selected Auto can be selected for the ID number When specifying ID names be careful not to specify the names that have already been used or externally defined names such as function names Rev 6 00 355 RENESAS REJ10B0060 0600 Section5 Configuration Table 5 5 Configurator Setting Items 1 Kernel Operating Condition Page 1 kernel interrupt mask level CFG_KNLMSKLVL L The kernel has a function to set SR IMASK to the specified value and execute it Interrupt handlers with level higher than CFG_KNLMSKLVL cannot issue a service call For the HI7000 4 interrupts with level higher than CFG_KNLMSKLVL must be described as direct interrupt handlers 2 Interrupt nest count with a level higher than the kernel CFG_UPPINTNST interrupt mask level only for HI7000 4
465. uring System Down The system down routine is called when the system goes down Information listed in table B 2 is passed to the system down routine Table B 2 Information Passed to the System Down Routine Parameters Passed to the System Down Routine System Down System Down Cause of System Going Error Type Error Code Information 1 Information 2 Down W type R4 ER ercd R5 VW inf1 R6 VW inf2 R7 Service call vsys_dwn 1 to H 7fffffff Parameter of service call vsys_dwn An error in the original 0 Error code 0 Error in kernel Indicates the definition of configurator side definition 1 Error in kernel umber where environment side 20 initial definition error has occurred in the kernel side or kernel environment side When a context error H ffffffff 1 E_CTX Address calling Undefined occurred as a result of H ffffffe7 ext_tsk service call ext_tsk being issued by the non task context When a context error H fffffffe 2 E_CTX Address calling Undefined occurred as a result of H ffffffe7 exd_tsk service call exd_tsk being issued by the non task context When an undefined interrupt H fffffffO 16 or an exception occurred Exception code or vector number PC at exception occurrence SR at exception occurrence Rev 6 00 402 REJ10B0060 0600 RENESAS Appendix B Error List Notes 1 Information saved by the CPU to the interrupt event register INTEVT or INTEVT2 or
466. uring task initiation table 3 8 is performed for the task that is removed from the stack wait queue and the task makes a transition to the READY state Rev 6 00 86 REJ10B0060 0600 RENESAS Section3 Service Calls 3 4 8 Change Task Priority chg_pri ichg_pri C Language API ER ercd chg_ pri ID tskid PRI tskpri ER ercd ichg_pri ID tskid PRI tskpri Parameters ID tskid R4 Task ID PRI tskpri R5 Base priority of task Return Parameters ER ercd RO Normal end E_OK or error code Error Codes E_PAR p Parameter error tskpri lt 0 or tskpri gt CFG_MAXTSKPRI E_ID p Invalid ID number tskpri lt 0 tskid gt CFG _MAXTSKID or tskid TSK_SELF 0 is specified in a non task context E_NOEXS k Undefined Task specified by tskid does not exist E_ILUSE k Illegal use of service call Upper limit priority is exceeded E_OBJ k Object state is invalid Task is in the DORMANT state Function Each service call changes the base task priority specified by the parameter tskid to the value specified by the parameter tskpri The current task priority is also changed By specifying tskid TSK_SELF 0 the current task can also be specified Specifying tskpri TPRI_INI 0 returns the task priority to the initial priority that was specified at task creation A priority changed by the service calls is valid until the task is terminated or until the service calls are called again When a task makes a transition to the D
467. v 6 00 443 REJ10B0060 0600 Appendix G Notes on FPU of SH2A FPU SH 4 SH4A G 4 2 FPSCR Structure 31 22 21 20 19 18 17 12 Ti Reserved FR SZ PR DN Cause Enable Flag RM Bit Meaning 21 FR FPU register 0 Bank 0 bank 1 Bank 1 20 SZ Transfer size 0 The data size of the FMOV instruction is 32 bits mode 1 The data size of the FMOV instruction is a 32 bit register pair 64 bits 19 PR Precision 0 Single precision mode 1 Double precision 18 DN Denormaliza 0 A denormalized number is treated as such tion mega 1 Adenormalized number is treated as zero 17 12 Cause FPU exception factor field 11 7 Enable FPU exception enable field 6 2 Flag FPU exception flag field 1 0 RM Rounding B 00 Round to Nearest mode B 01 Round to Zero Notes 1 Only in SH 4 and SH 4A 2 In SH2A FPU DN is always 1 Rev 6 00 444 REJ10B0060 0600 RENESAS Appendix G Notes on FPU of SH2A FPU SH 4 SH4A G 4 3 Handling by the Compiler This section explains handling by compiler The compiler never generates any object code to change the FPSCR when Single or Double has been specified as the FPU option 1 FPSCR PR Precision mode Table G 4 Handling of the FPSCR PR Bit by the Compiler Compiler Option Precision Mode Assumed FPU FPSCR by the Compiler on Entry Precision Mode Opti Option to
468. vely the CPU may be placed in the low power consumption mode for a greater part of the time Unlike the standard timer driver the optimized timer driver is built into the kernel The user cannot create an optimized timer driver In addition this function does not require the modification of existing application programs E 2 Operation Figure E 1 shows examples of operation where the standard timer driver and optimized timer driver are used to provide time precision of 1 ms CFG_TICNUME CFG_TICDENO Standard timer driver Timer interrupt 1 Dai E tslp_tsk 9 Optimized timer driver 5 ms timer interrupts 1 ms timer interrupts Dt ee Ney EO e tslp_tsk 9 Timeout Figure E 1 Example of Operation Two TMU timer channels one with a 1 ms and the other with a 5 ms period are used in operating the optimized timer driver as shown in figure E 1 the respective timing cycles are called the high precision and low precision cycle The high precision cycle is the result in ms of the division of values specified by the configurator i e CFG_TICNUME CFG_TICDENO Rev 6 00 423 RENESAS REJ10B0060 0600 Appendix E Optimized Timer Driver HI7700 4 The period of the low precision cycle is an integer multiple of this period and is set by the user statically When the optimized timer driver is in use the kernel investigates the following situations at the right time e Waiting tasks by service calls
469. vice call routine can be defined in the following ways e def_svc or idef_svc service call e Defined initially by the configurator Rev 6 00 306 REJ10B0060 0600 RENESAS Section4 Application Program Creation 4 8 Interrupt Handlers There are two types of interrupt handlers One is Normal interrupt handler and another is Direct interrupt handler for HI7000 4 The interrupt response of the direct interrupt handler is better than the normal interrupt handler 4 8 1 Normal Interrupt Handler A normal interrupt handler is initiated via the entrance and exit processing routine of the kernel when an interrupt occurs When the HI7000 4 is used the interrupts with a level higher than the kernel interrupt mask level CFG_KNLMSKLVL must be written and defined as the direct interrupt handler including NMI If these handlers are written and defined as the normal interrupt handler normal system operation cannot be guaranteed 1 Writing a Normal Interrupt Handler A normal interrupt handler is written in C language as shown in figure 4 4 include kernel h pragma noregsave Inh When SH 2A or SH2A FPU is used and CFG _REGBANK is checked this statement can be used because the handler does not have to guarantee general registers void Inh void lt An interrupt handler is defined as void Interrupt handler processing Figure 4 4 Example of a C Language Normal Interrupt Handler 2 Rules on U
470. vscr_tsk service calls When creating a task using the static stack select a stack used by the task in the static stack defined in item 2 Tasks with the same stack specification share the stack When specifying Start Task after Creating It TA_ACT for attribute the order of task execution may change according to the order of task creation Tasks are first created from the top of the kernel window side then from the top of the kernel environment window side Move the task registration location by pressing Up or Down in the pop up menu Automatic ID assignment can be set only to tasks using the dynamic stack and that have been created on the kernel environment side 6 _ Definition of task exception processing routine B The task exception processing routine can be defined for a task created in item 5 if necessary For separate linkage the task and the task exception processing routine must include the same linkage unit kernel side or kernel environment side as the target task When the task exception processing routine is defined the def_tex service call must be embedded Rev 6 00 360 REJ10B0060 0600 RENESAS Section5 Configuration Table 5 5 Configurator Setting Items cont 11 Semaphore Page 1 Maximum semaphore ID CFG_MAXSEMID The range of usable semaphore IDs is 1 to CPG_MAXSEMID The maximum value specifiable is 1023 When no semaphore is used specify 0 When a value more than 1 is specified the
471. w When an interrupt occurs an interrupt handler is initiated via kernel interrupt service routine To improve the interrupt response time the kernel can define the interrupt mask level at system configuration The interrupt mask level is called the kernel interrupt mask level CFG_KNLMSKLVL Interrupt handlers with mask levels higher than the kernel interrupt mask level can be immediately accepted even when the kernel is executed Note however that the service call must be issued by the interrupt handlers with the levels higher than the kernel interrupt mask level An interrupt handler is executed in the non task context state Tasks are scheduled after the interrupt handler has completed execution tasks are not scheduled even when a task with high priority is in the READY state due to the service call issued while the interrupt handler was being executed The interrupt handler must not make the interrupt mask level MASK bits in the SR register lower than the interrupt level 2 Direct interrupt handlers only in the HI7000 4 The HI7000 4 provides direct interrupt handlers i e handlers that do not require a kernel interrupt service routine A direct interrupt handler is directly recorded as a CPU interrupt vector and the response is better than a normal interrupt handler Direct interrupt handlers must have interrupt levels higher than the kernel interrupt mask level The difference between normal and direct interrupt handlers is show
472. which is used to create fixed size memory pool The mpfmb member indicates the address of the management table area The conventional or new management method is chosen by CFG_MPFMANAGE in Fixed size Memory Pool page of the configurator Note that both methods cannot be used simultaneously Related Pages e p 176 Section 3 13 1 Create Fixed Size Memory Pool cre_mpf icre_mpf e p 356 Item No 17 3 in table 5 5 of section 5 4 6 Configurator Settings Rev 6 00 462 REJ10B0060 0600 RENESAS Appendix J New Functions of HI7750 4 V2 J 4 Improvement of Variable Size Memory Pool V 2 01 Release 00 Selecting CFG_NEWMPL added to the configurator allows the following improvements 1 The performace to aquaire and release memory blocks In applications that use a large number of memory blocks the performance to aquaire and release memory blocks are faster than when CFG_NEWMPL is not selected 2 Reduced fragmentation of free space Selecting CFG_NEWMPL generally retards the fragmentation of free memory space but the newly supported VTA_UNFRAGMENT attribute further reduces fragmentation Although specifying the VTA_UNFRAGMENT attribute generally helps in reducing fragmentation the degree of fragmentation depends on how the memory pools are used To support the VTA_UNFRAGMENT attribute the following macro has been added SIZE mplsz VTSZ_MPLMB UINT sctnum Size of the management area for variable size memory pool with attribute
473. x lt 65 gt 6278 8001 Renesas Technology Korea Co Ltd Kukje Center Bldg 18th FI 191 2 ka Hangang ro Yongsan ku Seoul 140 702 Korea Tel lt 82 gt 2 796 3115 Fax lt 82 gt 2 796 2145 Renesas Technology Malaysia Sdn Bhd Unit 906 Block B Menara Amcorp Amcorp Trade Centre No 18 Jalan Persiaran Barat 46050 Petaling Jaya Selangor Darul Ehsan Malaysia Tel lt 603 gt 7955 9390 Fax lt 603 gt 7955 9510 Colophon 5 0 HI7000 4 Series HI7000 4 V 2 02 HI7700 4 V 2 02 and HI7750 4 V 2 02 User s Manual 2CENESAS Renesas Technology Corp 2 6 2 Ote machi Chiyoda ku Tokyo 100 0004 Japan
474. xtended service call routine according to G 4 3 Handling by the Compiler 2 Guarantee FPSCR When the extended service call routine is compiled with fpu mix and fpscr aggressive options the extended service call needs to guarantee FPSCR explicitly Rev 6 00 441 RENESAS REJ10B0060 0600 Appendix G Notes on FPU of SH2A FPU SH 4 SH4A Figure G 3 shows an example of extended service call routine to initialize and guarantee FPSCR register include lt machine h gt Include machine h to use set_fpscr define INI_FPSCR 0x00080000 FR 0 PR 1 DN 0 SZ 0 RM B 00 void ExtendedSVCRoutine VP_INT par1 UW old_fpscr old_fpscr get_fpscer j Save FPSCR set_fpscr INI_FPSCR Initialize FPSCR Extended service call routine processing set_fpscr old_fpscr Restore FPSCR Figure G 3 Example of Extended Service Call Routine to Initialize and Guarantee FPSCR Register G 3 2 Called from Task Context Table G 2 shows the attributes required for the calling task and task exception processing routine Table G 2 Required Attributes TA_COP1 and TA_COP2 for Caller Case SH2A FPU SH 4 SH 4A Matrix calculation both FPU register banks used an TA_COP1 TA_COP2 Normal floating point calculation only FPU registerbankO TA_COP1 TA_COP1 is used No floating point calculation and fpu mix is specified as TA_COP1 Unnecessary compiler option No floating point calculation
475. y operand cache e TC_EXCLUDE_OC H 00000002 Exclude operand cache only instruction cache clradr1 is omitted to the multiple of 32 and clradr2 is revalued to the multiple 1 of 32 1 Clear specified range This service call clears the cache entry whose logical address is from clradr1 to clradr2 If operand cache are contained in target before canceling a dirty entry it is written back to memory This service call repeats and executes the following instructions from clradr1 to clradr2 e mode TC_FULL ICBI and OCBP e mode TC_EXCLUDE_IC OCBI e mode TC_EXCLUDE_OC ICBI This processing is performed in the state of SR BL 0 and SR I 15 However whenever it processes one entry this service call restores SR at the time of this call That is interruption may be accepted by SR at the time of this call Rev 6 00 271 RENESAS REJ10B0060 0600 Section3 Service Calls In this service call only the fundamental error check indicated in the error code column is performed about clradr1 and clradr2 For example the following addresses should not be contained e P2 and P4 areas e Address corresponding to a physical address in the control area e Address corresponding to a physical address in X Y memory The processing time of this service call is proportional to the size of the appointed domain 2 Clear all If 0 is specified to be clradr1 and H ffffffff is specified to be clradr2 all the entries of the target cache det
476. ystem clock is shown as follows Case of CFG_TICNUME CFG_TICDENO lt 1 Maximum value H 7fffffffffff CFG_TICDENO Case of CFG_TICNUME CFG_TICDENO gt 1 Maximum value H 7fffffftffff When the system clock exceeds the above maximum value at timer interrupt isig_tim the system clock is initialized to 0 If a value larger than the above maximum value is specified in the set_tim service call the system operation is not guaranteed Rev 6 00 196 REJ10B0060 0600 RENESAS Section3 Service Calls 3 15 1 Set System Clock set_tim iset_tim C Language API ER ercd set_tim SYSTIM p_systim ER ercd iset_tim SYSTIM p_systim Parameters SYSTIM p_systim R4 Pointer to the packet where the current time data is indicated Return Parameters ER ercd RO Normal end E_OK or error code Packet Structure typedef struct systim UH utime 0 2 Current time data upper UW ltime 4 4 Current time data lower SYSTIM Error Codes E_PAR p Parameter error p_systim is other than a multiple of four Function Each service call changes the current system clock retained in the system to a value specified by p_systim If a value larger than 1 is specified for CFG_TICDENO the denominator for time tick cycles the maximum value that can be specified for tmout is H 7fffffff CFG_TICDENO If a value larger than this is specified operation is not guaranteed For detail of time watch method refer to section 2
477. ze Memory Pool V 2 01 Release 00 0 461 Improvement of Variable Size Memory Pool V 2 01 Release 00 a Macros for Calculating Size V 2 01 Release 00 0 eeseeceeceeseceteeeteeeeeeneeeeeeeeenees Initial Value of SR in Task Exception Processing Routine V 2 01 Release OQ OF Later wc sccceseiessveccsuessessiiccassiecsagnsccsessccassdedserencdedsseasaduestanseevendgsuesdguveciepuesignvtsas 464 Extension of Maximum Exception Code CFG_MAXVCTNO V 2 01 RELEASE QO i riseire sneer stvicccanectesaswceyecadescnssusvededcveernatanebsisacreses Handling of TRAPA 16 to 31 V 2 01 Release 00 Release of Restriction concerning Structure Alignment V 2 01 Release 00 465 ID Name V 2 01 Release 00 Open the file used last time Command for the Configurator V 2 02 Release OO E E AE E T E EAT 465 Rev 6 00 ix RENESAS REJ10B0060 0600 Section 1 Introduction 1 1 Overview Operating systems OSs for system development have grown with the ever increasing use of microcomputer systems in a wide variety of fields In particular realtime OSs have gained wide acceptance for use in industrial measurement and control systems 1 2 Features The HI7000 4 series kernel is based on the uITRON4 0 specifications Features of the kernel are outlined below e Comprehensive functions for realtime and multitasking processing e Priority based task scheduling e Task management including the creation deletion initiation
Download Pdf Manuals
Related Search
Related Contents
Diapositive 1 GRIF 2011 Fault Tree User Manual - GRIF Purgador de Bóia FT 14 The Grill Master - E PD6-N Technical Manual V1.1 Manhattan LCD TV Converter/Tuner Serie HED GBS-8220 CGA to VGA HD-Converter R3 Copyright © All rights reserved.
Failed to retrieve file