vivi源代码分析2
来源:互联网 发布:arc gis软件下载 编辑:程序博客网 时间:2024/06/11 22:04
@ get read to call C functions
ldr sp, DW_STACK_START @ setup stack pointer
mov fp, #0 @ no previous frame, so fp=0
mov a2, #0 @ set argv to NULL
bl main @ call main
@ jump to ram
@ a technology about trampoline
ldr pc, =on_the_ram
on_the_ram:
bl main
@ if main ever returns, reboot
mov pc, #FLASH_BASE
int main(void)
{
int ret;
/*
* Step 1:
* Print Vivi version information
*/
putstr("/r/n");
putstr(vivi_banner);
/*
* Step 2:
* initialize board environment
*/
ret = board_init();
if (ret) {
putstr("Failed a board_init() procedure/r/n");
error();
}
/*
* Step 3:
* MMU management
* When it's done, vivi is running on the ram and MMU is enabled.
*/
mem_map_init();
mmu_init();
putstr("Succeed memory mapping./r/n");
/*
* Step 4:
* initialize the heap area
*/
ret = heap_init();
if (ret) {
putstr("Failed initailizing heap region/r/n");
error();
}
/*
* Step 5:
* initialize the MTD device
*/
ret = mtd_dev_init();
/*
* Step 6:
* initialize the private data
*/
init_priv_data();
/*
* Step 7:
* initialize the humanmachine environment
*/
misc();
init_builtin_cmds();
/*
* Step 8:
* boot kernel or step into vivi
*/
boot_or_vivi();
return 0;
}
putstr("/r/n");
putstr(vivi_banner);
reset_handler();
#include "version.h"
#include "compile.h"
const char *vivi_banner =
"VIVI version " VIVI_RELEASE " (" VIVI_COMPILE_BY "@"
VIVI_COMPILE_HOST ") (" VIVI_COMPILER ") " UTS_VERSION "/r/n";
#include "compile.h"
const char *vivi_banner =
"/r/n/t^_^ Well done, boy! Go on -->/r/n"
"VIVI version " VIVI_RELEASE " (" VIVI_COMPILE_BY "@"
VIVI_COMPILE_HOST ") (" VIVI_COMPILER ") " UTS_VERSION "/r/n";
【lib/reset_handle.c】
void
reset_handler(void)
{
int pressed;
pressed = is_pressed_pw_btn();
if (pressed == PWBT_PRESS_LEVEL) {
DPRINTK("HARD RESET/r/n");
hard_reset_handle();
} else {
DPRINTK("SOFT RESET/r/n");
soft_reset_handle();
}
}
static int
is_pressed_pw_btn(void)
{
return read_bt_status();
}
--> read_bt_status
static int
read_bt_status(void)
{
ulong status;
//status = ((GPLR & (1 << GPIO_PWBT)) >> GPIO_PWBT);
status = ((PWBT_REG & (1 << PWBT_GPIO_NUM)) >> PWBT_GPIO_NUM);
if (status)
return HIGH;
else
return LOW;
}
#ifdef CONFIG_RESET_HANDLING
void reset_handler(void);
#else
#define reset_handler() (void)(0)
#endif
reset_handle.c: In function `read_bt_status':
reset_handle.c:31: `PWBT_REG' undeclared (first use in this function)
reset_handle.c:31: (Each undeclared identifier is reported only once
reset_handle.c:31: for each function it appears in.)
reset_handle.c:31: `PWBT_GPIO_NUM' undeclared (first use in this function)
reset_handle.c:28: warning: `status' might be used uninitialized in this function
reset_handle.c: In function `hard_reset_handle':
reset_handle.c:52: `USER_RAM_BASE' undeclared (first use in this function)
reset_handle.c:52: `USER_RAM_SIZE' undeclared (first use in this function)
reset_handle.c: In function `reset_handler':
reset_handle.c:68: `PWBT_PRESS_LEVEL' undeclared (first use in this function)
make[2]: *** [reset_handle.o] Error 1
make[2]: Leaving directory `/home/armlinux/embedded_Linux/s3c2410/bootloader/m-boot-1.0.0/lib'
make[1]: *** [first_rule] Error 2
make[1]: Leaving directory `/home/armlinux/embedded_Linux/s3c2410/bootloader/m-boot-1.0.0/lib
·删除【lib/reset_handle.c】,删除【include/reset_handle.h】
·【arch/config.in】,删除行bool 'support reset handler' CONFIG_RESET_HANDLING,这样就彻底把此项配置部分也删除了。如果还有原来的默认配置文件,可以把# CONFIG_RESET_HANDLING is not set删除。
·复制【lib/vsprintf.c】到vivi的lib目录下,更改名称为printk.c。然后只保留vsnprintf,及其用到的number函数、skip_atoi函数。skip_atoi中用到了isdigit,所以把【include/linux/ctype.h】复制到vivi的include目录下。另外,还要用到do_div和strnlen两个函数。其中do_div是宏,在【include/asm-arm/div64.h】中实现,直接复制到vivi的include文件夹中。strnlen应该在string.c中实现,可以从【lib/string.c】复制然后添加到vivi的lib下的string.c文件中,最后把声明加到include下的vivi_string.h中。这样,printk需要的基础部分就具备了。
#ifdef DEBUG_HEAP
#define DPRINTK(args...) printk(##args)
#else
#define DPRINTK(args...)
#endif
[armlinux@lqm printk_test]$ make
gcc -Wall -g -O2 -c -o printk.o printk.c
gcc -Wall -g -O2 -c -o test.o test.c
gcc -Wall -g -O2 printk.o test.o -o test
[armlinux@lqm printk_test]$ ls
Makefile printk.c printk.h printk.o test test.c test.o
[armlinux@lqm printk_test]$ ./test
test: i = 5, j = 10
[armlinux@lqm printk_test]$ make
gcc -Wall -g -O2 -c -o printk.o printk.c
gcc -Wall -g -O2 -c -o test.o test.c
test.c:23:47: warning: pasting "(" and ""test: i = %d, j = %d/n"" does not give a valid preprocessing token
gcc -Wall -g -O2 printk.o test.o -o test
[armlinux@lqm printk_test]$ ls
Makefile printk.c printk.h printk.o test test.c test.o
[armlinux@lqm printk_test]$ ./test
test: i = 5, j = 10
#ifdef DEBUG_HEAP
#define DPRINTK(fmt, args...) printk(fmt, ##args)
#else
#define DPRINTK(fmt, args...)
#endif
转自http://blog.chinaunix.net/u/21948/showart.php?id=377505
- vivi源代码分析2
- vivi源代码分析2
- Bootloader(Vivi)源代码分析
- vivi源代码分析1
- vivi源代码分析3
- Bootloader(Vivi)源代码分析
- vivi源代码分析1
- vivi源代码分析3
- Bootloader(Vivi)源代码分析
- s3c2410的Bootloader(Vivi)源代码分析
- s3c2410的Bootloader(Vivi)源代码分析
- vivi源代码最为详细分析(一)
- vivi源代码最为详细分析(二)
- vivi源代码最为详细分析(三)
- vivi分析
- vivi分析
- vivi开发笔记: MMU分析|ARM,vivi
- VIVI讲解与分析
- 提拉米苏
- 使用struts2+prototype.js创建无刷新注册检测
- 详细介绍ASP.NET状态保存方法
- vivi源代码分析1
- Linux下通过freetds连接MSSQL数据库
- vivi源代码分析2
- Microsoft ®Office2003 实战秘笈
- What's new in Spring 2.0 and 2.5?
- vivi源代码分析3
- 改变tomcat的默认页
- 在Windows下进行Linux/FreeBSD/Unix的GCC远程开发和调试
- 在VB中使用水晶报表的一种简易编程方法
- 解决vs2005自带水晶报表次数的限制的次数
- 上海电信区别对待老客户