Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * linux/arch/cris/mm/init.c |
| 3 | * |
| 4 | * Copyright (C) 1995 Linus Torvalds |
| 5 | * Copyright (C) 2000,2001 Axis Communications AB |
| 6 | * |
| 7 | * Authors: Bjorn Wesen (bjornw@axis.com) |
| 8 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 9 | */ |
| 10 | |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 11 | #include <linux/gfp.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 12 | #include <linux/init.h> |
| 13 | #include <linux/bootmem.h> |
Jesper Nilsson | 80d6170 | 2014-10-07 13:03:17 +0200 | [diff] [blame] | 14 | #include <linux/proc_fs.h> |
| 15 | #include <linux/kcore.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 16 | #include <asm/tlb.h> |
Jiang Liu | 2e52981 | 2013-04-29 15:06:36 -0700 | [diff] [blame] | 17 | #include <asm/sections.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 18 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 19 | unsigned long empty_zero_page; |
Jesper Nilsson | 80d6170 | 2014-10-07 13:03:17 +0200 | [diff] [blame] | 20 | EXPORT_SYMBOL(empty_zero_page); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 21 | |
Jesper Nilsson | 80d6170 | 2014-10-07 13:03:17 +0200 | [diff] [blame] | 22 | void __init mem_init(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 23 | { |
Stoyan Gaydarov | 59b9776 | 2009-03-10 06:10:40 +0100 | [diff] [blame] | 24 | BUG_ON(!mem_map); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 25 | |
| 26 | /* max/min_low_pfn was set by setup.c |
| 27 | * now we just copy it to some other necessary places... |
| 28 | * |
| 29 | * high_memory was also set in setup.c |
| 30 | */ |
Jiang Liu | 4e422de | 2013-07-03 15:03:54 -0700 | [diff] [blame] | 31 | max_mapnr = max_low_pfn - min_low_pfn; |
Jiang Liu | 0c98853 | 2013-07-03 15:03:24 -0700 | [diff] [blame] | 32 | free_all_bootmem(); |
Jiang Liu | 4e422de | 2013-07-03 15:03:54 -0700 | [diff] [blame] | 33 | mem_init_print_info(NULL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 34 | } |
| 35 | |
Jesper Nilsson | 80d6170 | 2014-10-07 13:03:17 +0200 | [diff] [blame] | 36 | /* Free a range of init pages. Virtual addresses. */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 37 | |
Jesper Nilsson | 80d6170 | 2014-10-07 13:03:17 +0200 | [diff] [blame] | 38 | void free_init_pages(const char *what, unsigned long begin, unsigned long end) |
| 39 | { |
| 40 | unsigned long addr; |
| 41 | |
| 42 | for (addr = begin; addr < end; addr += PAGE_SIZE) { |
| 43 | ClearPageReserved(virt_to_page(addr)); |
| 44 | init_page_count(virt_to_page(addr)); |
| 45 | free_page(addr); |
| 46 | totalram_pages++; |
| 47 | } |
| 48 | |
| 49 | printk(KERN_INFO "Freeing %s: %ldk freed\n", what, (end - begin) >> 10); |
| 50 | } |
| 51 | |
| 52 | /* Free the pages occupied by initialization code. */ |
| 53 | |
| 54 | void free_initmem(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 55 | { |
Jiang Liu | dbe67df | 2013-07-03 15:02:51 -0700 | [diff] [blame] | 56 | free_initmem_default(-1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 57 | } |
Jesper Nilsson | 80d6170 | 2014-10-07 13:03:17 +0200 | [diff] [blame] | 58 | |
| 59 | /* Free the pages occupied by initrd code. */ |
| 60 | |
| 61 | #ifdef CONFIG_BLK_DEV_INITRD |
| 62 | void free_initrd_mem(unsigned long start, unsigned long end) |
| 63 | { |
| 64 | free_init_pages("initrd memory", |
| 65 | start, |
| 66 | end); |
| 67 | } |
| 68 | #endif |