blob: 1e7fd45b60f82af0beefb2c609151a3879a2b6a7 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
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 Torvalds1da177e2005-04-16 15:20:36 -07009 */
10
Tejun Heo5a0e3ad2010-03-24 17:04:11 +090011#include <linux/gfp.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070012#include <linux/init.h>
13#include <linux/bootmem.h>
Jesper Nilsson80d61702014-10-07 13:03:17 +020014#include <linux/proc_fs.h>
15#include <linux/kcore.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070016#include <asm/tlb.h>
Jiang Liu2e529812013-04-29 15:06:36 -070017#include <asm/sections.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070018
Linus Torvalds1da177e2005-04-16 15:20:36 -070019unsigned long empty_zero_page;
Jesper Nilsson80d61702014-10-07 13:03:17 +020020EXPORT_SYMBOL(empty_zero_page);
Linus Torvalds1da177e2005-04-16 15:20:36 -070021
Jesper Nilsson80d61702014-10-07 13:03:17 +020022void __init mem_init(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -070023{
Stoyan Gaydarov59b97762009-03-10 06:10:40 +010024 BUG_ON(!mem_map);
Linus Torvalds1da177e2005-04-16 15:20:36 -070025
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 Liu4e422de2013-07-03 15:03:54 -070031 max_mapnr = max_low_pfn - min_low_pfn;
Jiang Liu0c988532013-07-03 15:03:24 -070032 free_all_bootmem();
Jiang Liu4e422de2013-07-03 15:03:54 -070033 mem_init_print_info(NULL);
Linus Torvalds1da177e2005-04-16 15:20:36 -070034}
35
Jesper Nilsson80d61702014-10-07 13:03:17 +020036/* Free a range of init pages. Virtual addresses. */
Linus Torvalds1da177e2005-04-16 15:20:36 -070037
Jesper Nilsson80d61702014-10-07 13:03:17 +020038void 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
54void free_initmem(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -070055{
Jiang Liudbe67df2013-07-03 15:02:51 -070056 free_initmem_default(-1);
Linus Torvalds1da177e2005-04-16 15:20:36 -070057}
Jesper Nilsson80d61702014-10-07 13:03:17 +020058
59/* Free the pages occupied by initrd code. */
60
61#ifdef CONFIG_BLK_DEV_INITRD
62void free_initrd_mem(unsigned long start, unsigned long end)
63{
64 free_init_pages("initrd memory",
65 start,
66 end);
67}
68#endif