static int of_bus_default_map(u32 *addr, const u32 *range, int na, int ns, int pna) { u32 result[OF_MAX_ADDR_CELLS]; int i; if (ns > 2) { printk("of_device: Cannot handle size cells (%d) > 2.", ns); return -EINVAL; } if (of_out_of_range(addr, range, range + na + pna, na, ns)) return -EINVAL; /* Start with the parent range base. */ memcpy(result, range + na, pna * 4); /* Add in the child address offset. */ for (i = 0; i < na; i++) result[pna - 1 - i] += (addr[na - 1 - i] - range[na - 1 - i]); memcpy(addr, result, pna * 4); return 0; }
static int of_bus_pci_map(u32 *addr, const u32 *range, int na, int ns, int pna) { u32 result[OF_MAX_ADDR_CELLS]; int i; /* Check address type match */ if ((addr[0] ^ range[0]) & 0x03000000) return -EINVAL; if (of_out_of_range(addr + 1, range + 1, range + na + pna, na - 1, ns)) return -EINVAL; /* Start with the parent range base. */ memcpy(result, range + na, pna * 4); /* Add in the child address offset, skipping high cell. */ for (i = 0; i < na - 1; i++) result[pna - 1 - i] += (addr[na - 1 - i] - range[na - 1 - i]); memcpy(addr, result, pna * 4); return 0; }
static int of_bus_pci_map(u32 *addr, const u32 *range, int na, int ns, int pna) { u32 result[OF_MAX_ADDR_CELLS]; int i; if ((addr[0] ^ range[0]) & 0x03000000) return -EINVAL; if (of_out_of_range(addr + 1, range + 1, range + na + pna, na - 1, ns)) return -EINVAL; memcpy(result, range + na, pna * 4); for (i = 0; i < na - 1; i++) result[pna - 1 - i] += (addr[na - 1 - i] - range[na - 1 - i]); memcpy(addr, result, pna * 4); return 0; }