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