···272 unsigned long start_here = __pa((u32)*((unsigned long *)273 pSeries_secondary_smp_init));274 unsigned int pcpu;0275276 if (cpu_isset(lcpu, of_spin_map))277 /* Already started by OF and sitting in spin loop */···283 /* Fixup atomic count: it exited inside IRQ handler. */284 paca[lcpu].__current->thread_info->preempt_count = 0;285286- status = rtas_call(rtas_token("start-cpu"), 3, 1, NULL,287- pcpu, start_here, lcpu);0000000288 if (status != 0) {289 printk(KERN_ERR "start-cpu failed: %i\n", status);290 return 0;291 }0292 return 1;293}294
···272 unsigned long start_here = __pa((u32)*((unsigned long *)273 pSeries_secondary_smp_init));274 unsigned int pcpu;275+ int start_cpu;276277 if (cpu_isset(lcpu, of_spin_map))278 /* Already started by OF and sitting in spin loop */···282 /* Fixup atomic count: it exited inside IRQ handler. */283 paca[lcpu].__current->thread_info->preempt_count = 0;284285+ /* 286+ * If the RTAS start-cpu token does not exist then presume the287+ * cpu is already spinning.288+ */289+ start_cpu = rtas_token("start-cpu");290+ if (start_cpu == RTAS_UNKNOWN_SERVICE)291+ return 1;292+293+ status = rtas_call(start_cpu, 3, 1, NULL, pcpu, start_here, lcpu);294 if (status != 0) {295 printk(KERN_ERR "start-cpu failed: %i\n", status);296 return 0;297 }298+299 return 1;300}301
+337-92
arch/ppc64/kernel/pci.c
···5152EXPORT_SYMBOL(io_page_mask);5300005455unsigned int pcibios_assign_all_busses(void)56{···229}230#endif23100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000232static int __init pcibios_init(void)233{234 struct pci_controller *hose, *tmp;235- struct pci_bus *bus;236237 /* For now, override phys_mem_access_prot. If we need it,238 * later, we may move that initialization to each ppc_md···523 printk("PCI: Probing PCI hardware\n");524525 /* Scan all of the recorded PCI controllers. */526- list_for_each_entry_safe(hose, tmp, &hose_list, list_node) {527- hose->last_busno = 0xff;528- bus = pci_scan_bus(hose->first_busno, hose->ops,529- hose->arch_data);530- hose->bus = bus;531- hose->last_busno = bus->subordinate;532- }533534#ifndef CONFIG_PPC_ISERIES535 if (pci_probe_only)···1096/*1097 * ppc64 can have multifunction devices that do not respond to function 0.1098 * In this case we must scan all functions.001099 */1100int pcibios_scan_all_fns(struct pci_bus *bus, int devfn)1101{1102- struct device_node *busdn, *dn;1103-1104- if (bus->self)1105- busdn = pci_device_to_OF_node(bus->self);1106- else1107- busdn = bus->sysdata; /* must be a phb */1108-1109- if (busdn == NULL)1110- return 0;1111-1112- /*1113- * Check to see if there is any of the 8 functions are in the1114- * device tree. If they are then we need to scan all the1115- * functions of this slot.1116- */1117- for (dn = busdn->child; dn; dn = dn->sibling) {1118- struct pci_dn *pdn = dn->data;1119- if (pdn && (pdn->devfn >> 3) == (devfn >> 3))1120- return 1;1121- }1122-1123 return 0;1124}11250000000000000000000000000000011261127void __devinit pcibios_fixup_device_resources(struct pci_dev *dev,1128- struct pci_bus *bus)1129{1130 /* Update device resources. */1131- struct pci_controller *hose = pci_bus_to_host(bus);1132 int i;11331134- for (i = 0; i < PCI_NUM_RESOURCES; i++) {1135- if (dev->resource[i].flags & IORESOURCE_IO) {1136- unsigned long offset = (unsigned long)hose->io_base_virt1137- - pci_io_base;1138- unsigned long start, end, mask;1139-1140- start = dev->resource[i].start += offset;1141- end = dev->resource[i].end += offset;1142-1143- /* Need to allow IO access to pages that are in the1144- ISA range */1145- if (start < MAX_ISA_PORT) {1146- if (end > MAX_ISA_PORT)1147- end = MAX_ISA_PORT;1148-1149- start >>= PAGE_SHIFT;1150- end >>= PAGE_SHIFT;1151-1152- /* get the range of pages for the map */1153- mask = ((1 << (end+1))-1) ^ ((1 << start)-1);1154- io_page_mask |= mask;1155- }1156- }1157- else if (dev->resource[i].flags & IORESOURCE_MEM) {1158- dev->resource[i].start += hose->pci_mem_offset;1159- dev->resource[i].end += hose->pci_mem_offset;1160- }1161- }1162}1163EXPORT_SYMBOL(pcibios_fixup_device_resources);11641165-void __devinit pcibios_fixup_bus(struct pci_bus *bus)1166{1167- struct pci_controller *hose = pci_bus_to_host(bus);1168- struct pci_dev *dev = bus->self;1169- struct resource *res;1170- int i;1171-1172- if (!dev) {1173- /* Root bus. */1174-1175- hose->bus = bus;1176- bus->resource[0] = res = &hose->io_resource;1177-1178- if (res->flags && request_resource(&ioport_resource, res))1179- printk(KERN_ERR "Failed to request IO on "1180- "PCI domain %d\n", pci_domain_nr(bus));1181-1182- for (i = 0; i < 3; ++i) {1183- res = &hose->mem_resources[i];1184- bus->resource[i+1] = res;1185- if (res->flags && request_resource(&iomem_resource, res))1186- printk(KERN_ERR "Failed to request MEM on "1187- "PCI domain %d\n",1188- pci_domain_nr(bus));1189- }1190- } else if (pci_probe_only &&1191- (dev->class >> 8) == PCI_CLASS_BRIDGE_PCI) {1192- /* This is a subordinate bridge */1193-1194- pci_read_bridge_bases(bus);1195- pcibios_fixup_device_resources(dev, bus);1196- }11971198 ppc_md.iommu_bus_setup(bus);1199···11571158 if (ppc_md.irq_bus_setup)1159 ppc_md.irq_bus_setup(bus);00000000000000011601161 if (!pci_probe_only)1162 return;11631164- list_for_each_entry(dev, &bus->devices, bus_list) {1165 if ((dev->class >> 8) != PCI_CLASS_BRIDGE_PCI)1166 pcibios_fixup_device_resources(dev, bus);1167- }1168}1169EXPORT_SYMBOL(pcibios_fixup_bus);1170
···5152EXPORT_SYMBOL(io_page_mask);5354+#ifdef CONFIG_PPC_MULTIPLATFORM55+static void fixup_resource(struct resource *res, struct pci_dev *dev);56+static void do_bus_setup(struct pci_bus *bus);57+#endif5859unsigned int pcibios_assign_all_busses(void)60{···225}226#endif227228+#ifdef CONFIG_PPC_MULTIPLATFORM229+static u32 get_int_prop(struct device_node *np, const char *name, u32 def)230+{231+ u32 *prop;232+ int len;233+234+ prop = (u32 *) get_property(np, name, &len);235+ if (prop && len >= 4)236+ return *prop;237+ return def;238+}239+240+static unsigned int pci_parse_of_flags(u32 addr0)241+{242+ unsigned int flags = 0;243+244+ if (addr0 & 0x02000000) {245+ flags |= IORESOURCE_MEM;246+ if (addr0 & 0x40000000)247+ flags |= IORESOURCE_PREFETCH;248+ } else if (addr0 & 0x01000000)249+ flags |= IORESOURCE_IO;250+ return flags;251+}252+253+#define GET_64BIT(prop, i) ((((u64) (prop)[(i)]) << 32) | (prop)[(i)+1])254+255+static void pci_parse_of_addrs(struct device_node *node, struct pci_dev *dev)256+{257+ u64 base, size;258+ unsigned int flags;259+ struct resource *res;260+ u32 *addrs, i;261+ int proplen;262+263+ addrs = (u32 *) get_property(node, "assigned-addresses", &proplen);264+ if (!addrs)265+ return;266+ for (; proplen >= 20; proplen -= 20, addrs += 5) {267+ flags = pci_parse_of_flags(addrs[0]);268+ if (!flags)269+ continue;270+ base = GET_64BIT(addrs, 1);271+ size = GET_64BIT(addrs, 3);272+ if (!size)273+ continue;274+ i = addrs[0] & 0xff;275+ if (PCI_BASE_ADDRESS_0 <= i && i <= PCI_BASE_ADDRESS_5) {276+ res = &dev->resource[(i - PCI_BASE_ADDRESS_0) >> 2];277+ } else if (i == dev->rom_base_reg) {278+ res = &dev->resource[PCI_ROM_RESOURCE];279+ flags |= IORESOURCE_READONLY | IORESOURCE_CACHEABLE;280+ } else {281+ printk(KERN_ERR "PCI: bad cfg reg num 0x%x\n", i);282+ continue;283+ }284+ res->start = base;285+ res->end = base + size - 1;286+ res->flags = flags;287+ res->name = pci_name(dev);288+ fixup_resource(res, dev);289+ }290+}291+292+static struct pci_dev *of_create_pci_dev(struct device_node *node,293+ struct pci_bus *bus, int devfn)294+{295+ struct pci_dev *dev;296+ const char *type;297+298+ dev = kmalloc(sizeof(struct pci_dev), GFP_KERNEL);299+ if (!dev)300+ return NULL;301+ type = get_property(node, "device_type", NULL);302+ if (type == NULL)303+ type = "";304+305+ memset(dev, 0, sizeof(struct pci_dev));306+ dev->bus = bus;307+ dev->sysdata = node;308+ dev->dev.parent = bus->bridge;309+ dev->dev.bus = &pci_bus_type;310+ dev->devfn = devfn;311+ dev->multifunction = 0; /* maybe a lie? */312+313+ dev->vendor = get_int_prop(node, "vendor-id", 0xffff);314+ dev->device = get_int_prop(node, "device-id", 0xffff);315+ dev->subsystem_vendor = get_int_prop(node, "subsystem-vendor-id", 0);316+ dev->subsystem_device = get_int_prop(node, "subsystem-id", 0);317+318+ dev->cfg_size = 256; /*pci_cfg_space_size(dev);*/319+320+ sprintf(pci_name(dev), "%04x:%02x:%02x.%d", pci_domain_nr(bus),321+ dev->bus->number, PCI_SLOT(devfn), PCI_FUNC(devfn));322+ dev->class = get_int_prop(node, "class-code", 0);323+324+ dev->current_state = 4; /* unknown power state */325+326+ if (!strcmp(type, "pci")) {327+ /* a PCI-PCI bridge */328+ dev->hdr_type = PCI_HEADER_TYPE_BRIDGE;329+ dev->rom_base_reg = PCI_ROM_ADDRESS1;330+ } else if (!strcmp(type, "cardbus")) {331+ dev->hdr_type = PCI_HEADER_TYPE_CARDBUS;332+ } else {333+ dev->hdr_type = PCI_HEADER_TYPE_NORMAL;334+ dev->rom_base_reg = PCI_ROM_ADDRESS;335+ dev->irq = NO_IRQ;336+ if (node->n_intrs > 0) {337+ dev->irq = node->intrs[0].line;338+ pci_write_config_byte(dev, PCI_INTERRUPT_LINE,339+ dev->irq);340+ }341+ }342+343+ pci_parse_of_addrs(node, dev);344+345+ pci_device_add(dev, bus);346+347+ /* XXX pci_scan_msi_device(dev); */348+349+ return dev;350+}351+352+static void of_scan_pci_bridge(struct device_node *node, struct pci_dev *dev);353+354+static void __devinit of_scan_bus(struct device_node *node,355+ struct pci_bus *bus)356+{357+ struct device_node *child = NULL;358+ u32 *reg;359+ int reglen, devfn;360+ struct pci_dev *dev;361+362+ while ((child = of_get_next_child(node, child)) != NULL) {363+ reg = (u32 *) get_property(child, "reg", ®len);364+ if (reg == NULL || reglen < 20)365+ continue;366+ devfn = (reg[0] >> 8) & 0xff;367+ /* create a new pci_dev for this device */368+ dev = of_create_pci_dev(child, bus, devfn);369+ if (!dev)370+ continue;371+ if (dev->hdr_type == PCI_HEADER_TYPE_BRIDGE ||372+ dev->hdr_type == PCI_HEADER_TYPE_CARDBUS)373+ of_scan_pci_bridge(child, dev);374+ }375+376+ do_bus_setup(bus);377+}378+379+static void __devinit of_scan_pci_bridge(struct device_node *node,380+ struct pci_dev *dev)381+{382+ struct pci_bus *bus;383+ u32 *busrange, *ranges;384+ int len, i, mode;385+ struct resource *res;386+ unsigned int flags;387+ u64 size;388+389+ /* parse bus-range property */390+ busrange = (u32 *) get_property(node, "bus-range", &len);391+ if (busrange == NULL || len != 8) {392+ printk(KERN_ERR "Can't get bus-range for PCI-PCI bridge %s\n",393+ node->full_name);394+ return;395+ }396+ ranges = (u32 *) get_property(node, "ranges", &len);397+ if (ranges == NULL) {398+ printk(KERN_ERR "Can't get ranges for PCI-PCI bridge %s\n",399+ node->full_name);400+ return;401+ }402+403+ bus = pci_add_new_bus(dev->bus, dev, busrange[0]);404+ if (!bus) {405+ printk(KERN_ERR "Failed to create pci bus for %s\n",406+ node->full_name);407+ return;408+ }409+410+ bus->primary = dev->bus->number;411+ bus->subordinate = busrange[1];412+ bus->bridge_ctl = 0;413+ bus->sysdata = node;414+415+ /* parse ranges property */416+ /* PCI #address-cells == 3 and #size-cells == 2 always */417+ res = &dev->resource[PCI_BRIDGE_RESOURCES];418+ for (i = 0; i < PCI_NUM_RESOURCES - PCI_BRIDGE_RESOURCES; ++i) {419+ res->flags = 0;420+ bus->resource[i] = res;421+ ++res;422+ }423+ i = 1;424+ for (; len >= 32; len -= 32, ranges += 8) {425+ flags = pci_parse_of_flags(ranges[0]);426+ size = GET_64BIT(ranges, 6);427+ if (flags == 0 || size == 0)428+ continue;429+ if (flags & IORESOURCE_IO) {430+ res = bus->resource[0];431+ if (res->flags) {432+ printk(KERN_ERR "PCI: ignoring extra I/O range"433+ " for bridge %s\n", node->full_name);434+ continue;435+ }436+ } else {437+ if (i >= PCI_NUM_RESOURCES - PCI_BRIDGE_RESOURCES) {438+ printk(KERN_ERR "PCI: too many memory ranges"439+ " for bridge %s\n", node->full_name);440+ continue;441+ }442+ res = bus->resource[i];443+ ++i;444+ }445+ res->start = GET_64BIT(ranges, 1);446+ res->end = res->start + size - 1;447+ res->flags = flags;448+ fixup_resource(res, dev);449+ }450+ sprintf(bus->name, "PCI Bus %04x:%02x", pci_domain_nr(bus),451+ bus->number);452+453+ mode = PCI_PROBE_NORMAL;454+ if (ppc_md.pci_probe_mode)455+ mode = ppc_md.pci_probe_mode(bus);456+ if (mode == PCI_PROBE_DEVTREE)457+ of_scan_bus(node, bus);458+ else if (mode == PCI_PROBE_NORMAL)459+ pci_scan_child_bus(bus);460+}461+#endif /* CONFIG_PPC_MULTIPLATFORM */462+463+static void __devinit scan_phb(struct pci_controller *hose)464+{465+ struct pci_bus *bus;466+ struct device_node *node = hose->arch_data;467+ int i, mode;468+ struct resource *res;469+470+ bus = pci_create_bus(NULL, hose->first_busno, hose->ops, node);471+ if (bus == NULL) {472+ printk(KERN_ERR "Failed to create bus for PCI domain %04x\n",473+ hose->global_number);474+ return;475+ }476+ bus->secondary = hose->first_busno;477+ hose->bus = bus;478+479+ bus->resource[0] = res = &hose->io_resource;480+ if (res->flags && request_resource(&ioport_resource, res))481+ printk(KERN_ERR "Failed to request PCI IO region "482+ "on PCI domain %04x\n", hose->global_number);483+484+ for (i = 0; i < 3; ++i) {485+ res = &hose->mem_resources[i];486+ bus->resource[i+1] = res;487+ if (res->flags && request_resource(&iomem_resource, res))488+ printk(KERN_ERR "Failed to request PCI memory region "489+ "on PCI domain %04x\n", hose->global_number);490+ }491+492+ mode = PCI_PROBE_NORMAL;493+#ifdef CONFIG_PPC_MULTIPLATFORM494+ if (ppc_md.pci_probe_mode)495+ mode = ppc_md.pci_probe_mode(bus);496+ if (mode == PCI_PROBE_DEVTREE) {497+ bus->subordinate = hose->last_busno;498+ of_scan_bus(node, bus);499+ }500+#endif /* CONFIG_PPC_MULTIPLATFORM */501+ if (mode == PCI_PROBE_NORMAL)502+ hose->last_busno = bus->subordinate = pci_scan_child_bus(bus);503+ pci_bus_add_devices(bus);504+}505+506static int __init pcibios_init(void)507{508 struct pci_controller *hose, *tmp;0509510 /* For now, override phys_mem_access_prot. If we need it,511 * later, we may move that initialization to each ppc_md···242 printk("PCI: Probing PCI hardware\n");243244 /* Scan all of the recorded PCI controllers. */245+ list_for_each_entry_safe(hose, tmp, &hose_list, list_node)246+ scan_phb(hose);00000247248#ifndef CONFIG_PPC_ISERIES249 if (pci_probe_only)···820/*821 * ppc64 can have multifunction devices that do not respond to function 0.822 * In this case we must scan all functions.823+ * XXX this can go now, we use the OF device tree in all the824+ * cases that caused problems. -- paulus825 */826int pcibios_scan_all_fns(struct pci_bus *bus, int devfn)827{000000000000000000000828 return 0;829}830831+static void __devinit fixup_resource(struct resource *res, struct pci_dev *dev)832+{833+ struct pci_controller *hose = pci_bus_to_host(dev->bus);834+ unsigned long start, end, mask, offset;835+836+ if (res->flags & IORESOURCE_IO) {837+ offset = (unsigned long)hose->io_base_virt - pci_io_base;838+839+ start = res->start += offset;840+ end = res->end += offset;841+842+ /* Need to allow IO access to pages that are in the843+ ISA range */844+ if (start < MAX_ISA_PORT) {845+ if (end > MAX_ISA_PORT)846+ end = MAX_ISA_PORT;847+848+ start >>= PAGE_SHIFT;849+ end >>= PAGE_SHIFT;850+851+ /* get the range of pages for the map */852+ mask = ((1 << (end+1)) - 1) ^ ((1 << start) - 1);853+ io_page_mask |= mask;854+ }855+ } else if (res->flags & IORESOURCE_MEM) {856+ res->start += hose->pci_mem_offset;857+ res->end += hose->pci_mem_offset;858+ }859+}860861void __devinit pcibios_fixup_device_resources(struct pci_dev *dev,862+ struct pci_bus *bus)863{864 /* Update device resources. */0865 int i;866867+ for (i = 0; i < PCI_NUM_RESOURCES; i++)868+ if (dev->resource[i].flags)869+ fixup_resource(&dev->resource[i], dev);0000000000000000000000000870}871EXPORT_SYMBOL(pcibios_fixup_device_resources);872873+static void __devinit do_bus_setup(struct pci_bus *bus)874{875+ struct pci_dev *dev;00000000000000000000000000000876877 ppc_md.iommu_bus_setup(bus);878···926927 if (ppc_md.irq_bus_setup)928 ppc_md.irq_bus_setup(bus);929+}930+931+void __devinit pcibios_fixup_bus(struct pci_bus *bus)932+{933+ struct pci_dev *dev = bus->self;934+935+ if (dev && pci_probe_only &&936+ (dev->class >> 8) == PCI_CLASS_BRIDGE_PCI) {937+ /* This is a subordinate bridge */938+939+ pci_read_bridge_bases(bus);940+ pcibios_fixup_device_resources(dev, bus);941+ }942+943+ do_bus_setup(bus);944945 if (!pci_probe_only)946 return;947948+ list_for_each_entry(dev, &bus->devices, bus_list)949 if ((dev->class >> 8) != PCI_CLASS_BRIDGE_PCI)950 pcibios_fixup_device_resources(dev, bus);0951}952EXPORT_SYMBOL(pcibios_fixup_bus);953
+28-28
arch/ppc64/kernel/pmac_pci.c
···388 * the reg address cell, we shall fix that by killing struct389 * reg_property and using some accessor functions instead390 */391- hose->first_busno = 0xf0;392 hose->last_busno = 0xff;393 has_uninorth = 1;394 hose->ops = ¯isc_pci_ops;···473 continue;474 } 475 cur++;476- DBG("U3/HT: hole, %d end at %08lx, %d start at %08lx\n",477 cur-1, res->start - 1, cur, res->end + 1);478 hose->mem_resources[cur].name = np->full_name;479 hose->mem_resources[cur].flags = IORESOURCE_MEM;···603 char* disp_name;604 int *bus_range;605 int primary = 1;606- struct property *of_prop;607608 DBG("Adding PCI host bridge %s\n", dev->full_name);609610- bus_range = (int *) get_property(dev, "bus-range", &len);611- if (bus_range == NULL || len < 2 * sizeof(int)) {612- printk(KERN_WARNING "Can't get bus-range for %s, assume bus 0\n",613- dev->full_name);614- }615616 hose = alloc_bootmem(sizeof(struct pci_controller));617 if (hose == NULL)618 return -ENOMEM;619- pci_setup_pci_controller(hose);620621- hose->arch_data = dev;622- hose->first_busno = bus_range ? bus_range[0] : 0;623- hose->last_busno = bus_range ? bus_range[1] : 0xff;624625 of_prop = alloc_bootmem(sizeof(struct property) +626 sizeof(hose->global_number));···634 }635636 disp_name = NULL;637- if (device_is_compatible(dev, "u3-agp")) {638- setup_u3_agp(hose);639- disp_name = "U3-AGP";640- primary = 0;641- } else if (device_is_compatible(dev, "u3-ht")) {642- setup_u3_ht(hose);643- disp_name = "U3-HT";644- primary = 1;645- }646- printk(KERN_INFO "Found %s PCI host bridge. Firmware bus number: %d->%d\n",647- disp_name, hose->first_busno, hose->last_busno);648649- /* Interpret the "ranges" property */650- /* This also maps the I/O region and sets isa_io/mem_base */651- pmac_process_bridge_OF_ranges(hose, dev, primary);652653- /* Fixup "bus-range" OF property */654- fixup_bus_range(dev);655656 return 0;657}
···388 * the reg address cell, we shall fix that by killing struct389 * reg_property and using some accessor functions instead390 */391+ hose->first_busno = 0xf0;392 hose->last_busno = 0xff;393 has_uninorth = 1;394 hose->ops = ¯isc_pci_ops;···473 continue;474 } 475 cur++;476+ DBG("U3/HT: hole, %d end at %08lx, %d start at %08lx\n",477 cur-1, res->start - 1, cur, res->end + 1);478 hose->mem_resources[cur].name = np->full_name;479 hose->mem_resources[cur].flags = IORESOURCE_MEM;···603 char* disp_name;604 int *bus_range;605 int primary = 1;606+ struct property *of_prop;607608 DBG("Adding PCI host bridge %s\n", dev->full_name);609610+ bus_range = (int *) get_property(dev, "bus-range", &len);611+ if (bus_range == NULL || len < 2 * sizeof(int)) {612+ printk(KERN_WARNING "Can't get bus-range for %s, assume bus 0\n",613+ dev->full_name);614+ }615616 hose = alloc_bootmem(sizeof(struct pci_controller));617 if (hose == NULL)618 return -ENOMEM;619+ pci_setup_pci_controller(hose);620621+ hose->arch_data = dev;622+ hose->first_busno = bus_range ? bus_range[0] : 0;623+ hose->last_busno = bus_range ? bus_range[1] : 0xff;624625 of_prop = alloc_bootmem(sizeof(struct property) +626 sizeof(hose->global_number));···634 }635636 disp_name = NULL;637+ if (device_is_compatible(dev, "u3-agp")) {638+ setup_u3_agp(hose);639+ disp_name = "U3-AGP";640+ primary = 0;641+ } else if (device_is_compatible(dev, "u3-ht")) {642+ setup_u3_ht(hose);643+ disp_name = "U3-HT";644+ primary = 1;645+ }646+ printk(KERN_INFO "Found %s PCI host bridge. Firmware bus number: %d->%d\n",647+ disp_name, hose->first_busno, hose->last_busno);648649+ /* Interpret the "ranges" property */650+ /* This also maps the I/O region and sets isa_io/mem_base */651+ pmac_process_bridge_OF_ranges(hose, dev, primary);652653+ /* Fixup "bus-range" OF property */654+ fixup_bus_range(dev);655656 return 0;657}
···54#include <asm/sections.h>55#include <asm/tlbflush.h>56#include <asm/time.h>57+#include <asm/plpar_wrappers.h>5859#ifndef CONFIG_SMP60struct task_struct *last_task_used_math = NULL;···163164#endif /* CONFIG_ALTIVEC */165166+static void set_dabr_spr(unsigned long val)167+{168+ mtspr(SPRN_DABR, val);169+}170+171+int set_dabr(unsigned long dabr)172+{173+ int ret = 0;174+175+ if (firmware_has_feature(FW_FEATURE_XDABR)) {176+ /* We want to catch accesses from kernel and userspace */177+ unsigned long flags = H_DABRX_KERNEL|H_DABRX_USER;178+ ret = plpar_set_xdabr(dabr, flags);179+ } else if (firmware_has_feature(FW_FEATURE_DABR)) {180+ ret = plpar_set_dabr(dabr);181+ } else {182+ set_dabr_spr(dabr);183+ }184+185+ return ret;186+}187+188DEFINE_PER_CPU(struct cpu_usage, cpu_usage_array);189+static DEFINE_PER_CPU(unsigned long, current_dabr);190191struct task_struct *__switch_to(struct task_struct *prev,192 struct task_struct *new)···197 if (new->thread.regs && last_task_used_altivec == new)198 new->thread.regs->msr |= MSR_VEC;199#endif /* CONFIG_ALTIVEC */200+201+ if (unlikely(__get_cpu_var(current_dabr) != new->thread.dabr)) {202+ set_dabr(new->thread.dabr);203+ __get_cpu_var(current_dabr) = new->thread.dabr;204+ }205206 flush_tlb_pending();207···334 last_task_used_altivec = NULL;335#endif /* CONFIG_ALTIVEC */336#endif /* CONFIG_SMP */337+338+ if (current->thread.dabr) {339+ current->thread.dabr = 0;340+ set_dabr(0);341+ }342}343344void
+28
arch/ppc64/kernel/ptrace.c
···17 * this archive for more details.18 */19020#include <linux/kernel.h>21#include <linux/sched.h>22#include <linux/mm.h>···207 break;208 }2090000000000000210 case PTRACE_DETACH:211 ret = ptrace_detach(child, data);212 break;···287 }288 break;289 }00000000000000290291 default:292 ret = ptrace_request(child, request, addr, data);
···17 * this archive for more details.18 */1920+#include <linux/config.h>21#include <linux/kernel.h>22#include <linux/sched.h>23#include <linux/mm.h>···206 break;207 }208209+ case PTRACE_GET_DEBUGREG: {210+ ret = -EINVAL;211+ /* We only support one DABR and no IABRS at the moment */212+ if (addr > 0)213+ break;214+ ret = put_user(child->thread.dabr,215+ (unsigned long __user *)data);216+ break;217+ }218+219+ case PTRACE_SET_DEBUGREG:220+ ret = ptrace_set_debugreg(child, addr, data);221+222 case PTRACE_DETACH:223 ret = ptrace_detach(child, data);224 break;···273 }274 break;275 }276+277+#ifdef CONFIG_ALTIVEC278+ case PTRACE_GETVRREGS:279+ /* Get the child altivec register state. */280+ flush_altivec_to_thread(child);281+ ret = get_vrregs((unsigned long __user *)data, child);282+ break;283+284+ case PTRACE_SETVRREGS:285+ /* Set the child altivec register state. */286+ flush_altivec_to_thread(child);287+ ret = set_vrregs(child, (unsigned long __user *)data);288+ break;289+#endif290291 default:292 ret = ptrace_request(child, request, addr, data);
+31-3
arch/ppc64/kernel/ptrace32.c
···17 * this archive for more details.18 */19020#include <linux/kernel.h>21#include <linux/sched.h>22#include <linux/mm.h>···338 break;339 }3400000000000000341 case PTRACE_DETACH:342 ret = ptrace_detach(child, data);343 break;···419 break;420 }421422- case PTRACE_GETEVENTMSG:423- ret = put_user(child->ptrace_message, (unsigned int __user *) data);424- break;00000000000000425426 default:427 ret = ptrace_request(child, request, addr, data);
···17 * this archive for more details.18 */1920+#include <linux/config.h>21#include <linux/kernel.h>22#include <linux/sched.h>23#include <linux/mm.h>···337 break;338 }339340+ case PTRACE_GET_DEBUGREG: {341+ ret = -EINVAL;342+ /* We only support one DABR and no IABRS at the moment */343+ if (addr > 0)344+ break;345+ ret = put_user(child->thread.dabr, (u32 __user *)data);346+ break;347+ }348+349+ case PTRACE_SET_DEBUGREG:350+ ret = ptrace_set_debugreg(child, addr, data);351+ break;352+353 case PTRACE_DETACH:354 ret = ptrace_detach(child, data);355 break;···405 break;406 }407408+ case PTRACE_GETEVENTMSG:409+ ret = put_user(child->ptrace_message, (unsigned int __user *) data);410+ break;411+412+#ifdef CONFIG_ALTIVEC413+ case PTRACE_GETVRREGS:414+ /* Get the child altivec register state. */415+ flush_altivec_to_thread(child);416+ ret = get_vrregs((unsigned long __user *)data, child);417+ break;418+419+ case PTRACE_SETVRREGS:420+ /* Set the child altivec register state. */421+ flush_altivec_to_thread(child);422+ ret = set_vrregs(child, (unsigned long __user *)data);423+ break;424+#endif425426 default:427 ret = ptrace_request(child, request, addr, data);
-2
arch/ppc64/kernel/ras.c
···59/* This is true if we are using the firmware NMI handler (typically LPAR) */60extern int fwnmi_active;6162-extern void _exception(int signr, struct pt_regs *regs, int code, unsigned long addr);63-64static int ras_get_sensor_state_token;65static int ras_check_exception_token;66
···59/* This is true if we are using the firmware NMI handler (typically LPAR) */60extern int fwnmi_active;610062static int ras_get_sensor_state_token;63static int ras_check_exception_token;64
-16
arch/ppc64/kernel/setup.c
···1064#define PPC64_LINUX_FUNCTION 0x0f0000001065#define PPC64_IPL_MESSAGE 0xc00000001066#define PPC64_TERM_MESSAGE 0xb00000001067-#define PPC64_ATTN_MESSAGE 0xa00000001068-#define PPC64_DUMP_MESSAGE 0xd000000010691070static void ppc64_do_msg(unsigned int src, const char *msg)1071{···1089{1090 ppc64_do_msg(PPC64_LINUX_FUNCTION|PPC64_TERM_MESSAGE|src, msg);1091 printk("[terminate]%04x %s\n", src, msg);1092-}1093-1094-/* Print something that needs attention (device error, etc) */1095-void ppc64_attention_msg(unsigned int src, const char *msg)1096-{1097- ppc64_do_msg(PPC64_LINUX_FUNCTION|PPC64_ATTN_MESSAGE|src, msg);1098- printk("[attention]%04x %s\n", src, msg);1099-}1100-1101-/* Print a dump progress message. */1102-void ppc64_dump_msg(unsigned int src, const char *msg)1103-{1104- ppc64_do_msg(PPC64_LINUX_FUNCTION|PPC64_DUMP_MESSAGE|src, msg);1105- printk("[dump]%04x %s\n", src, msg);1106}11071108/* This should only be called on processor 0 during calibrate decr */
···1064#define PPC64_LINUX_FUNCTION 0x0f0000001065#define PPC64_IPL_MESSAGE 0xc00000001066#define PPC64_TERM_MESSAGE 0xb00000000010671068static void ppc64_do_msg(unsigned int src, const char *msg)1069{···1091{1092 ppc64_do_msg(PPC64_LINUX_FUNCTION|PPC64_TERM_MESSAGE|src, msg);1093 printk("[terminate]%04x %s\n", src, msg);000000000000001094}10951096/* This should only be called on processor 0 during calibrate decr */
···550 /* Whee! Actually deliver the signal. */551 if (TRAP(regs) == 0x0C00)552 syscall_restart(regs, &ka);553+554+ /*555+ * Reenable the DABR before delivering the signal to556+ * user space. The DABR will have been cleared if it557+ * triggered inside the kernel.558+ */559+ if (current->thread.dabr)560+ set_dabr(current->thread.dabr);561+562 return handle_signal(signr, &ka, &info, oldset, regs);563 }564
+8
arch/ppc64/kernel/signal32.c
···970 newsp = regs->gpr[1];971 newsp &= ~0xfUL;97200000000973 /* Whee! Actually deliver the signal. */974 if (ka.sa.sa_flags & SA_SIGINFO)975 ret = handle_rt_signal32(signr, &ka, &info, oldset, regs, newsp);
···970 newsp = regs->gpr[1];971 newsp &= ~0xfUL;972973+ /*974+ * Reenable the DABR before delivering the signal to975+ * user space. The DABR will have been cleared if it976+ * triggered inside the kernel.977+ */978+ if (current->thread.dabr)979+ set_dabr(current->thread.dabr);980+981 /* Whee! Actually deliver the signal. */982 if (ka.sa.sa_flags & SA_SIGINFO)983 ret = handle_rt_signal32(signr, &ka, &info, oldset, regs, newsp);
+22-22
arch/ppc64/kernel/xics.c
···38static void xics_end_irq(unsigned int irq);39static void xics_set_affinity(unsigned int irq_nr, cpumask_t cpumask);4041-struct hw_interrupt_type xics_pic = {42 .typename = " XICS ",43 .startup = xics_startup,44 .enable = xics_enable_irq,···48 .set_affinity = xics_set_affinity49};5051-struct hw_interrupt_type xics_8259_pic = {52 .typename = " XICS/8259",53 .ack = xics_mask_and_ack_irq,54};···89static int xics_irq_8259_cascade = 0;90static int xics_irq_8259_cascade_real = 0;91static unsigned int default_server = 0xFF;92-/* also referenced in smp.c... */93-unsigned int default_distrib_server = 0;94-unsigned int interrupt_server_size = 8;9596/*97 * XICS only has a single IPI, so encode the messages per CPU···98struct xics_ipi_struct xics_ipi_message[NR_CPUS] __cacheline_aligned;99100/* RTAS service tokens */101-int ibm_get_xive;102-int ibm_set_xive;103-int ibm_int_on;104-int ibm_int_off;105106typedef struct {107 int (*xirr_info_get)(int cpu);···283 call_status = rtas_call(ibm_set_xive, 3, 1, NULL, irq, server,284 DEFAULT_PRIORITY);285 if (call_status != 0) {286- printk(KERN_ERR "xics_enable_irq: irq=%d: ibm_set_xive "287- "returned %x\n", irq, call_status);0288 return;289 }290291 /* Now unmask the interrupt (often a no-op) */292 call_status = rtas_call(ibm_int_on, 1, 1, NULL, irq);293 if (call_status != 0) {294- printk(KERN_ERR "xics_enable_irq: irq=%d: ibm_int_on "295- "returned %x\n", irq, call_status);296 return;297 }298}···308309 call_status = rtas_call(ibm_int_off, 1, 1, NULL, irq);310 if (call_status != 0) {311- printk(KERN_ERR "xics_disable_real_irq: irq=%d: "312- "ibm_int_off returned %x\n", irq, call_status);313 return;314 }315···317 /* Have to set XIVE to 0xff to be able to remove a slot */318 call_status = rtas_call(ibm_set_xive, 3, 1, NULL, irq, server, 0xff);319 if (call_status != 0) {320- printk(KERN_ERR "xics_disable_irq: irq=%d: ibm_set_xive(0xff)"321- " returned %x\n", irq, call_status);322 return;323 }324}···380 if (irq == NO_IRQ)381 irq = real_irq_to_virt_slowpath(vec);382 if (irq == NO_IRQ) {383- printk(KERN_ERR "Interrupt %d (real) is invalid,"384 " disabling it.\n", vec);385 xics_disable_real_irq(vec);386 } else···622 status = rtas_call(ibm_get_xive, 1, 3, xics_status, irq);623624 if (status) {625- printk(KERN_ERR "xics_set_affinity: irq=%d ibm,get-xive "626 "returns %d\n", irq, status);627 return;628 }···641 irq, newmask, xics_status[1]);642643 if (status) {644- printk(KERN_ERR "xics_set_affinity: irq=%d ibm,set-xive "645 "returns %d\n", irq, status);646 return;647 }···720721 status = rtas_call(ibm_get_xive, 1, 3, xics_status, irq);722 if (status) {723- printk(KERN_ERR "migrate_irqs_away: irq=%d "724 "ibm,get-xive returns %d\n",725 virq, status);726 goto unlock;···734 if (xics_status[0] != get_hard_smp_processor_id(cpu))735 goto unlock;736737- printk(KERN_WARNING "IRQ %d affinity broken off cpu %u\n",738 virq, cpu);739740 /* Reset affinity to all cpus */
···38static void xics_end_irq(unsigned int irq);39static void xics_set_affinity(unsigned int irq_nr, cpumask_t cpumask);4041+static struct hw_interrupt_type xics_pic = {42 .typename = " XICS ",43 .startup = xics_startup,44 .enable = xics_enable_irq,···48 .set_affinity = xics_set_affinity49};5051+static struct hw_interrupt_type xics_8259_pic = {52 .typename = " XICS/8259",53 .ack = xics_mask_and_ack_irq,54};···89static int xics_irq_8259_cascade = 0;90static int xics_irq_8259_cascade_real = 0;91static unsigned int default_server = 0xFF;92+static unsigned int default_distrib_server = 0;93+static unsigned int interrupt_server_size = 8;09495/*96 * XICS only has a single IPI, so encode the messages per CPU···99struct xics_ipi_struct xics_ipi_message[NR_CPUS] __cacheline_aligned;100101/* RTAS service tokens */102+static int ibm_get_xive;103+static int ibm_set_xive;104+static int ibm_int_on;105+static int ibm_int_off;106107typedef struct {108 int (*xirr_info_get)(int cpu);···284 call_status = rtas_call(ibm_set_xive, 3, 1, NULL, irq, server,285 DEFAULT_PRIORITY);286 if (call_status != 0) {287+ printk(KERN_ERR "xics_enable_irq: irq=%u: ibm_set_xive "288+ "returned %d\n", irq, call_status);289+ printk("set_xive %x, server %x\n", ibm_set_xive, server);290 return;291 }292293 /* Now unmask the interrupt (often a no-op) */294 call_status = rtas_call(ibm_int_on, 1, 1, NULL, irq);295 if (call_status != 0) {296+ printk(KERN_ERR "xics_enable_irq: irq=%u: ibm_int_on "297+ "returned %d\n", irq, call_status);298 return;299 }300}···308309 call_status = rtas_call(ibm_int_off, 1, 1, NULL, irq);310 if (call_status != 0) {311+ printk(KERN_ERR "xics_disable_real_irq: irq=%u: "312+ "ibm_int_off returned %d\n", irq, call_status);313 return;314 }315···317 /* Have to set XIVE to 0xff to be able to remove a slot */318 call_status = rtas_call(ibm_set_xive, 3, 1, NULL, irq, server, 0xff);319 if (call_status != 0) {320+ printk(KERN_ERR "xics_disable_irq: irq=%u: ibm_set_xive(0xff)"321+ " returned %d\n", irq, call_status);322 return;323 }324}···380 if (irq == NO_IRQ)381 irq = real_irq_to_virt_slowpath(vec);382 if (irq == NO_IRQ) {383+ printk(KERN_ERR "Interrupt %u (real) is invalid,"384 " disabling it.\n", vec);385 xics_disable_real_irq(vec);386 } else···622 status = rtas_call(ibm_get_xive, 1, 3, xics_status, irq);623624 if (status) {625+ printk(KERN_ERR "xics_set_affinity: irq=%u ibm,get-xive "626 "returns %d\n", irq, status);627 return;628 }···641 irq, newmask, xics_status[1]);642643 if (status) {644+ printk(KERN_ERR "xics_set_affinity: irq=%u ibm,set-xive "645 "returns %d\n", irq, status);646 return;647 }···720721 status = rtas_call(ibm_get_xive, 1, 3, xics_status, irq);722 if (status) {723+ printk(KERN_ERR "migrate_irqs_away: irq=%u "724 "ibm,get-xive returns %d\n",725 virq, status);726 goto unlock;···734 if (xics_status[0] != get_hard_smp_processor_id(cpu))735 goto unlock;736737+ printk(KERN_WARNING "IRQ %u affinity broken off cpu %u\n",738 virq, cpu);739740 /* Reset affinity to all cpus */
+25-6
arch/ppc64/mm/fault.c
···77 return 0;78}79000000000000000000000080/*81 * The error_code parameter is82 * - DSISR for a non-SLB data access fault,···133 if (!user_mode(regs) && (address >= TASK_SIZE))134 return SIGSEGV;135136- if (error_code & DSISR_DABRMATCH) {137- if (notify_die(DIE_DABR_MATCH, "dabr_match", regs, error_code,138- 11, SIGSEGV) == NOTIFY_STOP)139- return 0;140- if (debugger_dabr_match(regs))141- return 0;142 }143144 if (in_atomic() || mm == NULL) {
···77 return 0;78}7980+static void do_dabr(struct pt_regs *regs, unsigned long error_code)81+{82+ siginfo_t info;83+84+ if (notify_die(DIE_DABR_MATCH, "dabr_match", regs, error_code,85+ 11, SIGSEGV) == NOTIFY_STOP)86+ return;87+88+ if (debugger_dabr_match(regs))89+ return;90+91+ /* Clear the DABR */92+ set_dabr(0);93+94+ /* Deliver the signal to userspace */95+ info.si_signo = SIGTRAP;96+ info.si_errno = 0;97+ info.si_code = TRAP_HWBKPT;98+ info.si_addr = (void __user *)regs->nip;99+ force_sig_info(SIGTRAP, &info, current);100+}101+102/*103 * The error_code parameter is104 * - DSISR for a non-SLB data access fault,···111 if (!user_mode(regs) && (address >= TASK_SIZE))112 return SIGSEGV;113114+ if (error_code & DSISR_DABRMATCH) {115+ do_dabr(regs, error_code);116+ return 0;000117 }118119 if (in_atomic() || mm == NULL) {
···142#define PTRACE_GETEVRREGS 20143#define PTRACE_SETEVRREGS 21144145+/*146+ * Get or set a debug register. The first 16 are DABR registers and the147+ * second 16 are IABR registers.148+ */149+#define PTRACE_GET_DEBUGREG 25150+#define PTRACE_SET_DEBUGREG 26151+152#endif
···8889 /* PCI stuff */90 void (*pcibios_fixup)(void);09192 void (*restart)(char *cmd);93 void (*power_off)(void);···174void ppc64_boot_msg(unsigned int src, const char *msg);175/* Print a termination message (print only -- does not stop the kernel) */176void ppc64_terminate_msg(unsigned int src, const char *msg);177-/* Print something that needs attention (device error, etc) */178-void ppc64_attention_msg(unsigned int src, const char *msg);179-/* Print a dump progress message. */180-void ppc64_dump_msg(unsigned int src, const char *msg);181182static inline void log_error(char *buf, unsigned int err_type, int fatal)183{
···8889 /* PCI stuff */90 void (*pcibios_fixup)(void);91+ int (*pci_probe_mode)(struct pci_bus *);9293 void (*restart)(char *cmd);94 void (*power_off)(void);···173void ppc64_boot_msg(unsigned int src, const char *msg);174/* Print a termination message (print only -- does not stop the kernel) */175void ppc64_terminate_msg(unsigned int src, const char *msg);0000176177static inline void log_error(char *buf, unsigned int err_type, int fatal)178{
···119 return PCI_DN(busdn)->phb;120}121122+/* Return values for ppc_md.pci_probe_mode function */123+#define PCI_PROBE_NONE -1 /* Don't look at this bus at all */124+#define PCI_PROBE_NORMAL 0 /* Do normal PCI probing */125+#define PCI_PROBE_DEVTREE 1 /* Instantiate from device tree */126+127#endif128#endif /* __KERNEL__ */
···107 lbuf[1]);108}109110+static inline long plpar_set_xdabr(unsigned long address, unsigned long flags)111+{112+ return plpar_hcall_norets(H_SET_XDABR, address, flags);113+}114+115+static inline long plpar_set_dabr(unsigned long val)116+{117+ return plpar_hcall_norets(H_SET_DABR, val);118+}119120#endif /* _PPC64_PLPAR_WRAPPERS_H */
+1
include/asm-ppc64/processor.h
···433 unsigned long start_tb; /* Start purr when proc switched in */434 unsigned long accum_tb; /* Total accumilated purr for process */435 unsigned long vdso_base; /* base of the vDSO library */0436#ifdef CONFIG_ALTIVEC437 /* Complete AltiVec register set */438 vector128 vr[32] __attribute((aligned(16)));
···433 unsigned long start_tb; /* Start purr when proc switched in */434 unsigned long accum_tb; /* Total accumilated purr for process */435 unsigned long vdso_base; /* base of the vDSO library */436+ unsigned long dabr; /* Data address breakpoint register */437#ifdef CONFIG_ALTIVEC438 /* Complete AltiVec register set */439 vector128 vr[32] __attribute((aligned(16)));
+92
include/asm-ppc64/ptrace-common.h
···1112#ifndef _PPC64_PTRACE_COMMON_H13#define _PPC64_PTRACE_COMMON_H000014/*15 * Set of msr bits that gdb can change on behalf of a process.16 */···71 if (regs != NULL)72 regs->msr &= ~MSR_SE;73 clear_ti_thread_flag(task->thread_info, TIF_SINGLESTEP);000000000000000000000000000000000000000000000000000000000000000000000000000000000000000074}7576#endif /* _PPC64_PTRACE_COMMON_H */
···1112#ifndef _PPC64_PTRACE_COMMON_H13#define _PPC64_PTRACE_COMMON_H14+15+#include <linux/config.h>16+#include <asm/system.h>17+18/*19 * Set of msr bits that gdb can change on behalf of a process.20 */···67 if (regs != NULL)68 regs->msr &= ~MSR_SE;69 clear_ti_thread_flag(task->thread_info, TIF_SINGLESTEP);70+}71+72+#ifdef CONFIG_ALTIVEC73+/*74+ * Get/set all the altivec registers vr0..vr31, vscr, vrsave, in one go.75+ * The transfer totals 34 quadword. Quadwords 0-31 contain the76+ * corresponding vector registers. Quadword 32 contains the vscr as the77+ * last word (offset 12) within that quadword. Quadword 33 contains the78+ * vrsave as the first word (offset 0) within the quadword.79+ *80+ * This definition of the VMX state is compatible with the current PPC3281+ * ptrace interface. This allows signal handling and ptrace to use the82+ * same structures. This also simplifies the implementation of a bi-arch83+ * (combined (32- and 64-bit) gdb.84+ */85+86+/*87+ * Get contents of AltiVec register state in task TASK88+ */89+static inline int get_vrregs(unsigned long __user *data,90+ struct task_struct *task)91+{92+ unsigned long regsize;93+94+ /* copy AltiVec registers VR[0] .. VR[31] */95+ regsize = 32 * sizeof(vector128);96+ if (copy_to_user(data, task->thread.vr, regsize))97+ return -EFAULT;98+ data += (regsize / sizeof(unsigned long));99+100+ /* copy VSCR */101+ regsize = 1 * sizeof(vector128);102+ if (copy_to_user(data, &task->thread.vscr, regsize))103+ return -EFAULT;104+ data += (regsize / sizeof(unsigned long));105+106+ /* copy VRSAVE */107+ if (put_user(task->thread.vrsave, (u32 __user *)data))108+ return -EFAULT;109+110+ return 0;111+}112+113+/*114+ * Write contents of AltiVec register state into task TASK.115+ */116+static inline int set_vrregs(struct task_struct *task,117+ unsigned long __user *data)118+{119+ unsigned long regsize;120+121+ /* copy AltiVec registers VR[0] .. VR[31] */122+ regsize = 32 * sizeof(vector128);123+ if (copy_from_user(task->thread.vr, data, regsize))124+ return -EFAULT;125+ data += (regsize / sizeof(unsigned long));126+127+ /* copy VSCR */128+ regsize = 1 * sizeof(vector128);129+ if (copy_from_user(&task->thread.vscr, data, regsize))130+ return -EFAULT;131+ data += (regsize / sizeof(unsigned long));132+133+ /* copy VRSAVE */134+ if (get_user(task->thread.vrsave, (u32 __user *)data))135+ return -EFAULT;136+137+ return 0;138+}139+#endif140+141+static inline int ptrace_set_debugreg(struct task_struct *task,142+ unsigned long addr, unsigned long data)143+{144+ /* We only support one DABR and no IABRS at the moment */145+ if (addr > 0)146+ return -EINVAL;147+148+ /* The bottom 3 bits are flags */149+ if ((data & ~0x7UL) >= TASK_SIZE)150+ return -EIO;151+152+ /* Ensure translation is on */153+ if (data && !(data & DABR_TRANSLATION))154+ return -EIO;155+156+ task->thread.dabr = data;157+ return 0;158}159160#endif /* _PPC64_PTRACE_COMMON_H */
+76-52
include/asm-ppc64/ptrace.h
···25 */2627#ifndef __ASSEMBLY__28-#define PPC_REG unsigned long29struct pt_regs {30- PPC_REG gpr[32];31- PPC_REG nip;32- PPC_REG msr;33- PPC_REG orig_gpr3; /* Used for restarting system calls */34- PPC_REG ctr;35- PPC_REG link;36- PPC_REG xer;37- PPC_REG ccr;38- PPC_REG softe; /* Soft enabled/disabled */39- PPC_REG trap; /* Reason for being here */40- PPC_REG dar; /* Fault registers */41- PPC_REG dsisr;42- PPC_REG result; /* Result of a system call */43};4445-#define PPC_REG_32 unsigned int46struct pt_regs32 {47- PPC_REG_32 gpr[32];48- PPC_REG_32 nip;49- PPC_REG_32 msr;50- PPC_REG_32 orig_gpr3; /* Used for restarting system calls */51- PPC_REG_32 ctr;52- PPC_REG_32 link;53- PPC_REG_32 xer;54- PPC_REG_32 ccr;55- PPC_REG_32 mq; /* 601 only (not used at present) */56- /* Used on APUS to hold IPL value. */57- PPC_REG_32 trap; /* Reason for being here */58- PPC_REG_32 dar; /* Fault registers */59- PPC_REG_32 dsisr;60- PPC_REG_32 result; /* Result of a system call */61};006263#define instruction_pointer(regs) ((regs)->nip)064#ifdef CONFIG_SMP65extern unsigned long profile_pc(struct pt_regs *regs);66#else67#define profile_pc(regs) instruction_pointer(regs)68#endif69-70-#endif /* __ASSEMBLY__ */71-72-#define STACK_FRAME_OVERHEAD 112 /* size of minimum stack frame */73-74-/* Size of dummy stack frame allocated when calling signal handler. */75-#define __SIGNAL_FRAMESIZE 12876-#define __SIGNAL_FRAMESIZE32 647778#define user_mode(regs) ((((regs)->msr) >> MSR_PR_LG) & 0x1)79···81#define FULL_REGS(regs) (((regs)->trap & 1) == 0)82#define TRAP(regs) ((regs)->trap & ~0xF)83#define CHECK_FULL_REGS(regs) BUG_ON(regs->trap & 1)00000000008485/*86 * Offsets used by 'ptrace' system call interface.···138#define PT_XER 37139#define PT_CCR 38140#define PT_SOFTE 39000141#define PT_RESULT 43142143#define PT_FPR0 48144145-/* Kernel and userspace will both use this PT_FPSCR value. 32-bit apps will have146- * visibility to the asm-ppc/ptrace.h header instead of this one.0147 */148-#define PT_FPSCR (PT_FPR0 + 32) /* each FP reg occupies 1 slot in 64-bit space */149150#ifdef __KERNEL__151-#define PT_FPSCR32 (PT_FPR0 + 2*32 + 1) /* each FP reg occupies 2 32-bit userspace slots */152#endif153154#define PT_VR0 82 /* each Vector reg occupies 2 slots in 64-bit */···180#define PTRACE_GETVRREGS 18181#define PTRACE_SETVRREGS 19182183-/* Additional PTRACE requests implemented on PowerPC. */184-#define PPC_PTRACE_GETREGS 0x99 /* Get GPRs 0 - 31 */185-#define PPC_PTRACE_SETREGS 0x98 /* Set GPRs 0 - 31 */186-#define PPC_PTRACE_GETFPREGS 0x97 /* Get FPRs 0 - 31 */187-#define PPC_PTRACE_SETFPREGS 0x96 /* Set FPRs 0 - 31 */188-#define PPC_PTRACE_PEEKTEXT_3264 0x95 /* Read word at location ADDR on a 64-bit process from a 32-bit process. */189-#define PPC_PTRACE_PEEKDATA_3264 0x94 /* Read word at location ADDR on a 64-bit process from a 32-bit process. */190-#define PPC_PTRACE_POKETEXT_3264 0x93 /* Write word at location ADDR on a 64-bit process from a 32-bit process. */191-#define PPC_PTRACE_POKEDATA_3264 0x92 /* Write word at location ADDR on a 64-bit process from a 32-bit process. */192-#define PPC_PTRACE_PEEKUSR_3264 0x91 /* Read a register (specified by ADDR) out of the "user area" on a 64-bit process from a 32-bit process. */193-#define PPC_PTRACE_POKEUSR_3264 0x90 /* Write DATA into location ADDR within the "user area" on a 64-bit process from a 32-bit process. */19400000000000000000000195196#endif /* _PPC64_PTRACE_H */
···25 */2627#ifndef __ASSEMBLY__28+29struct pt_regs {30+ unsigned long gpr[32];31+ unsigned long nip;32+ unsigned long msr;33+ unsigned long orig_gpr3; /* Used for restarting system calls */34+ unsigned long ctr;35+ unsigned long link;36+ unsigned long xer;37+ unsigned long ccr;38+ unsigned long softe; /* Soft enabled/disabled */39+ unsigned long trap; /* Reason for being here */40+ unsigned long dar; /* Fault registers */41+ unsigned long dsisr;42+ unsigned long result; /* Result of a system call */43};44045struct pt_regs32 {46+ unsigned int gpr[32];47+ unsigned int nip;48+ unsigned int msr;49+ unsigned int orig_gpr3; /* Used for restarting system calls */50+ unsigned int ctr;51+ unsigned int link;52+ unsigned int xer;53+ unsigned int ccr;54+ unsigned int mq; /* 601 only (not used at present) */55+ unsigned int trap; /* Reason for being here */56+ unsigned int dar; /* Fault registers */57+ unsigned int dsisr;58+ unsigned int result; /* Result of a system call */059};60+61+#ifdef __KERNEL__6263#define instruction_pointer(regs) ((regs)->nip)64+65#ifdef CONFIG_SMP66extern unsigned long profile_pc(struct pt_regs *regs);67#else68#define profile_pc(regs) instruction_pointer(regs)69#endif000000007071#define user_mode(regs) ((((regs)->msr) >> MSR_PR_LG) & 0x1)72···88#define FULL_REGS(regs) (((regs)->trap & 1) == 0)89#define TRAP(regs) ((regs)->trap & ~0xF)90#define CHECK_FULL_REGS(regs) BUG_ON(regs->trap & 1)91+92+#endif /* __KERNEL__ */93+94+#endif /* __ASSEMBLY__ */95+96+#define STACK_FRAME_OVERHEAD 112 /* size of minimum stack frame */97+98+/* Size of dummy stack frame allocated when calling signal handler. */99+#define __SIGNAL_FRAMESIZE 128100+#define __SIGNAL_FRAMESIZE32 64101102/*103 * Offsets used by 'ptrace' system call interface.···135#define PT_XER 37136#define PT_CCR 38137#define PT_SOFTE 39138+#define PT_TRAP 40139+#define PT_DAR 41140+#define PT_DSISR 42141#define PT_RESULT 43142143#define PT_FPR0 48144145+/*146+ * Kernel and userspace will both use this PT_FPSCR value. 32-bit apps will147+ * have visibility to the asm-ppc/ptrace.h header instead of this one.148 */149+#define PT_FPSCR (PT_FPR0 + 32) /* each FP reg occupies 1 slot in 64-bit space */150151#ifdef __KERNEL__152+#define PT_FPSCR32 (PT_FPR0 + 2*32 + 1) /* each FP reg occupies 2 32-bit userspace slots */153#endif154155#define PT_VR0 82 /* each Vector reg occupies 2 slots in 64-bit */···173#define PTRACE_GETVRREGS 18174#define PTRACE_SETVRREGS 19175176+/*177+ * While we dont have 64bit book E processors, we need to reserve the178+ * relevant ptrace calls for 32bit compatibility.179+ */180+#if 0181+#define PTRACE_GETEVRREGS 20182+#define PTRACE_SETEVRREGS 21183+#endif000184185+/*186+ * Get or set a debug register. The first 16 are DABR registers and the187+ * second 16 are IABR registers.188+ */189+#define PTRACE_GET_DEBUGREG 25190+#define PTRACE_SET_DEBUGREG 26191+192+/* Additional PTRACE requests implemented on PowerPC. */193+#define PPC_PTRACE_GETREGS 0x99 /* Get GPRs 0 - 31 */194+#define PPC_PTRACE_SETREGS 0x98 /* Set GPRs 0 - 31 */195+#define PPC_PTRACE_GETFPREGS 0x97 /* Get FPRs 0 - 31 */196+#define PPC_PTRACE_SETFPREGS 0x96 /* Set FPRs 0 - 31 */197+198+/* Calls to trace a 64bit program from a 32bit program */199+#define PPC_PTRACE_PEEKTEXT_3264 0x95200+#define PPC_PTRACE_PEEKDATA_3264 0x94201+#define PPC_PTRACE_POKETEXT_3264 0x93202+#define PPC_PTRACE_POKEDATA_3264 0x92203+#define PPC_PTRACE_PEEKUSR_3264 0x91204+#define PPC_PTRACE_POKEUSR_3264 0x90205206#endif /* _PPC64_PTRACE_H */
+3
include/asm-ppc64/system.h
···101static inline int debugger_fault_handler(struct pt_regs *regs) { return 0; }102#endif103000104extern int fix_alignment(struct pt_regs *regs);105extern void bad_page_fault(struct pt_regs *regs, unsigned long address,106 int sig);
···101static inline int debugger_fault_handler(struct pt_regs *regs) { return 0; }102#endif103104+extern int set_dabr(unsigned long dabr);105+extern void _exception(int signr, struct pt_regs *regs, int code,106+ unsigned long addr);107extern int fix_alignment(struct pt_regs *regs);108extern void bad_page_fault(struct pt_regs *regs, unsigned long address,109 int sig);
+1-15
include/linux/crc16.h
···1/*2 * crc16.h - CRC-16 routine3 *4- * Implements the standard CRC-16, as used with 1-wire devices:5 * Width 166 * Poly 0x8005 (x^16 + x^15 + x^2 + 1)7 * Init 08- *9- * For 1-wire devices, the CRC is stored inverted, LSB-first10- *11- * Example buffer with the CRC attached:12- * 31 32 33 34 35 36 37 38 39 C2 4413- *14- * The CRC over a buffer with the CRC attached is 0xB001.15- * So, if (crc16(0, buf, size) == 0xB001) then the buffer is valid.16- *17- * Refer to "Application Note 937: Book of iButton Standards" for details.18- * http://www.maxim-ic.com/appnotes.cfm/appnote_number/93719 *20 * Copyright (c) 2005 Ben Gardner <bgardner@wabtec.com>21 *···16#define __CRC16_H1718#include <linux/types.h>19-20-#define CRC16_INIT 021-#define CRC16_VALID 0xb0012223extern u16 const crc16_table[256];24