📄 setup.c
字号:
early_serial_setup(&__frv_uart0);#endif#ifndef CONFIG_GDBSTUB_UART1 __reg(UART1_BASE + UART_IER * 8) = 0; early_serial_setup(&__frv_uart1);#endif#endif /* deal with the command line - RedBoot may have passed one to the kernel */ memcpy(command_line, boot_command_line, sizeof(command_line)); *cmdline_p = &command_line[0]; parse_cmdline_early(command_line); /* set up the memory description * - by now the stack is part of the init task */ printk("Memory %08lx-%08lx\n", memory_start, memory_end); BUG_ON(memory_start == memory_end); init_mm.start_code = (unsigned long) &_stext; init_mm.end_code = (unsigned long) &_etext; init_mm.end_data = (unsigned long) &_edata;#if 0 /* DAVIDM - don't set brk just incase someone decides to use it */ init_mm.brk = (unsigned long) &_end;#else init_mm.brk = (unsigned long) 0;#endif#ifdef DEBUG printk("KERNEL -> TEXT=0x%06x-0x%06x DATA=0x%06x-0x%06x BSS=0x%06x-0x%06x\n", (int) &_stext, (int) &_etext, (int) &_sdata, (int) &_edata, (int) &_sbss, (int) &_ebss);#endif#ifdef CONFIG_VT#if defined(CONFIG_VGA_CONSOLE) conswitchp = &vga_con;#elif defined(CONFIG_DUMMY_CONSOLE) conswitchp = &dummy_con;#endif#endif#ifdef CONFIG_MMU setup_linux_memory();#else setup_uclinux_memory();#endif /* get kmalloc into gear */ paging_init(); /* init DMA */ frv_dma_init();#ifdef DEBUG printk("Done setup_arch\n");#endif /* start the decrement timer running */// asm volatile("movgs %0,timerd" :: "r"(10000000));// __set_HSR(0, __get_HSR(0) | HSR0_ETMD);} /* end setup_arch() */#if 0/*****************************************************************************//* * */static int __devinit setup_arch_serial(void){ /* register those serial ports that are available */#ifndef CONFIG_GDBSTUB_UART0 early_serial_setup(&__frv_uart0);#endif#ifndef CONFIG_GDBSTUB_UART1 early_serial_setup(&__frv_uart1);#endif return 0;} /* end setup_arch_serial() */late_initcall(setup_arch_serial);#endif/*****************************************************************************//* * set up the memory map for normal MMU linux */#ifdef CONFIG_MMUstatic void __init setup_linux_memory(void){ unsigned long bootmap_size, low_top_pfn, kstart, kend, high_mem; kstart = (unsigned long) &__kernel_image_start - PAGE_OFFSET; kend = (unsigned long) &__kernel_image_end - PAGE_OFFSET; kstart = kstart & PAGE_MASK; kend = (kend + PAGE_SIZE - 1) & PAGE_MASK; /* give all the memory to the bootmap allocator, tell it to put the * boot mem_map immediately following the kernel image */ bootmap_size = init_bootmem_node(NODE_DATA(0), kend >> PAGE_SHIFT, /* map addr */ memory_start >> PAGE_SHIFT, /* start of RAM */ memory_end >> PAGE_SHIFT /* end of RAM */ ); /* pass the memory that the kernel can immediately use over to the bootmem allocator */ max_mapnr = num_physpages = (memory_end - memory_start) >> PAGE_SHIFT; low_top_pfn = (KERNEL_LOWMEM_END - KERNEL_LOWMEM_START) >> PAGE_SHIFT; high_mem = 0; if (num_physpages > low_top_pfn) {#ifdef CONFIG_HIGHMEM high_mem = num_physpages - low_top_pfn;#else max_mapnr = num_physpages = low_top_pfn;#endif } else { low_top_pfn = num_physpages; } min_low_pfn = memory_start >> PAGE_SHIFT; max_low_pfn = low_top_pfn; max_pfn = memory_end >> PAGE_SHIFT; num_mappedpages = low_top_pfn; printk(KERN_NOTICE "%ldMB LOWMEM available.\n", low_top_pfn >> (20 - PAGE_SHIFT)); free_bootmem(memory_start, low_top_pfn << PAGE_SHIFT);#ifdef CONFIG_HIGHMEM if (high_mem) printk(KERN_NOTICE "%ldMB HIGHMEM available.\n", high_mem >> (20 - PAGE_SHIFT));#endif /* take back the memory occupied by the kernel image and the bootmem alloc map */ reserve_bootmem(kstart, kend - kstart + bootmap_size); /* reserve the memory occupied by the initial ramdisk */#ifdef CONFIG_BLK_DEV_INITRD if (LOADER_TYPE && INITRD_START) { if (INITRD_START + INITRD_SIZE <= (low_top_pfn << PAGE_SHIFT)) { reserve_bootmem(INITRD_START, INITRD_SIZE); initrd_start = INITRD_START + PAGE_OFFSET; initrd_end = initrd_start + INITRD_SIZE; } else { printk(KERN_ERR "initrd extends beyond end of memory (0x%08lx > 0x%08lx)\n" "disabling initrd\n", INITRD_START + INITRD_SIZE, low_top_pfn << PAGE_SHIFT); initrd_start = 0; } }#endif} /* end setup_linux_memory() */#endif/*****************************************************************************//* * set up the memory map for uClinux */#ifndef CONFIG_MMUstatic void __init setup_uclinux_memory(void){#ifdef CONFIG_PROTECT_KERNEL unsigned long dampr;#endif unsigned long kend; int bootmap_size; kend = (unsigned long) &__kernel_image_end; kend = (kend + PAGE_SIZE - 1) & PAGE_MASK; /* give all the memory to the bootmap allocator, tell it to put the * boot mem_map immediately following the kernel image */ bootmap_size = init_bootmem_node(NODE_DATA(0), kend >> PAGE_SHIFT, /* map addr */ memory_start >> PAGE_SHIFT, /* start of RAM */ memory_end >> PAGE_SHIFT /* end of RAM */ ); /* free all the usable memory */ free_bootmem(memory_start, memory_end - memory_start); high_memory = (void *) (memory_end & PAGE_MASK); max_mapnr = num_physpages = ((unsigned long) high_memory - PAGE_OFFSET) >> PAGE_SHIFT; min_low_pfn = memory_start >> PAGE_SHIFT; max_low_pfn = memory_end >> PAGE_SHIFT; max_pfn = max_low_pfn; /* now take back the bits the core kernel is occupying */#ifndef CONFIG_PROTECT_KERNEL reserve_bootmem(kend, bootmap_size); reserve_bootmem((unsigned long) &__kernel_image_start, kend - (unsigned long) &__kernel_image_start);#else dampr = __get_DAMPR(0); dampr &= xAMPRx_SS; dampr = (dampr >> 4) + 17; dampr = 1 << dampr; reserve_bootmem(__get_DAMPR(0) & xAMPRx_PPFN, dampr);#endif /* reserve some memory to do uncached DMA through if requested */#ifdef CONFIG_RESERVE_DMA_COHERENT if (dma_coherent_mem_start) reserve_bootmem(dma_coherent_mem_start, dma_coherent_mem_end - dma_coherent_mem_start);#endif} /* end setup_uclinux_memory() */#endif/*****************************************************************************//* * get CPU information for use by procfs */static int show_cpuinfo(struct seq_file *m, void *v){ const char *gr, *fr, *fm, *fp, *cm, *nem, *ble;#ifdef CONFIG_PM const char *sep;#endif gr = cpu_hsr0_all & HSR0_GRHE ? "gr0-63" : "gr0-31"; fr = cpu_hsr0_all & HSR0_FRHE ? "fr0-63" : "fr0-31"; fm = cpu_psr_all & PSR_EM ? ", Media" : ""; fp = cpu_psr_all & PSR_EF ? ", FPU" : ""; cm = cpu_psr_all & PSR_CM ? ", CCCR" : ""; nem = cpu_psr_all & PSR_NEM ? ", NE" : ""; ble = cpu_psr_all & PSR_BE ? "BE" : "LE"; seq_printf(m, "CPU-Series:\t%s\n" "CPU-Core:\t%s, %s, %s%s%s\n" "CPU:\t\t%s\n" "MMU:\t\t%s\n" "FP-Media:\t%s%s%s\n" "System:\t\t%s", cpu_series, cpu_core, gr, ble, cm, nem, cpu_silicon, cpu_mmu, fr, fm, fp, cpu_system); if (cpu_board1) seq_printf(m, ", %s", cpu_board1); if (cpu_board2) seq_printf(m, ", %s", cpu_board2); seq_printf(m, "\n");#ifdef CONFIG_PM seq_printf(m, "PM-Controls:"); sep = "\t"; if (clock_bits_settable & CLOCK_BIT_CMODE) { seq_printf(m, "%scmode=0x%04hx", sep, clock_cmodes_permitted); sep = ", "; } if (clock_bits_settable & CLOCK_BIT_CM) { seq_printf(m, "%scm=0x%lx", sep, clock_bits_settable & CLOCK_BIT_CM); sep = ", "; } if (clock_bits_settable & CLOCK_BIT_P0) { seq_printf(m, "%sp0=0x3", sep); sep = ", "; } seq_printf(m, "%ssuspend=0x22\n", sep);#endif seq_printf(m, "PM-Status:\tcmode=%d, cm=%d, p0=%d\n", clock_cmode_current, clock_cm_current, clock_p0_current);#define print_clk(TAG, VAR) \ seq_printf(m, "Clock-" TAG ":\t%lu.%2.2lu MHz\n", VAR / 1000000, (VAR / 10000) % 100) print_clk("In", __clkin_clock_speed_HZ); print_clk("Core", __core_clock_speed_HZ); print_clk("SDRAM", __sdram_clock_speed_HZ); print_clk("CBus", __core_bus_clock_speed_HZ); print_clk("Res", __res_bus_clock_speed_HZ); print_clk("Ext", __ext_bus_clock_speed_HZ); print_clk("DSU", __dsu_clock_speed_HZ); seq_printf(m, "BogoMips:\t%lu.%02lu\n", (loops_per_jiffy * HZ) / 500000, ((loops_per_jiffy * HZ) / 5000) % 100); return 0;} /* end show_cpuinfo() */static void *c_start(struct seq_file *m, loff_t *pos){ return *pos < NR_CPUS ? (void *) 0x12345678 : NULL;}static void *c_next(struct seq_file *m, void *v, loff_t *pos){ ++*pos; return c_start(m, pos);}static void c_stop(struct seq_file *m, void *v){}struct seq_operations cpuinfo_op = { .start = c_start, .next = c_next, .stop = c_stop, .show = show_cpuinfo,};void arch_gettod(int *year, int *mon, int *day, int *hour, int *min, int *sec){ *year = *mon = *day = *hour = *min = *sec = 0;}/*****************************************************************************//* * */#ifdef CONFIG_MB93090_MB00static void __init mb93090_sendlcdcmd(uint32_t cmd){ unsigned long base = __addr_LCD(); int loop; /* request reading of the busy flag */ __set_LCD(base, LCD_CMD_READ_BUSY); __set_LCD(base, LCD_CMD_READ_BUSY & ~LCD_E); /* wait for the busy flag to become clear */ for (loop = 10000; loop > 0; loop--) if (!(__get_LCD(base) & 0x80)) break; /* send the command */ __set_LCD(base, cmd); __set_LCD(base, cmd & ~LCD_E);} /* end mb93090_sendlcdcmd() *//*****************************************************************************//* * write to the MB93090 LEDs and LCD */static void __init mb93090_display(void){ const char *p; __set_LEDS(0); /* set up the LCD */ mb93090_sendlcdcmd(LCD_CMD_CLEAR); mb93090_sendlcdcmd(LCD_CMD_FUNCSET(1,1,0)); mb93090_sendlcdcmd(LCD_CMD_ON(0,0)); mb93090_sendlcdcmd(LCD_CMD_HOME); mb93090_sendlcdcmd(LCD_CMD_SET_DD_ADDR(0)); for (p = mb93090_banner; *p; p++) mb93090_sendlcdcmd(LCD_DATA_WRITE(*p)); mb93090_sendlcdcmd(LCD_CMD_SET_DD_ADDR(64)); for (p = mb93090_version; *p; p++) mb93090_sendlcdcmd(LCD_DATA_WRITE(*p));} /* end mb93090_display() */#endif // CONFIG_MB93090_MB00
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -