📄 start.s
字号:
/*
* The above copyright holder, limited to cases in which one satisfies
* conditions (1) ~ (4) below, or the conditions described in Version 2
* of of the GNU Public License officially announced by the Free Software
* Foundation, consents to the use, reproduction, alteration, and
* redistribution (hereafter called utilization) of this software (this
* software includes alterations, likewise below) without compensation.
*
* (1) When this software is utilized in the form of source code, the
* above copyright declaration, these conditions of utilization, and the
* following stipulation of no guarantee shall be included in unchanged
* form inside the source code.
* (2) When this software is redistributed in a form in which it can be
* used in the development of other software, library form, etc., the above
* copyright display, these terms of utilization, and the following
* stipulation of no guarantee shall be inserted in documentation accompanying
* redistribution (user's manual, etc.).
* (3) When this software is redistributed in a form in which it cannot be used
* in the development of other software, embedded in devices, etc., one of the
* following conditions shall be satisfied.
* (a) The above copyright display, these terms of utilization, and the
* following stipulation of no guarantee shall be inserted in documentation
* accompanying redistribution (user's manual, etc.).
* (b) The TOPPERS Project shall be notified owing to a method in which the
* form of distribution is decided otherwise.
* (4) The above copyright holder and the TOPPERS Project shall be exempt
* from responsibility for whatever damages occur either directly or indirectly
* through the utilization of this software.
*
* This software is something that is provided with no guarantee. The above copyright
* holder and the TOPPERS Project make no guarantee whatsoever in regard to this
* software, including the possibility of its application. In addition, the above
* copyright holder and the TOPPERS Project shall also not bear responsibility for
* whatever damages occur either directly or indirectly through the utilization of
* this software.*
* @(#) $Id: start.S,v 1.3 2006/08/10 08:11:37 0684248 Exp $
*/
/*
* startup module used for kernel(for ARMv4)
*/
#define _MACRO_ONLY
#include <armv4.h>
#include <sys_defs.h>
#include <t_config.h>
/*
* The total size of Vector table and jump table
* is 0x3c
*/
.section .vector,"a"
.code 32
.align 4
.global vector_table
vector_table:
ldr pc, reset_vector /* Reset */
ldr pc, undef_vector /* undefined command */
ldr pc, swi_vector /* software interrupt */
ldr pc, prefech_vector /* Prefech aboard */
ldr pc, data_abort_vector /* Data aboard */
ldr pc, reset_vector
ldr pc, irq_vector /* IRQ */
ldr pc, fiq_vector /* IRQ */
/*
* Vector table
*/
reset_vector:
.long start
undef_vector:
.long undef_exception
swi_vector:
.long swi_exception
prefech_vector:
.long prefetch_exception
data_abort_vector:
.long data_abort_exception
irq_vector:
/* .long irq_exception */
.long IRQ_Handler
fiq_vector:
.long fiq_exception
.section .init
.code 32
.align 4
.global start
start:
mov r1, #(CPSR_SVC|CPSR_FIQ_BIT|CPSR_IRQ_BIT) /* To System mode */
msr cpsr, r1
/*
* Initialize the stack pointer and frame pointer
* Is it necessary to set the SL(stack upper boundary limitation register r10)?
* gcc is -mapcs by default, so it is unnecessary
*/
ldr r3, =STACKTOP
mov sp, r3
mov r11, #0 /* Frame pointer used for Arm mode */
mov r7, #0 /* Frame pointer used for Thubm mode */
/*
* Call hardware_init_hook (When it is not 0)
*
* When there is necessary to do the essential initialzation that dependent
* on the target hardwre ,the function named hardware_init_hook is prepared.
*/
ldr r0, =hardware_init_hook
cmp r0, #0x00
blne hardware_init_hook
#if ROMRAM_MODE
/*
* The program is copied to RAM.
*/
start_codeCopy: /* add by M.Kawashima */
ldr r1, =__rocode_start
ldr r3, =__rocode_end
cmp r1, r3
bhs start_1
ldr r2, =__text
start_codeCopy2:
ldr r0, [r1],#4
str r0, [r2],#4
cmp r1, r3
blo start_codeCopy2
/*
* The program is copied to RAM.
*/
start_constCopy: /* add by M.Kawashima */
ldr r1, =__rodata_start
ldr r3, =__rodata_end
cmp r1, r3
bhs start_1
ldr r2, =__rodata
start_constCopy2:
ldr r0, [r1],#4
str r0, [r2],#4
cmp r1, r3
blo start_constCopy2
#endif
/*
* Clear the bss section
*/
start_1:
ldr r1, =__bss_start
ldr r2, =__bss_end
cmp r1,r2
bhs start_3
mov r0,#0
start_2:
str r0,[r1],#4
cmp r1, r2
blo start_2
/*
* initialize the data section (For making to ROM)
* From __idata_start to __idata_end , Copy the part ag\fter __data_start
*/
start_3:
#if 1
ldr r1, =__idata_start
ldr r3, =__idata_end
cmp r1, r3
bhs start_5
ldr r2, =__data_start
start_4:
ldr r0, [r1],#4
str r0, [r2],#4
cmp r1, r3
blo start_4
#endif
/*
* Call software_init_hook (When it is not 0 )
*
* When there is necessary to process the initialization that depends on the
* software environment ( especially for library) the function named software_init_hook is prepared.
*/
start_5:
ldr r0, =software_init_hook
cmp r0, #0x00
blne software_init_hook
start_6:
ldr r0, kernel_addr
mov pc, r0
kernel_addr:
.long kernel_start
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -