CHAPTER 14 SYSTEM INITIALIZATION ROUTINE
The system initialization routine of the RI850V4 provides system initialization processing, which is required from the reset interrupt output until control is passed to the task.
The following shows a processing flow from when a reset interrupt occurs until the control is passed to the task.
To support various execution environments, the RI850V4 extracts from the system initialization processing the hardware-dependent processing (Boot processing) that is required to execute processing, as a user-own coding module. This enhances portability for various execution environments and facilitates customization as well.
This is a routine dedicated to initialization processing that is extracted as a user-own coding module to initialize the minimum required hardware for the RI850V4 to perform processing, and is called from Initialization routine.
- Basic form of boot processing
Code boot processing by using the void type function that has no arguments.
The following shows the basic form of boot processing in assembly.
Code boot processing by using the void type function that has no arguments.
The following shows the basic form of boot processing in assembly.
.public __boot .text .cseg text __boot : ......... mov #__kernel_start, r11 /*Jump to Kernel Initialization Module*/ jarl [r11], lp |
- Internal processing of boot processing
Boot processing is a routine dedicated to initialization processing that is called from Initialization routine, without RI850V4 intervention.
Therefore, note the following points when coding boot processing.
Boot processing is a routine dedicated to initialization processing that is called from Initialization routine, without RI850V4 intervention.
Therefore, note the following points when coding boot processing.
- Coding method
Code boot processing using C or assembly language.
When coding in C, they can be coded in the same manner as ordinary functions coded.
When coding in assembly language, code them according to the calling rules prescribed in the compiler used.
Code boot processing using C or assembly language.
When coding in C, they can be coded in the same manner as ordinary functions coded.
When coding in assembly language, code them according to the calling rules prescribed in the compiler used.
- Stack switching
Setting of stack pointer SP is not executed at the point when control is passed to boot processing.
To use a boot processing dedicated stack, setting of stack pointer SP must therefore be coded at the beginning of the boot processing.
Setting of stack pointer SP is not executed at the point when control is passed to boot processing.
To use a boot processing dedicated stack, setting of stack pointer SP must therefore be coded at the beginning of the boot processing.
- Service call issue
Execution of the Kernel Initialization Module is not performed when boot processing is started. issue of service calls is therefore prohibited during boot processing.
Execution of the Kernel Initialization Module is not performed when boot processing is started. issue of service calls is therefore prohibited during boot processing.
10 ) Initialization of Internal unit of CPU (such as the OS timer) and peripheral controllers (For initialization of the OS timer, see "9.2.1 Base clock timer interrupt".
11 ) Setting of the priority for the floating-point operation exception (only for the device incorporating the FPU)
Note 1 When initializing the interrupt configuration register (INTCFG), clear the ISPC bit to 0 to automatically update the ISPR value.
Note 2 If global pointer GP is modified outside the boot processing, correct operation is not guaranteed afterwards.
Note 3 When modifying element pointer EP in a processing program (such as a task or a cyclic handler), compiler option -Xep = callee must be specified (Property panel -> [Common Options] tabbed page -> [Register Mode] category -> [ep-register treatment] must be set to "Treat as callee-save").
Note 4 Setting of stack pointer sp is required only when the dedicated boot processing stack is used.
- CC-RH compiler
Use the RAM section area initialization function _INITSCT_RH in the CC-RH compiler to simplify the initialization code.
The following shows an example of assembly-language code for initializing ".kernel_data_init" section.
Use the RAM section area initialization function _INITSCT_RH in the CC-RH compiler to simplify the initialization code.
The following shows an example of assembly-language code for initializing ".kernel_data_init" section.
.section ".INIT_BSEC.const", const .align 0x4 .dw #__s.kernel_data_init, #__e.kernel_data_init mov r0, r6 mov r0, r7 mov #__s.INIT_BSEC.const, r8 mov #__e.INIT_BSEC.const, r9 jarl __INITSCT_RH, lp |
- CCV850 compiler
First, define ".kernel_data_init" section (where the kernel initialization flag is allocated) with the CLEAR section attribute added in the link directive file so that the section is initialized in the boot processing.
The following shows a sample code in the link directive file.
Withthis definition, the ".kernel_data_init" section information is included in the runtime clear tables (__ghsbinfo_clear and __ghseinfo_clear) generated by the CCV850 compiler. The following shows a sample code for initializing the section area included in the runtime clear tables.
First, define ".kernel_data_init" section (where the kernel initialization flag is allocated) with the CLEAR section attribute added in the link directive file so that the section is initialized in the boot processing.
The following shows a sample code in the link directive file.
Withthis definition, the ".kernel_data_init" section information is included in the runtime clear tables (__ghsbinfo_clear and __ghseinfo_clear) generated by the CCV850 compiler. The following shows a sample code for initializing the section area included in the runtime clear tables.
Note 6 Manipulate within the Initialization routine the RINT bit in the reset vector base address (RBASE) and the RINT bit in the exception handler vector address (EBASE) to specify whether operation should be done in the reduced mode, which is necessary when using an entry file in the direct vector method.
Note 7 Manipulate within the Initialization routine the MKn bits (or EIMKn bits) in the EI level interrupt mask register (IMRm) to enable acceptance of EI level maskable interrupts.
Note 8 Set the priority of the floating-point operation exception to a higher value than the maximum priority of interrupts managed by the kernel.
System-dependent information is a header file (file name: userown.h) including various information that is required for the RI850V4, which is extracted as a user-own coding module.
- Basic form of system-dependent information
When coding system-dependent information, use a specified file name (userown.h) and specified macro names (KERNEL_USR_TMCNTREG and KERNEL_USR_BASETIME).
The following shows the basic form of system-dependent information in the C language.
When coding system-dependent information, use a specified file name (userown.h) and specified macro names (KERNEL_USR_TMCNTREG and KERNEL_USR_BASETIME).
The following shows the basic form of system-dependent information in the C language.
#include <kernel_id.h> /*System information header file definition*/ #define KERNEL_USR_TMCNTREG 0xffec0004 /*I/O address*/ #define KERNEL_USR_BASETIME 250 /*time for one count (4MHz -> 250ns)*/ |
- Definition of the system information header file
Include the system information header file output as a result of execution of the configurator for the system configuration file.
Include the system information header file output as a result of execution of the configurator for the system configuration file.
Note This information is necessary only when "Taking in long-statistics by software trace mode" is selected in the Property panel -> [Task Analyzer] tabbed page -> [Trace] category -> [Selection of trace mode].
- Basic clock timer information
Define as macros the I/O address (register base address + 0x4) for the counter register (OSTMn) and the time (in nanoseconds) for one count in the OS timer calculated according to the frequency of the OS timer operation.
Define as macros the I/O address (register base address + 0x4) for the counter register (OSTMn) and the time (in nanoseconds) for one count in the OS timer calculated according to the frequency of the OS timer operation.
Note This information is necessary only when "Taking in trace chart by software trace mode" or "Taking in long-statistics by software trace mode" is selected in the Property panel -> [Task Analyzer] tabbed page -> [Trace] category -> [Selection of trace mode].
The kernel initialization module is a dedicated initialization processing routine provided for initializing the minimum required software for the RI850V4 to perform processing, and is called from Boot processing.
- Initializing management objects
Initializes the objects defined in the system configuration file (such as tasks and semaphores).
Initializes the objects defined in the system configuration file (such as tasks and semaphores).
- Initializing the system time
Initializes the system time (to 0), which is updated in units of the Base clock interval: tim_base when an EI level maskable interrupt defined in the Base clock timer exception code: tim_intno occurs.
Initializes the system time (to 0), which is updated in units of the Base clock interval: tim_base when an EI level maskable interrupt defined in the Base clock timer exception code: tim_intno occurs.
- Activating tasks
Moves the tasks whose Attribute: tskatr (such as coding language and initial activation state) is defined as TA_ACT from the DORMANT state to the READY state.
Moves the tasks whose Attribute: tskatr (such as coding language and initial activation state) is defined as TA_ACT from the DORMANT state to the READY state.
- Starting cyclic handlers
Moves the cyclic handlers whose Attribute: cycatr (such as coding language and initial activation state) is defined as TA_STA from the non-operational state (STP state) to the operational state (STA state).
Moves the cyclic handlers whose Attribute: cycatr (such as coding language and initial activation state) is defined as TA_STA from the non-operational state (STP state) to the operational state (STA state).
- Calling initialization routines
Calls the initialization routines defined in the Initialization routine information in the order of definitions in the system configuration file.
Calls the initialization routines defined in the Initialization routine information in the order of definitions in the system configuration file.