patch-2.1.9 linux/arch/sparc/prom/ranges.c
Next file: linux/arch/sparc/prom/segment.c
Previous file: linux/arch/sparc/prom/mp.c
Back to the patch index
Back to the overall index
- Lines: 156
- Date:
Sat Nov 9 10:12:29 1996
- Orig file:
v2.1.8/linux/arch/sparc/prom/ranges.c
- Orig date:
Sat Nov 25 03:00:14 1995
diff -u --recursive --new-file v2.1.8/linux/arch/sparc/prom/ranges.c linux/arch/sparc/prom/ranges.c
@@ -1,4 +1,4 @@
-/* $Id: ranges.c,v 1.4 1995/11/25 01:00:12 davem Exp $
+/* $Id: ranges.c,v 1.6 1996/11/03 08:12:01 davem Exp $
* ranges.c: Handle ranges in newer proms for obio/sbus.
*
* Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu)
@@ -6,10 +6,11 @@
#include <asm/openprom.h>
#include <asm/oplib.h>
+#include <asm/sbus.h>
+#include <asm/system.h>
struct linux_prom_ranges promlib_obio_ranges[PROMREG_MAX];
-struct linux_prom_ranges promlib_sbus_ranges[PROMREG_MAX];
-int num_obio_ranges, num_sbus_ranges;
+int num_obio_ranges;
/* Adjust register values based upon the ranges parameters. */
void
@@ -27,8 +28,6 @@
regp[regc].which_io = rangep[rngc].ot_parent_space;
regp[regc].phys_addr += rangep[rngc].ot_parent_base;
}
-
- return;
}
void
@@ -46,45 +45,35 @@
ranges1[rng1c].ot_parent_space = ranges2[rng2c].ot_parent_space;
ranges1[rng1c].ot_parent_base += ranges2[rng2c].ot_parent_base;
}
-
- return;
}
/* Apply probed obio ranges to registers passed, if no ranges return. */
void
prom_apply_obio_ranges(struct linux_prom_registers *regs, int nregs)
{
- if(!num_obio_ranges) return;
- prom_adjust_regs(regs, nregs, promlib_obio_ranges, num_obio_ranges);
- return;
+ if(num_obio_ranges)
+ prom_adjust_regs(regs, nregs, promlib_obio_ranges, num_obio_ranges);
}
/* Apply probed sbus ranges to registers passed, if no ranges return. */
void
-prom_apply_sbus_ranges(struct linux_prom_registers *regs, int nregs)
+prom_apply_sbus_ranges(struct linux_sbus *sbus, struct linux_prom_registers *regs, int nregs)
{
- if(!num_sbus_ranges) return;
- prom_adjust_regs(regs, nregs, promlib_sbus_ranges, num_sbus_ranges);
- return;
+ if(sbus->num_sbus_ranges)
+ prom_adjust_regs(regs, nregs, sbus->sbus_ranges, sbus->num_sbus_ranges);
}
void
prom_ranges_init(void)
{
- int node, obio_node, sbus_node;
+ int node, obio_node;
int success;
num_obio_ranges = 0;
- num_sbus_ranges = 0;
/* Check for obio and sbus ranges. */
node = prom_getchild(prom_root_node);
obio_node = prom_searchsiblings(node, "obio");
- sbus_node = prom_searchsiblings(node, "iommu");
- if(sbus_node) {
- sbus_node = prom_getchild(sbus_node);
- sbus_node = prom_searchsiblings(sbus_node, "sbus");
- }
if(obio_node) {
success = prom_getproperty(obio_node, "ranges",
@@ -94,17 +83,63 @@
num_obio_ranges = (success/sizeof(struct linux_prom_ranges));
}
- if(sbus_node) {
- success = prom_getproperty(sbus_node, "ranges",
- (char *) promlib_sbus_ranges,
- sizeof(promlib_sbus_ranges));
- if(success != -1)
- num_sbus_ranges = (success/sizeof(struct linux_prom_ranges));
- }
-
- if(num_obio_ranges || num_sbus_ranges)
- prom_printf("PROMLIB: obio_ranges %d sbus_ranges %d\n",
- num_obio_ranges, num_sbus_ranges);
+ if(num_obio_ranges)
+ prom_printf("PROMLIB: obio_ranges %d\n", num_obio_ranges);
return;
+}
+
+void
+prom_sbus_ranges_init(int parentnd, struct linux_sbus *sbus)
+{
+ int success;
+
+ sbus->num_sbus_ranges = 0;
+ if(sparc_cpu_model == sun4c)
+ return;
+ success = prom_getproperty(sbus->prom_node, "ranges",
+ (char *) sbus->sbus_ranges,
+ sizeof (sbus->sbus_ranges));
+ if (success != -1)
+ sbus->num_sbus_ranges = (success/sizeof(struct linux_prom_ranges));
+ if (sparc_cpu_model == sun4d) {
+ struct linux_prom_ranges iounit_ranges[PROMREG_MAX];
+ int num_iounit_ranges;
+
+ success = prom_getproperty(parentnd, "ranges",
+ (char *) iounit_ranges,
+ sizeof (iounit_ranges));
+ if (success != -1) {
+ num_iounit_ranges = (success/sizeof(struct linux_prom_ranges));
+ prom_adjust_ranges (sbus->sbus_ranges, sbus->num_sbus_ranges, iounit_ranges, num_iounit_ranges);
+ }
+ }
+}
+
+void
+prom_apply_generic_ranges (int node, int parent, struct linux_prom_registers *regs, int nregs)
+{
+ int success;
+ int num_ranges;
+ struct linux_prom_ranges ranges[PROMREG_MAX];
+
+ success = prom_getproperty(node, "ranges",
+ (char *) ranges,
+ sizeof (ranges));
+ if (success != -1) {
+ num_ranges = (success/sizeof(struct linux_prom_ranges));
+ if (parent) {
+ struct linux_prom_ranges parent_ranges[PROMREG_MAX];
+ int num_parent_ranges;
+
+ success = prom_getproperty(parent, "ranges",
+ (char *) parent_ranges,
+ sizeof (parent_ranges));
+ if (success != -1) {
+ num_parent_ranges = (success/sizeof(struct linux_prom_ranges));
+ prom_adjust_ranges (ranges, num_ranges, parent_ranges, num_parent_ranges);
+ }
+ }
+ prom_adjust_regs(regs, nregs, ranges, num_ranges);
+ }
}
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov