⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main.c

📁 ARM-LINUX,基于S3c2410处理器的开发板实验源代码
💻 C
📖 第 1 页 / 共 2 页
字号:
                3. invalidate I,D TLBs                4. load page table pointer(has been initialized at mmm_mapping_linear upside)                5. set MMU control registers:                    a. base location of exception = 0 (exception vectors' start address is 0x00000000)                    b. RS=0b00 (RS is not used as AP=0b11 which means all access types permitted                        in both supervisor and user mode)                    c. set little-endian                    d. mmu enable    putstr("Succeed memory mapping.\r\n");    /* NB: 瘤陛何磐绰 MMU啊 悼累且 荐档 乐澜 */    /*     * Now, vivi is running on the ram. MMU is enabled.     */    /*      * Step 4:     *   何飘肺歹俊辑 悼利 皋葛府 且寸阑 荤侩且 荐 乐档废     */    /* initialize the heap area*/    ret = heap_init();  /*lib/heap.c*/            /*heap is a memory from which the function mmalloc require a memory block              it calls mmalloc_init in lib/heap.c to initialize the heap            */    if (ret) {        putstr("Failed initailizing heap region\r\n");        error();    }    /* Step 5:     *    磊, 困俊辑 皋葛府 概俏捞 力措肺 灯促搁,     *    MTD率阑 棱酒 壕矫促.     *    悼矫俊, MTD狼 颇萍记partition 沥焊啊 乐促搁     *    棱酒郴摆烈.     */    ret = mtd_dev_init();   /*drivers/mtd/mtdcore.c*/                /*it calls the functions mtd_init at drivers/mtd/maps/s3c2410_flash.c:                    calls smc_init at the same file:                        a. mmalloc memory for strcut mymtd                        b. initialize (struct nand_chip *)(&mymtd[1]) for NAND FLASH                        c. call smc_insert at the same file:                            call the functions smc_scan at drivers/mtd/nand/smc_core.c:                                read the ID of NAND FLASH, compare it with the pre-defined                                    infomation of some usually types of NAND FLASH, and then                                  set the NAND FLASH's data struct (struct nand_chip *)(&mymtd[1]).                */    /* Step 6:     *   何飘肺歹甫 困茄 颇扼固磐 蔼甸阑 棱酒郴具摆烈.     */    init_priv_data();   /*lib/priv_data/rw.c*/                        /*there are two sets of vivi's parameters, one are the default parameters and the other are the saved parameters.                          init_priv_data load the default parameters on the memory, and then load the saved parameters and overwrite                  the corespointing part of the default parameters if the saved parameters is validate. The saved parameters were                          stored at the param partion of nand flash.                        1. get_default_data(lib/priv_data/rw.c):                            a. get_default_param_tlb, defined at struct default_vivi_parameters at arch/s3c2410/smdk.c                            b. get_default_linux_cmd, copy linux command "char linux_cmd[] = "noinitrd root=/dev/mtdblock/0                                init=/linuxrc console=ttyS0" "(arch/s3c2410/smdk.c)                            c. get_default_mtd_partition, defined at struct default_mtd_partitions at arch/s3c2410/smdk.c                        2. load_saved_priv_data(lib/priv_data/rw.c):                            a. read_saved_priv_data_blk(at the same file), read the saved vivi parameters from the param part of                               nand flash to DRAM_BASE                            b. copy the saved tlb parameters from DRAM_BASE to overwrite what 1.a stores                            c. copy the saved linux command from DRAM_BASE to overwrite what 1.b stores                            d. copy the saved part parameters from DRAM_BASE to overwrite what 1.c stores                        */    /* Step 7:     *   啊阐 荤捞(荤厩窍绊 捞惑茄)茄 焊靛甸阑 困秦辑     */    misc(); /*arch/s3c2410/smdk.c*/        /*call the function add_command(&cpu_cmd) defined at lib/command.c, to add the cpu command to the command chain          this command is used to change the cpu's clock        */      init_builtin_cmds();    /*lib/command.c*/            /*1. add_command(&bon_cmd)              2. add_command(&reset_cmd)              3. add_command(&param_cmd)              4. add_command(&part_cmd)              5. add_command(&mem_cmd)              6. add_command(&load_cmd)              7. add_command(&go_cmd)              8. add_command(&dump_cmd)              9. add_command(&call_cmd)              10.add_command(&boot_cmd)              11.add_command(&help_cmd)            */    /* Step 8:     *   绢叼肺 哎鳖唱?     */    boot_or_vivi(); /*call vivi_shell() or run_autoboot.              1. run_autoboot:                exec_string("boot") (lib/command.c):                    parse the sting "boot", and then call the function execcmd:                        use the execcmd's parameter to find the boot_cmd's function and executive it:                            the boot_cmd was defined at lib/boot_kernel.c(see follow):                            user_command_t boot_cmd = {                                "boot",                                command_boot,                                NULL,                                "boot [{cmds}] \t\t\t-- Booting linux kernel"                                };                            so, we call the function command_boot(lib/boot_kernel.c):                                       a. media_type = get_param_value("media_type", &ret)                                   (lib/priv_data/param.c), media_type=3                                b. kernel_part = get_mtd_partition("kernel")                                  (lib/priv_data/mtdpart.c), see also arch/s3c2410/smdk.c                                    name:       "kernel",                                    offset:     0x00030000,                                    size:       0x00100000,                                    flag:       0                                c. boot_kernel(from, size, media_type) (lib/boot_kernel.c):                                    i. copy the kernel image from the kernel partion on nand                                      flash to ram(boot_mem_base + LINUX_KERNEL_OFFSET,                                      0x30008000)using the copy_kernel_img.                                    ii.setup_linux_param, set the linux parameters at                                      boot_mem_base + LINUX_PARAM_OFFSET(0x30000100),                                       these parameters were stored as a struct param_struct,                                      which contains the command line parameter.                                    iii.call_linux(0, mach_type, to)                                       (boot_mem_base + LINUX_KERNEL_OFFSET=0x30008000)                                        (1). cache_clean_invalidate                                        (2). tlb_invalidate                                        (3). use the inline asm to jump to linux kernel:                                            define the p15 corprocessor:                                            zero PID                                            invalidate I,D caches                                            drain write buffer                                            invalidate I,D TLBs                                            get control register                                            disable MMU                                            write control register                                            set the PC register as the kernel address:                                            mov pc, r2            2. vivi_shell:                call the function serial_term at drivers/serial/term.c:                    a. printk("%s> ", prompt), display the string "vivi>"                    b. getcmd(cmd_buf, MAX_CMDBUF_SIZE) at drivers/serial/getcmd.c, wait for the command send                       from serial port by user                    c. exec_string(cmd_buf) at lib/command.c:                        parseargs                        execcmd            *//*******************************************************************************************Now, the DRAM is seperated to these parts;+-----------------------------------------------+ 0x33ff_ffff = 0x3000_0000+64M-1+                                               ++                                               ++                   1M  VIVI                    ++                                               ++                                               ++-----------------------------------------------+ 0x33f0_0000 = VIVI_RAM_BASE+                                               ++                                               ++                   1M  HEAP                    ++                                               ++                                               ++-----------------------------------------------+ 0x33e0_0000 = HEAP_BASE+                  16k MMU_TABLE                ++-----------------------------------------------+ 0x33df_c000 = MMU_TABLE_BASE (used at the stage2 of bootloader)+                  16k LINUX_CMD                ++                                               + LINUX_CMD_OFFSET = 16 k+                  16k PARAMETER_TLB            ++                                               + PARAMETER_TLB_OFFSET = 16k+                  16k PARAMETER_PART           ++-----------------------------------------------+ 0x33df_0000 = VIVI_PRIV_RAM_BASE (PARAMETER_PART_OFFSET = 0)+                                               ++                  32k STACK                    + +                                               ++-----------------------------------------------+ 0x33de_8000 = STACK_BASE+                       .                       ++                       .                       ++                       .                       ++                       .                       ++                       .                       ++                       .                       ++-----------------------------------------------++                                               ++                                               ++                  1M  LINUX KERNEL             ++                                               ++                                               ++-----------------------------------------------+ 0x3000_8000 = the kernel image is placed begin this address+                                               ++                  LINUX PAREMETER              + +-----------------------------------------------+ LINUX_PARAM_OFFSET = 0x100+-----------------------------------------------+ 0x3000_0000 = RAM_BASE*******************************************************************************************/    /* 咯扁鳖瘤 坷搁 捞惑窍瘤夸. 弊犯瘤 臼唱夸? */    return 0;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -