10 #include <linux/module.h>
12 #include <linux/kernel.h>
13 #include <linux/string.h>
14 #include <linux/types.h>
15 #include <linux/slab.h>
18 #include <asm/setup.h>
19 #include <asm/segment.h>
21 #include <asm/pgalloc.h>
26 #define PTRTREESIZE (256*1024)
35 #ifdef CPU_M68040_OR_M68060_ONLY
37 #define IO_SIZE PAGE_SIZE
39 static inline struct vm_struct *get_io_area(
unsigned long size)
45 static inline void free_io_area(
void *
addr)
52 #define IO_SIZE (256*1024)
65 for (p = &iolist; (tmp = *
p) ; p = &tmp->
next) {
66 if (size + addr < (
unsigned long)tmp->
addr)
74 area->
addr = (
void *)addr;
81 static inline void free_io_area(
void *addr)
87 addr = (
void *)((
unsigned long)addr & -
IO_SIZE);
88 for (p = &iolist ; (tmp = *
p) ; p = &tmp->
next) {
89 if (tmp->
addr == addr) {
108 unsigned long virtaddr, retaddr;
117 if (!size || physaddr > (
unsigned long)(-size))
122 if ((physaddr >= 0x40000000) && (physaddr + size < 0x60000000)
123 && (cacheflag == IOMAP_NOCACHE_SER))
124 return (
void __iomem *)physaddr;
129 printk(
"ioremap: 0x%lx,0x%lx(%d) - ", physaddr, size, cacheflag);
134 offset = physaddr & (
IO_SIZE - 1);
141 area = get_io_area(size);
145 virtaddr = (
unsigned long)area->
addr;
146 retaddr = virtaddr + offset;
148 printk(
"0x%lx,0x%lx,0x%lx", physaddr, virtaddr, retaddr);
158 case IOMAP_FULL_CACHING:
161 case IOMAP_NOCACHE_SER:
165 case IOMAP_NOCACHE_NONSER:
168 case IOMAP_WRITETHROUGH:
176 case IOMAP_NOCACHE_SER:
177 case IOMAP_NOCACHE_NONSER:
181 case IOMAP_FULL_CACHING:
182 case IOMAP_WRITETHROUGH:
187 while ((
long)size > 0) {
190 printk (
"\npa=%#lx va=%#lx ", physaddr, virtaddr);
195 printk(
"ioremap: no mem for pmd_dir\n");
205 pte_dir = pte_alloc_kernel(pmd_dir, virtaddr);
207 printk(
"ioremap: no mem for pte_dir\n");
222 return (
void __iomem *)retaddr;
233 (((
unsigned long)addr < 0x40000000) ||
234 ((
unsigned long)addr > 0x60000000)))
235 free_io_area((
__force void *)addr);
237 free_io_area((
__force void *)addr);
249 unsigned long virtaddr = (
unsigned long)addr;
254 while ((
long)size > 0) {
268 pmd_dir->
pmd[pmd_off] = 0;
272 }
else if (pmd_type == 0)
298 unsigned long virtaddr = (
unsigned long)addr;
305 case IOMAP_FULL_CACHING:
308 case IOMAP_NOCACHE_SER:
312 case IOMAP_NOCACHE_NONSER:
315 case IOMAP_WRITETHROUGH:
321 case IOMAP_NOCACHE_SER:
322 case IOMAP_NOCACHE_NONSER:
326 case IOMAP_FULL_CACHING:
327 case IOMAP_WRITETHROUGH:
332 while ((
long)size > 0) {
345 pmd_dir->
pmd[pmd_off] = (pmd_dir->
pmd[pmd_off] &