Embedded 版 (精华区)
发信人: snows (花自飘零水自流), 信区: Embedded
标 题: The _stext Function
发信站: 哈工大紫丁香 (2004年03月16日13:17:50 星期二), 站内信件
The _stext Function
The function _stext (called _start in some versions) is usually located in
arch/<host>/kernel/head.S.
_Stext sets the initial stack pointer and performs any other functions
necessary to create a minimal C runtime environment, like clearing the BSS
memory section. _Stext then jumps to start_kernel().
Figure 4 shows part of the code for the Hitachi SH version of _stext.
ENTRY(_stext)
! Initialize Status Register
mov.l 1f, r0 ! MD=1, RB=0, BL=0, IMASK=0xF
ldc r0, sr
! Initialize global interrupt mask
mov #0, r0
ldc r0, r6_bank
!
mov.l 2f, r0
mov r0, r15 ! Set initial r15 (stack pointer)
mov #0x20, r1 !
shll8 r1 ! r1 = 8192
sub r1, r0
ldc r0, r7_bank ! ... and init_task
! Initialize fpu
mov.l 7f, r0
jsr @r0
nop
! Enable cache
mov.l 6f, r0
jsr @r0
nop
! Clear BSS area
mov.l 3f, r1
add #4, r1
mov.l 4f, r2
mov #0, r0
mov #0, r0
9: cmp/hs r2, r1
bf/s 9b ! while (r1 < r2)
mov.l r0,@-r2
! Start kernel
mov.l 5f, r0
jmp @r0
nop
.balign 4
1: .long 0x400000F0 ! MD=1, RB=0, BL=0, FD=0, IMASK=0xF
2: .long SYMBOL_NAME(stack)
3: .long SYMBOL_NAME(__bss_start)
4: .long SYMBOL_NAME(_end)
5: .long SYMBOL_NAME(start_kernel)
6: .long SYMBOL_NAME(cache_init)
7: .long SYMBOL_NAME(fpu_init)
Figure 4. The Hitachi SH's _stext function.
--
-
╭────────────────────────────╮
│ 风萧传瑟声,叶落根深处,青阶入野无归途,他乡不知顾 │
│ 泣下问和谁,叹者行已暮,寒眉傲骨今尚在,奈何入凡土 │
╰────────────────────────────╯
※ 来源:·哈工大紫丁香 bbs.hit.edu.cn·[FROM: 202.118.229.154]
Powered by KBS BBS 2.0 (http://dev.kcn.cn)
页面执行时间:3.443毫秒