home *** CD-ROM | disk | FTP | other *** search
/ Il CD di internet / CD.iso / SOURCE / KERNEL-S / V1.2 / LINUX-1.2 / LINUX-1 / linux / arch / sparc / mm / fault.c next >
Encoding:
C/C++ Source or Header  |  1995-02-26  |  3.8 KB  |  174 lines

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