@ 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
vivi_banner就是字符串,中间有四个未知的宏,这是非常明显的。显然就是头文件中给出的。但是find,没有version.h、compile.h,这在前面Makefile分析时也详细讲解过了,而且还把version.h合并入compile.h里面了。可以just for fun,增加一些个性化的打印信息,比如,我的version.c修改如下:
#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";
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
可见这部分功能是多余的。可以选择把这部分设置完全去掉,方法如下:
·【init/main.c】去掉行reset_handler();,去掉#include 。
·删除【lib/reset_handle.c】,删除【include/reset_handle.h】
·【arch/config.in】,删除行bool 'support reset handler' CONFIG_RESET_HANDLING,这样就彻底把此项配置部分也删除了。如果还有原来的默认配置文件,可以把# CONFIG_RESET_HANDLING is not set删除。
分析这样是不妥的。原因就在于stdarg.h(注意,这里只需要定义头文件就可以把变长参数表的功能引入了。该头文件的实现因为不同的机器而不同,但是提供的接口是一致的。具体可以看《The C Programming Language》。但是一个细节就是你如果find,会找不到stdarg.h这个头文件,原因就是gcc直接把stdarg.h放到编译器里。)规定的变长参数表必须至少包括一个有名参数,va_start会将最后一个有名参数作为起点。这里封装的printk缺少了有名参数,这里可以做测试。测试工程如下: