TQ2440 startup code analysis (Part 3)

Publisher:骄阳少年Latest update time:2016-04-26 Source: eefocusKeywords:TQ2440 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
The entry address must be specified in the initialization program, because after the processor is reset (when emulating, loading the image), the PC must find the entry to start executing the code. When various exceptions or interrupts occur, the entry of each exception must also be found to start executing the code.

From here on is the real code entry!

 

The AREA directive is used to define a code segment or a data segment. The ARM assembler is designed in a segmented manner. An
ARM source program requires at least one code segment. A large program can contain as many code segments and data segments as desired.

CODE   is the definition code segment. The default attribute is READONLY;

READONLY  specifies that this section is read-only. The default attribute of the code section is READONLY.

;================================================== =========

;After the board is powered on and reset, the program starts to execute from 0x0. After the hardware is powered on and reset, the program starts to execute from here and jumps to the ResetHandler.

;DCD is used to allocate a single word memory chip and initialize it with the following pseudo instruction. The allocated bytes are determined by the number of expr

 

      AREA    Init,CODE,READONLY; declare a code segment named Init, ;Init initialization program

      ENTRY   program entry point, (for debugging)

      ;ENTRY is just a common entry point, and it can be defined in multiple places in the program.

The only entry point for an image file also requires setting relevant options in the linker.

      EXPORT __ENTRY

__ENTRY

ResetEntry  ;Entry after reset

      ;1)The code, which converts to Big-endian, should be in little endian code.

      ;2)The following little endian code will be compiled in Big-Endian mode.

      The code byte order should be changed as the memory bus width.

      ;3)The pseudo instruction,DCD can not be used here because the linker generates error.

      ASSERT :DEF:ENDIAN_CHANGE  

;ASSERT assertion error pseudo instruction, here indicates whether ENDIAN_CHANGE has been defined

      [ ENDIAN_CHANGE  ; If ENDIAN_CHANGE is defined

             ASSERT  :DEF:ENTRY_BUS_WIDTH  ; This indicates whether ENTRY_BUS_WIDTH has been defined

; If ENTRY_BUS_WIDTH is not defined, an error will be reported

             [ ENTRY_BUS_WIDTH=32   ;if  ENTRY_BUS_WIDTH=32

                       ChangeBigEndian     ; Jump to ChangeBigEndian (see the red code below), execute DCD 0xea000007 to change the big-endian and small-endian data modes

             ;end  if

 

             [ ENTRY_BUS_WIDTH=16  ;if ENTRY_BUS_WIDTH=16

                    andeq      r14,r7,r0,lsl #20   ;When the Z bit of the flag status register CPSR = 1, r14 = r7 + r0 logically shifts left by 20 bits, and executes DCD 0x0007ea00 to change the big-endian mode

             ] ;end if

 

             [ ENTRY_BUS_WIDTH=8  ;if  ENTRY_BUS_WIDTH=8

                    streq       r0,[r0,-r10,ror #1] ; When the Z bit of the flag status register CPSR = 1..., execute DCD 0x070000ea to change the big-endian mode

             ]

             ;ELSE if ENDIAN_CHANGE is not defined

                ResetHandler; reset abnormality, the development board enters 0x00 when powered on or reset

      ]

The interrupt vector table is generally located at the beginning of the startup code. It is between the user program and the startup code and between the startup code

It is a link between the various parts of the system. It consists of jump functions one by one, and it is like an ordinary jump function, except that

However, the process of scattering involves hardware mechanisms. When an exception occurs in the system, the ARM processor will force

The PC pointer points to the address of the corresponding exception jump function in the interrupt vector table, and then the program will jump to the corresponding

The service program is interrupted to execute.

   HandlerUndef ;handler for Undefined mode Undefined exception, 0x04 when encountering an unrecognizable instruction

   HandlerSWI   ;handler for SWI interrupt, soft interrupt exception 0x08 

   HandlerPabort ;handler for PAbort instruction prefetch error enters 0x0c  processing termination program access termination mode

   HandlerDabort       ;handler for DAbort enters 0x10  processing data access termination mode when data access cannot be completed

              ;reserved, reserved 0x14  "." represents the address of the instruction, which means an infinite loop

   HandlerIRQ    ;handler for IRQ interrupt When an IRQ interrupt occurs, enter 0x18

   HandlerFIQ    ;handler for FIQ interrupt When a FIQ interrupt occurs, enter 0x1c

 

;@0x20 "@" Current value of the storage location counter

   EnterPWDN   ; Must be @0x20.

158 ;================================================ ===============

159; The following is a program to change the big and small endianness. Here we use the method of directly defining the machine code. As for why we do this

160; You have to ask Samsung. Anyway, this code will not be executed in our program, so don't worry about it.

161 ;================================================ ===============

ChangeBigEndian  ; Change the big-endian and small-endian data modes

;@0x24

      [ENTRY_BUS_WIDTH=32

DCD is used to allocate a word memory unit and initialize it with expr in the pseudo instruction. The memory allocated by the DCD pseudo instruction
needs to be word aligned and can generally be used to define data tables or other constants. & is synonymous with DCD.

             DCD       0xee110f10     ;0xee110f10 => mrc p15,0,r0,c1,c0,0

             DCD       0xe3800080    ;0xe3800080 => orr r0,r0,#0x80;  //Big-endian

             DCD       0xee010f10     ;0xee010f10 => mcr p15,0,r0,c1,c0,0

      ]

      [ENTRY_BUS_WIDTH=16

             DCD 0x0f10ee11

             DCD 0x0080e380

             DCD 0x0f10ee01

      ]

      [ENTRY_BUS_WIDTH=8

             DCD 0x100f11ee

             DCD 0x800080e3

             DCD 0x100f01ee

      ]

      DCD 0xffffffff  ;swinv 0xffffff is similar with NOP and run well in both endian mode.

      DCD 0xffffffff

      DCD 0xffffffff

      DCD 0xffffffff

      DCD 0xffffffff

      b ResetHandler  ; Reset handler

 

; Enter power-down mode function

; 1. SDRAM must be in self-refresh mode.

; 2. All interrupts must be masked for SDRAM/DRAM self-refresh.

; 3. LCD off for SDRAM/DRAM self-refresh.

; 4. The I-cache may need to be enabled.

; 5. The location of the following code may have not to be changed.

 

; As mentioned above, the HANDLER macro is used here to establish the connection between Hander*** and Handle***

HandlerFIQ    HANDLER HandleFIQ     ;HandlerIRQ Line number    HANDLER Macro name  HandleIRQ Imported parameters

HandlerIRQ   HANDLER HandleIRQ

HandlerUndef HANDLER HandleUndef

HandlerSWI   HANDLER HandleSWI

HandlerDabort       HANDLER HandleDabort

HandlerPabort HANDLER HandlePabort

Keywords:TQ2440 Reference address:TQ2440 startup code analysis (Part 3)

Previous article:ARM (920T) exception and interrupt mapping process
Next article:The difference between Cortex-A8 and ARM11

Recommended ReadingLatest update time:2024-11-16 03:27

TQ2440 Naked running - running water light
I still remember that when I first came into contact with the microcontroller, I couldn't wait to play with the board. The first program to light up the LED light left a deep impression on me. After lighting it up, I made a running light. The same is true for ARM9. The first thing to run naked must be the LED light. Th
[Microcontroller]
TQ2440 Study Notes - 2. Network settings for pinging between Win7PC and virtual machine Ubuntu
I have studied for a long time how to ping Win7PC with the Ubuntu operating system in the virtual machine. I also referred to some information on the Internet. I always forget the configuration and it is very troublesome to do it again. Now I record it: Computer Configuration: Win7 64-bit operating system Virtua
[Microcontroller]
TQ2440 Study Notes - 2. Network settings for pinging between Win7PC and virtual machine Ubuntu
TQ2440 uboot---2.U_BOOT_CMD analysis
start_armboot { } main_loop { 1. Environment variable mtdparts, call mtdparts_init 2. If the space bar is not pressed during the boot process, boot_zImage If the space bar is pressed, run_command("menu",0) 3. Shell process, reads user input and executes corresponding commands { Get the command from the input end and s
[Microcontroller]
Porting u-boot 1.1.6 to TQ2440 development board - Phase 1
I recently bought a TQ2440 development board, but Tianqian only provided the compiled files, not the source code, so I transplanted Uboot from scratch.   Porting u-boot 1.1.6 to TQ2440 development board - Phase 1 Mainly modify, configure source code, compile source code   TQ2440 development board information:
[Microcontroller]
Linux-2.6.30.4 kernel transplantation based on TQ2440
Migration environment CPU:S3C2440 Cross compiler: arm-linux-gcc-4.3.3 Virtual machine system: Ubuntu12.04 Reference: "Tianqian Technology Linux Porting Manual" Transplantation steps 1. Get the kernel source code Website: http://ftp.sjtu.edu.cn/sites/ftp.kernel.org/pub/linux/kernel/ Find the linux-2.6.30.4 compressed
[Microcontroller]
Linux-2.6.30.4 kernel transplantation based on TQ2440
Transplantation of u-boot-2015.04 on tq2440 (use spl to boot u-boot)
The difference between this transplant and the previous one is that spl is used to guide u-boot. Please refer to the blog http://blog.csdn.net/fulinus/article/details/42738641 Download link: http://pan.baidu.com/s/1bnlRKgn   Instructions: 1. Compile   make tq2440_defconfig   make 2. Then u-boot.bin will be generated
[Microcontroller]
Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号