Commit d7cdc9e8 authored by Paul Mundt's avatar Paul Mundt

sh: ioremap() overhaul.

ioremap() overhaul. Add support for transparent PMB mapping, get rid of
p3_ioremap(), etc. Also drop ioremap() and iounmap() routines from the
machvec, as everyone can use the generic ioremap() API instead. For PCI
memory apertures and other special cases, use the pci_iomap() API, as
boards are already required to get the mapping right there.
Signed-off-by: default avatarPaul Mundt <lethal@linux-sh.org>
parent 26ff6c11
This diff is collapsed.
/* /*
* arch/sh/boards/landisk/setup.c * arch/sh/boards/landisk/setup.c
* *
* Copyright (C) 2000 Kazumoto Kojima
* Copyright (C) 2002 Paul Mundt * Copyright (C) 2002 Paul Mundt
* *
* May be copied or modified under the terms of the GNU General Public
* License. See linux/COPYING for more information.
*
* Setup code for an unknown machine (internal peripherials only)
*/
/*
* linux/arch/sh/kernel/setup_landisk.c
*
* Copyright (C) 2000 Kazumoto Kojima
*
* I-O DATA Device, Inc. LANDISK Support. * I-O DATA Device, Inc. LANDISK Support.
* *
* Modified for LANDISK by * Modified for LANDISK by
* Atom Create Engineering Co., Ltd. 2002. * Atom Create Engineering Co., Ltd. 2002.
*/ *
/*
* modifed by kogiidena * modifed by kogiidena
* 2005.09.16 * 2005.09.16
*
* This file is subject to the terms and conditions of the GNU General Public
* License. See the file "COPYING" in the main directory of this archive
* for more details.
*/ */
#include <linux/config.h> #include <linux/config.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/irq.h>
#include <linux/pm.h> #include <linux/pm.h>
#include <linux/mm.h>
#include <linux/hdreg.h>
#include <linux/ide.h>
#include <linux/pci.h>
#include <asm/machvec.h> #include <asm/machvec.h>
#include <asm/rtc.h> #include <asm/rtc.h>
#include <asm/machvec_init.h>
#include <asm/io.h>
#include <asm/landisk/iodata_landisk.h> #include <asm/landisk/iodata_landisk.h>
#include <asm/landisk/io.h> #include <asm/io.h>
#include <linux/mm.h>
#include <linux/vmalloc.h>
extern void (*board_time_init) (void);
void landisk_time_init(void); void landisk_time_init(void);
extern void init_landisk_IRQ(void); void init_landisk_IRQ(void);
int landisk_ledparam; int landisk_ledparam;
int landisk_buzzerparam; int landisk_buzzerparam;
int landisk_arch; int landisk_arch;
/* defined in mm/ioremap.c */ /* cycle the led's in the clasic knightrider/sun pattern */
extern void *p3_ioremap(unsigned long phys_addr, unsigned long size, static void heartbeat_landisk(void)
unsigned long flags);
/*
* Initialize the board
*/
const char *get_system_type(void)
{
return "LANDISK";
}
static void landisk_power_off(void)
{
ctrl_outb(0x01, PA_SHUTDOWN);
}
void check_usl5p(void)
{
volatile unsigned char *p = (volatile unsigned char *)PA_LED;
unsigned char tmp1, tmp2;
tmp1 = *p;
*p = 0x40;
tmp2 = *p;
*p = tmp1;
landisk_arch = (tmp2 == 0x40) ? 1 : 0;
if (landisk_arch == 1) { /* arch == usl-5p */
landisk_ledparam = 0x00000380;
landisk_ledparam |= (tmp1 & 0x07c);
} else { /* arch == landisk */
landisk_ledparam = 0x02000180;
landisk_ledparam |= 0x04;
}
return;
}
void __init platform_setup(void)
{
landisk_buzzerparam = 0;
check_usl5p();
printk(KERN_INFO "I-O DATA DEVICE, INC. \"LANDISK Series\" support.\n");
board_time_init = landisk_time_init;
pm_power_off = landisk_power_off;
}
void *area5_io_base;
void *area6_io_base;
int __init cf_init(void)
{
pgprot_t prot;
unsigned long paddrbase, psize;
/* open I/O area window */
paddrbase = virt_to_phys((void *)PA_AREA5_IO);
psize = PAGE_SIZE;
prot = PAGE_KERNEL_PCC(1, _PAGE_PCC_IO16);
area5_io_base = p3_ioremap(paddrbase, psize, prot.pgprot);
if (!area5_io_base) {
printk("allocate_cf_area : can't open CF I/O window!\n");
return -ENOMEM;
}
paddrbase = virt_to_phys((void *)PA_AREA6_IO);
psize = PAGE_SIZE;
prot = PAGE_KERNEL_PCC(0, _PAGE_PCC_IO16);
area6_io_base = p3_ioremap(paddrbase, psize, prot.pgprot);
if (!area6_io_base) {
printk("allocate_cf_area : can't open HDD I/O window!\n");
return -ENOMEM;
}
printk(KERN_INFO "Allocate Area5/6 success.\n");
/* XXX : do we need attribute and common-memory area also? */
return 0;
}
__initcall(cf_init);
#include <linux/sched.h>
/* Cycle the LED's in the clasic knightrider/Sun pattern */
void heartbeat_landisk(void)
{ {
static unsigned int cnt = 0, blink = 0x00, period = 25; static unsigned int cnt = 0, blink = 0x00, period = 25;
volatile unsigned char *p = (volatile unsigned char *)PA_LED; volatile u8 *p = (volatile u8 *)PA_LED;
char data; char data;
if ((landisk_ledparam & 0x080) == 0) { if ((landisk_ledparam & 0x080) == 0)
return; return;
}
cnt += 1; cnt += 1;
if (cnt < period) {
if (cnt < period)
return; return;
}
cnt = 0; cnt = 0;
blink++; blink++;
...@@ -167,17 +62,16 @@ void heartbeat_landisk(void) ...@@ -167,17 +62,16 @@ void heartbeat_landisk(void)
} }
*p = data; *p = data;
if (((landisk_ledparam & 0x007f7f00) == 0) if (((landisk_ledparam & 0x007f7f00) == 0) &&
&& (landisk_buzzerparam == 0)) { (landisk_buzzerparam == 0))
landisk_ledparam &= (~0x0080); landisk_ledparam &= (~0x0080);
}
landisk_buzzerparam >>= 1; landisk_buzzerparam >>= 1;
} }
/* /*
* The Machine Vector * The Machine Vector
*/ */
struct sh_machine_vector mv_landisk __initmv = { struct sh_machine_vector mv_landisk __initmv = {
.mv_nr_irqs = 72, .mv_nr_irqs = 72,
.mv_inb = landisk_inb, .mv_inb = landisk_inb,
...@@ -198,21 +92,88 @@ struct sh_machine_vector mv_landisk __initmv = { ...@@ -198,21 +92,88 @@ struct sh_machine_vector mv_landisk __initmv = {
.mv_outsb = landisk_outsb, .mv_outsb = landisk_outsb,
.mv_outsw = landisk_outsw, .mv_outsw = landisk_outsw,
.mv_outsl = landisk_outsl, .mv_outsl = landisk_outsl,
.mv_readb = landisk_readb, .mv_ioport_map = landisk_ioport_map,
.mv_readw = landisk_readw,
.mv_readl = landisk_readl,
.mv_writeb = landisk_writeb,
.mv_writew = landisk_writew,
.mv_writel = landisk_writel,
.mv_ioremap = landisk_ioremap,
.mv_iounmap = landisk_iounmap,
.mv_isa_port2addr = landisk_isa_port2addr,
.mv_init_irq = init_landisk_IRQ, .mv_init_irq = init_landisk_IRQ,
#ifdef CONFIG_HEARTBEAT #ifdef CONFIG_HEARTBEAT
.mv_heartbeat = heartbeat_landisk, .mv_heartbeat = heartbeat_landisk,
#endif #endif
}; };
ALIAS_MV(landisk) ALIAS_MV(landisk)
const char *get_system_type(void)
{
return "LANDISK";
}
static void landisk_power_off(void)
{
ctrl_outb(0x01, PA_SHUTDOWN);
}
static void check_usl5p(void)
{
volatile u8 *p = (volatile u8 *)PA_LED;
u8 tmp1, tmp2;
tmp1 = *p;
*p = 0x40;
tmp2 = *p;
*p = tmp1;
landisk_arch = (tmp2 == 0x40);
if (landisk_arch == 1) {
/* arch == usl-5p */
landisk_ledparam = 0x00000380;
landisk_ledparam |= (tmp1 & 0x07c);
} else {
/* arch == landisk */
landisk_ledparam = 0x02000180;
landisk_ledparam |= 0x04;
}
}
void __init platform_setup(void)
{
landisk_buzzerparam = 0;
check_usl5p();
printk(KERN_INFO "I-O DATA DEVICE, INC. \"LANDISK Series\" support.\n");
board_time_init = landisk_time_init;
pm_power_off = landisk_power_off;
}
void *area5_io_base;
void *area6_io_base;
static int __init landisk_cf_init(void)
{
pgprot_t prot;
unsigned long paddrbase, psize;
/* open I/O area window */
paddrbase = virt_to_phys((void *)PA_AREA5_IO);
psize = PAGE_SIZE;
prot = PAGE_KERNEL_PCC(1, _PAGE_PCC_IO16);
area5_io_base = p3_ioremap(paddrbase, psize, prot.pgprot);
if (!area5_io_base) {
printk("allocate_cf_area : can't open CF I/O window!\n");
return -ENOMEM;
}
paddrbase = virt_to_phys((void *)PA_AREA6_IO);
psize = PAGE_SIZE;
prot = PAGE_KERNEL_PCC(0, _PAGE_PCC_IO16);
area6_io_base = p3_ioremap(paddrbase, psize, prot.pgprot);
if (!area6_io_base) {
printk("allocate_cf_area : can't open HDD I/O window!\n");
return -ENOMEM;
}
printk(KERN_INFO "Allocate Area5/6 success.\n");
/* XXX : do we need attribute and common-memory area also? */
return 0;
}
__initcall(landisk_cf_init);
...@@ -294,15 +294,6 @@ void hs7751rvoip_outsl(unsigned long port, const void *addr, unsigned long count ...@@ -294,15 +294,6 @@ void hs7751rvoip_outsl(unsigned long port, const void *addr, unsigned long count
maybebadio(outsl, port); maybebadio(outsl, port);
} }
void *hs7751rvoip_ioremap(unsigned long offset, unsigned long size)
{
if (offset >= 0xfd000000)
return (void *)offset;
else
return (void *)P2SEGADDR(offset);
}
EXPORT_SYMBOL(hs7751rvoip_ioremap);
unsigned long hs7751rvoip_isa_port2addr(unsigned long offset) unsigned long hs7751rvoip_isa_port2addr(unsigned long offset)
{ {
return port2adr(offset); return port2adr(offset);
......
...@@ -60,7 +60,6 @@ struct sh_machine_vector mv_hs7751rvoip __initmv = { ...@@ -60,7 +60,6 @@ struct sh_machine_vector mv_hs7751rvoip __initmv = {
.mv_outsw = hs7751rvoip_outsw, .mv_outsw = hs7751rvoip_outsw,
.mv_outsl = hs7751rvoip_outsl, .mv_outsl = hs7751rvoip_outsl,
.mv_ioremap = hs7751rvoip_ioremap,
.mv_isa_port2addr = hs7751rvoip_isa_port2addr, .mv_isa_port2addr = hs7751rvoip_isa_port2addr,
.mv_init_irq = hs7751rvoip_init_irq, .mv_init_irq = hs7751rvoip_init_irq,
}; };
......
...@@ -321,15 +321,6 @@ void rts7751r2d_outsl(unsigned long port, const void *addr, unsigned long count) ...@@ -321,15 +321,6 @@ void rts7751r2d_outsl(unsigned long port, const void *addr, unsigned long count)
maybebadio(port); maybebadio(port);
} }
void *rts7751r2d_ioremap(unsigned long offset, unsigned long size)
{
if (offset >= 0xfd000000)
return (void *)offset;
else
return (void *)P2SEGADDR(offset);
}
EXPORT_SYMBOL(rts7751r2d_ioremap);
unsigned long rts7751r2d_isa_port2addr(unsigned long offset) unsigned long rts7751r2d_isa_port2addr(unsigned long offset)
{ {
return port2adr(offset); return port2adr(offset);
......
...@@ -19,7 +19,6 @@ ...@@ -19,7 +19,6 @@
extern void heartbeat_rts7751r2d(void); extern void heartbeat_rts7751r2d(void);
extern void init_rts7751r2d_IRQ(void); extern void init_rts7751r2d_IRQ(void);
extern void *rts7751r2d_ioremap(unsigned long, unsigned long);
extern int rts7751r2d_irq_demux(int irq); extern int rts7751r2d_irq_demux(int irq);
extern void *voyagergx_consistent_alloc(struct device *, size_t, dma_addr_t *, gfp_t); extern void *voyagergx_consistent_alloc(struct device *, size_t, dma_addr_t *, gfp_t);
...@@ -53,7 +52,6 @@ struct sh_machine_vector mv_rts7751r2d __initmv = { ...@@ -53,7 +52,6 @@ struct sh_machine_vector mv_rts7751r2d __initmv = {
.mv_outsw = rts7751r2d_outsw, .mv_outsw = rts7751r2d_outsw,
.mv_outsl = rts7751r2d_outsl, .mv_outsl = rts7751r2d_outsl,
.mv_ioremap = rts7751r2d_ioremap,
.mv_init_irq = init_rts7751r2d_IRQ, .mv_init_irq = init_rts7751r2d_IRQ,
#ifdef CONFIG_HEARTBEAT #ifdef CONFIG_HEARTBEAT
.mv_heartbeat = heartbeat_rts7751r2d, .mv_heartbeat = heartbeat_rts7751r2d,
......
...@@ -138,19 +138,12 @@ void titan_outsl(unsigned long port, const void *src, unsigned long count) ...@@ -138,19 +138,12 @@ void titan_outsl(unsigned long port, const void *src, unsigned long count)
maybebadio(port); maybebadio(port);
} }
void *titan_ioremap(unsigned long offset, unsigned long size) {
if (CHECK_SH7751_PCIIO(offset) || CHECK_SH7751_PCIMEMIO(offset))
return (void *)offset;
}
void __iomem *titan_ioport_map(unsigned long port, unsigned int size) void __iomem *titan_ioport_map(unsigned long port, unsigned int size)
{ {
if (PXSEG(port)) if (PXSEG(port) || CHECK_SH7751_PCIMEMIO(port))
return (void __iomem *)port; return (void __iomem *)port;
else if (CHECK_SH7751_PCIIO(port)) else if (CHECK_SH7751_PCIIO(port))
return (void __iomem *)PCI_IOMAP(port); return (void __iomem *)PCI_IOMAP(port);
return (void __iomem *)port2adr(port); return (void __iomem *)port2adr(port);
} }
EXPORT_SYMBOL(titan_ioremap);
...@@ -51,7 +51,6 @@ struct sh_machine_vector mv_titan __initmv = { ...@@ -51,7 +51,6 @@ struct sh_machine_vector mv_titan __initmv = {
.mv_insl = titan_insl, .mv_insl = titan_insl,
.mv_outsl = titan_outsl, .mv_outsl = titan_outsl,
.mv_ioremap = titan_ioremap,
.mv_ioport_map = titan_ioport_map, .mv_ioport_map = titan_ioport_map,
.mv_init_irq = init_titan_irq, .mv_init_irq = init_titan_irq,
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* arch/sh/drivers/pci/pci.c * arch/sh/drivers/pci/pci.c
* *
* Copyright (c) 2002 M. R. Brown <mrbrown@linux-sh.org> * Copyright (c) 2002 M. R. Brown <mrbrown@linux-sh.org>
* Copyright (c) 2004, 2005 Paul Mundt <lethal@linux-sh.org> * Copyright (c) 2004 - 2006 Paul Mundt <lethal@linux-sh.org>
* *
* These functions are collected here to reduce duplication of common * These functions are collected here to reduce duplication of common
* code amongst the many platform-specific PCI support code files. * code amongst the many platform-specific PCI support code files.
...@@ -172,10 +172,23 @@ void __iomem *pci_iomap(struct pci_dev *dev, int bar, unsigned long maxlen) ...@@ -172,10 +172,23 @@ void __iomem *pci_iomap(struct pci_dev *dev, int bar, unsigned long maxlen)
return NULL; return NULL;
if (maxlen && len > maxlen) if (maxlen && len > maxlen)
len = maxlen; len = maxlen;
if (flags & IORESOURCE_IO)
/*
* Presently the IORESOURCE_MEM case is a bit special, most
* SH7751 style PCI controllers have PCI memory at a fixed
* location in the address space where no remapping is desired
* (traditionally at 0xfd000000). Once this changes, the
* IORESOURCE_MEM case will have to switch to using ioremap() and
* more care will have to be taken to inhibit page table mapping
* for legacy cores.
*
* For now everything wraps to ioport_map(), since boards that
* have PCI will be able to check the address range properly on
* their own.
* -- PFM.
*/
if (flags & (IORESOURCE_IO | IORESOURCE_MEM))
return ioport_map(start, len); return ioport_map(start, len);
if (flags & IORESOURCE_MEM)
return ioremap(start, len);
return NULL; return NULL;
} }
......
...@@ -41,9 +41,6 @@ ...@@ -41,9 +41,6 @@
#define slot_no 1 #define slot_no 1
#endif #endif
/* defined in mm/ioremap.c */
extern void * p3_ioremap(unsigned long phys_addr, unsigned long size, unsigned long flags);
/* use this pointer to access to directly connected compact flash io area*/ /* use this pointer to access to directly connected compact flash io area*/
void *cf_io_base; void *cf_io_base;
...@@ -62,7 +59,7 @@ static int __init allocate_cf_area(void) ...@@ -62,7 +59,7 @@ static int __init allocate_cf_area(void)
return -ENOMEM; return -ENOMEM;
} }
/* printk("p3_ioremap(paddr=0x%08lx, psize=0x%08lx, prot=0x%08lx)=0x%08lx\n", /* printk("p3_ioremap(paddr=0x%08lx, psize=0x%08lx, prot=0x%08lx)=0x%08lx\n",
paddrbase, psize, prot.pgprot, cf_io_base);*/ paddrbase, psize, prot.pgprot, cf_io_base);*/
/* XXX : do we need attribute and common-memory area also? */ /* XXX : do we need attribute and common-memory area also? */
......
...@@ -27,7 +27,6 @@ EXPORT_SYMBOL(sh_mv); ...@@ -27,7 +27,6 @@ EXPORT_SYMBOL(sh_mv);
/* platform dependent support */ /* platform dependent support */
EXPORT_SYMBOL(dump_fpu); EXPORT_SYMBOL(dump_fpu);
EXPORT_SYMBOL(iounmap);
EXPORT_SYMBOL(enable_irq); EXPORT_SYMBOL(enable_irq);
EXPORT_SYMBOL(disable_irq); EXPORT_SYMBOL(disable_irq);
EXPORT_SYMBOL(probe_irq_mask); EXPORT_SYMBOL(probe_irq_mask);
......
...@@ -12,13 +12,14 @@ obj-$(CONFIG_DMA_PAGE_OPS) += pg-dma.o ...@@ -12,13 +12,14 @@ obj-$(CONFIG_DMA_PAGE_OPS) += pg-dma.o
obj-$(CONFIG_HUGETLB_PAGE) += hugetlbpage.o obj-$(CONFIG_HUGETLB_PAGE) += hugetlbpage.o
mmu-y := fault-nommu.o tlb-nommu.o pg-nommu.o mmu-y := fault-nommu.o tlb-nommu.o pg-nommu.o
mmu-$(CONFIG_MMU) := fault.o clear_page.o copy_page.o tlb-flush.o mmu-$(CONFIG_MMU) := fault.o clear_page.o copy_page.o tlb-flush.o \
ioremap.o
obj-y += $(mmu-y) obj-y += $(mmu-y)
ifdef CONFIG_MMU ifdef CONFIG_MMU
obj-$(CONFIG_CPU_SH3) += tlb-sh3.o obj-$(CONFIG_CPU_SH3) += tlb-sh3.o
obj-$(CONFIG_CPU_SH4) += tlb-sh4.o ioremap.o obj-$(CONFIG_CPU_SH4) += tlb-sh4.o
obj-$(CONFIG_SH7705_CACHE_32KB) += pg-sh7705.o obj-$(CONFIG_SH7705_CACHE_32KB) += pg-sh7705.o
endif endif
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
* *
* Privileged Space Mapping Buffer (PMB) Support. * Privileged Space Mapping Buffer (PMB) Support.
* *
* Copyright (C) 2005 Paul Mundt * Copyright (C) 2005, 2006 Paul Mundt
* *
* P1/P2 Section mapping definitions from map32.h, which was: * P1/P2 Section mapping definitions from map32.h, which was:
* *
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
#include <linux/err.h> #include <linux/err.h>
#include <asm/system.h> #include <asm/system.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
#include <asm/pgtable.h>
#include <asm/mmu.h> #include <asm/mmu.h>
#include <asm/io.h> #include <asm/io.h>
...@@ -127,11 +128,15 @@ int __set_pmb_entry(unsigned long vpn, unsigned long ppn, ...@@ -127,11 +128,15 @@ int __set_pmb_entry(unsigned long vpn, unsigned long ppn,
return 0; return 0;
} }
void set_pmb_entry(struct pmb_entry *pmbe) int set_pmb_entry(struct pmb_entry *pmbe)
{ {
int ret;
jump_to_P2(); jump_to_P2();
__set_pmb_entry(pmbe->vpn, pmbe->ppn, pmbe->flags, &pmbe->entry); ret = __set_pmb_entry(pmbe->vpn, pmbe->ppn, pmbe->flags, &pmbe->entry);
back_to_P1(); back_to_P1();
return ret;
} }
void clear_pmb_entry(struct pmb_entry *pmbe) void clear_pmb_entry(struct pmb_entry *pmbe)
...@@ -162,11 +167,141 @@ void clear_pmb_entry(struct pmb_entry *pmbe) ...@@ -162,11 +167,141 @@ void clear_pmb_entry(struct pmb_entry *pmbe)
clear_bit(entry, &pmb_map); clear_bit(entry, &pmb_map);
} }
static DEFINE_SPINLOCK(pmb_list_lock);
static struct pmb_entry *pmb_list;
static inline void pmb_list_add(struct pmb_entry *pmbe)
{
struct pmb_entry **p, *tmp;
p = &pmb_list;
while ((tmp = *p) != NULL)
p = &tmp->next;
pmbe->next = tmp;
*p = pmbe;
}
static inline void pmb_list_del(struct pmb_entry *pmbe)
{
struct pmb_entry **p, *tmp;
for (p = &pmb_list; (tmp = *p); p = &tmp->next)
if (tmp == pmbe) {
*p = tmp->next;
return;
}
}
static struct {
unsigned long size;
int flag;
} pmb_sizes[] = {
{ .size = 0x20000000, .flag = PMB_SZ_512M, },
{ .size = 0x08000000, .flag = PMB_SZ_128M, },
{ .size = 0x04000000, .flag = PMB_SZ_64M, },
{ .size = 0x01000000, .flag = PMB_SZ_16M, },
};
long pmb_remap(unsigned long vaddr, unsigned long phys,
unsigned long size, unsigned long flags)
{
struct pmb_entry *pmbp;
unsigned long wanted;
int pmb_flags, i;
/* Convert typical pgprot value to the PMB equivalent */
if (flags & _PAGE_CACHABLE) {
if (flags & _PAGE_WT)
pmb_flags = PMB_WT;
else
pmb_flags = PMB_C;
} else
pmb_flags = PMB_WT | PMB_UB;
pmbp = NULL;
wanted = size;
again:
for (i = 0; i < ARRAY_SIZE(pmb_sizes); i++) {
struct pmb_entry *pmbe;
int ret;
if (size < pmb_sizes[i].size)
continue;
pmbe = pmb_alloc(vaddr, phys, pmb_flags | pmb_sizes[i].flag);
if (IS_ERR(pmbe))
return PTR_ERR(pmbe);
ret = set_pmb_entry(pmbe);
if (ret != 0) {
pmb_free(pmbe);
return -EBUSY;
}
phys += pmb_sizes[i].size;
vaddr += pmb_sizes[i].size;
size -= pmb_sizes[i].size;
/*
* Link adjacent entries that span multiple PMB entries
* for easier tear-down.
*/
if (likely(pmbp))
pmbp->link = pmbe;
pmbp = pmbe;
}
if (size >= 0x1000000)
goto again;
return wanted - size;
}
void pmb_unmap(unsigned long addr)
{
struct pmb_entry **p, *pmbe;
for (p = &pmb_list; (pmbe = *p); p = &pmbe->next)
if (pmbe->vpn == addr)
break;
if (unlikely(!pmbe))
return;
WARN_ON(!test_bit(pmbe->entry, &pmb_map));
do {
struct pmb_entry *pmblink = pmbe;
clear_pmb_entry(pmbe);
pmbe = pmblink->link;
pmb_free(pmblink);
} while (pmbe);
}
static void pmb_cache_ctor(void *pmb, kmem_cache_t *cachep, unsigned long flags) static void pmb_cache_ctor(void *pmb, kmem_cache_t *cachep, unsigned long flags)
{ {
struct pmb_entry *pmbe = pmb;
memset(pmb, 0, sizeof(struct pmb_entry)); memset(pmb, 0, sizeof(struct pmb_entry));
((struct pmb_entry *)pmb)->entry = PMB_NO_ENTRY; spin_lock_irq(&pmb_list_lock);
pmbe->entry = PMB_NO_ENTRY;
pmb_list_add(pmbe);
spin_unlock_irq(&pmb_list_lock);
}
static void pmb_cache_dtor(void *pmb, kmem_cache_t *cachep, unsigned long flags)
{
spin_lock_irq(&pmb_list_lock);
pmb_list_del(pmb);
spin_unlock_irq(&pmb_list_lock);
} }
static int __init pmb_init(void) static int __init pmb_init(void)
...@@ -177,7 +312,7 @@ static int __init pmb_init(void) ...@@ -177,7 +312,7 @@ static int __init pmb_init(void)
BUG_ON(unlikely(nr_entries >= NR_PMB_ENTRIES)); BUG_ON(unlikely(nr_entries >= NR_PMB_ENTRIES));
pmb_cache = kmem_cache_create("pmb", sizeof(struct pmb_entry), pmb_cache = kmem_cache_create("pmb", sizeof(struct pmb_entry),
0, 0, pmb_cache_ctor, NULL); 0, 0, pmb_cache_ctor, pmb_cache_dtor);
BUG_ON(!pmb_cache); BUG_ON(!pmb_cache);
jump_to_P2(); jump_to_P2();
......
...@@ -74,5 +74,8 @@ extern int landisk_ledparam; /* from setup.c */ ...@@ -74,5 +74,8 @@ extern int landisk_ledparam; /* from setup.c */
extern int landisk_buzzerparam; /* from setup.c */ extern int landisk_buzzerparam; /* from setup.c */
extern int landisk_arch; /* from setup.c */ extern int landisk_arch; /* from setup.c */
#define __IO_PREFIX landisk
#include <asm/io_generic.h>
#endif /* __ASM_SH_IODATA_LANDISK_H */ #endif /* __ASM_SH_IODATA_LANDISK_H */
...@@ -50,6 +50,8 @@ typedef unsigned long mm_context_t; ...@@ -50,6 +50,8 @@ typedef unsigned long mm_context_t;
#define PMB_NO_ENTRY (-1) #define PMB_NO_ENTRY (-1)
struct pmb_entry;
struct pmb_entry { struct pmb_entry {
unsigned long vpn; unsigned long vpn;
unsigned long ppn; unsigned long ppn;
...@@ -60,16 +62,23 @@ struct pmb_entry { ...@@ -60,16 +62,23 @@ struct pmb_entry {
* PMB_NO_ENTRY to search for a free one * PMB_NO_ENTRY to search for a free one
*/ */
int entry; int entry;
struct pmb_entry *next;
/* Adjacent entry link for contiguous multi-entry mappings */
struct pmb_entry *link;
}; };
/* arch/sh/mm/pmb.c */ /* arch/sh/mm/pmb.c */
int __set_pmb_entry(unsigned long vpn, unsigned long ppn, int __set_pmb_entry(unsigned long vpn, unsigned long ppn,
unsigned long flags, int *entry); unsigned long flags, int *entry);
void set_pmb_entry(struct pmb_entry *pmbe); int set_pmb_entry(struct pmb_entry *pmbe);
void clear_pmb_entry(struct pmb_entry *pmbe); void clear_pmb_entry(struct pmb_entry *pmbe);
struct pmb_entry *pmb_alloc(unsigned long vpn, unsigned long ppn, struct pmb_entry *pmb_alloc(unsigned long vpn, unsigned long ppn,
unsigned long flags); unsigned long flags);
void pmb_free(struct pmb_entry *pmbe); void pmb_free(struct pmb_entry *pmbe);
long pmb_remap(unsigned long virt, unsigned long phys,
unsigned long size, unsigned long flags);
void pmb_unmap(unsigned long addr);
#endif /* __MMU_H */ #endif /* __MMU_H */
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