Thông tin tài liệu:
Real-Time Embedded Multithreading Using ThreadX and MIPS- P4:Although the history of embedded systems is relatively short, 1 the advances andsuccesses of this fi eld have been profound. Embedded systems are found in a vast array ofapplications such as consumer electronics, “ smart ” devices, communication equipment,automobiles, desktop computers, and medical equipment.
Nội dung trích xuất từ tài liệu:
Real-Time Embedded Multithreading Using ThreadX and MIPS- P4 MIPS Exception Handling 57 .text .globl _reset_vector # Address 0xBFC00000 _reset_vector: mfc0 $8, $12 li $9, 0xFFBFFFFF # Build mask to clear BEV bit and $8, $8, $9 # Clear BEV bit mtc0 $8, $12 # Use normal vector area lui $8, %hi(__start) # Build address of _start routine addi $8, $8, %lo(__start) # j $8 # Jump to _start nop .text .globl _tx_exception_vector _tx_exception_vector: # Address 0x80000180 la $26,_tx_exception_handler # Pickup exception handler address j $26 # Jump to exception handler nop # Delay slot Figure 6.2: ThreadX vector area There are several different ways to initialize the exception vector. You can set it up by loading it directly to address 0x80000180 with a JTAG debug device. Alternatively, your system may copy the exception vector to address 0x80000180 during initialization. The exception vector handler is typically located in the ThreadX low-level initialization file tx_initialize_low_level.S and may be modified according to application needs. For example, in many applications, the reset vector will actually point to some low-level application code that is responsible for preparing the hardware memory for execution. This code can also copy itself from flash memory to RAM if that is necessary for the application. Note that ThreadX can execute in place out of flash memory or in RAM. Once finished, the application low-level code must jump to the same location specified in the original reset vector. For example, suppose a low-level initialization routine called my_low_level_init is required to execute before anything else in the system. The application would have to change the reset vector to point to the routine in Figure 6.3. w w w.ne w nespress.comPlease purchase PDF Split-Merge on www.verypdf.com to remove this watermark. 58 Chapter 6 .globl _reset_vector # Address 0xBFC00000 _reset_vector: mfc0 $8, $12 # Pickup SR li $9, 0xFFBFFFFF # Build mask to clear BEV bit and $8, $8, $9 # Clear BEV bit mtc0 $8, $12 # Use normal vector area lui $8, %hi(__my_low_level_init) # Build address of my init routine addi $8, $8, %lo(__my_low_level_init) j $8 # Jump to _start nop Figure 6.3: Changing the reset vector .globl my_low_level_init _my_low_level_init # Build address of _start lui $8, %hi(__start) routine addi $8, $8, %lo(__start) # j $8 # Jump to _start nop Figure 6.4: ThreadX low-level initialization At the end of my_low_level_init, the code would have to branch (jump) to call the original compiler startup code, as illustrated in Figure 6.4. 6.2.1.1 Compiler Initialization Shortly after the MIPS processor executes the reset vector, the system executes the C compiler’s initialization code. In this example, the name of the compiler’s entry point is __start. The C compiler initialization is responsible for setting up all application data areas, including initialized and uninitialized global C variables. The C run-time library is also set up here, including the traditional heap memory area. If some of the application code was written in C , the initialization code instantiates all global C objects. Once the run- time environment is completely set up, the code calls the application’s “ma ...