root/arch/sparc/mm/fault.c

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

DEFINITIONS

This source file includes following definitions.
  1. probe_memory
  2. map_the_prom
  3. do_page_fault

   1 #include <linux/string.h>
   2 #include <linux/types.h>
   3 #include <linux/ptrace.h>
   4 #include <linux/mman.h>
   5 #include <linux/signal.h>
   6 #include <linux/mm.h>
   7 
   8 #include <asm/system.h>
   9 #include <asm/segment.h>
  10 #include <asm/openprom.h>
  11 #include <asm/page.h>
  12 #include <asm/pgtable.h>
  13 
  14 extern unsigned long pg0[1024];         /* page table for 0-4MB for everybody */
  15 extern void die_if_kernel(char *,struct pt_regs *,long);
  16 
  17 struct linux_romvec *romvec;
  18 
  19 /* foo */
  20 
  21 int tbase_needs_unmapping;
  22 
  23 /* At boot time we determine these two values necessary for setting
  24  * up the segment maps and page table entries (pte's).
  25  */
  26 
  27 int num_segmaps, num_contexts;
  28 int invalid_segment;
  29 
  30 /* various Virtual Address Cache parameters we find at boot time... */
  31 
  32 int vac_size, vac_linesize, vac_do_hw_vac_flushes;
  33 int vac_entries_per_context, vac_entries_per_segment;
  34 int vac_entries_per_page;
  35 
  36 /*
  37  * Define this if things work differently on a i386 and a i486:
  38  * it will (on a i486) warn about kernel memory accesses that are
  39  * done without a 'verify_area(VERIFY_WRITE,..)'
  40  */
  41 #undef CONFIG_TEST_VERIFY_AREA
  42 
  43 /* Traverse the memory lists in the prom to see how much physical we
  44  * have.
  45  */
  46 
  47 unsigned long
  48 probe_memory(void)
     /* [previous][next][first][last][top][bottom][index][help] */
  49 {
  50   register struct linux_romvec *lprom;
  51   register struct linux_mlist_v0 *mlist;
  52   register unsigned long bytes, base_paddr;
  53   register int i;
  54 
  55   bytes = 0;
  56   base_paddr = 0;
  57   lprom = romvec;
  58   switch(lprom->pv_romvers)
  59     {
  60     case 0:
  61       mlist=(*(lprom->pv_v0mem.v0_totphys));
  62       bytes=mlist->num_bytes;
  63       base_paddr = (unsigned long) mlist->start_adr;
  64       printk("Bank 1: starting at 0x%x holding %d bytes\n", 
  65              (unsigned int) base_paddr, (int) bytes);
  66       i=1;
  67       if(mlist->theres_more != (void *)0)
  68         {
  69           i++;
  70           mlist=mlist->theres_more;
  71           bytes+=mlist->num_bytes;
  72           printk("Bank %d: starting at 0x%x holding %d bytes\n", i,
  73                  (unsigned int) mlist->start_adr, (int) mlist->num_bytes);
  74         }
  75       break;
  76     case 2:
  77       printk("no v2 memory probe support yet.\n");
  78       (*(lprom->pv_halt))();
  79       break;
  80     }
  81   printk("Physical memory: %d bytes  starting at va 0x%x\n",
  82          (unsigned int) bytes, (int) base_paddr);
  83 
  84   return bytes;
  85 }
  86 
  87 /* Sparc routine to reserve the mapping of the open boot prom */
  88 
  89 /* uncomment this for FAME and FORTUNE! */
  90 /* #define DEBUG_MAP_PROM */
  91 
  92 int
  93 map_the_prom(int curr_num_segs)
     /* [previous][next][first][last][top][bottom][index][help] */
  94 {
  95   register unsigned long prom_va_begin;
  96   register unsigned long prom_va_end;
  97   register int segmap_entry, i;
  98 
  99   prom_va_begin = LINUX_OPPROM_BEGVM;
 100   prom_va_end   = LINUX_OPPROM_ENDVM;
 101 
 102 #ifdef DEBUG_MAP_PROM
 103   printk("\ncurr_num_segs = 0x%x\n", curr_num_segs);
 104 #endif
 105 
 106   while( prom_va_begin < prom_va_end)
 107     {
 108       segmap_entry=get_segmap(prom_va_begin);
 109 
 110       curr_num_segs = ((segmap_entry<curr_num_segs) 
 111                        ? segmap_entry : curr_num_segs);
 112 
 113       for(i = num_contexts; --i > 0;)
 114           (*romvec->pv_setctxt)(i, (char *) prom_va_begin,
 115                                 segmap_entry);
 116 
 117       if(segmap_entry == invalid_segment)
 118         {
 119 
 120 #ifdef DEBUG_MAP_PROM
 121           printk("invalid_segments, virt_addr 0x%x\n", prom_va_begin);
 122 #endif
 123 
 124           prom_va_begin += 0x40000;  /* num bytes per segment entry */
 125           continue;
 126         }
 127 
 128       /* DUH, prom maps itself so that users can access it. This is
 129        * broken.
 130        */
 131 
 132 #ifdef DEBUG_MAP_PROM
 133       printk("making segmap for prom privileged, va = 0x%x\n",
 134              prom_va_begin);
 135 #endif
 136 
 137       for(i = 0x40; --i >= 0; prom_va_begin+=4096)
 138         {
 139           put_pte(prom_va_begin, get_pte(prom_va_begin) | 0x20000000);
 140         }
 141 
 142     }
 143 
 144   printk("Mapped the PROM in all contexts...\n");
 145 
 146 #ifdef DEBUG_MAP_PROM
 147   printk("curr_num_segs = 0x%x\n", curr_num_segs);
 148 #endif
 149 
 150   return curr_num_segs;
 151 
 152 }
 153 
 154 /*
 155  * This routine handles page faults.  It determines the address,
 156  * and the problem, and then passes it off to one of the appropriate
 157  * routines.
 158  */
 159 asmlinkage void do_page_fault(struct pt_regs *regs, unsigned long error_code)
     /* [previous][next][first][last][top][bottom][index][help] */
 160 {
 161         die_if_kernel("Oops", regs, error_code);
 162         do_exit(SIGKILL);
 163 }
 164 
 165 
 166 
 167 

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