static unsigned long shmedia_ioremap(struct resource *res, u32 pa, int sz) { unsigned long offset = ((unsigned long) pa) & (~PAGE_MASK); unsigned long round_sz = (offset + sz + PAGE_SIZE-1) & PAGE_MASK; unsigned long va; unsigned int psz; if (allocate_resource(&shmedia_iomap, res, round_sz, shmedia_iomap.start, shmedia_iomap.end, PAGE_SIZE, NULL, NULL) != 0) { panic("alloc_io_res(%s): cannot occupy\n", (res->name != NULL)? res->name: "???"); } va = res->start; pa &= PAGE_MASK; psz = (res->end - res->start + (PAGE_SIZE - 1)) / PAGE_SIZE; /* log at boot time ... */ printk("mapioaddr: %6s [%2d page%s] va 0x%08lx pa 0x%08x\n", ((res->name != NULL) ? res->name : "???"), psz, psz == 1 ? " " : "s", va, pa); for (psz = res->end - res->start + 1; psz != 0; psz -= PAGE_SIZE) { shmedia_mapioaddr(pa, va); va += PAGE_SIZE; pa += PAGE_SIZE; } res->start += offset; res->end = res->start + sz - 1; /* not strictly necessary.. */ return res->start; }
static void __iomem *shmedia_ioremap(struct resource *res, u32 pa, int sz, unsigned long flags) { unsigned long offset = ((unsigned long) pa) & (~PAGE_MASK); unsigned long round_sz = (offset + sz + PAGE_SIZE-1) & PAGE_MASK; unsigned long va; unsigned int psz; if (allocate_resource(&shmedia_iomap, res, round_sz, shmedia_iomap.start, shmedia_iomap.end, PAGE_SIZE, NULL, NULL) != 0) { panic("alloc_io_res(%s): cannot occupy\n", (res->name != NULL) ? res->name : "???"); } va = res->start; pa &= PAGE_MASK; psz = (res->end - res->start + (PAGE_SIZE - 1)) / PAGE_SIZE; for (psz = res->end - res->start + 1; psz != 0; psz -= PAGE_SIZE) { shmedia_mapioaddr(pa, va, flags); va += PAGE_SIZE; pa += PAGE_SIZE; } return (void __iomem *)(unsigned long)(res->start + offset); }