mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-12-26 12:34:41 +08:00
57c8a661d9
Move remaining definitions and declarations from include/linux/bootmem.h into include/linux/memblock.h and remove the redundant header. The includes were replaced with the semantic patch below and then semi-automated removal of duplicated '#include <linux/memblock.h> @@ @@ - #include <linux/bootmem.h> + #include <linux/memblock.h> [sfr@canb.auug.org.au: dma-direct: fix up for the removal of linux/bootmem.h] Link: http://lkml.kernel.org/r/20181002185342.133d1680@canb.auug.org.au [sfr@canb.auug.org.au: powerpc: fix up for removal of linux/bootmem.h] Link: http://lkml.kernel.org/r/20181005161406.73ef8727@canb.auug.org.au [sfr@canb.auug.org.au: x86/kaslr, ACPI/NUMA: fix for linux/bootmem.h removal] Link: http://lkml.kernel.org/r/20181008190341.5e396491@canb.auug.org.au Link: http://lkml.kernel.org/r/1536927045-23536-30-git-send-email-rppt@linux.vnet.ibm.com Signed-off-by: Mike Rapoport <rppt@linux.vnet.ibm.com> Signed-off-by: Stephen Rothwell <sfr@canb.auug.org.au> Acked-by: Michal Hocko <mhocko@suse.com> Cc: Catalin Marinas <catalin.marinas@arm.com> Cc: Chris Zankel <chris@zankel.net> Cc: "David S. Miller" <davem@davemloft.net> Cc: Geert Uytterhoeven <geert@linux-m68k.org> Cc: Greentime Hu <green.hu@gmail.com> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Cc: Guan Xuetao <gxt@pku.edu.cn> Cc: Ingo Molnar <mingo@redhat.com> Cc: "James E.J. Bottomley" <jejb@parisc-linux.org> Cc: Jonas Bonn <jonas@southpole.se> Cc: Jonathan Corbet <corbet@lwn.net> Cc: Ley Foon Tan <lftan@altera.com> Cc: Mark Salter <msalter@redhat.com> Cc: Martin Schwidefsky <schwidefsky@de.ibm.com> Cc: Matt Turner <mattst88@gmail.com> Cc: Michael Ellerman <mpe@ellerman.id.au> Cc: Michal Simek <monstr@monstr.eu> Cc: Palmer Dabbelt <palmer@sifive.com> Cc: Paul Burton <paul.burton@mips.com> Cc: Richard Kuo <rkuo@codeaurora.org> Cc: Richard Weinberger <richard@nod.at> Cc: Rich Felker <dalias@libc.org> Cc: Russell King <linux@armlinux.org.uk> Cc: Serge Semin <fancer.lancer@gmail.com> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Tony Luck <tony.luck@intel.com> Cc: Vineet Gupta <vgupta@synopsys.com> Cc: Yoshinori Sato <ysato@users.sourceforge.jp> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
120 lines
2.9 KiB
C
120 lines
2.9 KiB
C
// SPDX-License-Identifier: GPL-2.0
|
|
/*
|
|
* memory.c: memory initialisation code.
|
|
*
|
|
* Copyright (C) 1998 Harald Koerfgen, Frieder Streffer and Paul M. Antoine
|
|
* Copyright (C) 2000, 2002 Maciej W. Rozycki
|
|
*/
|
|
#include <linux/init.h>
|
|
#include <linux/kernel.h>
|
|
#include <linux/mm.h>
|
|
#include <linux/memblock.h>
|
|
#include <linux/types.h>
|
|
|
|
#include <asm/addrspace.h>
|
|
#include <asm/bootinfo.h>
|
|
#include <asm/dec/machtype.h>
|
|
#include <asm/dec/prom.h>
|
|
#include <asm/page.h>
|
|
#include <asm/sections.h>
|
|
|
|
|
|
volatile unsigned long mem_err; /* So we know an error occurred */
|
|
|
|
/*
|
|
* Probe memory in 4MB chunks, waiting for an error to tell us we've fallen
|
|
* off the end of real memory. Only suitable for the 2100/3100's (PMAX).
|
|
*/
|
|
|
|
#define CHUNK_SIZE 0x400000
|
|
|
|
static inline void pmax_setup_memory_region(void)
|
|
{
|
|
volatile unsigned char *memory_page, dummy;
|
|
char old_handler[0x80];
|
|
extern char genexcept_early;
|
|
|
|
/* Install exception handler */
|
|
memcpy(&old_handler, (void *)(CKSEG0 + 0x80), 0x80);
|
|
memcpy((void *)(CKSEG0 + 0x80), &genexcept_early, 0x80);
|
|
|
|
/* read unmapped and uncached (KSEG1)
|
|
* DECstations have at least 4MB RAM
|
|
* Assume less than 480MB of RAM, as this is max for 5000/2xx
|
|
* FIXME this should be replaced by the first free page!
|
|
*/
|
|
for (memory_page = (unsigned char *)CKSEG1 + CHUNK_SIZE;
|
|
mem_err == 0 && memory_page < (unsigned char *)CKSEG1 + 0x1e00000;
|
|
memory_page += CHUNK_SIZE) {
|
|
dummy = *memory_page;
|
|
}
|
|
memcpy((void *)(CKSEG0 + 0x80), &old_handler, 0x80);
|
|
|
|
add_memory_region(0, (unsigned long)memory_page - CKSEG1 - CHUNK_SIZE,
|
|
BOOT_MEM_RAM);
|
|
}
|
|
|
|
/*
|
|
* Use the REX prom calls to get hold of the memory bitmap, and thence
|
|
* determine memory size.
|
|
*/
|
|
static inline void rex_setup_memory_region(void)
|
|
{
|
|
int i, bitmap_size;
|
|
unsigned long mem_start = 0, mem_size = 0;
|
|
memmap *bm;
|
|
|
|
/* some free 64k */
|
|
bm = (memmap *)CKSEG0ADDR(0x28000);
|
|
|
|
bitmap_size = rex_getbitmap(bm);
|
|
|
|
for (i = 0; i < bitmap_size; i++) {
|
|
/* FIXME: very simplistically only add full sets of pages */
|
|
if (bm->bitmap[i] == 0xff)
|
|
mem_size += (8 * bm->pagesize);
|
|
else if (!mem_size)
|
|
mem_start += (8 * bm->pagesize);
|
|
else {
|
|
add_memory_region(mem_start, mem_size, BOOT_MEM_RAM);
|
|
mem_start += mem_size + (8 * bm->pagesize);
|
|
mem_size = 0;
|
|
}
|
|
}
|
|
if (mem_size)
|
|
add_memory_region(mem_start, mem_size, BOOT_MEM_RAM);
|
|
}
|
|
|
|
void __init prom_meminit(u32 magic)
|
|
{
|
|
if (!prom_is_rex(magic))
|
|
pmax_setup_memory_region();
|
|
else
|
|
rex_setup_memory_region();
|
|
}
|
|
|
|
void __init prom_free_prom_memory(void)
|
|
{
|
|
unsigned long end;
|
|
|
|
/*
|
|
* Free everything below the kernel itself but leave
|
|
* the first page reserved for the exception handlers.
|
|
*/
|
|
|
|
#if IS_ENABLED(CONFIG_DECLANCE)
|
|
/*
|
|
* Leave 128 KB reserved for Lance memory for
|
|
* IOASIC DECstations.
|
|
*
|
|
* XXX: save this address for use in dec_lance.c?
|
|
*/
|
|
if (IOASIC)
|
|
end = __pa(&_text) - 0x00020000;
|
|
else
|
|
#endif
|
|
end = __pa(&_text);
|
|
|
|
free_init_pages("unused PROM memory", PAGE_SIZE, end);
|
|
}
|