import of ftp.dlink.com/GPL/DSMG-600_reB/ppclinux.tar.gz
[linux-2.4.21-pre4.git] / arch / ppc / mm / init.c
1 /*
2  * BK Id: SCCS/s.init.c 1.78 08/14/02 22:02:54 mporter
3  */
4 /*
5  *  PowerPC version
6  *    Copyright (C) 1995-1996 Gary Thomas (gdt@linuxppc.org)
7  *
8  *  Modifications by Paul Mackerras (PowerMac) (paulus@cs.anu.edu.au)
9  *  and Cort Dougan (PReP) (cort@cs.nmt.edu)
10  *    Copyright (C) 1996 Paul Mackerras
11  *  Amiga/APUS changes by Jesper Skov (jskov@cygnus.co.uk).
12  *  PPC440/36-bit changes by Matt Porter (mporter@mvista.com)
13  *
14  *  Derived from "arch/i386/mm/init.c"
15  *    Copyright (C) 1991, 1992, 1993, 1994  Linus Torvalds
16  *
17  *  This program is free software; you can redistribute it and/or
18  *  modify it under the terms of the GNU General Public License
19  *  as published by the Free Software Foundation; either version
20  *  2 of the License, or (at your option) any later version.
21  *
22  */
23
24 #include <linux/config.h>
25 #include <linux/sched.h>
26 #include <linux/kernel.h>
27 #include <linux/errno.h>
28 #include <linux/string.h>
29 #include <linux/types.h>
30 #include <linux/mm.h>
31 #include <linux/stddef.h>
32 #include <linux/init.h>
33 #include <linux/bootmem.h>
34 #include <linux/highmem.h>
35 #ifdef CONFIG_BLK_DEV_INITRD
36 #include <linux/blk.h>          /* for initrd_* */
37 #endif
38
39 #include <asm/pgalloc.h>
40 #include <asm/prom.h>
41 #include <asm/io.h>
42 #include <asm/mmu_context.h>
43 #include <asm/pgtable.h>
44 #include <asm/mmu.h>
45 #include <asm/smp.h>
46 #include <asm/machdep.h>
47 #include <asm/btext.h>
48 #include <asm/tlb.h>
49
50 #include "mem_pieces.h"
51 #include "mmu_decl.h"
52
53 #ifdef CONFIG_PPC_ISERIES
54 extern void create_virtual_bus_tce_table(void);
55 #endif
56
57 mmu_gather_t mmu_gathers[NR_CPUS];
58
59 unsigned long total_memory;
60 unsigned long total_lowmem;
61
62 unsigned long ppc_memstart;
63 unsigned long ppc_memoffset = PAGE_OFFSET;
64
65 int mem_init_done;
66 int init_bootmem_done;
67 int boot_mapsize;
68 unsigned long totalram_pages;
69 unsigned long totalhigh_pages;
70 #ifdef CONFIG_ALL_PPC
71 unsigned long agp_special_page;
72 #endif
73
74 extern char _end[];
75 extern char etext[], _stext[];
76 extern char __init_begin, __init_end;
77 extern char __prep_begin, __prep_end;
78 extern char __chrp_begin, __chrp_end;
79 extern char __pmac_begin, __pmac_end;
80 extern char __openfirmware_begin, __openfirmware_end;
81
82 #ifdef CONFIG_HIGHMEM
83 pte_t *kmap_pte;
84 pgprot_t kmap_prot;
85 #endif
86
87 void MMU_init(void);
88 void set_phys_avail(unsigned long total_ram);
89
90 /* XXX should be in current.h  -- paulus */
91 extern struct task_struct *current_set[NR_CPUS];
92
93 char *klimit = _end;
94 struct mem_pieces phys_avail;
95
96 extern char *sysmap;
97 extern unsigned long sysmap_size;
98 /*
99  * this tells the system to map all of ram with the segregs
100  * (i.e. page tables) instead of the bats.
101  * -- Cort
102  */
103 int __map_without_bats;
104
105 /* max amount of RAM to use */
106 unsigned long __max_memory;
107
108 int do_check_pgt_cache(int low, int high)
109 {
110         int freed = 0;
111         if (pgtable_cache_size > high) {
112                 do {
113                         if (pgd_quicklist) {
114                                 free_pgd_slow(get_pgd_fast());
115                                 freed++;
116                         }
117                         if (pte_quicklist) {
118                                 pte_free_slow(pte_alloc_one_fast(NULL, 0));
119                                 freed++;
120                         }
121                 } while (pgtable_cache_size > low);
122         }
123         return freed;
124 }
125
126 void show_mem(void)
127 {
128         int i,free = 0,total = 0,reserved = 0;
129         int shared = 0, cached = 0;
130         struct task_struct *p;
131         int highmem = 0;
132
133         printk("Mem-info:\n");
134         show_free_areas();
135         printk("Free swap:       %6dkB\n",nr_swap_pages<<(PAGE_SHIFT-10));
136         i = max_mapnr;
137         while (i-- > 0) {
138                 total++;
139                 if (PageHighMem(mem_map+i))
140                         highmem++;
141                 if (PageReserved(mem_map+i))
142                         reserved++;
143                 else if (PageSwapCache(mem_map+i))
144                         cached++;
145                 else if (!page_count(mem_map+i))
146                         free++;
147                 else
148                         shared += atomic_read(&mem_map[i].count) - 1;
149         }
150         printk("%d pages of RAM\n",total);
151         printk("%d pages of HIGHMEM\n", highmem);
152         printk("%d free pages\n",free);
153         printk("%d reserved pages\n",reserved);
154         printk("%d pages shared\n",shared);
155         printk("%d pages swap cached\n",cached);
156         printk("%d pages in page table cache\n",(int)pgtable_cache_size);
157         show_buffers();
158         printk("%-8s %3s %8s %8s %8s %9s %8s", "Process", "Pid",
159                "Ctx", "Ctx<<4", "Last Sys", "pc", "task");
160 #ifdef CONFIG_SMP
161         printk(" %3s", "CPU");
162 #endif /* CONFIG_SMP */
163         printk("\n");
164         for_each_task(p)
165         {
166                 printk("%-8.8s %3d %8ld %8ld %8ld %c%08lx %08lx ",
167                        p->comm,p->pid,
168                        (p->mm)?p->mm->context:0,
169                        (p->mm)?(p->mm->context<<4):0,
170                        p->thread.last_syscall,
171                        (p->thread.regs)?user_mode(p->thread.regs) ? 'u' : 'k' : '?',
172                        (p->thread.regs)?p->thread.regs->nip:0,
173                        (ulong)p);
174                 {
175                         int iscur = 0;
176 #ifdef CONFIG_SMP
177                         printk("%3d ", p->processor);
178                         if ( (p->processor != NO_PROC_ID) &&
179                              (p == current_set[p->processor]) )
180                         {
181                                 iscur = 1;
182                                 printk("current");
183                         }
184 #else
185                         if ( p == current )
186                         {
187                                 iscur = 1;
188                                 printk("current");
189                         }
190
191                         if ( p == last_task_used_math )
192                         {
193                                 if ( iscur )
194                                         printk(",");
195                                 printk("last math");
196                         }
197 #endif /* CONFIG_SMP */
198                         printk("\n");
199                 }
200         }
201 }
202
203 void si_meminfo(struct sysinfo *val)
204 {
205         val->totalram = totalram_pages;
206         val->sharedram = 0;
207         val->freeram = nr_free_pages();
208         val->bufferram = atomic_read(&buffermem_pages);
209         val->totalhigh = totalhigh_pages;
210         val->freehigh = nr_free_highpages();
211         val->mem_unit = PAGE_SIZE;
212 }
213
214 /* Free up now-unused memory */
215 static void free_sec(unsigned long start, unsigned long end, const char *name)
216 {
217         unsigned long cnt = 0;
218
219         while (start < end) {
220                 ClearPageReserved(virt_to_page(start));
221                 set_page_count(virt_to_page(start), 1);
222                 free_page(start);
223                 cnt++;
224                 start += PAGE_SIZE;
225         }
226         if (cnt) {
227                 printk(" %ldk %s", cnt << (PAGE_SHIFT - 10), name);
228                 totalram_pages += cnt;
229         }
230 }
231
232 void free_initmem(void)
233 {
234 #define FREESEC(TYPE) \
235         free_sec((unsigned long)(&__ ## TYPE ## _begin), \
236                  (unsigned long)(&__ ## TYPE ## _end), \
237                  #TYPE);
238
239         printk (KERN_INFO "Freeing unused kernel memory:");
240         FREESEC(init);
241         if (_machine != _MACH_Pmac)
242                 FREESEC(pmac);
243         if (_machine != _MACH_chrp)
244                 FREESEC(chrp);
245         if (_machine != _MACH_prep)
246                 FREESEC(prep);
247         if (!have_of)
248                 FREESEC(openfirmware);
249         printk("\n");
250 #undef FREESEC
251 }
252
253 #ifdef CONFIG_BLK_DEV_INITRD
254 void free_initrd_mem(unsigned long start, unsigned long end)
255 {
256         printk (KERN_INFO "Freeing initrd memory: %ldk freed\n", (end - start) >> 10);
257
258         for (; start < end; start += PAGE_SIZE) {
259                 ClearPageReserved(virt_to_page(start));
260                 set_page_count(virt_to_page(start), 1);
261                 free_page(start);
262                 totalram_pages++;
263         }
264 }
265 #endif
266
267 /*
268  * Check for command-line options that affect what MMU_init will do.
269  */
270 void MMU_setup(void)
271 {
272         /* Check for nobats option (used in mapin_ram). */
273         if (strstr(cmd_line, "nobats")) {
274                 __map_without_bats = 1;
275         }
276
277         /* Look for mem= option on command line */
278         if (strstr(cmd_line, "mem=")) {
279                 char *p, *q;
280                 unsigned long maxmem = 0;
281
282                 for (q = cmd_line; (p = strstr(q, "mem=")) != 0; ) {
283                         q = p + 4;
284                         if (p > cmd_line && p[-1] != ' ')
285                                 continue;
286                         maxmem = simple_strtoul(q, &q, 0);
287                         if (*q == 'k' || *q == 'K') {
288                                 maxmem <<= 10;
289                                 ++q;
290                         } else if (*q == 'm' || *q == 'M') {
291                                 maxmem <<= 20;
292                                 ++q;
293                         }
294                 }
295                 __max_memory = maxmem;
296         }
297 }
298
299 /*
300  * MMU_init sets up the basic memory mappings for the kernel,
301  * including both RAM and possibly some I/O regions,
302  * and sets up the page tables and the MMU hardware ready to go.
303  */
304 void __init MMU_init(void)
305 {
306         if (ppc_md.progress)
307                 ppc_md.progress("MMU:enter", 0x111);
308
309         /* parse args from command line */
310         MMU_setup();
311
312         /*
313          * Figure out how much memory we have, how much
314          * is lowmem, and how much is highmem.
315          */
316         total_memory = ppc_md.find_end_of_memory();
317
318         if (__max_memory && total_memory > __max_memory)
319                 total_memory = __max_memory;
320         total_lowmem = total_memory;
321         adjust_total_lowmem();  
322         set_phys_avail(total_lowmem);
323
324         /* Initialize the MMU hardware */
325         if (ppc_md.progress)
326                 ppc_md.progress("MMU:hw init", 0x300);
327         MMU_init_hw();
328
329         /* Map in all of RAM starting at KERNELBASE */
330         if (ppc_md.progress)
331                 ppc_md.progress("MMU:mapin", 0x301);
332         mapin_ram();
333
334 #ifdef CONFIG_HIGHMEM
335         ioremap_base = PKMAP_BASE;
336 #else
337         ioremap_base = 0xfe000000UL;    /* for now, could be 0xfffff000 */
338 #endif /* CONFIG_HIGHMEM */
339         ioremap_bot = ioremap_base;
340
341         /* Map in I/O resources */
342         if (ppc_md.progress)
343                 ppc_md.progress("MMU:setio", 0x302);
344         if (ppc_md.setup_io_mappings)
345                 ppc_md.setup_io_mappings();
346         
347         /* Initialize the context management stuff */
348         mmu_context_init();
349
350         if (ppc_md.progress)
351                 ppc_md.progress("MMU:exit", 0x211);
352
353 #ifdef CONFIG_BOOTX_TEXT
354         /* By default, we are no longer mapped */
355         boot_text_mapped = 0;   
356         /* Must be done last, or ppc_md.progress will die. */
357         map_boot_text();
358 #endif
359 }
360
361 /* This is only called until mem_init is done. */
362 void __init *early_get_page(void)
363 {
364         void *p;
365
366         if (init_bootmem_done) {
367                 p = alloc_bootmem_pages(PAGE_SIZE);
368         } else {
369                 p = mem_pieces_find(PAGE_SIZE, PAGE_SIZE);
370         }
371         return p;
372 }
373
374 /*
375  * Initialize the bootmem system and give it all the memory we
376  * have available.
377  */
378 void __init do_init_bootmem(void)
379 {
380         unsigned long start, size;
381         int i;
382
383         /*
384          * Find an area to use for the bootmem bitmap.
385          * We look for the first area which is at least
386          * 128kB in length (128kB is enough for a bitmap
387          * for 4GB of memory, using 4kB pages), plus 1 page
388          * (in case the address isn't page-aligned).
389          */
390         start = 0;
391         size = 0;
392         for (i = 0; i < phys_avail.n_regions; ++i) {
393                 unsigned long a = phys_avail.regions[i].address;
394                 unsigned long s = phys_avail.regions[i].size;
395                 if (s <= size)
396                         continue;
397                 start = a;
398                 size = s;
399                 if (s >= 33 * PAGE_SIZE)
400                         break;
401         }
402         start = PAGE_ALIGN(start);
403
404         min_low_pfn = start >> PAGE_SHIFT;
405         max_low_pfn = (PPC_MEMSTART + total_lowmem) >> PAGE_SHIFT;
406         boot_mapsize = init_bootmem_node(&contig_page_data, min_low_pfn,
407                                          PPC_MEMSTART >> PAGE_SHIFT,
408                                          max_low_pfn);
409
410         /* remove the bootmem bitmap from the available memory */
411         mem_pieces_remove(&phys_avail, start, boot_mapsize, 1);
412
413         /* add everything in phys_avail into the bootmem map */
414         for (i = 0; i < phys_avail.n_regions; ++i)
415                 free_bootmem(phys_avail.regions[i].address,
416                              phys_avail.regions[i].size);
417
418 #ifdef CONFIG_440
419         /*
420          * Reserve space in the pinned TLB area (ZONE_DMA).
421          * Assume all 44x systems have >16MB RAM and any
422          * initrd is located outside of our pinned TLB area.
423          */
424         reserve_bootmem(0x00800000, 0x00800000);
425 #endif
426
427         init_bootmem_done = 1;
428 }
429
430 /*
431  * paging_init() sets up the page tables - in fact we've already done this.
432  */
433 void __init paging_init(void)
434 {
435         unsigned long zones_size[MAX_NR_ZONES], i;
436
437 #ifdef CONFIG_HIGHMEM
438         map_page(PKMAP_BASE, 0, 0);     /* XXX gross */
439         pkmap_page_table = pte_offset(pmd_offset(pgd_offset_k(PKMAP_BASE), PKMAP_BASE), PKMAP_BASE);
440         map_page(KMAP_FIX_BEGIN, 0, 0); /* XXX gross */
441         kmap_pte = pte_offset(pmd_offset(pgd_offset_k(KMAP_FIX_BEGIN), KMAP_FIX_BEGIN), KMAP_FIX_BEGIN);
442         kmap_prot = PAGE_KERNEL;
443 #endif /* CONFIG_HIGHMEM */
444
445         /*
446          * All pages are DMA-able so we put them all in the DMA zone.
447          */
448 #ifndef CONFIG_440
449         zones_size[ZONE_DMA] = total_lowmem >> PAGE_SHIFT;
450
451         for (i = 1; i < MAX_NR_ZONES; i++)
452                 zones_size[i] = 0;
453 #else
454         /*
455          * On 440, we highjack the DMA zone to provide a zone
456          * which limits allocations to our pinned TLB region.
457          */
458         zones_size[ZONE_DMA] = PPC440_PIN_SIZE >> PAGE_SHIFT;
459         zones_size[ZONE_NORMAL] = (total_lowmem - PPC440_PIN_SIZE) >> PAGE_SHIFT;
460
461         for (i = 2; i < MAX_NR_ZONES; i++)
462                 zones_size[i] = 0;
463 #endif
464
465
466 #ifdef CONFIG_HIGHMEM
467         zones_size[ZONE_HIGHMEM] = (total_memory - total_lowmem) >> PAGE_SHIFT;
468 #endif /* CONFIG_HIGHMEM */
469
470         free_area_init(zones_size);
471 }
472
473 void __init mem_init(void)
474 {
475         unsigned long addr;
476         int codepages = 0;
477         int datapages = 0;
478         int initpages = 0;
479 #ifdef CONFIG_HIGHMEM
480         unsigned long highmem_mapnr;
481
482         highmem_mapnr = total_lowmem >> PAGE_SHIFT;
483         highmem_start_page = mem_map + highmem_mapnr;
484 #endif /* CONFIG_HIGHMEM */
485         max_mapnr = total_memory >> PAGE_SHIFT;
486
487         high_memory = (void *) __va(PPC_MEMSTART + total_lowmem);
488         num_physpages = max_mapnr;      /* RAM is assumed contiguous */
489
490 #ifdef CONFIG_440
491         /* Free reserved space in the pinned TLB area (ZONE_DMA) */
492         if (total_lowmem > PPC440_PIN_SIZE)
493                 free_bootmem(0x00800000, 0x00800000);
494 #endif
495
496         totalram_pages += free_all_bootmem();
497
498 #ifdef CONFIG_BLK_DEV_INITRD
499         /* if we are booted from BootX with an initial ramdisk,
500            make sure the ramdisk pages aren't reserved. */
501         if (initrd_start) {
502                 for (addr = initrd_start; addr < initrd_end; addr += PAGE_SIZE)
503                         ClearPageReserved(virt_to_page(addr));
504         }
505 #endif /* CONFIG_BLK_DEV_INITRD */
506
507 #if defined(CONFIG_ALL_PPC)
508         /* mark the RTAS pages as reserved */
509         if ( rtas_data )
510                 for (addr = (ulong)__va(rtas_data);
511                      addr < PAGE_ALIGN((ulong)__va(rtas_data)+rtas_size) ;
512                      addr += PAGE_SIZE)
513                         SetPageReserved(virt_to_page(addr));
514         if (agp_special_page)
515                 SetPageReserved(virt_to_page(agp_special_page));
516 #endif /* defined(CONFIG_ALL_PPC) */
517         if ( sysmap )
518                 for (addr = (unsigned long)sysmap;
519                      addr < PAGE_ALIGN((unsigned long)sysmap+sysmap_size) ;
520                      addr += PAGE_SIZE)
521                         SetPageReserved(virt_to_page(addr));
522
523         for (addr = PAGE_OFFSET; addr < (unsigned long)high_memory;
524              addr += PAGE_SIZE) {
525                 if (!PageReserved(virt_to_page(addr)))
526                         continue;
527                 if (addr < (ulong) etext)
528                         codepages++;
529                 else if (addr >= (unsigned long)&__init_begin
530                          && addr < (unsigned long)&__init_end)
531                         initpages++;
532                 else if (addr < (ulong) klimit)
533                         datapages++;
534         }
535
536 #ifdef CONFIG_HIGHMEM
537         {
538                 unsigned long pfn;
539
540                 for (pfn = highmem_mapnr; pfn < max_mapnr; ++pfn) {
541                         struct page *page = mem_map + pfn;
542
543                         ClearPageReserved(page);
544                         set_bit(PG_highmem, &page->flags);
545                         atomic_set(&page->count, 1);
546                         __free_page(page);
547                         totalhigh_pages++;
548                 }
549                 totalram_pages += totalhigh_pages;
550         }
551 #endif /* CONFIG_HIGHMEM */
552
553         printk(KERN_INFO "Memory: %luk available (%dk kernel code, %dk data, %dk init, %ldk highmem)\n",
554                (unsigned long)nr_free_pages()<< (PAGE_SHIFT-10),
555                codepages<< (PAGE_SHIFT-10), datapages<< (PAGE_SHIFT-10),
556                initpages<< (PAGE_SHIFT-10),
557                (unsigned long) (totalhigh_pages << (PAGE_SHIFT-10)));
558         if (sysmap)
559                 printk("System.map loaded at 0x%08x for debugger, size: %ld bytes\n",
560                         (unsigned int)sysmap, sysmap_size);
561 #if defined(CONFIG_ALL_PPC)
562         if (agp_special_page)
563                 printk(KERN_INFO "AGP special page: 0x%08lx\n", agp_special_page);
564 #endif /* defined(CONFIG_ALL_PPC) */
565 #ifdef CONFIG_PPC_ISERIES
566
567         create_virtual_bus_tce_table();
568
569 #endif /* CONFIG_PPC_ISERIES */
570         mem_init_done = 1;
571 }
572
573 /*
574  * Set phys_avail to the amount of physical memory,
575  * less the kernel text/data/bss.
576  */
577 void __init
578 set_phys_avail(unsigned long total_memory)
579 {
580         unsigned long kstart, ksize;
581
582         /*
583          * Initially, available physical memory is equivalent to all
584          * physical memory.
585          */
586
587         phys_avail.regions[0].address = PPC_MEMSTART;
588         phys_avail.regions[0].size = total_memory;
589         phys_avail.n_regions = 1;
590         //REX:
591         printk(KERN_INFO "Total memory is %d.\n", total_memory);
592         /*
593          * Map out the kernel text/data/bss from the available physical
594          * memory.
595          */
596
597         kstart = __pa(_stext);  /* should be 0 */
598         ksize = PAGE_ALIGN(klimit - _stext);
599
600         mem_pieces_remove(&phys_avail, kstart, ksize, 0);
601         mem_pieces_remove(&phys_avail, 0, 0x4000, 0);
602
603 #if defined(CONFIG_BLK_DEV_INITRD)
604         /* Remove the init RAM disk from the available memory. */
605         if (initrd_start) {
606                 mem_pieces_remove(&phys_avail, __pa(initrd_start),
607                                   initrd_end - initrd_start, 1);
608         }
609 #endif /* CONFIG_BLK_DEV_INITRD */
610 #ifdef CONFIG_ALL_PPC
611         /* remove the RTAS pages from the available memory */
612         if (rtas_data)
613                 mem_pieces_remove(&phys_avail, rtas_data, rtas_size, 1);
614         /* Because of some uninorth weirdness, we need a page of
615          * memory as high as possible (it must be outside of the
616          * bus address seen as the AGP aperture). It will be used
617          * by the r128 DRM driver
618          * 
619          * FIXME: We need to make sure that page doesn't overlap any of the\
620          * above. This could be done by improving mem_pieces_find to be able
621          * to do a backward search from the end of the list.
622          */
623         if (_machine == _MACH_Pmac && find_devices("uni-north-agp")) {
624                 agp_special_page = (total_memory - PAGE_SIZE);
625                 mem_pieces_remove(&phys_avail, agp_special_page, PAGE_SIZE, 0); 
626                 agp_special_page = (unsigned long)__va(agp_special_page);
627         }
628 #endif /* CONFIG_ALL_PPC */
629         /* remove the sysmap pages from the available memory */
630         if (sysmap)
631                 mem_pieces_remove(&phys_avail, __pa(sysmap), sysmap_size, 1);
632 }
633
634 /* Mark some memory as reserved by removing it from phys_avail. */
635 void __init reserve_phys_mem(unsigned long start, unsigned long size)
636 {
637         mem_pieces_remove(&phys_avail, start, size, 1);
638 }
639
640 /*
641  * This is called when a page has been modified by the kernel.
642  * It just marks the page as not i-cache clean.  We do the i-cache
643  * flush later when the page is given to a user process, if necessary.
644  */
645 void flush_dcache_page(struct page *page)
646 {
647         clear_bit(PG_arch_1, &page->flags);
648 }
649
650 void flush_icache_page(struct vm_area_struct *vma, struct page *page)
651 {
652         if (page->mapping && !PageReserved(page)
653             && !test_bit(PG_arch_1, &page->flags)) {
654                 __flush_dcache_icache(kmap(page));
655                 kunmap(page);
656                 set_bit(PG_arch_1, &page->flags);
657         }
658 }
659
660 void clear_user_page(void *page, unsigned long vaddr)
661 {
662         clear_page(page);
663         __flush_dcache_icache(page);
664 }
665
666 void copy_user_page(void *vto, void *vfrom, unsigned long vaddr)
667 {
668         copy_page(vto, vfrom);
669         __flush_dcache_icache(vto);
670 }
671
672 void flush_icache_user_range(struct vm_area_struct *vma, struct page *page,
673                              unsigned long addr, int len)
674 {
675         unsigned long maddr;
676
677         maddr = (unsigned long) kmap(page) + (addr & ~PAGE_MASK);
678         flush_icache_range(maddr, maddr + len);
679         kunmap(page);
680 }