2005-04-16 22:20:36 +00:00
|
|
|
/*
|
|
|
|
* linux/arch/m68k/mm/init.c
|
|
|
|
*
|
|
|
|
* Copyright (C) 1995 Hamish Macdonald
|
|
|
|
*
|
|
|
|
* Contains common initialization routines, specific init code moved
|
|
|
|
* to motorola.c and sun3mmu.c
|
|
|
|
*/
|
|
|
|
|
2007-05-31 07:40:54 +00:00
|
|
|
#include <linux/module.h>
|
2005-04-16 22:20:36 +00:00
|
|
|
#include <linux/signal.h>
|
|
|
|
#include <linux/sched.h>
|
|
|
|
#include <linux/mm.h>
|
|
|
|
#include <linux/swap.h>
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/string.h>
|
|
|
|
#include <linux/types.h>
|
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/bootmem.h>
|
|
|
|
|
|
|
|
#include <asm/setup.h>
|
|
|
|
#include <asm/uaccess.h>
|
|
|
|
#include <asm/page.h>
|
|
|
|
#include <asm/pgalloc.h>
|
|
|
|
#include <asm/system.h>
|
|
|
|
#include <asm/machdep.h>
|
|
|
|
#include <asm/io.h>
|
|
|
|
#ifdef CONFIG_ATARI
|
|
|
|
#include <asm/atari_stram.h>
|
|
|
|
#endif
|
2008-12-21 11:03:37 +00:00
|
|
|
#include <asm/sections.h>
|
2005-04-16 22:20:36 +00:00
|
|
|
#include <asm/tlb.h>
|
|
|
|
|
|
|
|
DEFINE_PER_CPU(struct mmu_gather, mmu_gathers);
|
|
|
|
|
2007-05-31 07:40:54 +00:00
|
|
|
pg_data_t pg_data_map[MAX_NUMNODES];
|
|
|
|
EXPORT_SYMBOL(pg_data_map);
|
|
|
|
|
|
|
|
int m68k_virt_to_node_shift;
|
|
|
|
|
|
|
|
#ifndef CONFIG_SINGLE_MEMORY_CHUNK
|
|
|
|
pg_data_t *pg_data_table[65];
|
|
|
|
EXPORT_SYMBOL(pg_data_table);
|
|
|
|
#endif
|
|
|
|
|
2007-07-20 03:33:28 +00:00
|
|
|
void __init m68k_setup_node(int node)
|
2007-05-31 07:40:54 +00:00
|
|
|
{
|
|
|
|
#ifndef CONFIG_SINGLE_MEMORY_CHUNK
|
|
|
|
struct mem_info *info = m68k_memory + node;
|
|
|
|
int i, end;
|
|
|
|
|
|
|
|
i = (unsigned long)phys_to_virt(info->addr) >> __virt_to_node_shift();
|
|
|
|
end = (unsigned long)phys_to_virt(info->addr + info->size - 1) >> __virt_to_node_shift();
|
|
|
|
for (; i <= end; i++) {
|
|
|
|
if (pg_data_table[i])
|
|
|
|
printk("overlap at %u for chunk %u\n", i, node);
|
|
|
|
pg_data_table[i] = pg_data_map + node;
|
|
|
|
}
|
|
|
|
#endif
|
2008-07-24 04:26:55 +00:00
|
|
|
pg_data_map[node].bdata = bootmem_node_data + node;
|
2007-05-31 07:40:54 +00:00
|
|
|
node_set_online(node);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
/*
|
|
|
|
* ZERO_PAGE is a special page that is used for zero-initialized
|
|
|
|
* data and COW.
|
|
|
|
*/
|
|
|
|
|
|
|
|
void *empty_zero_page;
|
2008-04-29 12:11:12 +00:00
|
|
|
EXPORT_SYMBOL(empty_zero_page);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
extern void init_pointer_table(unsigned long ptable);
|
|
|
|
|
|
|
|
/* References to section boundaries */
|
|
|
|
|
|
|
|
extern pmd_t *zero_pgtable;
|
|
|
|
|
|
|
|
void __init mem_init(void)
|
|
|
|
{
|
2007-05-31 07:40:54 +00:00
|
|
|
pg_data_t *pgdat;
|
2005-04-16 22:20:36 +00:00
|
|
|
int codepages = 0;
|
|
|
|
int datapages = 0;
|
|
|
|
int initpages = 0;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
#ifdef CONFIG_ATARI
|
|
|
|
if (MACH_IS_ATARI)
|
|
|
|
atari_stram_mem_init_hook();
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* this will put all memory onto the freelists */
|
2007-05-31 07:40:54 +00:00
|
|
|
totalram_pages = num_physpages = 0;
|
|
|
|
for_each_online_pgdat(pgdat) {
|
|
|
|
num_physpages += pgdat->node_present_pages;
|
|
|
|
|
|
|
|
totalram_pages += free_all_bootmem_node(pgdat);
|
|
|
|
for (i = 0; i < pgdat->node_spanned_pages; i++) {
|
|
|
|
struct page *page = pgdat->node_mem_map + i;
|
|
|
|
char *addr = page_to_virt(page);
|
|
|
|
|
|
|
|
if (!PageReserved(page))
|
|
|
|
continue;
|
|
|
|
if (addr >= _text &&
|
|
|
|
addr < _etext)
|
2005-04-16 22:20:36 +00:00
|
|
|
codepages++;
|
2007-05-31 07:40:54 +00:00
|
|
|
else if (addr >= __init_begin &&
|
|
|
|
addr < __init_end)
|
2005-04-16 22:20:36 +00:00
|
|
|
initpages++;
|
|
|
|
else
|
|
|
|
datapages++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifndef CONFIG_SUN3
|
|
|
|
/* insert pointer tables allocated so far into the tablelist */
|
|
|
|
init_pointer_table((unsigned long)kernel_pg_dir);
|
|
|
|
for (i = 0; i < PTRS_PER_PGD; i++) {
|
|
|
|
if (pgd_present(kernel_pg_dir[i]))
|
|
|
|
init_pointer_table(__pgd_page(kernel_pg_dir[i]));
|
|
|
|
}
|
|
|
|
|
|
|
|
/* insert also pointer table that we used to unmap the zero page */
|
|
|
|
if (zero_pgtable)
|
|
|
|
init_pointer_table((unsigned long)zero_pgtable);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
printk("Memory: %luk/%luk available (%dk kernel code, %dk data, %dk init)\n",
|
2009-09-22 00:02:36 +00:00
|
|
|
nr_free_pages() << (PAGE_SHIFT-10),
|
2007-05-31 07:40:54 +00:00
|
|
|
totalram_pages << (PAGE_SHIFT-10),
|
2005-04-16 22:20:36 +00:00
|
|
|
codepages << (PAGE_SHIFT-10),
|
|
|
|
datapages << (PAGE_SHIFT-10),
|
|
|
|
initpages << (PAGE_SHIFT-10));
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef CONFIG_BLK_DEV_INITRD
|
|
|
|
void free_initrd_mem(unsigned long start, unsigned long end)
|
|
|
|
{
|
|
|
|
int pages = 0;
|
|
|
|
for (; start < end; start += PAGE_SIZE) {
|
|
|
|
ClearPageReserved(virt_to_page(start));
|
2006-03-22 08:08:40 +00:00
|
|
|
init_page_count(virt_to_page(start));
|
2005-04-16 22:20:36 +00:00
|
|
|
free_page(start);
|
|
|
|
totalram_pages++;
|
|
|
|
pages++;
|
|
|
|
}
|
|
|
|
printk ("Freeing initrd memory: %dk freed\n", pages);
|
|
|
|
}
|
|
|
|
#endif
|