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