扫一扫
分享文章到微信
扫一扫
关注官方公众号
至顶头条
作者:宋宝华 来源:天极开发 2007年11月21日
关键字:
int main(int argc, char *argv[]) { int ret; /* * Step 1: */ putstr("\r\n"); putstr(vivi_banner); reset_handler(); /* * Step 2: */ ret = board_init(); if (ret) { putstr("Failed a board_init() procedure\r\n"); error(); } /* * Step 3: */ mem_map_init(); mmu_init(); putstr("Succeed memory mapping.\r\n"); /* * Now, vivi is running on the ram. MMU is enabled. */ /* * Step 4: */ /* initialize the heap area*/ ret = heap_init(); if (ret) { putstr("Failed initailizing heap region\r\n"); error(); } /* Step 5: */ ret = mtd_dev_init(); /* Step 6: */ init_priv_data(); /* Step 7: */ misc(); init_builtin_cmds(); /* Step 8: */ boot_or_vivi(); return 0; } |
const char *vivi_banner = "VIVI version " VIVI_RELEASE " (" VIVI_COMPILE_BY "@" VIVI_COMPILE_HOST ") (" VIVI_COMPILER ") " UTS_VERSION "\r\n"; |
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 void hard_reset_handle(void) { clear_mem((unsigned long)USER_RAM_BASE, (unsigned long)USER_RAM_SIZE); } |
int board_init(void) { init_time(); set_gpios(); return 0; } |
void mem_map_init(void) { #ifdef CONFIG_S3C2410_NAND_BOOT mem_map_nand_boot(); #else mem_map_nor(); #endif cache_clean_invalidate(); tlb_invalidate(); } |
static inline void arm920_setup(void) { unsigned long ttb = MMU_TABLE_BASE; __asm__( /* Invalidate caches */ "mov r0, #0\n" "mcr p15, 0, r0, c7, c7, 0\n" /* invalidate I,D caches on v4 */ "mcr p15, 0, r0, c7, c10, 4\n" /* drain write buffer on v4 */ "mcr p15, 0, r0, c8, c7, 0\n" /* invalidate I,D TLBs on v4 */ /* Load page table pointer */ "mov r4, %0\n" "mcr p15, 0, r4, c2, c0, 0\n" /* load page table pointer */ /* Write domain id (cp15_r3) */ "mvn r0, #0\n" /* Domains 0, 1 = client */ "mcr p15, 0, r0, c3, c0, 0\n" /* load domain access register */ /* Set control register v4 */ "mrc p15, 0, r0, c1, c0, 0\n" /* get control register v4 */ /* Clear out 'unwanted' bits (then put them in if we need them) */ /* .RVI ..RS B... .CAM */ "bic r0, r0, #0x3000\n" /* ..11 .... .... .... */ "bic r0, r0, #0x0300\n" /* .... ..11 .... .... */ "bic r0, r0, #0x0087\n" /* .... .... 1... .111 */ /* Turn on what we want */ /* Fault checking enabled */ "orr r0, r0, #0x0002\n" /* .... .... .... ..1. */ #ifdef CONFIG_CPU_D_CACHE_ON "orr r0, r0, #0x0004\n" /* .... .... .... .1.. */ #endif #ifdef CONFIG_CPU_I_CACHE_ON "orr r0, r0, #0x1000\n" /* ...1 .... .... .... */ #endif /* MMU enabled */ "orr r0, r0, #0x0001\n" /* .... .... .... ...1 */ "mcr p15, 0, r0, c1, c0, 0\n" /* write control register */ : /* no outputs */ : "r" (ttb) ); } |
#define DEFAULT_BOOT_DELAY 0x30000000 void boot_or_vivi(void) { char c; int ret; ulong boot_delay; boot_delay = get_param_value("boot_delay", &ret); if (ret) boot_delay = DEFAULT_BOOT_DELAY; /* If a value of boot_delay is zero, * unconditionally call vivi shell */ if (boot_delay == 0) vivi_shell(); /* * wait for a keystroke (or a button press if you want.) */ printk("Press Return to start the LINUX now, any other key for vivi\n"); c = awaitkey(boot_delay, NULL); if (((c != '\r') && (c != '\n') && (c != '\0'))) { printk("type \"help\" for help.\n"); vivi_shell(); } run_autoboot(); return; } |
void vivi_shell(void) { #ifdef CONFIG_SERIAL_TERM serial_term(); #else #error there is no terminal. #endif } void serial_term(void) { char cmd_buf[MAX_CMDBUF_SIZE]; for (;;) { printk("%s> ", prompt); getcmd(cmd_buf, MAX_CMDBUF_SIZE); /* execute a user command */ if (cmd_buf[0]) exec_string(cmd_buf); } } |
SECTIONS { . = 0x40000000; .text : { *(.text) } Image_RO_Limit = .; Image_RW_Base = .; .data : { *(.data) } .rodata : { *(.rodata) } Image_ZI_Base = .; .bss : { *(.bss) } Image_ZI_Limit = .; __bss_start__ = .; __bss_end__ = .; __EH_FRAME_BEGIN__ = .; __EH_FRAME_END__ = .; PROVIDE (__stack = .); end = .; _end = .; .debug_info 0 : { *(.debug_info) } .debug_line 0 : { *(.debug_line) } .debug_abbrev 0 : { *(.debug_abbrev)} .debug_frame 0 : { *(.debug_frame) } } |
如果您非常迫切的想了解IT领域最新产品与技术信息,那么订阅至顶网技术邮件将是您的最佳途径之一。
现场直击|2021世界人工智能大会
直击5G创新地带,就在2021MWC上海
5G已至 转型当时——服务提供商如何把握转型的绝佳时机
寻找自己的Flag
华为开发者大会2020(Cloud)- 科技行者