setup.c
来自「linux 内核源代码」· C语言 代码 · 共 706 行 · 第 1/2 页
C
706 行
/* * File: arch/blackfin/kernel/setup.c * Based on: * Author: * * Created: * Description: * * Modified: * Copyright 2004-2006 Analog Devices Inc. * * Bugs: Enter bugs at http://blackfin.uclinux.org/ * * 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, see the file COPYING, or write * to the Free Software Foundation, Inc., * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */#include <linux/delay.h>#include <linux/console.h>#include <linux/bootmem.h>#include <linux/seq_file.h>#include <linux/cpu.h>#include <linux/module.h>#include <linux/tty.h>#include <linux/ext2_fs.h>#include <linux/cramfs_fs.h>#include <linux/romfs_fs.h>#include <asm/cplb.h>#include <asm/cacheflush.h>#include <asm/blackfin.h>#include <asm/cplbinit.h>#include <asm/div64.h>#include <asm/fixed_code.h>#include <asm/early_printk.h>u16 _bfin_swrst;unsigned long memory_start, memory_end, physical_mem_end;unsigned long reserved_mem_dcache_on;unsigned long reserved_mem_icache_on;EXPORT_SYMBOL(memory_start);EXPORT_SYMBOL(memory_end);EXPORT_SYMBOL(physical_mem_end);EXPORT_SYMBOL(_ramend);#ifdef CONFIG_MTD_UCLINUXunsigned long memory_mtd_end, memory_mtd_start, mtd_size;unsigned long _ebss;EXPORT_SYMBOL(memory_mtd_end);EXPORT_SYMBOL(memory_mtd_start);EXPORT_SYMBOL(mtd_size);#endifchar __initdata command_line[COMMAND_LINE_SIZE];void __init bf53x_cache_init(void){#if defined(CONFIG_BFIN_DCACHE) || defined(CONFIG_BFIN_ICACHE) generate_cpl_tables();#endif#ifdef CONFIG_BFIN_ICACHE bfin_icache_init(); printk(KERN_INFO "Instruction Cache Enabled\n");#endif#ifdef CONFIG_BFIN_DCACHE bfin_dcache_init(); printk(KERN_INFO "Data Cache Enabled"# if defined CONFIG_BFIN_WB " (write-back)"# elif defined CONFIG_BFIN_WT " (write-through)"# endif "\n");#endif}void __init bf53x_relocate_l1_mem(void){ unsigned long l1_code_length; unsigned long l1_data_a_length; unsigned long l1_data_b_length; l1_code_length = _etext_l1 - _stext_l1; if (l1_code_length > L1_CODE_LENGTH) l1_code_length = L1_CODE_LENGTH; /* cannot complain as printk is not available as yet. * But we can continue booting and complain later! */ /* Copy _stext_l1 to _etext_l1 to L1 instruction SRAM */ dma_memcpy(_stext_l1, _l1_lma_start, l1_code_length); l1_data_a_length = _ebss_l1 - _sdata_l1; if (l1_data_a_length > L1_DATA_A_LENGTH) l1_data_a_length = L1_DATA_A_LENGTH; /* Copy _sdata_l1 to _ebss_l1 to L1 data bank A SRAM */ dma_memcpy(_sdata_l1, _l1_lma_start + l1_code_length, l1_data_a_length); l1_data_b_length = _ebss_b_l1 - _sdata_b_l1; if (l1_data_b_length > L1_DATA_B_LENGTH) l1_data_b_length = L1_DATA_B_LENGTH; /* Copy _sdata_b_l1 to _ebss_b_l1 to L1 data bank B SRAM */ dma_memcpy(_sdata_b_l1, _l1_lma_start + l1_code_length + l1_data_a_length, l1_data_b_length);}/* * Initial parsing of the command line. Currently, we support: * - Controlling the linux memory size: mem=xxx[KMG] * - Controlling the physical memory size: max_mem=xxx[KMG][$][#] * $ -> reserved memory is dcacheable * # -> reserved memory is icacheable */static __init void parse_cmdline_early(char *cmdline_p){ char c = ' ', *to = cmdline_p; unsigned int memsize; for (;;) { if (c == ' ') { if (!memcmp(to, "mem=", 4)) { to += 4; memsize = memparse(to, &to); if (memsize) _ramend = memsize; } else if (!memcmp(to, "max_mem=", 8)) { to += 8; memsize = memparse(to, &to); if (memsize) { physical_mem_end = memsize; if (*to != ' ') { if (*to == '$' || *(to + 1) == '$') reserved_mem_dcache_on = 1; if (*to == '#' || *(to + 1) == '#') reserved_mem_icache_on = 1; } } } else if (!memcmp(to, "earlyprintk=", 12)) { to += 12; setup_early_printk(to); } } c = *(to++); if (!c) break; }}void __init setup_arch(char **cmdline_p){ int bootmap_size; unsigned long l1_length, sclk, cclk;#ifdef CONFIG_MTD_UCLINUX unsigned long mtd_phys = 0;#endif#ifdef CONFIG_DUMMY_CONSOLE conswitchp = &dummy_con;#endif#if defined(CONFIG_CMDLINE_BOOL) strncpy(&command_line[0], CONFIG_CMDLINE, sizeof(command_line)); command_line[sizeof(command_line) - 1] = 0;#endif /* Keep a copy of command line */ *cmdline_p = &command_line[0]; memcpy(boot_command_line, command_line, COMMAND_LINE_SIZE); boot_command_line[COMMAND_LINE_SIZE - 1] = '\0'; /* setup memory defaults from the user config */ physical_mem_end = 0; _ramend = CONFIG_MEM_SIZE * 1024 * 1024; parse_cmdline_early(&command_line[0]); cclk = get_cclk(); sclk = get_sclk();#if !defined(CONFIG_BFIN_KERNEL_CLOCK) if (ANOMALY_05000273 && cclk == sclk) panic("ANOMALY 05000273, SCLK can not be same as CCLK");#endif#ifdef BF561_FAMILY if (ANOMALY_05000266) { bfin_read_IMDMA_D0_IRQ_STATUS(); bfin_read_IMDMA_D1_IRQ_STATUS(); }#endif printk(KERN_INFO "Hardware Trace "); if (bfin_read_TBUFCTL() & 0x1 ) printk("Active "); else printk("Off "); if (bfin_read_TBUFCTL() & 0x2) printk("and Enabled\n"); else printk("and Disabled\n");#if defined(CONFIG_CHR_DEV_FLASH) || defined(CONFIG_BLK_DEV_FLASH) /* we need to initialize the Flashrom device here since we might * do things with flash early on in the boot */ flash_probe();#endif if (physical_mem_end == 0) physical_mem_end = _ramend; /* by now the stack is part of the init task */ memory_end = _ramend - DMA_UNCACHED_REGION; _ramstart = (unsigned long)__bss_stop; memory_start = PAGE_ALIGN(_ramstart);#if defined(CONFIG_MTD_UCLINUX) /* generic memory mapped MTD driver */ memory_mtd_end = memory_end; mtd_phys = _ramstart; mtd_size = PAGE_ALIGN(*((unsigned long *)(mtd_phys + 8)));# if defined(CONFIG_EXT2_FS) || defined(CONFIG_EXT3_FS) if (*((unsigned short *)(mtd_phys + 0x438)) == EXT2_SUPER_MAGIC) mtd_size = PAGE_ALIGN(*((unsigned long *)(mtd_phys + 0x404)) << 10);# endif# if defined(CONFIG_CRAMFS) if (*((unsigned long *)(mtd_phys)) == CRAMFS_MAGIC) mtd_size = PAGE_ALIGN(*((unsigned long *)(mtd_phys + 0x4)));# endif# if defined(CONFIG_ROMFS_FS) if (((unsigned long *)mtd_phys)[0] == ROMSB_WORD0 && ((unsigned long *)mtd_phys)[1] == ROMSB_WORD1) mtd_size = PAGE_ALIGN(be32_to_cpu(((unsigned long *)mtd_phys)[2]));# if (defined(CONFIG_BFIN_ICACHE) && ANOMALY_05000263) /* Due to a Hardware Anomaly we need to limit the size of usable * instruction memory to max 60MB, 56 if HUNT_FOR_ZERO is on * 05000263 - Hardware loop corrupted when taking an ICPLB exception */# if (defined(CONFIG_DEBUG_HUNT_FOR_ZERO)) if (memory_end >= 56 * 1024 * 1024) memory_end = 56 * 1024 * 1024;# else if (memory_end >= 60 * 1024 * 1024) memory_end = 60 * 1024 * 1024;# endif /* CONFIG_DEBUG_HUNT_FOR_ZERO */# endif /* ANOMALY_05000263 */# endif /* CONFIG_ROMFS_FS */ memory_end -= mtd_size; if (mtd_size == 0) { console_init(); panic("Don't boot kernel without rootfs attached.\n"); } /* Relocate MTD image to the top of memory after the uncached memory area */ dma_memcpy((char *)memory_end, __bss_stop, mtd_size); memory_mtd_start = memory_end; _ebss = memory_mtd_start; /* define _ebss for compatible */#endif /* CONFIG_MTD_UCLINUX */#if (defined(CONFIG_BFIN_ICACHE) && ANOMALY_05000263) /* Due to a Hardware Anomaly we need to limit the size of usable * instruction memory to max 60MB, 56 if HUNT_FOR_ZERO is on * 05000263 - Hardware loop corrupted when taking an ICPLB exception */#if (defined(CONFIG_DEBUG_HUNT_FOR_ZERO)) if (memory_end >= 56 * 1024 * 1024) memory_end = 56 * 1024 * 1024;#else if (memory_end >= 60 * 1024 * 1024) memory_end = 60 * 1024 * 1024;#endif /* CONFIG_DEBUG_HUNT_FOR_ZERO */ printk(KERN_NOTICE "Warning: limiting memory to %liMB due to hardware anomaly 05000263\n", memory_end >> 20);#endif /* ANOMALY_05000263 */#if !defined(CONFIG_MTD_UCLINUX) memory_end -= SIZE_4K; /*In case there is no valid CPLB behind memory_end make sure we don't get to close*/#endif init_mm.start_code = (unsigned long)_stext; init_mm.end_code = (unsigned long)_etext; init_mm.end_data = (unsigned long)_edata; init_mm.brk = (unsigned long)0; init_leds(); _bfin_swrst = bfin_read_SWRST(); if (_bfin_swrst & RESET_DOUBLE) printk(KERN_INFO "Recovering from Double Fault event\n"); else if (_bfin_swrst & RESET_WDOG) printk(KERN_INFO "Recovering from Watchdog event\n"); else if (_bfin_swrst & RESET_SOFTWARE) printk(KERN_NOTICE "Reset caused by Software reset\n"); printk(KERN_INFO "Blackfin support (C) 2004-2007 Analog Devices, Inc.\n"); if (bfin_compiled_revid() == 0xffff) printk(KERN_INFO "Compiled for ADSP-%s Rev any\n", CPU); else if (bfin_compiled_revid() == -1) printk(KERN_INFO "Compiled for ADSP-%s Rev none\n", CPU); else printk(KERN_INFO "Compiled for ADSP-%s Rev 0.%d\n", CPU, bfin_compiled_revid()); if (bfin_revid() != bfin_compiled_revid()) { if (bfin_compiled_revid() == -1) printk(KERN_ERR "Warning: Compiled for Rev none, but running on Rev %d\n", bfin_revid()); else if (bfin_compiled_revid() != 0xffff) printk(KERN_ERR "Warning: Compiled for Rev %d, but running on Rev %d\n", bfin_compiled_revid(), bfin_revid()); } if (bfin_revid() < SUPPORTED_REVID) printk(KERN_ERR "Warning: Unsupported Chip Revision ADSP-%s Rev 0.%d detected\n", CPU, bfin_revid()); printk(KERN_INFO "Blackfin Linux support by http://blackfin.uclinux.org/\n"); printk(KERN_INFO "Processor Speed: %lu MHz core clock and %lu MHz System Clock\n", cclk / 1000000, sclk / 1000000); if (ANOMALY_05000273 && (cclk >> 1) <= sclk) printk("\n\n\nANOMALY_05000273: CCLK must be >= 2*SCLK !!!\n\n\n");
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?