當前位置:首頁 > 芯聞號 > 充電吧
[導讀]程序從start。S開始啟動start_code:?/*? * set the cpu to SVC32 mode? 設(shè)置管理模式? */?mrs?r0, cpsr??????? ?bic?r0, r

程序從start。S開始啟動

start_code:
?/*
? * set the cpu to SVC32 mode? 設(shè)置管理模式
? */
?mrs?r0, cpsr???????
?bic?r0, r0, #0x1f??????
?orr?r0, r0, #0xd3
?msr?cpsr, r0

#ifdef CONFIG_S3C24X0
?/* turn off the watchdog */

/*關(guān)看門狗 關(guān)中斷*/

# if defined(CONFIG_S3C2400)
#? define pWTCON?0x15300000
#? define INTMSK?0x14400008?/* Interupt-Controller base addresses */
#? define CLKDIVN?0x14800014?/* clock divisor register */
#else
#? define pWTCON?0x53000000
#? define INTMSK?0x4A000008?/* Interupt-Controller base addresses */
#? define INTSUBMSK?0x4A00001C
#? define CLKDIVN?0x4C000014?/* clock divisor register */
# endif

?ldr?r0, =pWTCON
?mov?r1, #0x0
?str?r1, [r0]

?/*
? * mask all IRQs by setting all bits in the INTMR - default
? */
?mov?r1, #0xffffffff
?ldr?r0, =INTMSK
?str?r1, [r0]
# if defined(CONFIG_S3C2410)??? //shut up all interrupt
?ldr?r1, =0x3ff
?ldr?r0, =INTSUBMSK
?str?r1, [r0]
# endif

?/* FCLK:HCLK:PCLK = 1:2:4 */
?/* default FCLK is 120 MHz ! */
?ldr?r0, =CLKDIVN
?mov?r1, #3
?str?r1, [r0]
#endif?/* CONFIG_S3C24X0 */

#ifndef CONFIG_SKIP_LOWLEVEL_INIT
?bl?cpu_init_crit????????? #跳轉(zhuǎn)到cpu_init_crit處 對CPU的cashe mmu進行初始化 關(guān)閉
#endif

#ifndef CONFIG_SKIP_RELOCATE_UBOOT
relocate:????/* relocate U-Boot to RAM???? */#加載uboot到RAM對于nor flash 啟動boot//本可以直接運行但是效率低所以加載到RAM中運行
?adr?r0, _start??/* r0 <- current position of code?? */?? #加載運行起始地址到r0? 如果從nor flash啟動 這里為0x0
?ldr?r1, _TEXT_BASE??/* test if we run from flash or RAM */ #加載_TEXT_BASE到r1 _TEXT_BASE位于SDRAM中??默認為0x33f80000
?cmp?r0, r1???/* don't reloc during debug???????? */????? #比較r0 與 r1 即判斷程序是從flash啟動還是從RAM啟動
?beq?stack_setup?? /*如果r0 == r1 就跳轉(zhuǎn)到stack_up*/???????? #如果相等 表示從RAM啟動 那么下面的代碼搬運到RAM步驟就沒比要了 直接跳到stack_setup運行

?ldr?r2, _armboot_start?????????? #代碼搬運
?ldr?r3, _bss_start?????? /*U-boot.lds中定義 uboot代碼的結(jié)束地址*/
?sub?r2, r3, r2??/* r2 <- size of armboot??????????? */?? #得到代碼長度
?add?r2, r0, r2??/* r2 <- source end address???????? */? #r2中存放uboot結(jié)束代碼地址

copy_loop:???????????????????? /*將數(shù)據(jù)從norflash搬到SDRAM r0為_start程序開始地址r1為_TEXT_BASE屬于SDRAM中的地址0x33f80000 所以我們的uboot 512KB*/
?ldmia?r0!, {r3-r10}??/* copy from source address [r0]??? */? #從起始地址開始搬_start
?stmia?r1!, {r3-r10}??/* copy to?? target address [r1]??? */????? #搬到目的地址 從_TEXT_BASE開始
?cmp?r0, r2???/* until source end addreee [r2]??? */???????????? #判斷是否搬完 即r0中的值是否==上面r2中值
?ble?copy_loop
#endif?/* CONFIG_SKIP_RELOCATE_UBOOT */

?/* Set up the stack????????? */
stack_setup:??????????????????????????????????????????????????? #搬完了后設(shè)置棧? 前面說的判斷程序啟動地址 如果從RAM啟動 則直接來設(shè)置棧,有棧了后才能使用c語言。。。
?ldr?r0, _TEXT_BASE??/* upper 128 KiB: relocated uboot?? */?? #棧為向下生長 在確定棧指針sp之前? 先留出部分空間?放下面的內(nèi)容
?sub?r0, r0, #CONFIG_SYS_MALLOC_LEN?/* malloc area????????????? */??? #1? 一段長度放置malloc段
?sub?r0, r0, #CONFIG_SYS_GBL_DATA_SIZE /* bdinfo???????????????? */????? #2? 一段長度放置GBL段
#ifdef CONFIG_USE_IRQ
?sub?r0, r0, #(CONFIG_STACKSIZE_IRQ+CONFIG_STACKSIZE_FIQ)?? #3 還要留一段長度放置IRQ FIQ中斷狀態(tài)保存段
#endif
?sub?sp, r0, #12??/* leave 3 words for abort-stack??? */
?bic?sp, sp, #7??/* 8-byte alignment for ABI compliance */??????????????? #接下來就是sp指針的位置了

clear_bss:?????????????????????????????????????????????????????????????????????????????????????????????? #做完了后在開始跳到uboot第二階段的C代碼前?清BSS段 這里放了一些初始化為0的或者沒有初始化的全局?#????? 變????????? 量??? 局部變量? 可以先清掉 在當要調(diào)用的時候再賦值
?ldr?r0, _bss_start??/* find start of bss segment??????? */
?ldr?r1, _bss_end??/* stop here??????????????????????? */
?mov?r2, #0x00000000??/* clear??????????????????????????? */???? #全部清空

clbss_l:str?r2, [r0]??/* clear loop...??????????????????? */
?add?r0, r0, #4
?cmp?r0, r1
?ble?clbss_l

?ldr?pc, _start_armboot???????????????????????????????????????? #將指針指向_start_armboot? 這里為第二階段C函數(shù)的入口了

_start_armboot:?.word start_armboot

?

void start_armboot (void)
{
?init_fnc_t **init_fnc_ptr;
?char *s;
#if defined(CONFIG_VFD) || defined(CONFIG_LCD)
?unsigned long addr;
#endif

?/* Pointer is writable since we allocated a register for it */
?gd = (gd_t*)(_armboot_start - CONFIG_SYS_MALLOC_LEN - sizeof(gd_t));
?/* compiler optimization barrier needed for GCC >= 3.4 */
?__asm__ __volatile__("": : :"memory");

?memset ((void*)gd, 0, sizeof (gd_t));
?gd->bd = (bd_t*)((char*)gd - sizeof(bd_t));
?memset (gd->bd, 0, sizeof (bd_t));

?gd->flags |= GD_FLG_RELOC;

?monitor_flash_len = _bss_start - _armboot_start;

?for (init_fnc_ptr = init_sequence; *init_fnc_ptr; ++init_fnc_ptr) {??????????????????????? //這里為調(diào)用一系列初始化函數(shù)? 具體見uboot源碼,就是初始化各個外設(shè)模塊 串口啊 GPIO USB
??if ((*init_fnc_ptr)() != 0) {
???hang ();
??}
?}

?/* armboot_start is defined in the board-specific linker script */
?mem_malloc_init (_armboot_start - CONFIG_SYS_MALLOC_LEN,
???CONFIG_SYS_MALLOC_LEN);

#ifndef CONFIG_SYS_NO_FLASH
?/* configure available FLASH banks */
?display_flash_config (flash_init ());
#endif /* CONFIG_SYS_NO_FLASH */

#ifdef CONFIG_VFD
#?ifndef PAGE_SIZE
#?? define PAGE_SIZE 4096
#?endif
?/*
? * reserve memory for VFD display (always full pages)
? */
?/* bss_end is defined in the board-specific linker script */
?addr = (_bss_end + (PAGE_SIZE - 1)) & ~(PAGE_SIZE - 1);
?vfd_setmem (addr);
?gd->fb_base = addr;
#endif /* CONFIG_VFD */

#ifdef CONFIG_LCD
?/* board init may have inited fb_base */
?if (!gd->fb_base) {
#??ifndef PAGE_SIZE
#??? define PAGE_SIZE 4096
#??endif
??/*
?? * reserve memory for LCD display (always full pages)
?? */
??/* bss_end is defined in the board-specific linker script */
??addr = (_bss_end + (PAGE_SIZE - 1)) & ~(PAGE_SIZE - 1);
??lcd_setmem (addr);
??gd->fb_base = addr;
?}
#endif /* CONFIG_LCD */

#if defined(CONFIG_CMD_NAND)
?puts ("NAND:? ");
?nand_init();??/* go init the NAND */
#endif

#if defined(CONFIG_CMD_ONENAND)
?onenand_init();
#endif

#ifdef CONFIG_HAS_DATAFLASH
?AT91F_DataflashInit();
?dataflash_print_info();
#endif

?/* initialize environment */
?env_relocate ();

#ifdef CONFIG_VFD
?/* must do this after the framebuffer is allocated */
?drv_vfd_init();
#endif /* CONFIG_VFD */

#ifdef CONFIG_SERIAL_MULTI
?serial_initialize();
#endif

?/* IP Address */
?gd->bd->bi_ip_addr = getenv_IPaddr ("ipaddr");

?stdio_init ();?/* get the devices list going. */

?jumptable_init ();

#if defined(CONFIG_API)
?/* Initialize API */
?api_init ();
#endif

?console_init_r ();?/* fully init console as a device */

#if defined(CONFIG_ARCH_MISC_INIT)
?/* miscellaneous arch dependent initialisations */
?arch_misc_init ();
#endif
#if defined(CONFIG_MISC_INIT_R)
?/* miscellaneous platform dependent initialisations */
?misc_init_r ();
#endif

?/* enable exceptions */
?enable_interrupts ();

?/* Perform network card initialisation if necessary */
#ifdef CONFIG_DRIVER_TI_EMAC
?/* XXX: this needs to be moved to board init */
extern void davinci_eth_set_mac_addr (const u_int8_t *addr);
?if (getenv ("ethaddr")) {
??uchar enetaddr[6];
??eth_getenv_enetaddr("ethaddr", enetaddr);
??davinci_eth_set_mac_addr(enetaddr);
?}
#endif

#if defined(CONFIG_DRIVER_SMC91111) || defined (CONFIG_DRIVER_LAN91C96)
?/* XXX: this needs to be moved to board init */
?if (getenv ("ethaddr")) {
??uchar enetaddr[6];
??eth_getenv_enetaddr("ethaddr", enetaddr);
??smc_set_mac_addr(enetaddr);
?}
#endif /* CONFIG_DRIVER_SMC91111 || CONFIG_DRIVER_LAN91C96 */

?/* Initialize from environment */
?if ((s = getenv ("loadaddr")) != NULL) {
??load_addr = simple_strtoul (s, NULL, 16);
?}
#if defined(CONFIG_CMD_NET)
?if ((s = getenv ("bootfile")) != NULL) {
??copy_filename (BootFile, s, sizeof (BootFile));
?}
#endif

#ifdef BOARD_LATE_INIT
?board_late_init ();
#endif

#ifdef CONFIG_GENERIC_MMC
?puts ("MMC:?? ");
?mmc_initialize (gd->bd);
#endif

#ifdef CONFIG_BITBANGMII
?bb_miiphy_init();
#endif
#if defined(CONFIG_CMD_NET)
#if defined(CONFIG_NET_MULTI)
?puts ("Net:?? ");
#endif
?eth_initialize(gd->bd);
#if defined(CONFIG_RESET_PHY_R)
?debug ("Reset Ethernet PHYn");
?reset_phy();
#endif
#endif
?/* main_loop() can return to retry autoboot, if so just run it again. */
?for (;;) {
??main_loop ();?????????????????????//上面各個板級外設(shè)初始化完成后 開始進入main_loop()死循環(huán)
?}

?/* NOTREACHED - no way out of command loop except booting */
}

void main_loop (void)

s = getenv ("bootdelay");
?bootdelay = s ? (int)simple_strtol(s, NULL, 10) : CONFIG_BOOTDELAY;??????? //如果定義了延時 加載這條? 這里涉及一個重要的函數(shù)getenv()獲得環(huán)境變量

run_command (s, 0);?????? //死循環(huán)中運行命令函數(shù)? 我們在串口輸入各種命令 就是靠這個函數(shù)解析

本站聲明: 本文章由作者或相關(guān)機構(gòu)授權(quán)發(fā)布,目的在于傳遞更多信息,并不代表本站贊同其觀點,本站亦不保證或承諾內(nèi)容真實性等。需要轉(zhuǎn)載請聯(lián)系該專欄作者,如若文章內(nèi)容侵犯您的權(quán)益,請及時聯(lián)系本站刪除。
換一批
延伸閱讀

9月2日消息,不造車的華為或?qū)⒋呱龈蟮莫毥谦F公司,隨著阿維塔和賽力斯的入局,華為引望愈發(fā)顯得引人矚目。

關(guān)鍵字: 阿維塔 塞力斯 華為

加利福尼亞州圣克拉拉縣2024年8月30日 /美通社/ -- 數(shù)字化轉(zhuǎn)型技術(shù)解決方案公司Trianz今天宣布,該公司與Amazon Web Services (AWS)簽訂了...

關(guān)鍵字: AWS AN BSP 數(shù)字化

倫敦2024年8月29日 /美通社/ -- 英國汽車技術(shù)公司SODA.Auto推出其旗艦產(chǎn)品SODA V,這是全球首款涵蓋汽車工程師從創(chuàng)意到認證的所有需求的工具,可用于創(chuàng)建軟件定義汽車。 SODA V工具的開發(fā)耗時1.5...

關(guān)鍵字: 汽車 人工智能 智能驅(qū)動 BSP

北京2024年8月28日 /美通社/ -- 越來越多用戶希望企業(yè)業(yè)務(wù)能7×24不間斷運行,同時企業(yè)卻面臨越來越多業(yè)務(wù)中斷的風險,如企業(yè)系統(tǒng)復雜性的增加,頻繁的功能更新和發(fā)布等。如何確保業(yè)務(wù)連續(xù)性,提升韌性,成...

關(guān)鍵字: 亞馬遜 解密 控制平面 BSP

8月30日消息,據(jù)媒體報道,騰訊和網(wǎng)易近期正在縮減他們對日本游戲市場的投資。

關(guān)鍵字: 騰訊 編碼器 CPU

8月28日消息,今天上午,2024中國國際大數(shù)據(jù)產(chǎn)業(yè)博覽會開幕式在貴陽舉行,華為董事、質(zhì)量流程IT總裁陶景文發(fā)表了演講。

關(guān)鍵字: 華為 12nm EDA 半導體

8月28日消息,在2024中國國際大數(shù)據(jù)產(chǎn)業(yè)博覽會上,華為常務(wù)董事、華為云CEO張平安發(fā)表演講稱,數(shù)字世界的話語權(quán)最終是由生態(tài)的繁榮決定的。

關(guān)鍵字: 華為 12nm 手機 衛(wèi)星通信

要點: 有效應(yīng)對環(huán)境變化,經(jīng)營業(yè)績穩(wěn)中有升 落實提質(zhì)增效舉措,毛利潤率延續(xù)升勢 戰(zhàn)略布局成效顯著,戰(zhàn)新業(yè)務(wù)引領(lǐng)增長 以科技創(chuàng)新為引領(lǐng),提升企業(yè)核心競爭力 堅持高質(zhì)量發(fā)展策略,塑強核心競爭優(yōu)勢...

關(guān)鍵字: 通信 BSP 電信運營商 數(shù)字經(jīng)濟

北京2024年8月27日 /美通社/ -- 8月21日,由中央廣播電視總臺與中國電影電視技術(shù)學會聯(lián)合牽頭組建的NVI技術(shù)創(chuàng)新聯(lián)盟在BIRTV2024超高清全產(chǎn)業(yè)鏈發(fā)展研討會上宣布正式成立。 活動現(xiàn)場 NVI技術(shù)創(chuàng)新聯(lián)...

關(guān)鍵字: VI 傳輸協(xié)議 音頻 BSP

北京2024年8月27日 /美通社/ -- 在8月23日舉辦的2024年長三角生態(tài)綠色一體化發(fā)展示范區(qū)聯(lián)合招商會上,軟通動力信息技術(shù)(集團)股份有限公司(以下簡稱"軟通動力")與長三角投資(上海)有限...

關(guān)鍵字: BSP 信息技術(shù)
關(guān)閉
關(guān)閉