root/arch/sparc/prom/ranges.c

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

DEFINITIONS

This source file includes following definitions.
  1. prom_adjust_regs
  2. prom_adjust_ranges
  3. prom_apply_obio_ranges
  4. prom_apply_sbus_ranges
  5. prom_ranges_init

   1 /* $Id: ranges.c,v 1.4 1995/11/25 01:00:12 davem Exp $
   2  * ranges.c: Handle ranges in newer proms for obio/sbus.
   3  *
   4  * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu)
   5  */
   6 
   7 #include <asm/openprom.h>
   8 #include <asm/oplib.h>
   9 
  10 struct linux_prom_ranges promlib_obio_ranges[PROMREG_MAX];
  11 struct linux_prom_ranges promlib_sbus_ranges[PROMREG_MAX];
  12 int num_obio_ranges, num_sbus_ranges;
  13 
  14 /* Adjust register values based upon the ranges parameters. */
  15 void
  16 prom_adjust_regs(struct linux_prom_registers *regp, int nregs,
     /* [previous][next][first][last][top][bottom][index][help] */
  17                  struct linux_prom_ranges *rangep, int nranges)
  18 {
  19         int regc, rngc;
  20 
  21         for(regc=0; regc < nregs; regc++) {
  22                 for(rngc=0; rngc < nranges; rngc++)
  23                         if(regp[regc].which_io == rangep[rngc].ot_child_space)
  24                                 break; /* Fount it */
  25                 if(rngc==nranges) /* oops */
  26                         prom_printf("adjust_regs: Could not find range with matching bus type...\n");
  27                 regp[regc].which_io = rangep[rngc].ot_parent_space;
  28                 regp[regc].phys_addr += rangep[rngc].ot_parent_base;
  29         }
  30 
  31         return;
  32 }
  33 
  34 void
  35 prom_adjust_ranges(struct linux_prom_ranges *ranges1, int nranges1,
     /* [previous][next][first][last][top][bottom][index][help] */
  36                    struct linux_prom_ranges *ranges2, int nranges2)
  37 {
  38         int rng1c, rng2c;
  39 
  40         for(rng1c=0; rng1c < nranges1; rng1c++) {
  41                 for(rng2c=0; rng2c < nranges2; rng2c++)
  42                         if(ranges1[rng1c].ot_child_space ==
  43                            ranges2[rng2c].ot_child_space) break;
  44                 if(rng2c == nranges2) /* oops */
  45                         prom_printf("adjust_ranges: Could not find matching bus type...\n");
  46                 ranges1[rng1c].ot_parent_space = ranges2[rng2c].ot_parent_space;
  47                 ranges1[rng1c].ot_parent_base += ranges2[rng2c].ot_parent_base;
  48         }
  49 
  50         return;
  51 }
  52 
  53 /* Apply probed obio ranges to registers passed, if no ranges return. */
  54 void
  55 prom_apply_obio_ranges(struct linux_prom_registers *regs, int nregs)
     /* [previous][next][first][last][top][bottom][index][help] */
  56 {
  57         if(!num_obio_ranges) return;
  58         prom_adjust_regs(regs, nregs, promlib_obio_ranges, num_obio_ranges);
  59         return;
  60 }
  61 
  62 /* Apply probed sbus ranges to registers passed, if no ranges return. */
  63 void
  64 prom_apply_sbus_ranges(struct linux_prom_registers *regs, int nregs)
     /* [previous][next][first][last][top][bottom][index][help] */
  65 {
  66         if(!num_sbus_ranges) return;
  67         prom_adjust_regs(regs, nregs, promlib_sbus_ranges, num_sbus_ranges);
  68         return;
  69 }
  70 
  71 void
  72 prom_ranges_init(void)
     /* [previous][next][first][last][top][bottom][index][help] */
  73 {
  74         int node, obio_node, sbus_node;
  75         int success;
  76 
  77         num_obio_ranges = 0;
  78         num_sbus_ranges = 0;
  79 
  80         /* Check for obio and sbus ranges. */
  81         node = prom_getchild(prom_root_node);
  82         obio_node = prom_searchsiblings(node, "obio");
  83         sbus_node = prom_searchsiblings(node, "iommu");
  84         if(sbus_node) {
  85                 sbus_node = prom_getchild(sbus_node);
  86                 sbus_node = prom_searchsiblings(sbus_node, "sbus");
  87         }
  88 
  89         if(obio_node) {
  90                 success = prom_getproperty(obio_node, "ranges",
  91                                            (char *) promlib_obio_ranges,
  92                                            sizeof(promlib_obio_ranges));
  93                 if(success != -1)
  94                         num_obio_ranges = (success/sizeof(struct linux_prom_ranges));
  95         }
  96 
  97         if(sbus_node) {
  98                 success = prom_getproperty(sbus_node, "ranges",
  99                                            (char *) promlib_sbus_ranges,
 100                                            sizeof(promlib_sbus_ranges));
 101                 if(success != -1)
 102                         num_sbus_ranges = (success/sizeof(struct linux_prom_ranges));
 103         }
 104 
 105         if(num_obio_ranges || num_sbus_ranges)
 106                 prom_printf("PROMLIB: obio_ranges %d sbus_ranges %d\n",
 107                             num_obio_ranges, num_sbus_ranges);
 108 
 109         return;
 110 }

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