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

📄 init.c

📁 内核linux2.4.20,可跟rtlinux3.2打补丁 组成实时linux系统,编译内核
💻 C
📖 第 1 页 / 共 2 页
字号:
/* *  linux/arch/cris/mm/init.c * *  Copyright (C) 1995  Linus Torvalds *  Copyright (C) 2000,2001  Axis Communications AB * *  Authors:  Bjorn Wesen (bjornw@axis.com) * *  $Log: init.c,v $ *  Revision 1.31  2001/11/13 16:22:00  bjornw *  Skip calculating totalram and sharedram in si_meminfo * *  Revision 1.30  2001/11/12 19:02:10  pkj *  Fixed compiler warnings. * *  Revision 1.29  2001/07/25 16:09:50  bjornw *  val->sharedram will stay 0 * *  Revision 1.28  2001/06/28 16:30:17  bjornw *  Oops. This needs to wait until 2.4.6 is merged * *  Revision 1.27  2001/06/28 14:04:07  bjornw *  Fill in sharedram * *  Revision 1.26  2001/06/18 06:36:02  hp *  Enable free_initmem of __init-type pages * *  Revision 1.25  2001/06/13 00:02:23  bjornw *  Use a separate variable to store the current pgd to avoid races in schedule * *  Revision 1.24  2001/05/15 00:52:20  hp *  Only map segment 0xa as seg if CONFIG_JULIETTE * *  Revision 1.23  2001/04/04 14:35:40  bjornw *  * Removed get_pte_slow and friends (2.4.3 change) *  * Removed bad_pmd handling (2.4.3 change) * *  Revision 1.22  2001/04/04 13:38:04  matsfg *  Moved ioremap to a separate function instead * *  Revision 1.21  2001/03/27 09:28:33  bjornw *  ioremap used too early - lets try it in mem_init instead * *  Revision 1.20  2001/03/23 07:39:21  starvik *  Corrected according to review remarks * *  Revision 1.19  2001/03/15 14:25:17  bjornw *  More general shadow registers and ioremaped addresses for external I/O * *  Revision 1.18  2001/02/23 12:46:44  bjornw *  * 0xc was not CSE1; 0x8 is, same as uncached flash, so we move the uncached *    flash during CRIS_LOW_MAP from 0xe to 0x8 so both the flash and the I/O *    is mapped straight over (for !CRIS_LOW_MAP the uncached flash is still 0xe) * *  Revision 1.17  2001/02/22 15:05:21  bjornw *  Map 0x9 straight over during LOW_MAP to allow for memory mapped LEDs * *  Revision 1.16  2001/02/22 15:02:35  bjornw *  Map 0xc straight over during LOW_MAP to allow for memory mapped I/O * *  Revision 1.15  2001/01/10 21:12:10  bjornw *  loops_per_sec -> loops_per_jiffy * *  Revision 1.14  2000/11/22 16:23:20  bjornw *  Initialize totalhigh counters to 0 to make /proc/meminfo look nice. * *  Revision 1.13  2000/11/21 16:37:51  bjornw *  Temporarily disable initmem freeing * *  Revision 1.12  2000/11/21 13:55:07  bjornw *  Use CONFIG_CRIS_LOW_MAP for the low VM map instead of explicit CPU type * *  Revision 1.11  2000/10/06 12:38:22  bjornw *  Cast empty_bad_page correctly (should really be of * type from the start.. * *  Revision 1.10  2000/10/04 16:53:57  bjornw *  Fix memory-map due to LX features * *  Revision 1.9  2000/09/13 15:47:49  bjornw *  Wrong count in reserved-pages loop * *  Revision 1.8  2000/09/13 14:35:10  bjornw *  2.4.0-test8 added a new arg to free_area_init_node * *  Revision 1.7  2000/08/17 15:35:55  bjornw *  2.4.0-test6 removed MAP_NR and inserted virt_to_page * * */#include <linux/config.h>#include <linux/signal.h>#include <linux/sched.h>#include <linux/kernel.h>#include <linux/errno.h>#include <linux/string.h>#include <linux/types.h>#include <linux/ptrace.h>#include <linux/mman.h>#include <linux/mm.h>#include <linux/swap.h>#include <linux/smp.h>#include <linux/bootmem.h>#include <asm/system.h>#include <asm/segment.h>#include <asm/pgalloc.h>#include <asm/pgtable.h>#include <asm/dma.h>#include <asm/svinto.h>#include <asm/io.h>#include <asm/mmu_context.h>static unsigned long totalram_pages;struct pgtable_cache_struct quicklists;  /* see asm/pgalloc.h */const char bad_pmd_string[] = "Bad pmd in pte_alloc: %08lx\n";extern void die_if_kernel(char *,struct pt_regs *,long);extern void show_net_buffers(void);extern void tlb_init(void);unsigned long empty_zero_page;/* trim the page-table cache if necessary */int do_check_pgt_cache(int low, int high){        int freed = 0;        if(pgtable_cache_size > high) {                do {                        if(pgd_quicklist) {                                free_pgd_slow(get_pgd_fast());                                freed++;                        }                        if(pmd_quicklist) {                                pmd_free_slow(pmd_alloc_one_fast(NULL, 0));                                freed++;                        }                        if(pte_quicklist) {                                pte_free_slow(pte_alloc_one_fast(NULL, 0));				freed++;                        }                } while(pgtable_cache_size > low);        }        return freed;}void show_mem(void){	int i,free = 0,total = 0,cached = 0, reserved = 0, nonshared = 0;	int shared = 0;	printk("\nMem-info:\n");	show_free_areas();	printk("Free swap:       %6dkB\n",nr_swap_pages<<(PAGE_SHIFT-10));	i = max_mapnr;	while (i-- > 0) {		total++;		if (PageReserved(mem_map+i))			reserved++;		else if (PageSwapCache(mem_map+i))			cached++;		else if (!page_count(mem_map+i))			free++;		else if (page_count(mem_map+i) == 1)			nonshared++;		else			shared += page_count(mem_map+i) - 1;	}	printk("%d pages of RAM\n",total);	printk("%d free pages\n",free);	printk("%d reserved pages\n",reserved);	printk("%d pages nonshared\n",nonshared);	printk("%d pages shared\n",shared);	printk("%d pages swap cached\n",cached);	printk("%ld pages in page table cache\n",pgtable_cache_size);	show_buffers();}/* * The kernel is already mapped with a kernel segment at kseg_c so  * we don't need to map it with a page table. However head.S also * temporarily mapped it at kseg_4 so we should set up the ksegs again, * clear the TLB and do some other paging setup stuff. */void __init paging_init(void){	int i;	unsigned long zones_size[MAX_NR_ZONES];	printk("Setting up paging and the MMU.\n");		/* clear out the init_mm.pgd that will contain the kernel's mappings */	for(i = 0; i < PTRS_PER_PGD; i++)		swapper_pg_dir[i] = __pgd(0);		/* make sure the current pgd table points to something sane	 * (even if it is most probably not used until the next 	 *  switch_mm)	 */	current_pgd = init_mm.pgd;	/* initialise the TLB (tlb.c) */	tlb_init();	/* see README.mm for details on the KSEG setup */#ifndef CONFIG_CRIS_LOW_MAP	/* This code is for the corrected Etrax-100 LX version 2... */	*R_MMU_KSEG = ( IO_STATE(R_MMU_KSEG, seg_f, seg  ) | /* cached flash */			IO_STATE(R_MMU_KSEG, seg_e, seg  ) | /* uncached flash */			IO_STATE(R_MMU_KSEG, seg_d, page ) | /* vmalloc area */			IO_STATE(R_MMU_KSEG, seg_c, seg  ) | /* kernel area */			IO_STATE(R_MMU_KSEG, seg_b, seg  ) | /* kernel reg area */			IO_STATE(R_MMU_KSEG, seg_a, page ) | /* user area */			IO_STATE(R_MMU_KSEG, seg_9, page ) |			IO_STATE(R_MMU_KSEG, seg_8, page ) |			IO_STATE(R_MMU_KSEG, seg_7, page ) |			IO_STATE(R_MMU_KSEG, seg_6, page ) |			IO_STATE(R_MMU_KSEG, seg_5, page ) |			IO_STATE(R_MMU_KSEG, seg_4, page ) |			IO_STATE(R_MMU_KSEG, seg_3, page ) |			IO_STATE(R_MMU_KSEG, seg_2, page ) |			IO_STATE(R_MMU_KSEG, seg_1, page ) |			IO_STATE(R_MMU_KSEG, seg_0, page ) );	*R_MMU_KBASE_HI = ( IO_FIELD(R_MMU_KBASE_HI, base_f, 0x0 ) |			    IO_FIELD(R_MMU_KBASE_HI, base_e, 0x8 ) |			    IO_FIELD(R_MMU_KBASE_HI, base_d, 0x0 ) |			    IO_FIELD(R_MMU_KBASE_HI, base_c, 0x4 ) |

⌨️ 快捷键说明

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