linux 2.6.16.38 w/ vs2.0.3-rc1
[linux-2.6.git] / arch / parisc / mm / init.c
index f2b96f1..7847ca1 100644 (file)
@@ -6,10 +6,10 @@
  *    changed by Philipp Rumpf
  *  Copyright 1999 Philipp Rumpf (prumpf@tux.org)
  *  Copyright 2004 Randolph Chung (tausq@debian.org)
- *  Copyright 2006 Helge Deller (deller@gmx.de)
  *
  */
 
+#include <linux/config.h>
 
 #include <linux/module.h>
 #include <linux/mm.h>
@@ -27,7 +27,6 @@
 #include <asm/tlb.h>
 #include <asm/pdc_chassis.h>
 #include <asm/mmzone.h>
-#include <asm/sections.h>
 
 DEFINE_PER_CPU(struct mmu_gather, mmu_gathers);
 
@@ -372,8 +371,8 @@ static void __init setup_bootmem(void)
 
 void free_initmem(void)
 {
-       unsigned long addr, init_begin, init_end;
-
+       unsigned long addr;
+       
        printk(KERN_INFO "Freeing unused kernel memory: ");
 
 #ifdef CONFIG_DEBUG_KERNEL
@@ -396,13 +395,10 @@ void free_initmem(void)
        local_irq_enable();
 #endif
        
-       /* align __init_begin and __init_end to page size,
-          ignoring linker script where we might have tried to save RAM */
-       init_begin = PAGE_ALIGN((unsigned long)(&__init_begin));
-       init_end   = PAGE_ALIGN((unsigned long)(&__init_end));
-       for (addr = init_begin; addr < init_end; addr += PAGE_SIZE) {
+       addr = (unsigned long)(&__init_begin);
+       for (; addr < (unsigned long)(&__init_end); addr += PAGE_SIZE) {
                ClearPageReserved(virt_to_page(addr));
-               init_page_count(virt_to_page(addr));
+               set_page_count(virt_to_page(addr), 1);
                free_page(addr);
                num_physpages++;
                totalram_pages++;
@@ -411,17 +407,18 @@ void free_initmem(void)
        /* set up a new led state on systems shipped LED State panel */
        pdc_chassis_send_status(PDC_CHASSIS_DIRECT_BCOMPLETE);
        
-       printk("%luk freed\n", (init_end - init_begin) >> 10);
+       printk("%luk freed\n", (unsigned long)(&__init_end - &__init_begin) >> 10);
 }
 
 
 #ifdef CONFIG_DEBUG_RODATA
 void mark_rodata_ro(void)
 {
+       extern char __start_rodata, __end_rodata;
        /* rodata memory was already mapped with KERNEL_RO access rights by
            pagetable_init() and map_pages(). No need to do additional stuff here */
        printk (KERN_INFO "Write protecting the kernel read-only data: %luk\n",
-               (unsigned long)(__end_rodata - __start_rodata) >> 10);
+               (unsigned long)(&__end_rodata - &__start_rodata) >> 10);
 }
 #endif
 
@@ -642,13 +639,11 @@ static void __init map_pages(unsigned long start_vaddr, unsigned long start_padd
                                 * Map the fault vector writable so we can
                                 * write the HPMC checksum.
                                 */
-#if defined(CONFIG_PARISC_PAGE_SIZE_4KB)
                                if (address >= ro_start && address < ro_end
                                                        && address != fv_addr
                                                        && address != gw_addr)
                                    pte = __mk_pte(address, PAGE_KERNEL_RO);
                                else
-#endif
                                    pte = __mk_pte(address, pgprot);
 
                                if (address >= end_paddr)
@@ -879,7 +874,8 @@ unsigned long alloc_sid(void)
                        flush_tlb_all(); /* flush_tlb_all() calls recycle_sids() */
                        spin_lock(&sid_lock);
                }
-               BUG_ON(free_space_ids == 0);
+               if (free_space_ids == 0)
+                       BUG();
        }
 
        free_space_ids--;
@@ -903,7 +899,8 @@ void free_sid(unsigned long spaceid)
 
        spin_lock(&sid_lock);
 
-       BUG_ON(*dirty_space_offset & (1L << index)); /* attempt to free space id twice */
+       if (*dirty_space_offset & (1L << index))
+           BUG(); /* attempt to free space id twice */
 
        *dirty_space_offset |= (1L << index);
        dirty_space_ids++;
@@ -978,7 +975,7 @@ static void recycle_sids(void)
 
 static unsigned long recycle_ndirty;
 static unsigned long recycle_dirty_array[SID_ARRAY_SIZE];
-static unsigned int recycle_inuse;
+static unsigned int recycle_inuse = 0;
 
 void flush_tlb_all(void)
 {
@@ -987,7 +984,9 @@ void flush_tlb_all(void)
        do_recycle = 0;
        spin_lock(&sid_lock);
        if (dirty_space_ids > RECYCLE_THRESHOLD) {
-           BUG_ON(recycle_inuse);  /* FIXME: Use a semaphore/wait queue here */
+           if (recycle_inuse) {
+               BUG();  /* FIXME: Use a semaphore/wait queue here */
+           }
            get_dirty_sids(&recycle_ndirty,recycle_dirty_array);
            recycle_inuse++;
            do_recycle++;
@@ -1014,15 +1013,16 @@ void flush_tlb_all(void)
 #ifdef CONFIG_BLK_DEV_INITRD
 void free_initrd_mem(unsigned long start, unsigned long end)
 {
-       if (start >= end)
-               return;
-       printk(KERN_INFO "Freeing initrd memory: %ldk freed\n", (end - start) >> 10);
+#if 0
+       if (start < end)
+               printk(KERN_INFO "Freeing initrd memory: %ldk freed\n", (end - start) >> 10);
        for (; start < end; start += PAGE_SIZE) {
                ClearPageReserved(virt_to_page(start));
-               init_page_count(virt_to_page(start));
+               set_page_count(virt_to_page(start), 1);
                free_page(start);
                num_physpages++;
                totalram_pages++;
        }
+#endif
 }
 #endif