1 /* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License, Version 1.0 only 6 * (the "License"). You may not use this file except in compliance 7 * with the License. 8 * 9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10 * or http://www.opensolaris.org/os/licensing. 11 * See the License for the specific language governing permissions 12 * and limitations under the License. 13 * 14 * When distributing Covered Code, include this CDDL HEADER in each 15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16 * If applicable, add the following below this CDDL HEADER, with the 17 * fields enclosed by brackets "[]" replaced with your own identifying 18 * information: Portions Copyright [yyyy] [name of copyright owner] 19 * 20 * CDDL HEADER END 21 */ 22 /* 23 * Copyright 2005 Sun Microsystems, Inc. All rights reserved. 24 * Use is subject to license terms. 25 */ 26 27 #pragma ident "%Z%%M% %I% %E% SMI" 28 29 /* 30 * PC specific DDI implementation 31 */ 32 #include <sys/types.h> 33 #include <sys/autoconf.h> 34 #include <sys/avintr.h> 35 #include <sys/bootconf.h> 36 #include <sys/conf.h> 37 #include <sys/cpuvar.h> 38 #include <sys/ddi_impldefs.h> 39 #include <sys/ddi_subrdefs.h> 40 #include <sys/ethernet.h> 41 #include <sys/fp.h> 42 #include <sys/instance.h> 43 #include <sys/kmem.h> 44 #include <sys/machsystm.h> 45 #include <sys/modctl.h> 46 #include <sys/promif.h> 47 #include <sys/prom_plat.h> 48 #include <sys/sunndi.h> 49 #include <sys/ndi_impldefs.h> 50 #include <sys/ddi_impldefs.h> 51 #include <sys/sysmacros.h> 52 #include <sys/systeminfo.h> 53 #include <sys/utsname.h> 54 #include <sys/atomic.h> 55 #include <sys/spl.h> 56 #include <sys/archsystm.h> 57 #include <vm/seg_kmem.h> 58 #include <sys/ontrap.h> 59 #include <sys/ramdisk.h> 60 #include <sys/sunndi.h> 61 #include <sys/vmem.h> 62 #include <sys/pci_impl.h> 63 64 /* 65 * DDI Boot Configuration 66 */ 67 68 /* 69 * No platform drivers on this platform 70 */ 71 char *platform_module_list[] = { 72 (char *)0 73 }; 74 75 /* pci bus resource maps */ 76 struct pci_bus_resource *pci_bus_res; 77 78 extern int root_is_svm; 79 uint64_t ramdisk_start, ramdisk_end; 80 81 /* 82 * Forward declarations 83 */ 84 static int getlongprop_buf(); 85 static void get_boot_properties(void); 86 static void impl_bus_initialprobe(void); 87 static void impl_bus_reprobe(void); 88 89 static int poke_mem(peekpoke_ctlops_t *in_args); 90 static int peek_mem(peekpoke_ctlops_t *in_args); 91 92 #define CTGENTRIES 15 93 94 static struct ctgas { 95 struct ctgas *ctg_next; 96 int ctg_index; 97 void *ctg_addr[CTGENTRIES]; 98 size_t ctg_size[CTGENTRIES]; 99 } ctglist; 100 101 static kmutex_t ctgmutex; 102 #define CTGLOCK() mutex_enter(&ctgmutex) 103 #define CTGUNLOCK() mutex_exit(&ctgmutex) 104 105 /* 106 * Minimum pfn value of page_t's put on the free list. This is to simplify 107 * support of ddi dma memory requests which specify small, non-zero addr_lo 108 * values. 109 * 110 * The default value of 2, which corresponds to the only known non-zero addr_lo 111 * value used, means a single page will be sacrificed (pfn typically starts 112 * at 1). ddiphysmin can be set to 0 to disable. It cannot be set above 0x100 113 * otherwise mp startup panics. 114 */ 115 pfn_t ddiphysmin = 2; 116 117 static void 118 check_driver_disable(void) 119 { 120 int proplen = 128; 121 char *prop_name; 122 char *drv_name, *propval; 123 major_t major; 124 125 prop_name = kmem_alloc(proplen, KM_SLEEP); 126 for (major = 0; major < devcnt; major++) { 127 drv_name = ddi_major_to_name(major); 128 if (drv_name == NULL) 129 continue; 130 (void) snprintf(prop_name, proplen, "disable-%s", drv_name); 131 if (ddi_prop_lookup_string(DDI_DEV_T_ANY, ddi_root_node(), 132 DDI_PROP_DONTPASS, prop_name, &propval) == DDI_SUCCESS) { 133 if (strcmp(propval, "true") == 0) { 134 devnamesp[major].dn_flags |= DN_DRIVER_REMOVED; 135 cmn_err(CE_NOTE, "driver %s disabled", 136 drv_name); 137 } 138 ddi_prop_free(propval); 139 } 140 } 141 kmem_free(prop_name, proplen); 142 } 143 144 145 /* 146 * Configure the hardware on the system. 147 * Called before the rootfs is mounted 148 */ 149 void 150 configure(void) 151 { 152 extern void i_ddi_init_root(); 153 154 #if defined(__i386) 155 extern int fpu_pentium_fdivbug; 156 #endif /* __i386 */ 157 extern int fpu_ignored; 158 159 /* 160 * Determine if an FPU is attached 161 */ 162 163 fpu_probe(); 164 165 #if defined(__i386) 166 if (fpu_pentium_fdivbug) { 167 printf("\ 168 FP hardware exhibits Pentium floating point divide problem\n"); 169 } 170 #endif /* __i386 */ 171 172 if (fpu_ignored) { 173 printf("FP hardware will not be used\n"); 174 } else if (!fpu_exists) { 175 printf("No FPU in configuration\n"); 176 } 177 178 /* 179 * Initialize devices on the machine. 180 * Uses configuration tree built by the PROMs to determine what 181 * is present, and builds a tree of prototype dev_info nodes 182 * corresponding to the hardware which identified itself. 183 */ 184 #if !defined(SAS) && !defined(MPSAS) 185 /* 186 * Check for disabled drivers and initialize root node. 187 */ 188 check_driver_disable(); 189 i_ddi_init_root(); 190 191 /* 192 * attach the isa nexus to get ACPI resource usage 193 * isa is "kind of" a pseudo node 194 */ 195 (void) i_ddi_attach_pseudo_node("isa"); 196 197 /* reprogram devices not set up by firmware (BIOS) */ 198 impl_bus_reprobe(); 199 #endif /* !SAS && !MPSAS */ 200 } 201 202 /* 203 * The "status" property indicates the operational status of a device. 204 * If this property is present, the value is a string indicating the 205 * status of the device as follows: 206 * 207 * "okay" operational. 208 * "disabled" not operational, but might become operational. 209 * "fail" not operational because a fault has been detected, 210 * and it is unlikely that the device will become 211 * operational without repair. no additional details 212 * are available. 213 * "fail-xxx" not operational because a fault has been detected, 214 * and it is unlikely that the device will become 215 * operational without repair. "xxx" is additional 216 * human-readable information about the particular 217 * fault condition that was detected. 218 * 219 * The absence of this property means that the operational status is 220 * unknown or okay. 221 * 222 * This routine checks the status property of the specified device node 223 * and returns 0 if the operational status indicates failure, and 1 otherwise. 224 * 225 * The property may exist on plug-in cards the existed before IEEE 1275-1994. 226 * And, in that case, the property may not even be a string. So we carefully 227 * check for the value "fail", in the beginning of the string, noting 228 * the property length. 229 */ 230 int 231 status_okay(int id, char *buf, int buflen) 232 { 233 char status_buf[OBP_MAXPROPNAME]; 234 char *bufp = buf; 235 int len = buflen; 236 int proplen; 237 static const char *status = "status"; 238 static const char *fail = "fail"; 239 int fail_len = (int)strlen(fail); 240 241 /* 242 * Get the proplen ... if it's smaller than "fail", 243 * or doesn't exist ... then we don't care, since 244 * the value can't begin with the char string "fail". 245 * 246 * NB: proplen, if it's a string, includes the NULL in the 247 * the size of the property, and fail_len does not. 248 */ 249 proplen = prom_getproplen((dnode_t)id, (caddr_t)status); 250 if (proplen <= fail_len) /* nonexistant or uninteresting len */ 251 return (1); 252 253 /* 254 * if a buffer was provided, use it 255 */ 256 if ((buf == (char *)NULL) || (buflen <= 0)) { 257 bufp = status_buf; 258 len = sizeof (status_buf); 259 } 260 *bufp = (char)0; 261 262 /* 263 * Get the property into the buffer, to the extent of the buffer, 264 * and in case the buffer is smaller than the property size, 265 * NULL terminate the buffer. (This handles the case where 266 * a buffer was passed in and the caller wants to print the 267 * value, but the buffer was too small). 268 */ 269 (void) prom_bounded_getprop((dnode_t)id, (caddr_t)status, 270 (caddr_t)bufp, len); 271 *(bufp + len - 1) = (char)0; 272 273 /* 274 * If the value begins with the char string "fail", 275 * then it means the node is failed. We don't care 276 * about any other values. We assume the node is ok 277 * although it might be 'disabled'. 278 */ 279 if (strncmp(bufp, fail, fail_len) == 0) 280 return (0); 281 282 return (1); 283 } 284 285 /* 286 * Check the status of the device node passed as an argument. 287 * 288 * if ((status is OKAY) || (status is DISABLED)) 289 * return DDI_SUCCESS 290 * else 291 * print a warning and return DDI_FAILURE 292 */ 293 /*ARGSUSED1*/ 294 int 295 check_status(int id, char *name, dev_info_t *parent) 296 { 297 char status_buf[64]; 298 char devtype_buf[OBP_MAXPROPNAME]; 299 int retval = DDI_FAILURE; 300 301 /* 302 * is the status okay? 303 */ 304 if (status_okay(id, status_buf, sizeof (status_buf))) 305 return (DDI_SUCCESS); 306 307 /* 308 * a status property indicating bad memory will be associated 309 * with a node which has a "device_type" property with a value of 310 * "memory-controller". in this situation, return DDI_SUCCESS 311 */ 312 if (getlongprop_buf(id, OBP_DEVICETYPE, devtype_buf, 313 sizeof (devtype_buf)) > 0) { 314 if (strcmp(devtype_buf, "memory-controller") == 0) 315 retval = DDI_SUCCESS; 316 } 317 318 /* 319 * print the status property information 320 */ 321 cmn_err(CE_WARN, "status '%s' for '%s'", status_buf, name); 322 return (retval); 323 } 324 325 /*ARGSUSED*/ 326 uint_t 327 softlevel1(caddr_t arg1, caddr_t arg2) 328 { 329 softint(); 330 return (1); 331 } 332 333 /* 334 * Allow for implementation specific correction of PROM property values. 335 */ 336 337 /*ARGSUSED*/ 338 void 339 impl_fix_props(dev_info_t *dip, dev_info_t *ch_dip, char *name, int len, 340 caddr_t buffer) 341 { 342 /* 343 * There are no adjustments needed in this implementation. 344 */ 345 } 346 347 static int 348 getlongprop_buf(int id, char *name, char *buf, int maxlen) 349 { 350 int size; 351 352 size = prom_getproplen((dnode_t)id, name); 353 if (size <= 0 || (size > maxlen - 1)) 354 return (-1); 355 356 if (-1 == prom_getprop((dnode_t)id, name, buf)) 357 return (-1); 358 359 if (strcmp("name", name) == 0) { 360 if (buf[size - 1] != '\0') { 361 buf[size] = '\0'; 362 size += 1; 363 } 364 } 365 366 return (size); 367 } 368 369 static int 370 get_prop_int_array(dev_info_t *di, char *pname, int **pval, uint_t *plen) 371 { 372 int ret; 373 374 if ((ret = ddi_prop_lookup_int_array(DDI_DEV_T_ANY, di, 375 DDI_PROP_DONTPASS, pname, pval, plen)) 376 == DDI_PROP_SUCCESS) { 377 *plen = (*plen) * (sizeof (int)); 378 } 379 return (ret); 380 } 381 382 383 /* 384 * Node Configuration 385 */ 386 387 struct prop_ispec { 388 uint_t pri, vec; 389 }; 390 391 /* 392 * Create a ddi_parent_private_data structure from the ddi properties of 393 * the dev_info node. 394 * 395 * The "reg" and either an "intr" or "interrupts" properties are required 396 * if the driver wishes to create mappings or field interrupts on behalf 397 * of the device. 398 * 399 * The "reg" property is assumed to be a list of at least one triple 400 * 401 * <bustype, address, size>*1 402 * 403 * The "intr" property is assumed to be a list of at least one duple 404 * 405 * <SPARC ipl, vector#>*1 406 * 407 * The "interrupts" property is assumed to be a list of at least one 408 * n-tuples that describes the interrupt capabilities of the bus the device 409 * is connected to. For SBus, this looks like 410 * 411 * <SBus-level>*1 412 * 413 * (This property obsoletes the 'intr' property). 414 * 415 * The "ranges" property is optional. 416 */ 417 void 418 make_ddi_ppd(dev_info_t *child, struct ddi_parent_private_data **ppd) 419 { 420 struct ddi_parent_private_data *pdptr; 421 int n; 422 int *reg_prop, *rng_prop, *intr_prop, *irupts_prop; 423 uint_t reg_len, rng_len, intr_len, irupts_len; 424 425 *ppd = pdptr = kmem_zalloc(sizeof (*pdptr), KM_SLEEP); 426 427 /* 428 * Handle the 'reg' property. 429 */ 430 if ((get_prop_int_array(child, "reg", ®_prop, ®_len) == 431 DDI_PROP_SUCCESS) && (reg_len != 0)) { 432 pdptr->par_nreg = reg_len / (int)sizeof (struct regspec); 433 pdptr->par_reg = (struct regspec *)reg_prop; 434 } 435 436 /* 437 * See if I have a range (adding one where needed - this 438 * means to add one for sbus node in sun4c, when romvec > 0, 439 * if no range is already defined in the PROM node. 440 * (Currently no sun4c PROMS define range properties, 441 * but they should and may in the future.) For the SBus 442 * node, the range is defined by the SBus reg property. 443 */ 444 if (get_prop_int_array(child, "ranges", &rng_prop, &rng_len) 445 == DDI_PROP_SUCCESS) { 446 pdptr->par_nrng = rng_len / (int)(sizeof (struct rangespec)); 447 pdptr->par_rng = (struct rangespec *)rng_prop; 448 } 449 450 /* 451 * Handle the 'intr' and 'interrupts' properties 452 */ 453 454 /* 455 * For backwards compatibility 456 * we first look for the 'intr' property for the device. 457 */ 458 if (get_prop_int_array(child, "intr", &intr_prop, &intr_len) 459 != DDI_PROP_SUCCESS) { 460 intr_len = 0; 461 } 462 463 /* 464 * If we're to support bus adapters and future platforms cleanly, 465 * we need to support the generalized 'interrupts' property. 466 */ 467 if (get_prop_int_array(child, "interrupts", &irupts_prop, 468 &irupts_len) != DDI_PROP_SUCCESS) { 469 irupts_len = 0; 470 } else if (intr_len != 0) { 471 /* 472 * If both 'intr' and 'interrupts' are defined, 473 * then 'interrupts' wins and we toss the 'intr' away. 474 */ 475 ddi_prop_free((void *)intr_prop); 476 intr_len = 0; 477 } 478 479 if (intr_len != 0) { 480 481 /* 482 * Translate the 'intr' property into an array 483 * an array of struct intrspec's. There's not really 484 * very much to do here except copy what's out there. 485 */ 486 487 struct intrspec *new; 488 struct prop_ispec *l; 489 490 n = pdptr->par_nintr = 491 intr_len / sizeof (struct prop_ispec); 492 l = (struct prop_ispec *)intr_prop; 493 pdptr->par_intr = 494 new = kmem_zalloc(n * sizeof (struct intrspec), KM_SLEEP); 495 while (n--) { 496 new->intrspec_pri = l->pri; 497 new->intrspec_vec = l->vec; 498 new++; 499 l++; 500 } 501 ddi_prop_free((void *)intr_prop); 502 503 } else if ((n = irupts_len) != 0) { 504 size_t size; 505 int *out; 506 507 /* 508 * Translate the 'interrupts' property into an array 509 * of intrspecs for the rest of the DDI framework to 510 * toy with. Only our ancestors really know how to 511 * do this, so ask 'em. We massage the 'interrupts' 512 * property so that it is pre-pended by a count of 513 * the number of integers in the argument. 514 */ 515 size = sizeof (int) + n; 516 out = kmem_alloc(size, KM_SLEEP); 517 *out = n / sizeof (int); 518 bcopy(irupts_prop, out + 1, (size_t)n); 519 ddi_prop_free((void *)irupts_prop); 520 if (ddi_ctlops(child, child, DDI_CTLOPS_XLATE_INTRS, 521 out, pdptr) != DDI_SUCCESS) { 522 cmn_err(CE_CONT, 523 "Unable to translate 'interrupts' for %s%d\n", 524 DEVI(child)->devi_binding_name, 525 DEVI(child)->devi_instance); 526 } 527 kmem_free(out, size); 528 } 529 } 530 531 /* 532 * Name a child 533 */ 534 static int 535 impl_sunbus_name_child(dev_info_t *child, char *name, int namelen) 536 { 537 /* 538 * Fill in parent-private data and this function returns to us 539 * an indication if it used "registers" to fill in the data. 540 */ 541 if (ddi_get_parent_data(child) == NULL) { 542 struct ddi_parent_private_data *pdptr; 543 make_ddi_ppd(child, &pdptr); 544 ddi_set_parent_data(child, pdptr); 545 } 546 547 name[0] = '\0'; 548 if (sparc_pd_getnreg(child) > 0) { 549 (void) snprintf(name, namelen, "%x,%x", 550 (uint_t)sparc_pd_getreg(child, 0)->regspec_bustype, 551 (uint_t)sparc_pd_getreg(child, 0)->regspec_addr); 552 } 553 554 return (DDI_SUCCESS); 555 } 556 557 /* 558 * Called from the bus_ctl op of sunbus (sbus, obio, etc) nexus drivers 559 * to implement the DDI_CTLOPS_INITCHILD operation. That is, it names 560 * the children of sun busses based on the reg spec. 561 * 562 * Handles the following properties (in make_ddi_ppd): 563 * Property value 564 * Name type 565 * reg register spec 566 * intr old-form interrupt spec 567 * interrupts new (bus-oriented) interrupt spec 568 * ranges range spec 569 */ 570 int 571 impl_ddi_sunbus_initchild(dev_info_t *child) 572 { 573 char name[MAXNAMELEN]; 574 void impl_ddi_sunbus_removechild(dev_info_t *); 575 576 /* 577 * Name the child, also makes parent private data 578 */ 579 (void) impl_sunbus_name_child(child, name, MAXNAMELEN); 580 ddi_set_name_addr(child, name); 581 582 /* 583 * Attempt to merge a .conf node; if successful, remove the 584 * .conf node. 585 */ 586 if ((ndi_dev_is_persistent_node(child) == 0) && 587 (ndi_merge_node(child, impl_sunbus_name_child) == DDI_SUCCESS)) { 588 /* 589 * Return failure to remove node 590 */ 591 impl_ddi_sunbus_removechild(child); 592 return (DDI_FAILURE); 593 } 594 return (DDI_SUCCESS); 595 } 596 597 void 598 impl_free_ddi_ppd(dev_info_t *dip) 599 { 600 struct ddi_parent_private_data *pdptr; 601 size_t n; 602 603 if ((pdptr = ddi_get_parent_data(dip)) == NULL) 604 return; 605 606 if ((n = (size_t)pdptr->par_nintr) != 0) 607 /* 608 * Note that kmem_free is used here (instead of 609 * ddi_prop_free) because the contents of the 610 * property were placed into a separate buffer and 611 * mucked with a bit before being stored in par_intr. 612 * The actual return value from the prop lookup 613 * was freed with ddi_prop_free previously. 614 */ 615 kmem_free(pdptr->par_intr, n * sizeof (struct intrspec)); 616 617 if ((n = (size_t)pdptr->par_nrng) != 0) 618 ddi_prop_free((void *)pdptr->par_rng); 619 620 if ((n = pdptr->par_nreg) != 0) 621 ddi_prop_free((void *)pdptr->par_reg); 622 623 kmem_free(pdptr, sizeof (*pdptr)); 624 ddi_set_parent_data(dip, NULL); 625 } 626 627 void 628 impl_ddi_sunbus_removechild(dev_info_t *dip) 629 { 630 impl_free_ddi_ppd(dip); 631 ddi_set_name_addr(dip, NULL); 632 /* 633 * Strip the node to properly convert it back to prototype form 634 */ 635 impl_rem_dev_props(dip); 636 } 637 638 /* 639 * DDI Interrupt 640 */ 641 642 /* 643 * turn this on to force isa, eisa, and mca device to ignore the new 644 * hardware nodes in the device tree (normally turned on only for 645 * drivers that need it by setting the property "ignore-hardware-nodes" 646 * in their driver.conf file). 647 * 648 * 7/31/96 -- Turned off globally. Leaving variable in for the moment 649 * as safety valve. 650 */ 651 int ignore_hardware_nodes = 0; 652 653 /* 654 * Local data 655 */ 656 static struct impl_bus_promops *impl_busp; 657 658 659 /* 660 * New DDI interrupt framework 661 */ 662 663 /* 664 * i_ddi_handle_intr_ops: 665 */ 666 int 667 i_ddi_handle_intr_ops(dev_info_t *dip, dev_info_t *rdip, ddi_intr_op_t op, 668 ddi_intr_handle_impl_t *hdlp, void * result) 669 { 670 return (i_ddi_intr_ops(dip, rdip, op, hdlp, result)); 671 } 672 673 /* 674 * i_ddi_intr_ops: 675 * 676 * This is the interrupt operator function wrapper for the bus function 677 * bus_intr_op. 678 */ 679 int 680 i_ddi_intr_ops(dev_info_t *dip, dev_info_t *rdip, ddi_intr_op_t op, 681 ddi_intr_handle_impl_t *hdlp, void * result) 682 { 683 dev_info_t *pdip = (dev_info_t *)DEVI(dip)->devi_parent; 684 int ret = DDI_FAILURE; 685 686 /* request parent to process this interrupt op */ 687 if (NEXUS_HAS_INTR_OP(pdip)) 688 ret = (*(DEVI(pdip)->devi_ops->devo_bus_ops->bus_intr_op))( 689 pdip, rdip, op, hdlp, result); 690 else 691 cmn_err(CE_WARN, "Failed to process interrupt " 692 "for %s%d due to down-rev nexus driver %s%d", 693 ddi_get_name(rdip), ddi_get_instance(rdip), 694 ddi_get_name(pdip), ddi_get_instance(pdip)); 695 return (ret); 696 } 697 698 /* 699 * i_ddi_add_softint - allocate and add a soft interrupt to the system 700 */ 701 int 702 i_ddi_add_softint(ddi_softint_hdl_impl_t *hdlp) 703 { 704 int ret; 705 706 /* add soft interrupt handler */ 707 ret = add_avsoftintr((void *)hdlp, hdlp->ih_pri, hdlp->ih_cb_func, 708 DEVI(hdlp->ih_dip)->devi_name, hdlp->ih_cb_arg1, hdlp->ih_cb_arg2); 709 return (ret ? DDI_SUCCESS : DDI_FAILURE); 710 } 711 712 713 void 714 i_ddi_remove_softint(ddi_softint_hdl_impl_t *hdlp) 715 { 716 (void) rem_avsoftintr((void *)hdlp, hdlp->ih_pri, hdlp->ih_cb_func); 717 } 718 719 720 extern void (*setsoftint)(int); 721 722 int 723 i_ddi_trigger_softint(ddi_softint_hdl_impl_t *hdlp) 724 { 725 if (!hdlp->ih_pending) { 726 update_avsoftintr_args((void *)hdlp, 727 hdlp->ih_pri, hdlp->ih_cb_arg2); 728 hdlp->ih_pending = 1; 729 } 730 (*setsoftint)(hdlp->ih_pri); 731 return (DDI_SUCCESS); 732 } 733 734 /* 735 * i_ddi_set_softint_pri: 736 * 737 * The way this works is that it first tries to add a softint vector 738 * at the new priority in hdlp. If that succeeds; then it removes the 739 * existing softint vector at the old priority. 740 */ 741 int 742 i_ddi_set_softint_pri(ddi_softint_hdl_impl_t *hdlp, uint_t old_pri) 743 { 744 /* 745 * If a softint is pending at the old priority then fail the request. 746 * OR 747 * If we failed to add a softint vector with the new priority; then 748 * fail the request with a DDI_FAILURE 749 */ 750 if (hdlp->ih_pending || i_ddi_add_softint(hdlp) != DDI_SUCCESS) 751 return (DDI_FAILURE); 752 753 /* Now, remove the softint at the old priority */ 754 (void) rem_avsoftintr((void *)hdlp, old_pri, hdlp->ih_cb_func); 755 return (DDI_SUCCESS); 756 } 757 758 /* 759 * DDI Memory/DMA 760 */ 761 762 /* 763 * Support for allocating DMAable memory to implement 764 * ddi_dma_mem_alloc(9F) interface. 765 */ 766 767 #define KA_ALIGN_SHIFT 7 768 #define KA_ALIGN (1 << KA_ALIGN_SHIFT) 769 #define KA_NCACHE (PAGESHIFT + 1 - KA_ALIGN_SHIFT) 770 771 /* 772 * Dummy DMA attribute template for kmem_io[].kmem_io_attr. We only 773 * care about addr_lo, addr_hi, and align. addr_hi will be dynamically set. 774 */ 775 776 static ddi_dma_attr_t kmem_io_attr = { 777 DMA_ATTR_V0, 778 0x0000000000000000ULL, /* dma_attr_addr_lo */ 779 0x0000000000000000ULL, /* dma_attr_addr_hi */ 780 0x00ffffff, 781 0x1000, /* dma_attr_align */ 782 1, 1, 0xffffffffULL, 0xffffffffULL, 0x1, 1, 0 783 }; 784 785 /* kmem io memory ranges and indices */ 786 enum { 787 IO_4P, IO_64G, IO_4G, IO_2G, IO_1G, IO_512M, 788 IO_256M, IO_128M, IO_64M, IO_32M, IO_16M, MAX_MEM_RANGES 789 }; 790 791 static struct { 792 vmem_t *kmem_io_arena; 793 kmem_cache_t *kmem_io_cache[KA_NCACHE]; 794 ddi_dma_attr_t kmem_io_attr; 795 } kmem_io[MAX_MEM_RANGES]; 796 797 static int kmem_io_idx; /* index of first populated kmem_io[] */ 798 799 static page_t * 800 page_create_io_wrapper(void *addr, size_t len, int vmflag, void *arg) 801 { 802 extern page_t *page_create_io(vnode_t *, u_offset_t, uint_t, 803 uint_t, struct as *, caddr_t, ddi_dma_attr_t *); 804 805 return (page_create_io(&kvp, (u_offset_t)(uintptr_t)addr, len, 806 PG_EXCL | ((vmflag & VM_NOSLEEP) ? 0 : PG_WAIT), &kas, addr, arg)); 807 } 808 809 static void * 810 segkmem_alloc_io_4P(vmem_t *vmp, size_t size, int vmflag) 811 { 812 return (segkmem_xalloc(vmp, NULL, size, vmflag, 0, 813 page_create_io_wrapper, &kmem_io[IO_4P].kmem_io_attr)); 814 } 815 816 static void * 817 segkmem_alloc_io_64G(vmem_t *vmp, size_t size, int vmflag) 818 { 819 return (segkmem_xalloc(vmp, NULL, size, vmflag, 0, 820 page_create_io_wrapper, &kmem_io[IO_64G].kmem_io_attr)); 821 } 822 823 static void * 824 segkmem_alloc_io_4G(vmem_t *vmp, size_t size, int vmflag) 825 { 826 return (segkmem_xalloc(vmp, NULL, size, vmflag, 0, 827 page_create_io_wrapper, &kmem_io[IO_4G].kmem_io_attr)); 828 } 829 830 static void * 831 segkmem_alloc_io_2G(vmem_t *vmp, size_t size, int vmflag) 832 { 833 return (segkmem_xalloc(vmp, NULL, size, vmflag, 0, 834 page_create_io_wrapper, &kmem_io[IO_2G].kmem_io_attr)); 835 } 836 837 static void * 838 segkmem_alloc_io_1G(vmem_t *vmp, size_t size, int vmflag) 839 { 840 return (segkmem_xalloc(vmp, NULL, size, vmflag, 0, 841 page_create_io_wrapper, &kmem_io[IO_1G].kmem_io_attr)); 842 } 843 844 static void * 845 segkmem_alloc_io_512M(vmem_t *vmp, size_t size, int vmflag) 846 { 847 return (segkmem_xalloc(vmp, NULL, size, vmflag, 0, 848 page_create_io_wrapper, &kmem_io[IO_512M].kmem_io_attr)); 849 } 850 851 static void * 852 segkmem_alloc_io_256M(vmem_t *vmp, size_t size, int vmflag) 853 { 854 return (segkmem_xalloc(vmp, NULL, size, vmflag, 0, 855 page_create_io_wrapper, &kmem_io[IO_256M].kmem_io_attr)); 856 } 857 858 static void * 859 segkmem_alloc_io_128M(vmem_t *vmp, size_t size, int vmflag) 860 { 861 return (segkmem_xalloc(vmp, NULL, size, vmflag, 0, 862 page_create_io_wrapper, &kmem_io[IO_128M].kmem_io_attr)); 863 } 864 865 static void * 866 segkmem_alloc_io_64M(vmem_t *vmp, size_t size, int vmflag) 867 { 868 return (segkmem_xalloc(vmp, NULL, size, vmflag, 0, 869 page_create_io_wrapper, &kmem_io[IO_64M].kmem_io_attr)); 870 } 871 872 static void * 873 segkmem_alloc_io_32M(vmem_t *vmp, size_t size, int vmflag) 874 { 875 return (segkmem_xalloc(vmp, NULL, size, vmflag, 0, 876 page_create_io_wrapper, &kmem_io[IO_32M].kmem_io_attr)); 877 } 878 879 static void * 880 segkmem_alloc_io_16M(vmem_t *vmp, size_t size, int vmflag) 881 { 882 return (segkmem_xalloc(vmp, NULL, size, vmflag, 0, 883 page_create_io_wrapper, &kmem_io[IO_16M].kmem_io_attr)); 884 } 885 886 struct { 887 uint64_t io_limit; 888 char *io_name; 889 void *(*io_alloc)(vmem_t *, size_t, int); 890 int io_initial; /* kmem_io_init during startup */ 891 } io_arena_params[MAX_MEM_RANGES] = { 892 {0x000fffffffffffffULL, "kmem_io_4P", segkmem_alloc_io_4P, 1}, 893 {0x0000000fffffffffULL, "kmem_io_64G", segkmem_alloc_io_64G, 0}, 894 {0x00000000ffffffffULL, "kmem_io_4G", segkmem_alloc_io_4G, 1}, 895 {0x000000007fffffffULL, "kmem_io_2G", segkmem_alloc_io_2G, 1}, 896 {0x000000003fffffffULL, "kmem_io_1G", segkmem_alloc_io_1G, 0}, 897 {0x000000001fffffffULL, "kmem_io_512M", segkmem_alloc_io_512M, 0}, 898 {0x000000000fffffffULL, "kmem_io_256M", segkmem_alloc_io_256M, 0}, 899 {0x0000000007ffffffULL, "kmem_io_128M", segkmem_alloc_io_128M, 0}, 900 {0x0000000003ffffffULL, "kmem_io_64M", segkmem_alloc_io_64M, 0}, 901 {0x0000000001ffffffULL, "kmem_io_32M", segkmem_alloc_io_32M, 0}, 902 {0x0000000000ffffffULL, "kmem_io_16M", segkmem_alloc_io_16M, 1} 903 }; 904 905 void 906 kmem_io_init(int a) 907 { 908 int c; 909 char name[40]; 910 911 kmem_io[a].kmem_io_arena = vmem_create(io_arena_params[a].io_name, 912 NULL, 0, PAGESIZE, io_arena_params[a].io_alloc, 913 segkmem_free, heap_arena, 0, VM_SLEEP); 914 for (c = 0; c < KA_NCACHE; c++) { 915 size_t size = KA_ALIGN << c; 916 (void) sprintf(name, "%s_%lu", 917 io_arena_params[a].io_name, size); 918 kmem_io[a].kmem_io_cache[c] = kmem_cache_create(name, 919 size, size, NULL, NULL, NULL, NULL, 920 kmem_io[a].kmem_io_arena, 0); 921 } 922 } 923 924 /* 925 * Return the index of the highest memory range for addr. 926 */ 927 static int 928 kmem_io_index(uint64_t addr) 929 { 930 int n; 931 932 for (n = kmem_io_idx; n < MAX_MEM_RANGES; n++) { 933 if (kmem_io[n].kmem_io_attr.dma_attr_addr_hi <= addr) { 934 if (kmem_io[n].kmem_io_arena == NULL) 935 kmem_io_init(n); 936 return (n); 937 } 938 } 939 panic("kmem_io_index: invalid addr - must be at least 16m"); 940 941 /*NOTREACHED*/ 942 } 943 944 /* 945 * Return the index of the next kmem_io populated memory range 946 * after curindex. 947 */ 948 static int 949 kmem_io_index_next(int curindex) 950 { 951 int n; 952 953 for (n = curindex + 1; n < MAX_MEM_RANGES; n++) { 954 if (kmem_io[n].kmem_io_arena) 955 return (n); 956 } 957 return (-1); 958 } 959 960 void 961 ka_init(void) 962 { 963 int a; 964 extern pfn_t physmax; 965 uint64_t maxphysaddr = mmu_ptob((uint64_t)physmax + 1) - 1; 966 967 ASSERT(maxphysaddr <= io_arena_params[0].io_limit); 968 969 for (a = 0; a < MAX_MEM_RANGES; a++) { 970 if (maxphysaddr >= io_arena_params[a + 1].io_limit) { 971 if (maxphysaddr > io_arena_params[a + 1].io_limit) 972 io_arena_params[a].io_limit = maxphysaddr; 973 else 974 a++; 975 break; 976 } 977 } 978 kmem_io_idx = a; 979 980 for (; a < MAX_MEM_RANGES; a++) { 981 kmem_io[a].kmem_io_attr = kmem_io_attr; 982 kmem_io[a].kmem_io_attr.dma_attr_addr_hi = 983 io_arena_params[a].io_limit; 984 /* 985 * initialize kmem_io[] arena/cache corresponding to 986 * maxphysaddr and to the "common" io memory ranges that 987 * have io_initial set to a non-zero value. 988 */ 989 if (io_arena_params[a].io_initial || a == kmem_io_idx) 990 kmem_io_init(a); 991 } 992 } 993 994 /* 995 * put contig address/size 996 */ 997 static void * 998 putctgas(void *addr, size_t size) 999 { 1000 struct ctgas *ctgp = &ctglist; 1001 int i; 1002 1003 CTGLOCK(); 1004 do { 1005 if ((i = ctgp->ctg_index) < CTGENTRIES) { 1006 ctgp->ctg_addr[i] = addr; 1007 ctgp->ctg_size[i] = size; 1008 ctgp->ctg_index++; 1009 break; 1010 } 1011 if (!ctgp->ctg_next) 1012 ctgp->ctg_next = kmem_zalloc(sizeof (struct ctgas), 1013 KM_NOSLEEP); 1014 ctgp = ctgp->ctg_next; 1015 } while (ctgp); 1016 1017 CTGUNLOCK(); 1018 return (ctgp); 1019 } 1020 1021 /* 1022 * get contig size by addr 1023 */ 1024 static size_t 1025 getctgsz(void *addr) 1026 { 1027 struct ctgas *ctgp = &ctglist; 1028 int i, j; 1029 size_t sz; 1030 1031 ASSERT(addr); 1032 CTGLOCK(); 1033 1034 while (ctgp) { 1035 for (i = 0; i < ctgp->ctg_index; i++) { 1036 if (addr != ctgp->ctg_addr[i]) 1037 continue; 1038 1039 sz = ctgp->ctg_size[i]; 1040 j = --ctgp->ctg_index; 1041 if (i != j) { 1042 ctgp->ctg_size[i] = ctgp->ctg_size[j]; 1043 ctgp->ctg_addr[i] = ctgp->ctg_addr[j]; 1044 } 1045 CTGUNLOCK(); 1046 return (sz); 1047 } 1048 ctgp = ctgp->ctg_next; 1049 } 1050 1051 CTGUNLOCK(); 1052 return (0); 1053 } 1054 1055 /* 1056 * contig_alloc: 1057 * 1058 * allocates contiguous memory to satisfy the 'size' and dma attributes 1059 * specified in 'attr'. 1060 * 1061 * Not all of memory need to be physically contiguous if the 1062 * scatter-gather list length is greater than 1. 1063 */ 1064 1065 /*ARGSUSED*/ 1066 void * 1067 contig_alloc(size_t size, ddi_dma_attr_t *attr, uintptr_t align, int cansleep) 1068 { 1069 pgcnt_t pgcnt = btopr(size); 1070 size_t asize = pgcnt * PAGESIZE; 1071 page_t *ppl; 1072 int pflag; 1073 void *addr; 1074 1075 extern page_t *page_create_io(vnode_t *, u_offset_t, uint_t, 1076 uint_t, struct as *, caddr_t, ddi_dma_attr_t *); 1077 1078 /* segkmem_xalloc */ 1079 1080 if (align <= PAGESIZE) 1081 addr = vmem_alloc(heap_arena, asize, 1082 (cansleep) ? VM_SLEEP : VM_NOSLEEP); 1083 else 1084 addr = vmem_xalloc(heap_arena, asize, align, 0, 0, NULL, NULL, 1085 (cansleep) ? VM_SLEEP : VM_NOSLEEP); 1086 if (addr) { 1087 ASSERT(!((uintptr_t)addr & (align - 1))); 1088 1089 if (page_resv(pgcnt, 1090 (cansleep) ? KM_SLEEP : KM_NOSLEEP) == 0) { 1091 1092 vmem_free(heap_arena, addr, asize); 1093 return (NULL); 1094 } 1095 pflag = PG_EXCL; 1096 1097 if (cansleep) 1098 pflag |= PG_WAIT; 1099 1100 /* 4k req gets from freelists rather than pfn search */ 1101 if (pgcnt > 1 || align > PAGESIZE) 1102 pflag |= PG_PHYSCONTIG; 1103 1104 ppl = page_create_io(&kvp, (u_offset_t)(uintptr_t)addr, 1105 asize, pflag, &kas, (caddr_t)addr, attr); 1106 1107 if (!ppl) { 1108 vmem_free(heap_arena, addr, asize); 1109 page_unresv(pgcnt); 1110 return (NULL); 1111 } 1112 1113 while (ppl != NULL) { 1114 page_t *pp = ppl; 1115 page_sub(&ppl, pp); 1116 ASSERT(page_iolock_assert(pp)); 1117 page_io_unlock(pp); 1118 page_downgrade(pp); 1119 hat_memload(kas.a_hat, (caddr_t)(uintptr_t)pp->p_offset, 1120 pp, (PROT_ALL & ~PROT_USER) | 1121 HAT_NOSYNC, HAT_LOAD_LOCK); 1122 } 1123 } 1124 return (addr); 1125 } 1126 1127 static void 1128 contig_free(void *addr, size_t size) 1129 { 1130 pgcnt_t pgcnt = btopr(size); 1131 size_t asize = pgcnt * PAGESIZE; 1132 caddr_t a, ea; 1133 page_t *pp; 1134 1135 hat_unload(kas.a_hat, addr, asize, HAT_UNLOAD_UNLOCK); 1136 1137 for (a = addr, ea = a + asize; a < ea; a += PAGESIZE) { 1138 pp = page_find(&kvp, 1139 (u_offset_t)(uintptr_t)a); 1140 if (!pp) 1141 panic("contig_free: contig pp not found"); 1142 1143 if (!page_tryupgrade(pp)) { 1144 page_unlock(pp); 1145 pp = page_lookup(&kvp, 1146 (u_offset_t)(uintptr_t)a, SE_EXCL); 1147 if (pp == NULL) 1148 panic("contig_free: page freed"); 1149 } 1150 page_destroy(pp, 0); 1151 } 1152 1153 page_unresv(pgcnt); 1154 vmem_free(heap_arena, addr, asize); 1155 } 1156 1157 /* 1158 * Allocate from the system, aligned on a specific boundary. 1159 * The alignment, if non-zero, must be a power of 2. 1160 */ 1161 static void * 1162 kalloca(size_t size, size_t align, int cansleep, int physcontig, 1163 ddi_dma_attr_t *attr) 1164 { 1165 size_t *addr, *raddr, rsize; 1166 size_t hdrsize = 4 * sizeof (size_t); /* must be power of 2 */ 1167 int a, i, c; 1168 vmem_t *vmp; 1169 kmem_cache_t *cp = NULL; 1170 1171 align = MAX(align, hdrsize); 1172 ASSERT((align & (align - 1)) == 0); 1173 1174 /* 1175 * All of our allocators guarantee 16-byte alignment, so we don't 1176 * need to reserve additional space for the header. 1177 * To simplify picking the correct kmem_io_cache, we round up to 1178 * a multiple of KA_ALIGN. 1179 */ 1180 rsize = P2ROUNDUP_TYPED(size + align, KA_ALIGN, size_t); 1181 1182 if (physcontig && rsize > PAGESIZE) { 1183 if (addr = contig_alloc(size, attr, align, cansleep)) { 1184 if (!putctgas(addr, size)) 1185 contig_free(addr, size); 1186 else 1187 return (addr); 1188 } 1189 return (NULL); 1190 } 1191 1192 ASSERT(attr->dma_attr_addr_lo <= mmu_ptob((uint64_t)ddiphysmin)); 1193 1194 a = kmem_io_index(attr->dma_attr_addr_hi); 1195 1196 if (rsize > PAGESIZE) { 1197 vmp = kmem_io[a].kmem_io_arena; 1198 raddr = vmem_alloc(vmp, rsize, 1199 (cansleep) ? VM_SLEEP : VM_NOSLEEP); 1200 } else { 1201 c = highbit((rsize >> KA_ALIGN_SHIFT) - 1); 1202 cp = kmem_io[a].kmem_io_cache[c]; 1203 raddr = kmem_cache_alloc(cp, (cansleep) ? KM_SLEEP : 1204 KM_NOSLEEP); 1205 } 1206 1207 if (raddr == NULL) { 1208 int na; 1209 1210 ASSERT(cansleep == 0); 1211 if (rsize > PAGESIZE) 1212 return (NULL); 1213 /* 1214 * System does not have memory in the requested range. 1215 * Try smaller kmem io ranges and larger cache sizes 1216 * to see if there might be memory available in 1217 * these other caches. 1218 */ 1219 1220 for (na = kmem_io_index_next(a); na >= 0; 1221 na = kmem_io_index_next(na)) { 1222 ASSERT(kmem_io[na].kmem_io_arena); 1223 cp = kmem_io[na].kmem_io_cache[c]; 1224 raddr = kmem_cache_alloc(cp, KM_NOSLEEP); 1225 if (raddr) 1226 goto kallocdone; 1227 } 1228 /* now try the larger kmem io cache sizes */ 1229 for (na = a; na >= 0; na = kmem_io_index_next(na)) { 1230 for (i = c + 1; i < KA_NCACHE; i++) { 1231 cp = kmem_io[na].kmem_io_cache[i]; 1232 raddr = kmem_cache_alloc(cp, KM_NOSLEEP); 1233 if (raddr) 1234 goto kallocdone; 1235 } 1236 } 1237 return (NULL); 1238 } 1239 1240 kallocdone: 1241 ASSERT(!P2CROSS((uintptr_t)raddr, (uintptr_t)raddr + rsize - 1, 1242 PAGESIZE) || rsize > PAGESIZE); 1243 1244 addr = (size_t *)P2ROUNDUP((uintptr_t)raddr + hdrsize, align); 1245 ASSERT((uintptr_t)addr + size - (uintptr_t)raddr <= rsize); 1246 1247 addr[-4] = (size_t)cp; 1248 addr[-3] = (size_t)vmp; 1249 addr[-2] = (size_t)raddr; 1250 addr[-1] = rsize; 1251 1252 return (addr); 1253 } 1254 1255 static void 1256 kfreea(void *addr) 1257 { 1258 size_t size; 1259 1260 if (!((uintptr_t)addr & PAGEOFFSET) && (size = getctgsz(addr))) { 1261 contig_free(addr, size); 1262 } else { 1263 size_t *saddr = addr; 1264 if (saddr[-4] == 0) 1265 vmem_free((vmem_t *)saddr[-3], (void *)saddr[-2], 1266 saddr[-1]); 1267 else 1268 kmem_cache_free((kmem_cache_t *)saddr[-4], 1269 (void *)saddr[-2]); 1270 } 1271 } 1272 1273 /* 1274 * This should actually be called i_ddi_dma_mem_alloc. There should 1275 * also be an i_ddi_pio_mem_alloc. i_ddi_dma_mem_alloc should call 1276 * through the device tree with the DDI_CTLOPS_DMA_ALIGN ctl ops to 1277 * get alignment requirements for DMA memory. i_ddi_pio_mem_alloc 1278 * should use DDI_CTLOPS_PIO_ALIGN. Since we only have i_ddi_mem_alloc 1279 * so far which is used for both, DMA and PIO, we have to use the DMA 1280 * ctl ops to make everybody happy. 1281 */ 1282 /*ARGSUSED*/ 1283 int 1284 i_ddi_mem_alloc(dev_info_t *dip, ddi_dma_attr_t *attr, 1285 size_t length, int cansleep, int streaming, 1286 ddi_device_acc_attr_t *accattrp, caddr_t *kaddrp, 1287 size_t *real_length, ddi_acc_hdl_t *ap) 1288 { 1289 caddr_t a; 1290 int iomin; 1291 ddi_acc_impl_t *iap; 1292 int physcontig = 0; 1293 pgcnt_t npages; 1294 pgcnt_t minctg; 1295 1296 /* 1297 * Check legality of arguments 1298 */ 1299 if (length == 0 || kaddrp == NULL || attr == NULL) { 1300 return (DDI_FAILURE); 1301 } 1302 if (attr->dma_attr_minxfer == 0 || attr->dma_attr_align == 0 || 1303 (attr->dma_attr_align & (attr->dma_attr_align - 1)) || 1304 (attr->dma_attr_minxfer & (attr->dma_attr_minxfer - 1))) { 1305 return (DDI_FAILURE); 1306 } 1307 1308 /* 1309 * figure out most restrictive alignment requirement 1310 */ 1311 iomin = attr->dma_attr_minxfer; 1312 iomin = maxbit(iomin, attr->dma_attr_align); 1313 if (iomin == 0) 1314 return (DDI_FAILURE); 1315 1316 ASSERT((iomin & (iomin - 1)) == 0); 1317 1318 1319 /* 1320 * Determine if we need to satisfy the request for physically 1321 * contiguous memory or alignments larger than pagesize. 1322 */ 1323 npages = btopr(length + attr->dma_attr_align); 1324 minctg = howmany(npages, attr->dma_attr_sgllen); 1325 1326 if (minctg > 1) { 1327 uint64_t pfnseg = attr->dma_attr_seg >> PAGESHIFT; 1328 /* 1329 * verify that the minimum contig requirement for the 1330 * actual length does not cross segment boundary. 1331 */ 1332 length = P2ROUNDUP_TYPED(length, attr->dma_attr_minxfer, 1333 size_t); 1334 npages = btopr(length); 1335 minctg = howmany(npages, attr->dma_attr_sgllen); 1336 if (minctg > pfnseg + 1) 1337 return (DDI_FAILURE); 1338 physcontig = 1; 1339 } else { 1340 length = P2ROUNDUP_TYPED(length, iomin, size_t); 1341 } 1342 1343 /* 1344 * Allocate the requested amount from the system. 1345 */ 1346 a = kalloca(length, iomin, cansleep, physcontig, attr); 1347 1348 if ((*kaddrp = a) == NULL) 1349 return (DDI_FAILURE); 1350 1351 if (real_length) { 1352 *real_length = length; 1353 } 1354 if (ap) { 1355 /* 1356 * initialize access handle 1357 */ 1358 iap = (ddi_acc_impl_t *)ap->ah_platform_private; 1359 iap->ahi_acc_attr |= DDI_ACCATTR_CPU_VADDR; 1360 impl_acc_hdl_init(ap); 1361 } 1362 return (DDI_SUCCESS); 1363 } 1364 1365 /* 1366 * covert old DMA limits structure to DMA attribute structure 1367 * and continue 1368 */ 1369 int 1370 i_ddi_mem_alloc_lim(dev_info_t *dip, ddi_dma_lim_t *limits, 1371 size_t length, int cansleep, int streaming, 1372 ddi_device_acc_attr_t *accattrp, caddr_t *kaddrp, 1373 uint_t *real_length, ddi_acc_hdl_t *ap) 1374 { 1375 ddi_dma_attr_t dma_attr, *attrp; 1376 size_t rlen; 1377 int ret; 1378 1379 if (limits == NULL) { 1380 return (DDI_FAILURE); 1381 } 1382 1383 /* 1384 * set up DMA attribute structure to pass to i_ddi_mem_alloc() 1385 */ 1386 attrp = &dma_attr; 1387 attrp->dma_attr_version = DMA_ATTR_V0; 1388 attrp->dma_attr_addr_lo = (uint64_t)limits->dlim_addr_lo; 1389 attrp->dma_attr_addr_hi = (uint64_t)limits->dlim_addr_hi; 1390 attrp->dma_attr_count_max = (uint64_t)limits->dlim_ctreg_max; 1391 attrp->dma_attr_align = 1; 1392 attrp->dma_attr_burstsizes = (uint_t)limits->dlim_burstsizes; 1393 attrp->dma_attr_minxfer = (uint32_t)limits->dlim_minxfer; 1394 attrp->dma_attr_maxxfer = (uint64_t)limits->dlim_reqsize; 1395 attrp->dma_attr_seg = (uint64_t)limits->dlim_adreg_max; 1396 attrp->dma_attr_sgllen = limits->dlim_sgllen; 1397 attrp->dma_attr_granular = (uint32_t)limits->dlim_granular; 1398 attrp->dma_attr_flags = 0; 1399 1400 ret = i_ddi_mem_alloc(dip, attrp, length, cansleep, streaming, 1401 accattrp, kaddrp, &rlen, ap); 1402 if (ret == DDI_SUCCESS) { 1403 if (real_length) 1404 *real_length = (uint_t)rlen; 1405 } 1406 return (ret); 1407 } 1408 1409 /* ARGSUSED */ 1410 void 1411 i_ddi_mem_free(caddr_t kaddr, int stream) 1412 { 1413 kfreea(kaddr); 1414 } 1415 1416 /* 1417 * Access Barriers 1418 * 1419 */ 1420 /*ARGSUSED*/ 1421 int 1422 i_ddi_ontrap(ddi_acc_handle_t hp) 1423 { 1424 return (DDI_FAILURE); 1425 } 1426 1427 /*ARGSUSED*/ 1428 void 1429 i_ddi_notrap(ddi_acc_handle_t hp) 1430 { 1431 } 1432 1433 1434 /* 1435 * Misc Functions 1436 */ 1437 1438 /* 1439 * Implementation instance override functions 1440 * 1441 * No override on i86pc 1442 */ 1443 /*ARGSUSED*/ 1444 uint_t 1445 impl_assign_instance(dev_info_t *dip) 1446 { 1447 return ((uint_t)-1); 1448 } 1449 1450 /*ARGSUSED*/ 1451 int 1452 impl_keep_instance(dev_info_t *dip) 1453 { 1454 return (DDI_FAILURE); 1455 } 1456 1457 /*ARGSUSED*/ 1458 int 1459 impl_free_instance(dev_info_t *dip) 1460 { 1461 return (DDI_FAILURE); 1462 } 1463 1464 /*ARGSUSED*/ 1465 int 1466 impl_check_cpu(dev_info_t *devi) 1467 { 1468 return (DDI_SUCCESS); 1469 } 1470 1471 /* 1472 * Referenced in common/cpr_driver.c: Power off machine. 1473 * Don't know how to power off i86pc. 1474 */ 1475 void 1476 arch_power_down() 1477 {} 1478 1479 /* 1480 * Copy name to property_name, since name 1481 * is in the low address range below kernelbase. 1482 */ 1483 static void 1484 copy_boot_str(const char *boot_str, char *kern_str, int len) 1485 { 1486 int i = 0; 1487 1488 while (i < len - 1 && boot_str[i] != '\0') { 1489 kern_str[i] = boot_str[i]; 1490 i++; 1491 } 1492 1493 kern_str[i] = 0; /* null terminate */ 1494 if (boot_str[i] != '\0') 1495 cmn_err(CE_WARN, 1496 "boot property string is truncated to %s", kern_str); 1497 } 1498 1499 static void 1500 get_boot_properties(void) 1501 { 1502 extern char hw_provider[]; 1503 dev_info_t *devi; 1504 char *name; 1505 int length; 1506 char property_name[50], property_val[50]; 1507 void *bop_staging_area; 1508 1509 bop_staging_area = kmem_zalloc(MMU_PAGESIZE, KM_NOSLEEP); 1510 1511 /* 1512 * Import "root" properties from the boot. 1513 * 1514 * We do this by invoking BOP_NEXTPROP until the list 1515 * is completely copied in. 1516 */ 1517 1518 devi = ddi_root_node(); 1519 for (name = BOP_NEXTPROP(bootops, ""); /* get first */ 1520 name; /* NULL => DONE */ 1521 name = BOP_NEXTPROP(bootops, name)) { /* get next */ 1522 1523 /* copy string to memory above kernelbase */ 1524 copy_boot_str(name, property_name, 50); 1525 1526 /* 1527 * Skip vga properties. They will be picked up later 1528 * by get_vga_properties. 1529 */ 1530 if (strcmp(property_name, "display-edif-block") == 0 || 1531 strcmp(property_name, "display-edif-id") == 0) { 1532 continue; 1533 } 1534 1535 length = BOP_GETPROPLEN(bootops, property_name); 1536 if (length == 0) 1537 continue; 1538 if (length > MMU_PAGESIZE) { 1539 cmn_err(CE_NOTE, 1540 "boot property %s longer than 0x%x, ignored\n", 1541 property_name, MMU_PAGESIZE); 1542 continue; 1543 } 1544 BOP_GETPROP(bootops, property_name, bop_staging_area); 1545 1546 /* 1547 * special properties: 1548 * si-machine, si-hw-provider 1549 * goes to kernel data structures. 1550 * bios-boot-device and stdout 1551 * goes to hardware property list so it may show up 1552 * in the prtconf -vp output. This is needed by 1553 * Install/Upgrade. Once we fix install upgrade, 1554 * this can be taken out. 1555 */ 1556 if (strcmp(name, "si-machine") == 0) { 1557 (void) strncpy(utsname.machine, bop_staging_area, 1558 SYS_NMLN); 1559 utsname.machine[SYS_NMLN - 1] = (char)NULL; 1560 } else if (strcmp(name, "si-hw-provider") == 0) { 1561 (void) strncpy(hw_provider, bop_staging_area, SYS_NMLN); 1562 hw_provider[SYS_NMLN - 1] = (char)NULL; 1563 } else if (strcmp(name, "bios-boot-device") == 0) { 1564 copy_boot_str(bop_staging_area, property_val, 50); 1565 (void) ndi_prop_update_string(DDI_DEV_T_NONE, devi, 1566 property_name, property_val); 1567 } else if (strcmp(name, "stdout") == 0) { 1568 (void) ndi_prop_update_int(DDI_DEV_T_NONE, devi, 1569 property_name, *((int *)bop_staging_area)); 1570 } else { 1571 /* Property type unknown, use old prop interface */ 1572 (void) e_ddi_prop_create(DDI_DEV_T_NONE, devi, 1573 DDI_PROP_CANSLEEP, property_name, bop_staging_area, 1574 length); 1575 } 1576 } 1577 1578 kmem_free(bop_staging_area, MMU_PAGESIZE); 1579 } 1580 1581 static void 1582 get_vga_properties(void) 1583 { 1584 dev_info_t *devi; 1585 major_t major; 1586 char *name; 1587 int length; 1588 char property_val[50]; 1589 void *bop_staging_area; 1590 1591 major = ddi_name_to_major("vgatext"); 1592 if (major == (major_t)-1) 1593 return; 1594 devi = devnamesp[major].dn_head; 1595 if (devi == NULL) 1596 return; 1597 1598 bop_staging_area = kmem_zalloc(MMU_PAGESIZE, KM_SLEEP); 1599 1600 /* 1601 * Import "vga" properties from the boot. 1602 */ 1603 name = "display-edif-block"; 1604 length = BOP_GETPROPLEN(bootops, name); 1605 if (length > 0 && length < MMU_PAGESIZE) { 1606 BOP_GETPROP(bootops, name, bop_staging_area); 1607 (void) ndi_prop_update_byte_array(DDI_DEV_T_NONE, 1608 devi, name, bop_staging_area, length); 1609 } 1610 1611 /* 1612 * kdmconfig is also looking for display-type and 1613 * video-adapter-type. We default to color and svga. 1614 * 1615 * Could it be "monochrome", "vga"? 1616 * Nah, you've got to come to the 21st century... 1617 * And you can set monitor type manually in kdmconfig 1618 * if you are really an old junky. 1619 */ 1620 (void) ndi_prop_update_string(DDI_DEV_T_NONE, 1621 devi, "display-type", "color"); 1622 (void) ndi_prop_update_string(DDI_DEV_T_NONE, 1623 devi, "video-adapter-type", "svga"); 1624 1625 name = "display-edif-id"; 1626 length = BOP_GETPROPLEN(bootops, name); 1627 if (length > 0 && length < MMU_PAGESIZE) { 1628 BOP_GETPROP(bootops, name, bop_staging_area); 1629 copy_boot_str(bop_staging_area, property_val, length); 1630 (void) ndi_prop_update_string(DDI_DEV_T_NONE, 1631 devi, name, property_val); 1632 } 1633 1634 kmem_free(bop_staging_area, MMU_PAGESIZE); 1635 } 1636 1637 1638 /* 1639 * This is temporary, but absolutely necessary. If we are being 1640 * booted with a device tree created by the DevConf project's bootconf 1641 * program, then we have device information nodes that reflect 1642 * reality. At this point in time in the Solaris release schedule, the 1643 * kernel drivers aren't prepared for reality. They still depend on their 1644 * own ad-hoc interpretations of the properties created when their .conf 1645 * files were interpreted. These drivers use an "ignore-hardware-nodes" 1646 * property to prevent them from using the nodes passed up from the bootconf 1647 * device tree. 1648 * 1649 * Trying to assemble root file system drivers as we are booting from 1650 * devconf will fail if the kernel driver is basing its name_addr's on the 1651 * psuedo-node device info while the bootpath passed up from bootconf is using 1652 * reality-based name_addrs. We help the boot along in this case by 1653 * looking at the pre-bootconf bootpath and determining if we would have 1654 * successfully matched if that had been the bootpath we had chosen. 1655 * 1656 * Note that we only even perform this extra check if we've booted 1657 * using bootconf's 1275 compliant bootpath, this is the boot device, and 1658 * we're trying to match the name_addr specified in the 1275 bootpath. 1659 */ 1660 1661 #define MAXCOMPONENTLEN 32 1662 1663 int 1664 x86_old_bootpath_name_addr_match(dev_info_t *cdip, char *caddr, char *naddr) 1665 { 1666 /* 1667 * There are multiple criteria to be met before we can even 1668 * consider allowing a name_addr match here. 1669 * 1670 * 1) We must have been booted such that the bootconf program 1671 * created device tree nodes and properties. This can be 1672 * determined by examining the 'bootpath' property. This 1673 * property will be a non-null string iff bootconf was 1674 * involved in the boot. 1675 * 1676 * 2) The module that we want to match must be the boot device. 1677 * 1678 * 3) The instance of the module we are thinking of letting be 1679 * our match must be ignoring hardware nodes. 1680 * 1681 * 4) The name_addr we want to match must be the name_addr 1682 * specified in the 1275 bootpath. 1683 */ 1684 static char bootdev_module[MAXCOMPONENTLEN]; 1685 static char bootdev_oldmod[MAXCOMPONENTLEN]; 1686 static char bootdev_newaddr[MAXCOMPONENTLEN]; 1687 static char bootdev_oldaddr[MAXCOMPONENTLEN]; 1688 static int quickexit; 1689 1690 char *daddr; 1691 int dlen; 1692 1693 char *lkupname; 1694 int rv = DDI_FAILURE; 1695 1696 if ((ddi_getlongprop(DDI_DEV_T_ANY, cdip, DDI_PROP_DONTPASS, 1697 "devconf-addr", (caddr_t)&daddr, &dlen) == DDI_PROP_SUCCESS) && 1698 (ddi_getprop(DDI_DEV_T_ANY, cdip, DDI_PROP_DONTPASS, 1699 "ignore-hardware-nodes", -1) != -1)) { 1700 if (strcmp(daddr, caddr) == 0) { 1701 return (DDI_SUCCESS); 1702 } 1703 } 1704 1705 if (quickexit) 1706 return (rv); 1707 1708 if (bootdev_module[0] == '\0') { 1709 char *addrp, *eoaddrp; 1710 char *busp, *modp, *atp; 1711 char *bp1275, *bp; 1712 int bp1275len, bplen; 1713 1714 bp1275 = bp = addrp = eoaddrp = busp = modp = atp = NULL; 1715 1716 if (ddi_getlongprop(DDI_DEV_T_ANY, 1717 ddi_root_node(), 0, "bootpath", 1718 (caddr_t)&bp1275, &bp1275len) != DDI_PROP_SUCCESS || 1719 bp1275len <= 1) { 1720 /* 1721 * We didn't boot from bootconf so we never need to 1722 * do any special matches. 1723 */ 1724 quickexit = 1; 1725 if (bp1275) 1726 kmem_free(bp1275, bp1275len); 1727 return (rv); 1728 } 1729 1730 if (ddi_getlongprop(DDI_DEV_T_ANY, 1731 ddi_root_node(), 0, "boot-path", 1732 (caddr_t)&bp, &bplen) != DDI_PROP_SUCCESS || bplen <= 1) { 1733 /* 1734 * No fallback position for matching. This is 1735 * certainly unexpected, but we'll handle it 1736 * just in case. 1737 */ 1738 quickexit = 1; 1739 kmem_free(bp1275, bp1275len); 1740 if (bp) 1741 kmem_free(bp, bplen); 1742 return (rv); 1743 } 1744 1745 /* 1746 * Determine boot device module and 1275 name_addr 1747 * 1748 * bootpath assumed to be of the form /bus/module@name_addr 1749 */ 1750 if (busp = strchr(bp1275, '/')) { 1751 if (modp = strchr(busp + 1, '/')) { 1752 if (atp = strchr(modp + 1, '@')) { 1753 *atp = '\0'; 1754 addrp = atp + 1; 1755 if (eoaddrp = strchr(addrp, '/')) 1756 *eoaddrp = '\0'; 1757 } 1758 } 1759 } 1760 1761 if (modp && addrp) { 1762 (void) strncpy(bootdev_module, modp + 1, 1763 MAXCOMPONENTLEN); 1764 bootdev_module[MAXCOMPONENTLEN - 1] = '\0'; 1765 1766 (void) strncpy(bootdev_newaddr, addrp, MAXCOMPONENTLEN); 1767 bootdev_newaddr[MAXCOMPONENTLEN - 1] = '\0'; 1768 } else { 1769 quickexit = 1; 1770 kmem_free(bp1275, bp1275len); 1771 kmem_free(bp, bplen); 1772 return (rv); 1773 } 1774 1775 /* 1776 * Determine fallback name_addr 1777 * 1778 * 10/3/96 - Also save fallback module name because it 1779 * might actually be different than the current module 1780 * name. E.G., ISA pnp drivers have new names. 1781 * 1782 * bootpath assumed to be of the form /bus/module@name_addr 1783 */ 1784 addrp = NULL; 1785 if (busp = strchr(bp, '/')) { 1786 if (modp = strchr(busp + 1, '/')) { 1787 if (atp = strchr(modp + 1, '@')) { 1788 *atp = '\0'; 1789 addrp = atp + 1; 1790 if (eoaddrp = strchr(addrp, '/')) 1791 *eoaddrp = '\0'; 1792 } 1793 } 1794 } 1795 1796 if (modp && addrp) { 1797 (void) strncpy(bootdev_oldmod, modp + 1, 1798 MAXCOMPONENTLEN); 1799 bootdev_module[MAXCOMPONENTLEN - 1] = '\0'; 1800 1801 (void) strncpy(bootdev_oldaddr, addrp, MAXCOMPONENTLEN); 1802 bootdev_oldaddr[MAXCOMPONENTLEN - 1] = '\0'; 1803 } 1804 1805 /* Free up the bootpath storage now that we're done with it. */ 1806 kmem_free(bp1275, bp1275len); 1807 kmem_free(bp, bplen); 1808 1809 if (bootdev_oldaddr[0] == '\0') { 1810 quickexit = 1; 1811 return (rv); 1812 } 1813 } 1814 1815 if (((lkupname = ddi_get_name(cdip)) != NULL) && 1816 (strcmp(bootdev_module, lkupname) == 0 || 1817 strcmp(bootdev_oldmod, lkupname) == 0) && 1818 ((ddi_getprop(DDI_DEV_T_ANY, cdip, DDI_PROP_DONTPASS, 1819 "ignore-hardware-nodes", -1) != -1) || 1820 ignore_hardware_nodes) && 1821 strcmp(bootdev_newaddr, caddr) == 0 && 1822 strcmp(bootdev_oldaddr, naddr) == 0) { 1823 rv = DDI_SUCCESS; 1824 } 1825 1826 return (rv); 1827 } 1828 1829 /* 1830 * Perform a copy from a memory mapped device (whose devinfo pointer is devi) 1831 * separately mapped at devaddr in the kernel to a kernel buffer at kaddr. 1832 */ 1833 /*ARGSUSED*/ 1834 int 1835 e_ddi_copyfromdev(dev_info_t *devi, 1836 off_t off, const void *devaddr, void *kaddr, size_t len) 1837 { 1838 bcopy(devaddr, kaddr, len); 1839 return (0); 1840 } 1841 1842 /* 1843 * Perform a copy to a memory mapped device (whose devinfo pointer is devi) 1844 * separately mapped at devaddr in the kernel from a kernel buffer at kaddr. 1845 */ 1846 /*ARGSUSED*/ 1847 int 1848 e_ddi_copytodev(dev_info_t *devi, 1849 off_t off, const void *kaddr, void *devaddr, size_t len) 1850 { 1851 bcopy(kaddr, devaddr, len); 1852 return (0); 1853 } 1854 1855 1856 static int 1857 poke_mem(peekpoke_ctlops_t *in_args) 1858 { 1859 int err = DDI_SUCCESS; 1860 on_trap_data_t otd; 1861 1862 /* Set up protected environment. */ 1863 if (!on_trap(&otd, OT_DATA_ACCESS)) { 1864 switch (in_args->size) { 1865 case sizeof (uint8_t): 1866 *(uint8_t *)(in_args->dev_addr) = 1867 *(uint8_t *)in_args->host_addr; 1868 break; 1869 1870 case sizeof (uint16_t): 1871 *(uint16_t *)(in_args->dev_addr) = 1872 *(uint16_t *)in_args->host_addr; 1873 break; 1874 1875 case sizeof (uint32_t): 1876 *(uint32_t *)(in_args->dev_addr) = 1877 *(uint32_t *)in_args->host_addr; 1878 break; 1879 1880 case sizeof (uint64_t): 1881 *(uint64_t *)(in_args->dev_addr) = 1882 *(uint64_t *)in_args->host_addr; 1883 break; 1884 1885 default: 1886 err = DDI_FAILURE; 1887 break; 1888 } 1889 } else 1890 err = DDI_FAILURE; 1891 1892 /* Take down protected environment. */ 1893 no_trap(); 1894 1895 return (err); 1896 } 1897 1898 1899 static int 1900 peek_mem(peekpoke_ctlops_t *in_args) 1901 { 1902 int err = DDI_SUCCESS; 1903 on_trap_data_t otd; 1904 1905 if (!on_trap(&otd, OT_DATA_ACCESS)) { 1906 switch (in_args->size) { 1907 case sizeof (uint8_t): 1908 *(uint8_t *)in_args->host_addr = 1909 *(uint8_t *)in_args->dev_addr; 1910 break; 1911 1912 case sizeof (uint16_t): 1913 *(uint16_t *)in_args->host_addr = 1914 *(uint16_t *)in_args->dev_addr; 1915 break; 1916 1917 case sizeof (uint32_t): 1918 *(uint32_t *)in_args->host_addr = 1919 *(uint32_t *)in_args->dev_addr; 1920 break; 1921 1922 case sizeof (uint64_t): 1923 *(uint64_t *)in_args->host_addr = 1924 *(uint64_t *)in_args->dev_addr; 1925 break; 1926 1927 default: 1928 err = DDI_FAILURE; 1929 break; 1930 } 1931 } else 1932 err = DDI_FAILURE; 1933 1934 no_trap(); 1935 return (err); 1936 } 1937 1938 1939 /* 1940 * This is called only to process peek/poke when the DIP is NULL. 1941 * Assume that this is for memory, as nexi take care of device safe accesses. 1942 */ 1943 int 1944 peekpoke_mem(ddi_ctl_enum_t cmd, peekpoke_ctlops_t *in_args) 1945 { 1946 return (cmd == DDI_CTLOPS_PEEK ? peek_mem(in_args) : poke_mem(in_args)); 1947 } 1948 1949 void 1950 impl_setup_ddi(void) 1951 { 1952 dev_info_t *xdip, *isa_dip; 1953 rd_existing_t rd_mem_prop; 1954 int err; 1955 1956 ndi_devi_alloc_sleep(ddi_root_node(), "ramdisk", 1957 (dnode_t)DEVI_SID_NODEID, &xdip); 1958 1959 (void) BOP_GETPROP(bootops, 1960 "ramdisk_start", (void *)&ramdisk_start); 1961 (void) BOP_GETPROP(bootops, 1962 "ramdisk_end", (void *)&ramdisk_end); 1963 1964 rd_mem_prop.phys = ramdisk_start; 1965 rd_mem_prop.size = ramdisk_end - ramdisk_start + 1; 1966 1967 (void) ndi_prop_update_byte_array(DDI_DEV_T_NONE, xdip, 1968 RD_EXISTING_PROP_NAME, (uchar_t *)&rd_mem_prop, 1969 sizeof (rd_mem_prop)); 1970 err = ndi_devi_bind_driver(xdip, 0); 1971 ASSERT(err == 0); 1972 1973 /* isa node */ 1974 ndi_devi_alloc_sleep(ddi_root_node(), "isa", 1975 (dnode_t)DEVI_SID_NODEID, &isa_dip); 1976 (void) ndi_prop_update_string(DDI_DEV_T_NONE, isa_dip, 1977 "device_type", "isa"); 1978 (void) ndi_prop_update_string(DDI_DEV_T_NONE, isa_dip, 1979 "bus-type", "isa"); 1980 (void) ndi_devi_bind_driver(isa_dip, 0); 1981 1982 /* 1983 * Read in the properties from the boot. 1984 */ 1985 get_boot_properties(); 1986 1987 /* do bus dependent probes. */ 1988 impl_bus_initialprobe(); 1989 1990 /* not framebuffer should be enumerated, if present */ 1991 get_vga_properties(); 1992 } 1993 1994 dev_t 1995 getrootdev(void) 1996 { 1997 /* 1998 * Precedence given to rootdev if set in /etc/system 1999 */ 2000 if (root_is_svm) { 2001 return (ddi_pathname_to_dev_t(svm_bootpath)); 2002 } 2003 2004 /* 2005 * Usually rootfs.bo_name is initialized by the 2006 * the bootpath property from bootenv.rc, but 2007 * defaults to "/ramdisk:a" otherwise. 2008 */ 2009 return (ddi_pathname_to_dev_t(rootfs.bo_name)); 2010 } 2011 2012 static struct bus_probe { 2013 struct bus_probe *next; 2014 void (*probe)(int); 2015 } *bus_probes; 2016 2017 void 2018 impl_bus_add_probe(void (*func)(int)) 2019 { 2020 struct bus_probe *probe; 2021 2022 probe = kmem_alloc(sizeof (*probe), KM_SLEEP); 2023 probe->next = bus_probes; 2024 probe->probe = func; 2025 bus_probes = probe; 2026 } 2027 2028 /*ARGSUSED*/ 2029 void 2030 impl_bus_delete_probe(void (*func)(int)) 2031 { 2032 struct bus_probe *prev = NULL; 2033 struct bus_probe *probe = bus_probes; 2034 2035 while (probe) { 2036 if (probe->probe == func) 2037 break; 2038 prev = probe; 2039 probe = probe->next; 2040 } 2041 2042 if (probe == NULL) 2043 return; 2044 2045 if (prev) 2046 prev->next = probe->next; 2047 else 2048 bus_probes = probe->next; 2049 2050 kmem_free(probe, sizeof (struct bus_probe)); 2051 } 2052 2053 /* 2054 * impl_bus_initialprobe 2055 * Modload the prom simulator, then let it probe to verify existence 2056 * and type of PCI support. 2057 */ 2058 static void 2059 impl_bus_initialprobe(void) 2060 { 2061 struct bus_probe *probe; 2062 2063 /* load modules to install bus probes */ 2064 if (modload("misc", "pci_autoconfig") < 0) { 2065 cmn_err(CE_PANIC, "failed to load misc/pci_autoconfig"); 2066 } 2067 2068 probe = bus_probes; 2069 while (probe) { 2070 /* run the probe function */ 2071 (*probe->probe)(0); 2072 probe = probe->next; 2073 } 2074 } 2075 2076 /* 2077 * impl_bus_reprobe 2078 * Reprogram devices not set up by firmware. 2079 */ 2080 static void 2081 impl_bus_reprobe(void) 2082 { 2083 struct bus_probe *probe; 2084 2085 probe = bus_probes; 2086 while (probe) { 2087 /* run the probe function */ 2088 (*probe->probe)(1); 2089 probe = probe->next; 2090 } 2091 } 2092