VisionFive2 Linux kernel

StarFive Tech Linux Kernel for VisionFive (JH7110) boards (mirror)

More than 9999 Commits   32 Branches   54 Tags
b24413180f560 (Greg Kroah-Hartman 2017-11-01 15:07:57 +0100   1) // SPDX-License-Identifier: GPL-2.0
bbeb79acb3b44 (Yoshinori Sato     2015-01-28 02:47:36 +0900   2) /*
bbeb79acb3b44 (Yoshinori Sato     2015-01-28 02:47:36 +0900   3)  *  linux/arch/h8300/mm/init.c
bbeb79acb3b44 (Yoshinori Sato     2015-01-28 02:47:36 +0900   4)  *
bbeb79acb3b44 (Yoshinori Sato     2015-01-28 02:47:36 +0900   5)  *  Copyright (C) 1998  D. Jeff Dionne <jeff@lineo.ca>,
bbeb79acb3b44 (Yoshinori Sato     2015-01-28 02:47:36 +0900   6)  *                      Kenneth Albanowski <kjahds@kjahds.com>,
bbeb79acb3b44 (Yoshinori Sato     2015-01-28 02:47:36 +0900   7)  *  Copyright (C) 2000  Lineo, Inc.  (www.lineo.com)
bbeb79acb3b44 (Yoshinori Sato     2015-01-28 02:47:36 +0900   8)  *
bbeb79acb3b44 (Yoshinori Sato     2015-01-28 02:47:36 +0900   9)  *  Based on:
bbeb79acb3b44 (Yoshinori Sato     2015-01-28 02:47:36 +0900  10)  *
bbeb79acb3b44 (Yoshinori Sato     2015-01-28 02:47:36 +0900  11)  *  linux/arch/m68knommu/mm/init.c
bbeb79acb3b44 (Yoshinori Sato     2015-01-28 02:47:36 +0900  12)  *  linux/arch/m68k/mm/init.c
bbeb79acb3b44 (Yoshinori Sato     2015-01-28 02:47:36 +0900  13)  *
bbeb79acb3b44 (Yoshinori Sato     2015-01-28 02:47:36 +0900  14)  *  Copyright (C) 1995  Hamish Macdonald
bbeb79acb3b44 (Yoshinori Sato     2015-01-28 02:47:36 +0900  15)  *
bbeb79acb3b44 (Yoshinori Sato     2015-01-28 02:47:36 +0900  16)  *  JAN/1999 -- hacked to support ColdFire (gerg@snapgear.com)
bbeb79acb3b44 (Yoshinori Sato     2015-01-28 02:47:36 +0900  17)  *  DEC/2000 -- linux 2.4 support <davidm@snapgear.com>
bbeb79acb3b44 (Yoshinori Sato     2015-01-28 02:47:36 +0900  18)  */
bbeb79acb3b44 (Yoshinori Sato     2015-01-28 02:47:36 +0900  19) 
bbeb79acb3b44 (Yoshinori Sato     2015-01-28 02:47:36 +0900  20) #include <linux/signal.h>
bbeb79acb3b44 (Yoshinori Sato     2015-01-28 02:47:36 +0900  21) #include <linux/sched.h>
bbeb79acb3b44 (Yoshinori Sato     2015-01-28 02:47:36 +0900  22) #include <linux/kernel.h>
bbeb79acb3b44 (Yoshinori Sato     2015-01-28 02:47:36 +0900  23) #include <linux/errno.h>
bbeb79acb3b44 (Yoshinori Sato     2015-01-28 02:47:36 +0900  24) #include <linux/string.h>
bbeb79acb3b44 (Yoshinori Sato     2015-01-28 02:47:36 +0900  25) #include <linux/types.h>
bbeb79acb3b44 (Yoshinori Sato     2015-01-28 02:47:36 +0900  26) #include <linux/ptrace.h>
bbeb79acb3b44 (Yoshinori Sato     2015-01-28 02:47:36 +0900  27) #include <linux/mman.h>
bbeb79acb3b44 (Yoshinori Sato     2015-01-28 02:47:36 +0900  28) #include <linux/mm.h>
bbeb79acb3b44 (Yoshinori Sato     2015-01-28 02:47:36 +0900  29) #include <linux/swap.h>
bbeb79acb3b44 (Yoshinori Sato     2015-01-28 02:47:36 +0900  30) #include <linux/init.h>
bbeb79acb3b44 (Yoshinori Sato     2015-01-28 02:47:36 +0900  31) #include <linux/highmem.h>
bbeb79acb3b44 (Yoshinori Sato     2015-01-28 02:47:36 +0900  32) #include <linux/pagemap.h>
57c8a661d95df (Mike Rapoport      2018-10-30 15:09:49 -0700  33) #include <linux/memblock.h>
bbeb79acb3b44 (Yoshinori Sato     2015-01-28 02:47:36 +0900  34) #include <linux/gfp.h>
bbeb79acb3b44 (Yoshinori Sato     2015-01-28 02:47:36 +0900  35) 
bbeb79acb3b44 (Yoshinori Sato     2015-01-28 02:47:36 +0900  36) #include <asm/setup.h>
bbeb79acb3b44 (Yoshinori Sato     2015-01-28 02:47:36 +0900  37) #include <asm/segment.h>
bbeb79acb3b44 (Yoshinori Sato     2015-01-28 02:47:36 +0900  38) #include <asm/page.h>
bbeb79acb3b44 (Yoshinori Sato     2015-01-28 02:47:36 +0900  39) #include <asm/sections.h>
bbeb79acb3b44 (Yoshinori Sato     2015-01-28 02:47:36 +0900  40) 
bbeb79acb3b44 (Yoshinori Sato     2015-01-28 02:47:36 +0900  41) /*
bbeb79acb3b44 (Yoshinori Sato     2015-01-28 02:47:36 +0900  42)  * ZERO_PAGE is a special page that is used for zero-initialized
bbeb79acb3b44 (Yoshinori Sato     2015-01-28 02:47:36 +0900  43)  * data and COW.
bbeb79acb3b44 (Yoshinori Sato     2015-01-28 02:47:36 +0900  44)  */
bbeb79acb3b44 (Yoshinori Sato     2015-01-28 02:47:36 +0900  45) unsigned long empty_zero_page;
bbeb79acb3b44 (Yoshinori Sato     2015-01-28 02:47:36 +0900  46) 
bbeb79acb3b44 (Yoshinori Sato     2015-01-28 02:47:36 +0900  47) /*
bbeb79acb3b44 (Yoshinori Sato     2015-01-28 02:47:36 +0900  48)  * paging_init() continues the virtual memory environment setup which
bbeb79acb3b44 (Yoshinori Sato     2015-01-28 02:47:36 +0900  49)  * was begun by the code in arch/head.S.
bbeb79acb3b44 (Yoshinori Sato     2015-01-28 02:47:36 +0900  50)  * The parameters are pointers to where to stick the starting and ending
bbeb79acb3b44 (Yoshinori Sato     2015-01-28 02:47:36 +0900  51)  * addresses of available kernel virtual memory.
bbeb79acb3b44 (Yoshinori Sato     2015-01-28 02:47:36 +0900  52)  */
bbeb79acb3b44 (Yoshinori Sato     2015-01-28 02:47:36 +0900  53) void __init paging_init(void)
bbeb79acb3b44 (Yoshinori Sato     2015-01-28 02:47:36 +0900  54) {
bbeb79acb3b44 (Yoshinori Sato     2015-01-28 02:47:36 +0900  55) 	/*
bbeb79acb3b44 (Yoshinori Sato     2015-01-28 02:47:36 +0900  56) 	 * Make sure start_mem is page aligned,  otherwise bootmem and
bbeb79acb3b44 (Yoshinori Sato     2015-01-28 02:47:36 +0900  57) 	 * page_alloc get different views og the world.
bbeb79acb3b44 (Yoshinori Sato     2015-01-28 02:47:36 +0900  58) 	 */
bbeb79acb3b44 (Yoshinori Sato     2015-01-28 02:47:36 +0900  59) 	unsigned long start_mem = PAGE_ALIGN(memory_start);
bbeb79acb3b44 (Yoshinori Sato     2015-01-28 02:47:36 +0900  60) 	unsigned long end_mem   = memory_end & PAGE_MASK;
bbeb79acb3b44 (Yoshinori Sato     2015-01-28 02:47:36 +0900  61) 
bbeb79acb3b44 (Yoshinori Sato     2015-01-28 02:47:36 +0900  62) 	pr_debug("start_mem is %#lx\nvirtual_end is %#lx\n",
bbeb79acb3b44 (Yoshinori Sato     2015-01-28 02:47:36 +0900  63) 		 start_mem, end_mem);
bbeb79acb3b44 (Yoshinori Sato     2015-01-28 02:47:36 +0900  64) 
bbeb79acb3b44 (Yoshinori Sato     2015-01-28 02:47:36 +0900  65) 	/*
bbeb79acb3b44 (Yoshinori Sato     2015-01-28 02:47:36 +0900  66) 	 * Initialize the bad page table and bad page to point
bbeb79acb3b44 (Yoshinori Sato     2015-01-28 02:47:36 +0900  67) 	 * to a couple of allocated pages.
bbeb79acb3b44 (Yoshinori Sato     2015-01-28 02:47:36 +0900  68) 	 */
15c3c114ed144 (Mike Rapoport      2018-10-30 15:08:58 -0700  69) 	empty_zero_page = (unsigned long)memblock_alloc(PAGE_SIZE, PAGE_SIZE);
8a7f97b902f4f (Mike Rapoport      2019-03-11 23:30:31 -0700  70) 	if (!empty_zero_page)
8a7f97b902f4f (Mike Rapoport      2019-03-11 23:30:31 -0700  71) 		panic("%s: Failed to allocate %lu bytes align=0x%lx\n",
8a7f97b902f4f (Mike Rapoport      2019-03-11 23:30:31 -0700  72) 		      __func__, PAGE_SIZE, PAGE_SIZE);
bbeb79acb3b44 (Yoshinori Sato     2015-01-28 02:47:36 +0900  73) 
bbeb79acb3b44 (Yoshinori Sato     2015-01-28 02:47:36 +0900  74) 	/*
bbeb79acb3b44 (Yoshinori Sato     2015-01-28 02:47:36 +0900  75) 	 * Set up SFC/DFC registers (user data space).
bbeb79acb3b44 (Yoshinori Sato     2015-01-28 02:47:36 +0900  76) 	 */
bbeb79acb3b44 (Yoshinori Sato     2015-01-28 02:47:36 +0900  77) 	set_fs(USER_DS);
bbeb79acb3b44 (Yoshinori Sato     2015-01-28 02:47:36 +0900  78) 
bbeb79acb3b44 (Yoshinori Sato     2015-01-28 02:47:36 +0900  79) 	pr_debug("before free_area_init\n");
bbeb79acb3b44 (Yoshinori Sato     2015-01-28 02:47:36 +0900  80) 
bbeb79acb3b44 (Yoshinori Sato     2015-01-28 02:47:36 +0900  81) 	pr_debug("free_area_init -> start_mem is %#lx\nvirtual_end is %#lx\n",
bbeb79acb3b44 (Yoshinori Sato     2015-01-28 02:47:36 +0900  82) 		 start_mem, end_mem);
bbeb79acb3b44 (Yoshinori Sato     2015-01-28 02:47:36 +0900  83) 
bbeb79acb3b44 (Yoshinori Sato     2015-01-28 02:47:36 +0900  84) 	{
fa3354e4ea39e (Mike Rapoport      2020-06-03 15:57:06 -0700  85) 		unsigned long max_zone_pfn[MAX_NR_ZONES] = {0, };
bbeb79acb3b44 (Yoshinori Sato     2015-01-28 02:47:36 +0900  86) 
fa3354e4ea39e (Mike Rapoport      2020-06-03 15:57:06 -0700  87) 		max_zone_pfn[ZONE_NORMAL] = end_mem >> PAGE_SHIFT;
fa3354e4ea39e (Mike Rapoport      2020-06-03 15:57:06 -0700  88) 		free_area_init(max_zone_pfn);
bbeb79acb3b44 (Yoshinori Sato     2015-01-28 02:47:36 +0900  89) 	}
bbeb79acb3b44 (Yoshinori Sato     2015-01-28 02:47:36 +0900  90) }
bbeb79acb3b44 (Yoshinori Sato     2015-01-28 02:47:36 +0900  91) 
bbeb79acb3b44 (Yoshinori Sato     2015-01-28 02:47:36 +0900  92) void __init mem_init(void)
bbeb79acb3b44 (Yoshinori Sato     2015-01-28 02:47:36 +0900  93) {
bbeb79acb3b44 (Yoshinori Sato     2015-01-28 02:47:36 +0900  94) 	pr_devel("Mem_init: start=%lx, end=%lx\n", memory_start, memory_end);
bbeb79acb3b44 (Yoshinori Sato     2015-01-28 02:47:36 +0900  95) 
bbeb79acb3b44 (Yoshinori Sato     2015-01-28 02:47:36 +0900  96) 	high_memory = (void *) (memory_end & PAGE_MASK);
bbeb79acb3b44 (Yoshinori Sato     2015-01-28 02:47:36 +0900  97) 	max_mapnr = MAP_NR(high_memory);
bbeb79acb3b44 (Yoshinori Sato     2015-01-28 02:47:36 +0900  98) 
bbeb79acb3b44 (Yoshinori Sato     2015-01-28 02:47:36 +0900  99) 	/* this will put all low memory onto the freelists */
c6ffc5ca8fb31 (Mike Rapoport      2018-10-30 15:09:30 -0700 100) 	memblock_free_all();
bbeb79acb3b44 (Yoshinori Sato     2015-01-28 02:47:36 +0900 101) }