xref: /OK3568_Linux_fs/kernel/arch/c6x/mm/init.c (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun // SPDX-License-Identifier: GPL-2.0-only
2*4882a593Smuzhiyun /*
3*4882a593Smuzhiyun  *  Port on Texas Instruments TMS320C6x architecture
4*4882a593Smuzhiyun  *
5*4882a593Smuzhiyun  *  Copyright (C) 2004, 2009, 2010, 2011 Texas Instruments Incorporated
6*4882a593Smuzhiyun  *  Author: Aurelien Jacquiot (aurelien.jacquiot@jaluna.com)
7*4882a593Smuzhiyun  */
8*4882a593Smuzhiyun #include <linux/mm.h>
9*4882a593Smuzhiyun #include <linux/swap.h>
10*4882a593Smuzhiyun #include <linux/module.h>
11*4882a593Smuzhiyun #include <linux/memblock.h>
12*4882a593Smuzhiyun #ifdef CONFIG_BLK_DEV_RAM
13*4882a593Smuzhiyun #include <linux/blkdev.h>
14*4882a593Smuzhiyun #endif
15*4882a593Smuzhiyun #include <linux/initrd.h>
16*4882a593Smuzhiyun 
17*4882a593Smuzhiyun #include <asm/sections.h>
18*4882a593Smuzhiyun #include <linux/uaccess.h>
19*4882a593Smuzhiyun 
20*4882a593Smuzhiyun /*
21*4882a593Smuzhiyun  * ZERO_PAGE is a special page that is used for zero-initialized
22*4882a593Smuzhiyun  * data and COW.
23*4882a593Smuzhiyun  */
24*4882a593Smuzhiyun unsigned long empty_zero_page;
25*4882a593Smuzhiyun EXPORT_SYMBOL(empty_zero_page);
26*4882a593Smuzhiyun 
27*4882a593Smuzhiyun /*
28*4882a593Smuzhiyun  * paging_init() continues the virtual memory environment setup which
29*4882a593Smuzhiyun  * was begun by the code in arch/head.S.
30*4882a593Smuzhiyun  * The parameters are pointers to where to stick the starting and ending
31*4882a593Smuzhiyun  * addresses  of available kernel virtual memory.
32*4882a593Smuzhiyun  */
paging_init(void)33*4882a593Smuzhiyun void __init paging_init(void)
34*4882a593Smuzhiyun {
35*4882a593Smuzhiyun 	struct pglist_data *pgdat = NODE_DATA(0);
36*4882a593Smuzhiyun 	unsigned long max_zone_pfn[MAX_NR_ZONES] = {0, };
37*4882a593Smuzhiyun 
38*4882a593Smuzhiyun 	empty_zero_page      = (unsigned long) memblock_alloc(PAGE_SIZE,
39*4882a593Smuzhiyun 							      PAGE_SIZE);
40*4882a593Smuzhiyun 	if (!empty_zero_page)
41*4882a593Smuzhiyun 		panic("%s: Failed to allocate %lu bytes align=0x%lx\n",
42*4882a593Smuzhiyun 		      __func__, PAGE_SIZE, PAGE_SIZE);
43*4882a593Smuzhiyun 
44*4882a593Smuzhiyun 	/*
45*4882a593Smuzhiyun 	 * Set up user data space
46*4882a593Smuzhiyun 	 */
47*4882a593Smuzhiyun 	set_fs(KERNEL_DS);
48*4882a593Smuzhiyun 
49*4882a593Smuzhiyun 	/*
50*4882a593Smuzhiyun 	 * Define zones
51*4882a593Smuzhiyun 	 */
52*4882a593Smuzhiyun 	max_zone_pfn[ZONE_NORMAL] = memory_end >> PAGE_SHIFT;
53*4882a593Smuzhiyun 
54*4882a593Smuzhiyun 	free_area_init(max_zone_pfn);
55*4882a593Smuzhiyun }
56*4882a593Smuzhiyun 
mem_init(void)57*4882a593Smuzhiyun void __init mem_init(void)
58*4882a593Smuzhiyun {
59*4882a593Smuzhiyun 	high_memory = (void *)(memory_end & PAGE_MASK);
60*4882a593Smuzhiyun 
61*4882a593Smuzhiyun 	/* this will put all memory onto the freelists */
62*4882a593Smuzhiyun 	memblock_free_all();
63*4882a593Smuzhiyun 
64*4882a593Smuzhiyun 	mem_init_print_info(NULL);
65*4882a593Smuzhiyun }
66