📄 main_edit2.c
字号:
/* * vivi/main.c: main routine * * Copyright (C) 2001,2002 MIZI Research, Inc. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * * Author: Janghoon Lyu <nandy@mizi.com> * Date : $Date: 2002/08/28 06:00:11 $ * * $Revision: 1.7 $ * $Id: main.c,v 1.7 2002/08/28 06:00:11 nandy Exp $ * * * History * * 2001-10-xx: Janghoon Lyu <nandy@mizi.com> * - Initial code * * 2001-01-26: Janghoon Lyu <nandy@mizi.com> * - Release VIVI Bootloader * * 2002-07-02: Janghoon Lyu <nandy@mizi.com> * - bootldr狼 儡犁甫 没家窍搁辑 货酚霸 累己 */#include "config.h"#include "machine.h"#include "mmu.h"#include "heap.h"#include "serial.h"#include "printk.h"#include "command.h"#include "priv_data.h"#include "getcmd.h"#include "vivi_string.h"#include "mtd/mtd.h"#include "processor.h"#include <reset_handle.h>#include <types.h> extern char *vivi_banner;void vivi_shell(void){#ifdef CONFIG_SERIAL_TERM /*CONFIG_SERIAL_TERM=y*/ serial_term(); /*drivers/serial/term.c*/#else#error there is no terminal.#endif}void run_autoboot(void){/*defined at lib/boot_kernel.cuser_command_t boot_cmd = { "boot", command_boot, //defined at lib/boot_kernel.c NULL, "boot [{cmds}] \t\t\t-- Booting linux kernel"};*/ while (1) { exec_string("boot"); /*lib/command.c*/ printk("Failed 'boot' command. reentering vivi shell\n"); /* if default boot fails, drop into the shell */ vivi_shell(); }}static void error(void){ putstr("Sorry. We can not run vivi\n"); for (;;) /* nothing */; /* infinite loop */}#define DEFAULT_BOOT_DELAY 0x30000000void boot_or_vivi(void){ char c; int ret; ulong boot_delay;/*在include/priv_data.h中定义typedef struct parameter { char name[MAX_PARAM_NAME]; param_value_t value; void (*update_func)(param_value_t value);} vivi_parameter_t; *//*在arch/s3c2410/smdk.c中定义vivi_parameter_t default_vivi_parameters[] = { { "mach_type", MACH_TYPE, NULL }, { "media_type", MT_S3C2410, NULL }, { "boot_mem_base", 0x30000000, NULL }, { "baudrate", UART_BAUD_RATE, NULL }, { "xmodem_one_nak", 0, NULL }, { "xmodem_initial_timeout", 300000, NULL }, { "xmodem_timeout", 1000000, NULL }, { "ymodem_initial_timeout", 1500000, NULL }, { "boot_delay", 0x1000, NULL }};*/ boot_delay = get_param_value("boot_delay", &ret); /*lib/priv_data/param.c*/ 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); /*drivers/serial/serial_core.c*/ if (((c != '\r') && (c != '\n') && (c != '\0'))) { printk("type \"help\" for help.\n"); vivi_shell(); } run_autoboot(); return;}/***************************************************************************************************what main do(this is the stage2 of bootloader):******************************************************************************************************/int main(int argc, char *argv[]){ int ret; putstr("\r\n"); putstr(vivi_banner); reset_handler(); /*lib/reset_handle.c */ /*it calls function clear_mem((unsigned long)USER_RAM_BASE, (unsigned long)USER_RAM_SIZE) in lib/memory.c*/ /*I can't find where USER_RAM_BASE and USER_RAM_SIZE were defined. */ ret = board_init(); /*arch/s3c2410/smdk.c*/ /*it calls init_time(at arch/s3c2410/proc.c) and set_gpios(in arch/s3c2410/smdk.c)*/ /*init_time: TCFG0 = 0 | 0xf00 | 0 */ if (ret) { putstr("Failed a board_init() procedure\r\n"); error(); } mem_map_init(); /*arch/s3c2410/mmu.c line194*/ /*1. call mem_map_nand_boot in arch/s3c2410/mmu.c this function call mem_mapping_linear immediately mem_mapping_linear(arch/s3c2410/mmu.c): initialize the mmu translation table, Make DRAM section cacheable 2. call cache_clean_invalidate in arch/s3c2410/mmu.c: clean and invalidate all cache lines 3. call tlb_invalidate in arch/s3c2410/mmu.c: invalidate I & D TLBs */ mmu_init(); /*arch/s3c2410/mmu.c line120*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -