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

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