Commit d9b2b2a2 authored by David S. Miller's avatar David S. Miller

[LIB]: Make PowerPC LMB code generic so sparc64 can use it too.

Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent e760e716
...@@ -90,6 +90,7 @@ config PPC ...@@ -90,6 +90,7 @@ config PPC
select HAVE_IDE select HAVE_IDE
select HAVE_OPROFILE select HAVE_OPROFILE
select HAVE_KPROBES select HAVE_KPROBES
select HAVE_LMB
config EARLY_PRINTK config EARLY_PRINTK
bool bool
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include <linux/string.h> #include <linux/string.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/lmb.h>
#include <asm/sections.h> #include <asm/sections.h>
#include <asm/prom.h> #include <asm/prom.h>
...@@ -15,7 +16,7 @@ ...@@ -15,7 +16,7 @@
#include <asm/mmu.h> #include <asm/mmu.h>
#include <asm/pgtable.h> #include <asm/pgtable.h>
#include <asm/io.h> #include <asm/io.h>
#include <asm/lmb.h> #include <asm/prom.h>
#include <asm/processor.h> #include <asm/processor.h>
#include <asm/udbg.h> #include <asm/udbg.h>
......
...@@ -24,12 +24,13 @@ ...@@ -24,12 +24,13 @@
#include <linux/init.h> #include <linux/init.h>
#include <linux/irq.h> #include <linux/irq.h>
#include <linux/types.h> #include <linux/types.h>
#include <linux/lmb.h>
#include <asm/processor.h> #include <asm/processor.h>
#include <asm/machdep.h> #include <asm/machdep.h>
#include <asm/kexec.h> #include <asm/kexec.h>
#include <asm/kdump.h> #include <asm/kdump.h>
#include <asm/lmb.h> #include <asm/prom.h>
#include <asm/firmware.h> #include <asm/firmware.h>
#include <asm/smp.h> #include <asm/smp.h>
#include <asm/system.h> #include <asm/system.h>
......
...@@ -13,8 +13,9 @@ ...@@ -13,8 +13,9 @@
#include <linux/crash_dump.h> #include <linux/crash_dump.h>
#include <linux/bootmem.h> #include <linux/bootmem.h>
#include <linux/lmb.h>
#include <asm/kdump.h> #include <asm/kdump.h>
#include <asm/lmb.h> #include <asm/prom.h>
#include <asm/firmware.h> #include <asm/firmware.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
......
...@@ -12,8 +12,9 @@ ...@@ -12,8 +12,9 @@
#include <linux/kexec.h> #include <linux/kexec.h>
#include <linux/reboot.h> #include <linux/reboot.h>
#include <linux/threads.h> #include <linux/threads.h>
#include <linux/lmb.h>
#include <asm/machdep.h> #include <asm/machdep.h>
#include <asm/lmb.h> #include <asm/prom.h>
void machine_crash_shutdown(struct pt_regs *regs) void machine_crash_shutdown(struct pt_regs *regs)
{ {
......
...@@ -31,10 +31,10 @@ ...@@ -31,10 +31,10 @@
#include <linux/kexec.h> #include <linux/kexec.h>
#include <linux/debugfs.h> #include <linux/debugfs.h>
#include <linux/irq.h> #include <linux/irq.h>
#include <linux/lmb.h>
#include <asm/prom.h> #include <asm/prom.h>
#include <asm/rtas.h> #include <asm/rtas.h>
#include <asm/lmb.h>
#include <asm/page.h> #include <asm/page.h>
#include <asm/processor.h> #include <asm/processor.h>
#include <asm/irq.h> #include <asm/irq.h>
......
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
#include <linux/smp.h> #include <linux/smp.h>
#include <linux/completion.h> #include <linux/completion.h>
#include <linux/cpumask.h> #include <linux/cpumask.h>
#include <linux/lmb.h>
#include <asm/prom.h> #include <asm/prom.h>
#include <asm/rtas.h> #include <asm/rtas.h>
...@@ -34,7 +35,6 @@ ...@@ -34,7 +35,6 @@
#include <asm/system.h> #include <asm/system.h>
#include <asm/delay.h> #include <asm/delay.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
#include <asm/lmb.h>
#include <asm/udbg.h> #include <asm/udbg.h>
#include <asm/syscalls.h> #include <asm/syscalls.h>
#include <asm/smp.h> #include <asm/smp.h>
......
...@@ -34,6 +34,7 @@ ...@@ -34,6 +34,7 @@
#include <linux/serial_8250.h> #include <linux/serial_8250.h>
#include <linux/debugfs.h> #include <linux/debugfs.h>
#include <linux/percpu.h> #include <linux/percpu.h>
#include <linux/lmb.h>
#include <asm/io.h> #include <asm/io.h>
#include <asm/prom.h> #include <asm/prom.h>
#include <asm/processor.h> #include <asm/processor.h>
...@@ -56,7 +57,6 @@ ...@@ -56,7 +57,6 @@
#include <asm/cache.h> #include <asm/cache.h>
#include <asm/page.h> #include <asm/page.h>
#include <asm/mmu.h> #include <asm/mmu.h>
#include <asm/lmb.h>
#include <asm/xmon.h> #include <asm/xmon.h>
#include <asm/cputhreads.h> #include <asm/cputhreads.h>
......
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
#include <linux/serial_8250.h> #include <linux/serial_8250.h>
#include <linux/bootmem.h> #include <linux/bootmem.h>
#include <linux/pci.h> #include <linux/pci.h>
#include <linux/lmb.h>
#include <asm/io.h> #include <asm/io.h>
#include <asm/kdump.h> #include <asm/kdump.h>
#include <asm/prom.h> #include <asm/prom.h>
...@@ -55,7 +56,6 @@ ...@@ -55,7 +56,6 @@
#include <asm/cache.h> #include <asm/cache.h>
#include <asm/page.h> #include <asm/page.h>
#include <asm/mmu.h> #include <asm/mmu.h>
#include <asm/lmb.h>
#include <asm/firmware.h> #include <asm/firmware.h>
#include <asm/xmon.h> #include <asm/xmon.h>
#include <asm/udbg.h> #include <asm/udbg.h>
......
...@@ -21,13 +21,14 @@ ...@@ -21,13 +21,14 @@
#include <linux/elf.h> #include <linux/elf.h>
#include <linux/security.h> #include <linux/security.h>
#include <linux/bootmem.h> #include <linux/bootmem.h>
#include <linux/lmb.h>
#include <asm/pgtable.h> #include <asm/pgtable.h>
#include <asm/system.h> #include <asm/system.h>
#include <asm/processor.h> #include <asm/processor.h>
#include <asm/mmu.h> #include <asm/mmu.h>
#include <asm/mmu_context.h> #include <asm/mmu_context.h>
#include <asm/lmb.h> #include <asm/prom.h>
#include <asm/machdep.h> #include <asm/machdep.h>
#include <asm/cputable.h> #include <asm/cputable.h>
#include <asm/sections.h> #include <asm/sections.h>
......
...@@ -6,7 +6,7 @@ ifeq ($(CONFIG_PPC64),y) ...@@ -6,7 +6,7 @@ ifeq ($(CONFIG_PPC64),y)
EXTRA_CFLAGS += -mno-minimal-toc EXTRA_CFLAGS += -mno-minimal-toc
endif endif
obj-y := fault.o mem.o lmb.o \ obj-y := fault.o mem.o \
init_$(CONFIG_WORD_SIZE).o \ init_$(CONFIG_WORD_SIZE).o \
pgtable_$(CONFIG_WORD_SIZE).o \ pgtable_$(CONFIG_WORD_SIZE).o \
mmu_context_$(CONFIG_WORD_SIZE).o mmu_context_$(CONFIG_WORD_SIZE).o
......
...@@ -31,6 +31,7 @@ ...@@ -31,6 +31,7 @@
#include <linux/cache.h> #include <linux/cache.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/signal.h> #include <linux/signal.h>
#include <linux/lmb.h>
#include <asm/processor.h> #include <asm/processor.h>
#include <asm/pgtable.h> #include <asm/pgtable.h>
...@@ -41,7 +42,7 @@ ...@@ -41,7 +42,7 @@
#include <asm/system.h> #include <asm/system.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
#include <asm/machdep.h> #include <asm/machdep.h>
#include <asm/lmb.h> #include <asm/prom.h>
#include <asm/abs_addr.h> #include <asm/abs_addr.h>
#include <asm/tlbflush.h> #include <asm/tlbflush.h>
#include <asm/io.h> #include <asm/io.h>
......
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
#include <linux/highmem.h> #include <linux/highmem.h>
#include <linux/initrd.h> #include <linux/initrd.h>
#include <linux/pagemap.h> #include <linux/pagemap.h>
#include <linux/lmb.h>
#include <asm/pgalloc.h> #include <asm/pgalloc.h>
#include <asm/prom.h> #include <asm/prom.h>
...@@ -41,7 +42,6 @@ ...@@ -41,7 +42,6 @@
#include <asm/machdep.h> #include <asm/machdep.h>
#include <asm/btext.h> #include <asm/btext.h>
#include <asm/tlb.h> #include <asm/tlb.h>
#include <asm/lmb.h>
#include <asm/sections.h> #include <asm/sections.h>
#include "mmu_decl.h" #include "mmu_decl.h"
......
...@@ -38,11 +38,11 @@ ...@@ -38,11 +38,11 @@
#include <linux/nodemask.h> #include <linux/nodemask.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/poison.h> #include <linux/poison.h>
#include <linux/lmb.h>
#include <asm/pgalloc.h> #include <asm/pgalloc.h>
#include <asm/page.h> #include <asm/page.h>
#include <asm/prom.h> #include <asm/prom.h>
#include <asm/lmb.h>
#include <asm/rtas.h> #include <asm/rtas.h>
#include <asm/io.h> #include <asm/io.h>
#include <asm/mmu_context.h> #include <asm/mmu_context.h>
......
...@@ -31,6 +31,7 @@ ...@@ -31,6 +31,7 @@
#include <linux/initrd.h> #include <linux/initrd.h>
#include <linux/pagemap.h> #include <linux/pagemap.h>
#include <linux/suspend.h> #include <linux/suspend.h>
#include <linux/lmb.h>
#include <asm/pgalloc.h> #include <asm/pgalloc.h>
#include <asm/prom.h> #include <asm/prom.h>
...@@ -42,7 +43,6 @@ ...@@ -42,7 +43,6 @@
#include <asm/machdep.h> #include <asm/machdep.h>
#include <asm/btext.h> #include <asm/btext.h>
#include <asm/tlb.h> #include <asm/tlb.h>
#include <asm/lmb.h>
#include <asm/sections.h> #include <asm/sections.h>
#include <asm/vdso.h> #include <asm/vdso.h>
......
...@@ -17,8 +17,9 @@ ...@@ -17,8 +17,9 @@
#include <linux/nodemask.h> #include <linux/nodemask.h>
#include <linux/cpu.h> #include <linux/cpu.h>
#include <linux/notifier.h> #include <linux/notifier.h>
#include <linux/lmb.h>
#include <asm/sparsemem.h> #include <asm/sparsemem.h>
#include <asm/lmb.h> #include <asm/prom.h>
#include <asm/system.h> #include <asm/system.h>
#include <asm/smp.h> #include <asm/smp.h>
......
...@@ -26,11 +26,11 @@ ...@@ -26,11 +26,11 @@
#include <linux/mm.h> #include <linux/mm.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/highmem.h> #include <linux/highmem.h>
#include <linux/lmb.h>
#include <asm/prom.h> #include <asm/prom.h>
#include <asm/mmu.h> #include <asm/mmu.h>
#include <asm/machdep.h> #include <asm/machdep.h>
#include <asm/lmb.h>
#include "mmu_decl.h" #include "mmu_decl.h"
......
...@@ -12,12 +12,14 @@ ...@@ -12,12 +12,14 @@
* 2 of the License, or (at your option) any later version. * 2 of the License, or (at your option) any later version.
*/ */
#include <linux/lmb.h>
#include <asm/pgtable.h> #include <asm/pgtable.h>
#include <asm/mmu.h> #include <asm/mmu.h>
#include <asm/mmu_context.h> #include <asm/mmu_context.h>
#include <asm/paca.h> #include <asm/paca.h>
#include <asm/cputable.h> #include <asm/cputable.h>
#include <asm/lmb.h> #include <asm/prom.h>
#include <asm/abs_addr.h> #include <asm/abs_addr.h>
#include <asm/firmware.h> #include <asm/firmware.h>
#include <asm/iseries/hv_call.h> #include <asm/iseries/hv_call.h>
......
...@@ -28,13 +28,13 @@ ...@@ -28,13 +28,13 @@
#include <linux/notifier.h> #include <linux/notifier.h>
#include <linux/of.h> #include <linux/of.h>
#include <linux/of_platform.h> #include <linux/of_platform.h>
#include <linux/lmb.h>
#include <asm/prom.h> #include <asm/prom.h>
#include <asm/iommu.h> #include <asm/iommu.h>
#include <asm/machdep.h> #include <asm/machdep.h>
#include <asm/pci-bridge.h> #include <asm/pci-bridge.h>
#include <asm/udbg.h> #include <asm/udbg.h>
#include <asm/lmb.h>
#include <asm/firmware.h> #include <asm/firmware.h>
#include <asm/cell-regs.h> #include <asm/cell-regs.h>
......
...@@ -43,6 +43,7 @@ ...@@ -43,6 +43,7 @@
#include <linux/smp.h> #include <linux/smp.h>
#include <linux/bitops.h> #include <linux/bitops.h>
#include <linux/of_device.h> #include <linux/of_device.h>
#include <linux/lmb.h>
#include <asm/processor.h> #include <asm/processor.h>
#include <asm/sections.h> #include <asm/sections.h>
...@@ -57,7 +58,6 @@ ...@@ -57,7 +58,6 @@
#include <asm/dma.h> #include <asm/dma.h>
#include <asm/cputable.h> #include <asm/cputable.h>
#include <asm/time.h> #include <asm/time.h>
#include <asm/lmb.h>
#include <asm/mpic.h> #include <asm/mpic.h>
#include <asm/rtas.h> #include <asm/rtas.h>
#include <asm/udbg.h> #include <asm/udbg.h>
......
...@@ -53,6 +53,7 @@ ...@@ -53,6 +53,7 @@
#include <linux/suspend.h> #include <linux/suspend.h>
#include <linux/of_device.h> #include <linux/of_device.h>
#include <linux/of_platform.h> #include <linux/of_platform.h>
#include <linux/lmb.h>
#include <asm/reg.h> #include <asm/reg.h>
#include <asm/sections.h> #include <asm/sections.h>
...@@ -74,7 +75,6 @@ ...@@ -74,7 +75,6 @@
#include <asm/iommu.h> #include <asm/iommu.h>
#include <asm/smu.h> #include <asm/smu.h>
#include <asm/pmc.h> #include <asm/pmc.h>
#include <asm/lmb.h>
#include <asm/udbg.h> #include <asm/udbg.h>
#include "pmac.h" #include "pmac.h"
......
...@@ -19,9 +19,10 @@ ...@@ -19,9 +19,10 @@
*/ */
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/lmb.h>
#include <asm/machdep.h> #include <asm/machdep.h>
#include <asm/lmb.h> #include <asm/prom.h>
#include <asm/udbg.h> #include <asm/udbg.h>
#include <asm/lv1call.h> #include <asm/lv1call.h>
#include <asm/ps3fb.h> #include <asm/ps3fb.h>
......
...@@ -21,9 +21,10 @@ ...@@ -21,9 +21,10 @@
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/memory_hotplug.h> #include <linux/memory_hotplug.h>
#include <linux/lmb.h>
#include <asm/firmware.h> #include <asm/firmware.h>
#include <asm/lmb.h> #include <asm/prom.h>
#include <asm/udbg.h> #include <asm/udbg.h>
#include <asm/lv1call.h> #include <asm/lv1call.h>
......
...@@ -24,8 +24,9 @@ ...@@ -24,8 +24,9 @@
#include <linux/fs.h> #include <linux/fs.h>
#include <linux/syscalls.h> #include <linux/syscalls.h>
#include <linux/ctype.h> #include <linux/ctype.h>
#include <linux/lmb.h>
#include <asm/lmb.h> #include <asm/prom.h>
#include "platform.h" #include "platform.h"
......
...@@ -37,6 +37,7 @@ ...@@ -37,6 +37,7 @@
#include <linux/dma-mapping.h> #include <linux/dma-mapping.h>
#include <linux/vmalloc.h> #include <linux/vmalloc.h>
#include <linux/suspend.h> #include <linux/suspend.h>
#include <linux/lmb.h>
#include <asm/io.h> #include <asm/io.h>
#include <asm/prom.h> #include <asm/prom.h>
#include <asm/iommu.h> #include <asm/iommu.h>
...@@ -44,7 +45,6 @@ ...@@ -44,7 +45,6 @@
#include <asm/machdep.h> #include <asm/machdep.h>
#include <asm/abs_addr.h> #include <asm/abs_addr.h>
#include <asm/cacheflush.h> #include <asm/cacheflush.h>
#include <asm/lmb.h>
#include <asm/ppc-pci.h> #include <asm/ppc-pci.h>
#include "dart.h" #include "dart.h"
......
...@@ -15,6 +15,7 @@ config SPARC64 ...@@ -15,6 +15,7 @@ config SPARC64
bool bool
default y default y
select HAVE_IDE select HAVE_IDE
select HAVE_LMB
help help
SPARC is a family of RISC microprocessors designed and marketed by SPARC is a family of RISC microprocessors designed and marketed by
Sun Microsystems, incorporated. This port covers the newer 64-bit Sun Microsystems, incorporated. This port covers the newer 64-bit
......
...@@ -12,10 +12,11 @@ ...@@ -12,10 +12,11 @@
* 2 of the License, or (at your option) any later version. * 2 of the License, or (at your option) any later version.
*/ */
#include <linux/lmb.h>
#include <asm/types.h> #include <asm/types.h>
#include <asm/page.h> #include <asm/page.h>
#include <asm/prom.h> #include <asm/prom.h>
#include <asm/lmb.h>
#include <asm/firmware.h> #include <asm/firmware.h>
struct mschunks_map { struct mschunks_map {
......
#ifndef _ASM_POWERPC_LMB_H #ifndef _ASM_POWERPC_LMB_H
#define _ASM_POWERPC_LMB_H #define _ASM_POWERPC_LMB_H
#ifdef __KERNEL__
/* #include <asm/udbg.h>
* Definitions for talking to the Open Firmware PROM on
* Power Macintosh computers.
*
* Copyright (C) 2001 Peter Bergner, IBM Corp.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version
* 2 of the License, or (at your option) any later version.
*/
#include <linux/init.h> #define LMB_DBG(fmt...) udbg_printf(fmt)
#include <asm/prom.h>
#define MAX_LMB_REGIONS 128 #ifdef CONFIG_PPC32
extern unsigned long __max_low_memory;
#define LMB_REAL_LIMIT __max_low_memory
#else
#define LMB_REAL_LIMIT 0
#endif
struct lmb_property {
unsigned long base;
unsigned long size;
};
struct lmb_region {
unsigned long cnt;
unsigned long size;
struct lmb_property region[MAX_LMB_REGIONS+1];
};
struct lmb {
unsigned long debug;
unsigned long rmo_size;
struct lmb_region memory;
struct lmb_region reserved;
};
extern struct lmb lmb;
extern void __init lmb_init(void);
extern void __init lmb_analyze(void);
extern long __init lmb_add(unsigned long base, unsigned long size);
extern long __init lmb_reserve(unsigned long base, unsigned long size);
extern unsigned long __init lmb_alloc(unsigned long size, unsigned long align);
extern unsigned long __init lmb_alloc_base(unsigned long size,
unsigned long align, unsigned long max_addr);
extern unsigned long __init __lmb_alloc_base(unsigned long size,
unsigned long align, unsigned long max_addr);
extern unsigned long __init lmb_phys_mem_size(void);
extern unsigned long __init lmb_end_of_DRAM(void);
extern void __init lmb_enforce_memory_limit(unsigned long memory_limit);
extern int __init lmb_is_reserved(unsigned long addr);
extern void lmb_dump_all(void);
static inline unsigned long
lmb_size_bytes(struct lmb_region *type, unsigned long region_nr)
{
return type->region[region_nr].size;
}
static inline unsigned long
lmb_size_pages(struct lmb_region *type, unsigned long region_nr)
{
return lmb_size_bytes(type, region_nr) >> PAGE_SHIFT;
}
static inline unsigned long
lmb_start_pfn(struct lmb_region *type, unsigned long region_nr)
{
return type->region[region_nr].base >> PAGE_SHIFT;
}
static inline unsigned long
lmb_end_pfn(struct lmb_region *type, unsigned long region_nr)
{
return lmb_start_pfn(type, region_nr) +
lmb_size_pages(type, region_nr);
}
#endif /* __KERNEL__ */
#endif /* _ASM_POWERPC_LMB_H */ #endif /* _ASM_POWERPC_LMB_H */
#ifndef _SPARC64_LMB_H
#define _SPARC64_LMB_H
#include <asm/oplib.h>
#define LMB_DBG(fmt...) prom_printf(fmt)
#define LMB_REAL_LIMIT 0
#endif /* !(_SPARC64_LMB_H) */
#ifndef _LINUX_LMB_H
#define _LINUX_LMB_H
#ifdef __KERNEL__
/*
* Logical memory blocks.
*
* Copyright (C) 2001 Peter Bergner, IBM Corp.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version
* 2 of the License, or (at your option) any later version.
*/
#include <linux/init.h>
#include <linux/mm.h>
#define MAX_LMB_REGIONS 128
struct lmb_property {
unsigned long base;
unsigned long size;
};
struct lmb_region {
unsigned long cnt;
unsigned long size;
struct lmb_property region[MAX_LMB_REGIONS+1];
};
struct lmb {
unsigned long debug;
unsigned long rmo_size;
struct lmb_region memory;
struct lmb_region reserved;
};
extern struct lmb lmb;
extern void __init lmb_init(void);
extern void __init lmb_analyze(void);
extern long __init lmb_add(unsigned long base, unsigned long size);
extern long __init lmb_reserve(unsigned long base, unsigned long size);
extern unsigned long __init lmb_alloc(unsigned long size, unsigned long align);
extern unsigned long __init lmb_alloc_base(unsigned long size,
unsigned long align, unsigned long max_addr);
extern unsigned long __init __lmb_alloc_base(unsigned long size,
unsigned long align, unsigned long max_addr);
extern unsigned long __init lmb_phys_mem_size(void);
extern unsigned long __init lmb_end_of_DRAM(void);
extern void __init lmb_enforce_memory_limit(unsigned long memory_limit);
extern int __init lmb_is_reserved(unsigned long addr);
extern void lmb_dump_all(void);
static inline unsigned long
lmb_size_bytes(struct lmb_region *type, unsigned long region_nr)
{
return type->region[region_nr].size;
}
static inline unsigned long
lmb_size_pages(struct lmb_region *type, unsigned long region_nr)
{
return lmb_size_bytes(type, region_nr) >> PAGE_SHIFT;
}
static inline unsigned long
lmb_start_pfn(struct lmb_region *type, unsigned long region_nr)
{
return type->region[region_nr].base >> PAGE_SHIFT;
}
static inline unsigned long
lmb_end_pfn(struct lmb_region *type, unsigned long region_nr)
{
return lmb_start_pfn(type, region_nr) +
lmb_size_pages(type, region_nr);
}
#include <asm/lmb.h>
#endif /* __KERNEL__ */
#endif /* _LINUX_LMB_H */
...@@ -141,4 +141,7 @@ config HAS_DMA ...@@ -141,4 +141,7 @@ config HAS_DMA
config CHECK_SIGNATURE config CHECK_SIGNATURE
bool bool
config HAVE_LMB
boolean
endmenu endmenu
...@@ -70,6 +70,8 @@ obj-$(CONFIG_FAULT_INJECTION) += fault-inject.o ...@@ -70,6 +70,8 @@ obj-$(CONFIG_FAULT_INJECTION) += fault-inject.o
lib-$(CONFIG_GENERIC_BUG) += bug.o lib-$(CONFIG_GENERIC_BUG) += bug.o
obj-$(CONFIG_HAVE_LMB) += lmb.o
hostprogs-y := gen_crc32table hostprogs-y := gen_crc32table
clean-files := crc32table.h clean-files := crc32table.h
......
...@@ -13,19 +13,12 @@ ...@@ -13,19 +13,12 @@
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/bitops.h> #include <linux/bitops.h>
#include <asm/types.h> #include <linux/lmb.h>
#include <asm/page.h>
#include <asm/prom.h>
#include <asm/lmb.h>
#ifdef CONFIG_PPC32
#include "mmu_decl.h" /* for __max_low_memory */
#endif
#undef DEBUG #undef DEBUG
#ifdef DEBUG #ifdef DEBUG
#include <asm/udbg.h> #define DBG(fmt...) LMB_DBG(fmt)
#define DBG(fmt...) udbg_printf(fmt)
#else #else
#define DBG(fmt...) #define DBG(fmt...)
#endif #endif
...@@ -247,6 +240,11 @@ unsigned long __init lmb_alloc_base(unsigned long size, unsigned long align, ...@@ -247,6 +240,11 @@ unsigned long __init lmb_alloc_base(unsigned long size, unsigned long align,
return alloc; return alloc;
} }
static unsigned long lmb_align_down(unsigned long addr, unsigned long size)
{
return addr & ~(size - 1);
}
unsigned long __init __lmb_alloc_base(unsigned long size, unsigned long align, unsigned long __init __lmb_alloc_base(unsigned long size, unsigned long align,
unsigned long max_addr) unsigned long max_addr)
{ {
...@@ -255,26 +253,25 @@ unsigned long __init __lmb_alloc_base(unsigned long size, unsigned long align, ...@@ -255,26 +253,25 @@ unsigned long __init __lmb_alloc_base(unsigned long size, unsigned long align,
BUG_ON(0 == size); BUG_ON(0 == size);
#ifdef CONFIG_PPC32 /* On some platforms, make sure we allocate lowmem */
/* On 32-bit, make sure we allocate lowmem */
if (max_addr == LMB_ALLOC_ANYWHERE) if (max_addr == LMB_ALLOC_ANYWHERE)
max_addr = __max_low_memory; max_addr = LMB_REAL_LIMIT;
#endif
for (i = lmb.memory.cnt-1; i >= 0; i--) { for (i = lmb.memory.cnt-1; i >= 0; i--) {
unsigned long lmbbase = lmb.memory.region[i].base; unsigned long lmbbase = lmb.memory.region[i].base;
unsigned long lmbsize = lmb.memory.region[i].size; unsigned long lmbsize = lmb.memory.region[i].size;
if (max_addr == LMB_ALLOC_ANYWHERE) if (max_addr == LMB_ALLOC_ANYWHERE)
base = _ALIGN_DOWN(lmbbase + lmbsize - size, align); base = lmb_align_down(lmbbase + lmbsize - size, align);
else if (lmbbase < max_addr) { else if (lmbbase < max_addr) {
base = min(lmbbase + lmbsize, max_addr); base = min(lmbbase + lmbsize, max_addr);
base = _ALIGN_DOWN(base - size, align); base = lmb_align_down(base - size, align);
} else } else
continue; continue;
while ((lmbbase <= base) && while ((lmbbase <= base) &&
((j = lmb_overlaps_region(&lmb.reserved, base, size)) >= 0) ) ((j = lmb_overlaps_region(&lmb.reserved, base, size)) >= 0) )
base = _ALIGN_DOWN(lmb.reserved.region[j].base - size, base = lmb_align_down(lmb.reserved.region[j].base - size,
align); align);
if ((base != 0) && (lmbbase <= base)) if ((base != 0) && (lmbbase <= base))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment