root/arch/alpha/mm/init.c

/* [previous][next][first][last][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. __bad_pagetable
  2. __bad_page
  3. __zero_page
  4. show_mem
  5. paging_init
  6. mem_init
  7. si_meminfo

   1 /*
   2  *  linux/arch/alpha/mm/init.c
   3  *
   4  *  Copyright (C) 1995  Linus Torvalds
   5  */
   6 
   7 #include <linux/config.h>
   8 #include <linux/signal.h>
   9 #include <linux/sched.h>
  10 #include <linux/head.h>
  11 #include <linux/kernel.h>
  12 #include <linux/errno.h>
  13 #include <linux/string.h>
  14 #include <linux/types.h>
  15 #include <linux/ptrace.h>
  16 #include <linux/mman.h>
  17 #include <linux/mm.h>
  18 
  19 #include <asm/system.h>
  20 #include <asm/segment.h>
  21 #include <asm/hwrpb.h>
  22 
  23 extern void scsi_mem_init(unsigned long);
  24 extern void sound_mem_init(void);
  25 extern void die_if_kernel(char *,struct pt_regs *,long);
  26 extern void show_net_buffers(void);
  27 
  28 /*
  29  * BAD_PAGE is the page that is used for page faults when linux
  30  * is out-of-memory. Older versions of linux just did a
  31  * do_exit(), but using this instead means there is less risk
  32  * for a process dying in kernel mode, possibly leaving a inode
  33  * unused etc..
  34  *
  35  * BAD_PAGETABLE is the accompanying page-table: it is initialized
  36  * to point to BAD_PAGE entries.
  37  *
  38  * ZERO_PAGE is a special page that is used for zero-initialized
  39  * data and COW.
  40  */
  41 struct pte * __bad_pagetable(void)
     /* [previous][next][first][last][top][bottom][index][help] */
  42 {
  43         memset((void *) EMPTY_PGT, 0, PAGE_SIZE);
  44         return (struct pte *) EMPTY_PGT;
  45 }
  46 
  47 unsigned long __bad_page(void)
     /* [previous][next][first][last][top][bottom][index][help] */
  48 {
  49         memset((void *) EMPTY_PGE, 0, PAGE_SIZE);
  50         return EMPTY_PGE;
  51 }
  52 
  53 unsigned long __zero_page(void)
     /* [previous][next][first][last][top][bottom][index][help] */
  54 {
  55         memset((void *) ZERO_PGE, 0, PAGE_SIZE);
  56         return ZERO_PGE;
  57 }
  58 
  59 void show_mem(void)
     /* [previous][next][first][last][top][bottom][index][help] */
  60 {
  61         int i,free = 0,total = 0,reserved = 0;
  62         int shared = 0;
  63 
  64         printk("Mem-info:\n");
  65         show_free_areas();
  66         printk("Free swap:       %6dkB\n",nr_swap_pages<<(PAGE_SHIFT-10));
  67         i = high_memory >> PAGE_SHIFT;
  68         while (i-- > 0) {
  69                 total++;
  70                 if (mem_map[i] & MAP_PAGE_RESERVED)
  71                         reserved++;
  72                 else if (!mem_map[i])
  73                         free++;
  74                 else
  75                         shared += mem_map[i]-1;
  76         }
  77         printk("%d pages of RAM\n",total);
  78         printk("%d free pages\n",free);
  79         printk("%d reserved pages\n",reserved);
  80         printk("%d pages shared\n",shared);
  81         show_buffers();
  82 #ifdef CONFIG_NET
  83         show_net_buffers();
  84 #endif
  85 }
  86 
  87 extern unsigned long free_area_init(unsigned long, unsigned long);
  88 
  89 /*
  90  * paging_init() sets up the page tables: in the alpha version this actually
  91  * unmaps the bootup page table (as we're now in KSEG, so we don't need it).
  92  *
  93  * The bootup sequence put the virtual page table into high memory: that
  94  * means that we can change the L1 page table by just using VL1p below.
  95  */
  96 #define VL1p ((unsigned long *) 0xffffffffffffe000)
  97 unsigned long paging_init(unsigned long start_mem, unsigned long end_mem)
     /* [previous][next][first][last][top][bottom][index][help] */
  98 {
  99         int i;
 100         struct memclust_struct * cluster;
 101         struct memdesc_struct * memdesc;
 102 
 103         /* initialize mem_map[] */
 104         start_mem = free_area_init(start_mem, end_mem);
 105 
 106         /* find free clusters, update mem_map[] accordingly */
 107         memdesc = (struct memdesc_struct *) (INIT_HWRPB->mddt_offset + (unsigned long) INIT_HWRPB);
 108         cluster = memdesc->cluster;
 109         for (i = memdesc->numclusters ; i > 0; i--, cluster++) {
 110                 unsigned long pfn, nr;
 111                 if (cluster->usage & 1)
 112                         continue;
 113                 pfn = cluster->start_pfn;
 114                 nr = cluster->numpages;
 115 
 116                 /* non-volatile memory. We might want to mark this for later */
 117                 if (cluster->usage & 2)
 118                         continue;
 119 
 120                 while (nr--)
 121                         mem_map[pfn++] = 0;
 122         }
 123 
 124         /* unmap the console stuff: we don't need it, and we don't want it */
 125         for (i = 0; i < 1023; i++)
 126                 VL1p[i] = 0;
 127         invalidate_all();
 128         return start_mem;
 129 }
 130 
 131 void mem_init(unsigned long start_mem, unsigned long end_mem)
     /* [previous][next][first][last][top][bottom][index][help] */
 132 {
 133         unsigned long tmp;
 134 
 135         end_mem &= PAGE_MASK;
 136         high_memory = end_mem;
 137         start_mem = PAGE_ALIGN(start_mem);
 138 
 139         /*
 140          * Mark the pages used by the kernel as reserved,,
 141          */
 142         tmp = KERNEL_START;
 143         while (tmp < start_mem) {
 144                 mem_map[MAP_NR(tmp)] = MAP_PAGE_RESERVED;
 145                 tmp += PAGE_SIZE;
 146         }
 147 
 148 
 149 #ifdef CONFIG_SCSI
 150         scsi_mem_init(high_memory);
 151 #endif
 152 #ifdef CONFIG_SOUND
 153         sound_mem_init();
 154 #endif
 155 
 156         for (tmp = PAGE_OFFSET ; tmp < high_memory ; tmp += PAGE_SIZE) {
 157                 if (mem_map[MAP_NR(tmp)])
 158                         continue;
 159                 mem_map[MAP_NR(tmp)] = 1;
 160                 free_page(tmp);
 161         }
 162         tmp = nr_free_pages << PAGE_SHIFT;
 163         printk("Memory: %luk available\n", tmp >> 10);
 164         return;
 165 }
 166 
 167 void si_meminfo(struct sysinfo *val)
     /* [previous][next][first][last][top][bottom][index][help] */
 168 {
 169         int i;
 170 
 171         i = high_memory >> PAGE_SHIFT;
 172         val->totalram = 0;
 173         val->sharedram = 0;
 174         val->freeram = nr_free_pages << PAGE_SHIFT;
 175         val->bufferram = buffermem;
 176         while (i-- > 0)  {
 177                 if (mem_map[i] & MAP_PAGE_RESERVED)
 178                         continue;
 179                 val->totalram++;
 180                 if (!mem_map[i])
 181                         continue;
 182                 val->sharedram += mem_map[i]-1;
 183         }
 184         val->totalram <<= PAGE_SHIFT;
 185         val->sharedram <<= PAGE_SHIFT;
 186         return;
 187 }

/* [previous][next][first][last][top][bottom][index][help] */