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 (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9 * or http://www.opensolaris.org/os/licensing. 10 * See the License for the specific language governing permissions 11 * and limitations under the License. 12 * 13 * When distributing Covered Code, include this CDDL HEADER in each 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15 * If applicable, add the following below this CDDL HEADER, with the 16 * fields enclosed by brackets "[]" replaced with your own identifying 17 * information: Portions Copyright [yyyy] [name of copyright owner] 18 * 19 * CDDL HEADER END 20 */ 21 /* 22 * Copyright 2007 Sun Microsystems, Inc. All rights reserved. 23 * Use is subject to license terms. 24 */ 25 26 #pragma ident "%Z%%M% %I% %E% SMI" 27 28 #include <sys/cpuvar.h> 29 #include <sys/systm.h> 30 #include <sys/sysmacros.h> 31 #include <sys/promif.h> 32 #include <sys/platform_module.h> 33 #include <sys/cmn_err.h> 34 #include <sys/errno.h> 35 #include <sys/machsystm.h> 36 #include <sys/bootconf.h> 37 #include <sys/nvpair.h> 38 #include <sys/kobj.h> 39 #include <sys/mem_cage.h> 40 #include <sys/opl.h> 41 #include <sys/scfd/scfostoescf.h> 42 #include <sys/cpu_sgnblk_defs.h> 43 #include <sys/utsname.h> 44 #include <sys/ddi.h> 45 #include <sys/sunndi.h> 46 #include <sys/lgrp.h> 47 #include <sys/memnode.h> 48 #include <sys/sysmacros.h> 49 #include <vm/vm_dep.h> 50 51 int (*opl_get_mem_unum)(int, uint64_t, char *, int, int *); 52 int (*opl_get_mem_sid)(char *unum, char *buf, int buflen, int *lenp); 53 int (*opl_get_mem_offset)(uint64_t paddr, uint64_t *offp); 54 int (*opl_get_mem_addr)(char *unum, char *sid, 55 uint64_t offset, uint64_t *paddr); 56 57 /* Memory for fcode claims. 16k times # maximum possible IO units */ 58 #define EFCODE_SIZE (OPL_MAX_BOARDS * OPL_MAX_IO_UNITS_PER_BOARD * 0x4000) 59 int efcode_size = EFCODE_SIZE; 60 61 #define OPL_MC_MEMBOARD_SHIFT 38 /* Boards on 256BG boundary */ 62 63 /* Set the maximum number of boards for DR */ 64 int opl_boards = OPL_MAX_BOARDS; 65 66 void sgn_update_all_cpus(ushort_t, uchar_t, uchar_t); 67 68 extern int tsb_lgrp_affinity; 69 70 int opl_tsb_spares = (OPL_MAX_BOARDS) * (OPL_MAX_PCICH_UNITS_PER_BOARD) * 71 (OPL_MAX_TSBS_PER_PCICH); 72 73 pgcnt_t opl_startup_cage_size = 0; 74 75 static opl_model_info_t opl_models[] = { 76 { "FF1", OPL_MAX_BOARDS_FF1, FF1, STD_DISPATCH_TABLE }, 77 { "FF2", OPL_MAX_BOARDS_FF2, FF2, STD_DISPATCH_TABLE }, 78 { "DC1", OPL_MAX_BOARDS_DC1, DC1, STD_DISPATCH_TABLE }, 79 { "DC2", OPL_MAX_BOARDS_DC2, DC2, EXT_DISPATCH_TABLE }, 80 { "DC3", OPL_MAX_BOARDS_DC3, DC3, EXT_DISPATCH_TABLE }, 81 }; 82 static int opl_num_models = sizeof (opl_models)/sizeof (opl_model_info_t); 83 84 /* 85 * opl_cur_model defaults to FF1. 86 */ 87 static opl_model_info_t *opl_cur_model = &opl_models[0]; 88 89 static struct memlist *opl_memlist_per_board(struct memlist *ml); 90 91 int 92 set_platform_max_ncpus(void) 93 { 94 return (OPL_MAX_CPU_PER_BOARD * OPL_MAX_BOARDS); 95 } 96 97 int 98 set_platform_tsb_spares(void) 99 { 100 return (MIN(opl_tsb_spares, MAX_UPA)); 101 } 102 103 static void 104 set_model_info() 105 { 106 extern int ts_dispatch_extended; 107 char name[MAXSYSNAME]; 108 int i; 109 110 /* 111 * Get model name from the root node. 112 * 113 * We are using the prom device tree since, at this point, 114 * the Solaris device tree is not yet setup. 115 */ 116 (void) prom_getprop(prom_rootnode(), "model", (caddr_t)name); 117 118 for (i = 0; i < opl_num_models; i++) { 119 if (strncmp(name, opl_models[i].model_name, MAXSYSNAME) == 0) { 120 opl_cur_model = &opl_models[i]; 121 break; 122 } 123 } 124 125 if (i == opl_num_models) 126 halt("No valid OPL model is found!"); 127 128 if ((opl_cur_model->model_cmds & EXT_DISPATCH_TABLE) && 129 (ts_dispatch_extended == -1)) { 130 /* 131 * Based on a platform model, select a dispatch table. 132 * Only DC2 and DC3 systems uses the alternate/extended 133 * TS dispatch table. 134 * FF1, FF2 and DC1 systems used standard dispatch tables. 135 */ 136 ts_dispatch_extended = 1; 137 } 138 139 } 140 141 static void 142 set_max_mmu_ctxdoms() 143 { 144 extern uint_t max_mmu_ctxdoms; 145 int max_boards; 146 147 /* 148 * From the model, get the maximum number of boards 149 * supported and set the value accordingly. If the model 150 * could not be determined or recognized, we assume the max value. 151 */ 152 if (opl_cur_model == NULL) 153 max_boards = OPL_MAX_BOARDS; 154 else 155 max_boards = opl_cur_model->model_max_boards; 156 157 /* 158 * On OPL, cores and MMUs are one-to-one. 159 */ 160 max_mmu_ctxdoms = OPL_MAX_CORE_UNITS_PER_BOARD * max_boards; 161 } 162 163 #pragma weak mmu_init_large_pages 164 165 void 166 set_platform_defaults(void) 167 { 168 extern char *tod_module_name; 169 extern void cpu_sgn_update(ushort_t, uchar_t, uchar_t, int); 170 extern void mmu_init_large_pages(size_t); 171 172 /* Set the CPU signature function pointer */ 173 cpu_sgn_func = cpu_sgn_update; 174 175 /* Set appropriate tod module for OPL platform */ 176 ASSERT(tod_module_name == NULL); 177 tod_module_name = "todopl"; 178 179 if ((mmu_page_sizes == max_mmu_page_sizes) && 180 (mmu_ism_pagesize != DEFAULT_ISM_PAGESIZE)) { 181 if (&mmu_init_large_pages) 182 mmu_init_large_pages(mmu_ism_pagesize); 183 } 184 185 tsb_lgrp_affinity = 1; 186 187 set_model_info(); 188 set_max_mmu_ctxdoms(); 189 } 190 191 /* 192 * Convert logical a board number to a physical one. 193 */ 194 195 #define LSBPROP "board#" 196 #define PSBPROP "physical-board#" 197 198 int 199 opl_get_physical_board(int id) 200 { 201 dev_info_t *root_dip, *dip = NULL; 202 char *dname = NULL; 203 int circ; 204 205 pnode_t pnode; 206 char pname[MAXSYSNAME] = {0}; 207 208 int lsb_id; /* Logical System Board ID */ 209 int psb_id; /* Physical System Board ID */ 210 211 212 /* 213 * This function is called on early stage of bootup when the 214 * kernel device tree is not initialized yet, and also 215 * later on when the device tree is up. We want to try 216 * the fast track first. 217 */ 218 root_dip = ddi_root_node(); 219 if (root_dip) { 220 /* Get from devinfo node */ 221 ndi_devi_enter(root_dip, &circ); 222 for (dip = ddi_get_child(root_dip); dip; 223 dip = ddi_get_next_sibling(dip)) { 224 225 dname = ddi_node_name(dip); 226 if (strncmp(dname, "pseudo-mc", 9) != 0) 227 continue; 228 229 if ((lsb_id = (int)ddi_getprop(DDI_DEV_T_ANY, dip, 230 DDI_PROP_DONTPASS, LSBPROP, -1)) == -1) 231 continue; 232 233 if (id == lsb_id) { 234 if ((psb_id = (int)ddi_getprop(DDI_DEV_T_ANY, 235 dip, DDI_PROP_DONTPASS, PSBPROP, -1)) 236 == -1) { 237 ndi_devi_exit(root_dip, circ); 238 return (-1); 239 } else { 240 ndi_devi_exit(root_dip, circ); 241 return (psb_id); 242 } 243 } 244 } 245 ndi_devi_exit(root_dip, circ); 246 } 247 248 /* 249 * We do not have the kernel device tree, or we did not 250 * find the node for some reason (let's say the kernel 251 * device tree was modified), let's try the OBP tree. 252 */ 253 pnode = prom_rootnode(); 254 for (pnode = prom_childnode(pnode); pnode; 255 pnode = prom_nextnode(pnode)) { 256 257 if ((prom_getprop(pnode, "name", (caddr_t)pname) == -1) || 258 (strncmp(pname, "pseudo-mc", 9) != 0)) 259 continue; 260 261 if (prom_getprop(pnode, LSBPROP, (caddr_t)&lsb_id) == -1) 262 continue; 263 264 if (id == lsb_id) { 265 if (prom_getprop(pnode, PSBPROP, 266 (caddr_t)&psb_id) == -1) { 267 return (-1); 268 } else { 269 return (psb_id); 270 } 271 } 272 } 273 274 return (-1); 275 } 276 277 /* 278 * For OPL it's possible that memory from two or more successive boards 279 * will be contiguous across the boards, and therefore represented as a 280 * single chunk. 281 * This function splits such chunks down the board boundaries. 282 */ 283 static struct memlist * 284 opl_memlist_per_board(struct memlist *ml) 285 { 286 uint64_t ssize, low, high, boundary; 287 struct memlist *head, *tail, *new; 288 289 ssize = (1ull << OPL_MC_MEMBOARD_SHIFT); 290 291 head = tail = NULL; 292 293 for (; ml; ml = ml->next) { 294 low = (uint64_t)ml->address; 295 high = low+(uint64_t)(ml->size); 296 while (low < high) { 297 boundary = roundup(low+1, ssize); 298 boundary = MIN(high, boundary); 299 new = kmem_zalloc(sizeof (struct memlist), KM_SLEEP); 300 new->address = low; 301 new->size = boundary - low; 302 if (head == NULL) 303 head = new; 304 if (tail) { 305 tail->next = new; 306 new->prev = tail; 307 } 308 tail = new; 309 low = boundary; 310 } 311 } 312 return (head); 313 } 314 315 void 316 set_platform_cage_params(void) 317 { 318 extern pgcnt_t total_pages; 319 extern struct memlist *phys_avail; 320 struct memlist *ml, *tml; 321 int ret; 322 323 if (kernel_cage_enable) { 324 pgcnt_t preferred_cage_size; 325 326 preferred_cage_size = 327 MAX(opl_startup_cage_size, total_pages / 256); 328 329 ml = opl_memlist_per_board(phys_avail); 330 331 kcage_range_lock(); 332 /* 333 * Note: we are assuming that post has load the 334 * whole show in to the high end of memory. Having 335 * taken this leap, we copy the whole of phys_avail 336 * the glist and arrange for the cage to grow 337 * downward (descending pfns). 338 */ 339 ret = kcage_range_init(ml, 1); 340 341 /* free the memlist */ 342 do { 343 tml = ml->next; 344 kmem_free(ml, sizeof (struct memlist)); 345 ml = tml; 346 } while (ml != NULL); 347 348 if (ret == 0) 349 kcage_init(preferred_cage_size); 350 kcage_range_unlock(); 351 } 352 353 if (kcage_on) 354 cmn_err(CE_NOTE, "!DR Kernel Cage is ENABLED"); 355 else 356 cmn_err(CE_NOTE, "!DR Kernel Cage is DISABLED"); 357 } 358 359 /*ARGSUSED*/ 360 int 361 plat_cpu_poweron(struct cpu *cp) 362 { 363 int (*opl_cpu_poweron)(struct cpu *) = NULL; 364 365 opl_cpu_poweron = 366 (int (*)(struct cpu *))kobj_getsymvalue("drmach_cpu_poweron", 0); 367 368 if (opl_cpu_poweron == NULL) 369 return (ENOTSUP); 370 else 371 return ((opl_cpu_poweron)(cp)); 372 373 } 374 375 /*ARGSUSED*/ 376 int 377 plat_cpu_poweroff(struct cpu *cp) 378 { 379 int (*opl_cpu_poweroff)(struct cpu *) = NULL; 380 381 opl_cpu_poweroff = 382 (int (*)(struct cpu *))kobj_getsymvalue("drmach_cpu_poweroff", 0); 383 384 if (opl_cpu_poweroff == NULL) 385 return (ENOTSUP); 386 else 387 return ((opl_cpu_poweroff)(cp)); 388 389 } 390 391 int 392 plat_max_boards(void) 393 { 394 return (OPL_MAX_BOARDS); 395 } 396 397 int 398 plat_max_cpu_units_per_board(void) 399 { 400 return (OPL_MAX_CPU_PER_BOARD); 401 } 402 403 int 404 plat_max_mem_units_per_board(void) 405 { 406 return (OPL_MAX_MEM_UNITS_PER_BOARD); 407 } 408 409 int 410 plat_max_io_units_per_board(void) 411 { 412 return (OPL_MAX_IO_UNITS_PER_BOARD); 413 } 414 415 int 416 plat_max_cmp_units_per_board(void) 417 { 418 return (OPL_MAX_CMP_UNITS_PER_BOARD); 419 } 420 421 int 422 plat_max_core_units_per_board(void) 423 { 424 return (OPL_MAX_CORE_UNITS_PER_BOARD); 425 } 426 427 int 428 plat_pfn_to_mem_node(pfn_t pfn) 429 { 430 return (pfn >> mem_node_pfn_shift); 431 } 432 433 /* ARGSUSED */ 434 void 435 plat_build_mem_nodes(u_longlong_t *list, size_t nelems) 436 { 437 size_t elem; 438 pfn_t basepfn; 439 pgcnt_t npgs; 440 uint64_t boundary, ssize; 441 uint64_t low, high; 442 443 /* 444 * OPL mem slices are always aligned on a 256GB boundary. 445 */ 446 mem_node_pfn_shift = OPL_MC_MEMBOARD_SHIFT - MMU_PAGESHIFT; 447 mem_node_physalign = 0; 448 449 /* 450 * Boot install lists are arranged <addr, len>, <addr, len>, ... 451 */ 452 ssize = (1ull << OPL_MC_MEMBOARD_SHIFT); 453 for (elem = 0; elem < nelems; elem += 2) { 454 low = (uint64_t)list[elem]; 455 high = low+(uint64_t)(list[elem+1]); 456 while (low < high) { 457 boundary = roundup(low+1, ssize); 458 boundary = MIN(high, boundary); 459 basepfn = btop(low); 460 npgs = btop(boundary - low); 461 mem_node_add_slice(basepfn, basepfn + npgs - 1); 462 low = boundary; 463 } 464 } 465 } 466 467 /* 468 * Find the CPU associated with a slice at boot-time. 469 */ 470 void 471 plat_fill_mc(pnode_t nodeid) 472 { 473 int board; 474 int memnode; 475 struct { 476 uint64_t addr; 477 uint64_t size; 478 } mem_range; 479 480 if (prom_getprop(nodeid, "board#", (caddr_t)&board) < 0) { 481 panic("Can not find board# property in mc node %x", nodeid); 482 } 483 if (prom_getprop(nodeid, "sb-mem-ranges", (caddr_t)&mem_range) < 0) { 484 panic("Can not find sb-mem-ranges property in mc node %x", 485 nodeid); 486 } 487 memnode = mem_range.addr >> OPL_MC_MEMBOARD_SHIFT; 488 plat_assign_lgrphand_to_mem_node(board, memnode); 489 } 490 491 /* 492 * Return the platform handle for the lgroup containing the given CPU 493 * 494 * For OPL, lgroup platform handle == board #. 495 */ 496 497 extern int mpo_disabled; 498 extern lgrp_handle_t lgrp_default_handle; 499 500 lgrp_handle_t 501 plat_lgrp_cpu_to_hand(processorid_t id) 502 { 503 lgrp_handle_t plathand; 504 505 /* 506 * Return the real platform handle for the CPU until 507 * such time as we know that MPO should be disabled. 508 * At that point, we set the "mpo_disabled" flag to true, 509 * and from that point on, return the default handle. 510 * 511 * By the time we know that MPO should be disabled, the 512 * first CPU will have already been added to a leaf 513 * lgroup, but that's ok. The common lgroup code will 514 * double check that the boot CPU is in the correct place, 515 * and in the case where mpo should be disabled, will move 516 * it to the root if necessary. 517 */ 518 if (mpo_disabled) { 519 /* If MPO is disabled, return the default (UMA) handle */ 520 plathand = lgrp_default_handle; 521 } else 522 plathand = (lgrp_handle_t)LSB_ID(id); 523 return (plathand); 524 } 525 526 /* 527 * Platform specific lgroup initialization 528 */ 529 void 530 plat_lgrp_init(void) 531 { 532 extern uint32_t lgrp_expand_proc_thresh; 533 extern uint32_t lgrp_expand_proc_diff; 534 535 /* 536 * Set tuneables for the OPL architecture 537 * 538 * lgrp_expand_proc_thresh is the minimum load on the lgroups 539 * this process is currently running on before considering 540 * expanding threads to another lgroup. 541 * 542 * lgrp_expand_proc_diff determines how much less the remote lgroup 543 * must be loaded before expanding to it. 544 * 545 * Since remote latencies can be costly, attempt to keep 3 threads 546 * within the same lgroup before expanding to the next lgroup. 547 */ 548 lgrp_expand_proc_thresh = LGRP_LOADAVG_THREAD_MAX * 3; 549 lgrp_expand_proc_diff = LGRP_LOADAVG_THREAD_MAX; 550 } 551 552 /* 553 * Platform notification of lgroup (re)configuration changes 554 */ 555 /*ARGSUSED*/ 556 void 557 plat_lgrp_config(lgrp_config_flag_t evt, uintptr_t arg) 558 { 559 update_membounds_t *umb; 560 lgrp_config_mem_rename_t lmr; 561 int sbd, tbd; 562 lgrp_handle_t hand, shand, thand; 563 int mnode, snode, tnode; 564 pfn_t start, end; 565 566 if (mpo_disabled) 567 return; 568 569 switch (evt) { 570 571 case LGRP_CONFIG_MEM_ADD: 572 /* 573 * Establish the lgroup handle to memnode translation. 574 */ 575 umb = (update_membounds_t *)arg; 576 577 hand = umb->u_board; 578 mnode = plat_pfn_to_mem_node(umb->u_base >> MMU_PAGESHIFT); 579 plat_assign_lgrphand_to_mem_node(hand, mnode); 580 581 break; 582 583 case LGRP_CONFIG_MEM_DEL: 584 /* 585 * Special handling for possible memory holes. 586 */ 587 umb = (update_membounds_t *)arg; 588 hand = umb->u_board; 589 if ((mnode = plat_lgrphand_to_mem_node(hand)) != -1) { 590 if (mem_node_config[mnode].exists) { 591 start = mem_node_config[mnode].physbase; 592 end = mem_node_config[mnode].physmax; 593 mem_node_pre_del_slice(start, end); 594 mem_node_post_del_slice(start, end, 0); 595 } 596 } 597 598 break; 599 600 case LGRP_CONFIG_MEM_RENAME: 601 /* 602 * During a DR copy-rename operation, all of the memory 603 * on one board is moved to another board -- but the 604 * addresses/pfns and memnodes don't change. This means 605 * the memory has changed locations without changing identity. 606 * 607 * Source is where we are copying from and target is where we 608 * are copying to. After source memnode is copied to target 609 * memnode, the physical addresses of the target memnode are 610 * renamed to match what the source memnode had. Then target 611 * memnode can be removed and source memnode can take its 612 * place. 613 * 614 * To do this, swap the lgroup handle to memnode mappings for 615 * the boards, so target lgroup will have source memnode and 616 * source lgroup will have empty target memnode which is where 617 * its memory will go (if any is added to it later). 618 * 619 * Then source memnode needs to be removed from its lgroup 620 * and added to the target lgroup where the memory was living 621 * but under a different name/memnode. The memory was in the 622 * target memnode and now lives in the source memnode with 623 * different physical addresses even though it is the same 624 * memory. 625 */ 626 sbd = arg & 0xffff; 627 tbd = (arg & 0xffff0000) >> 16; 628 shand = sbd; 629 thand = tbd; 630 snode = plat_lgrphand_to_mem_node(shand); 631 tnode = plat_lgrphand_to_mem_node(thand); 632 633 /* 634 * Special handling for possible memory holes. 635 */ 636 if (tnode != -1 && mem_node_config[tnode].exists) { 637 start = mem_node_config[tnode].physbase; 638 end = mem_node_config[tnode].physmax; 639 mem_node_pre_del_slice(start, end); 640 mem_node_post_del_slice(start, end, 0); 641 } 642 643 plat_assign_lgrphand_to_mem_node(thand, snode); 644 plat_assign_lgrphand_to_mem_node(shand, tnode); 645 646 lmr.lmem_rename_from = shand; 647 lmr.lmem_rename_to = thand; 648 649 /* 650 * Remove source memnode of copy rename from its lgroup 651 * and add it to its new target lgroup 652 */ 653 lgrp_config(LGRP_CONFIG_MEM_RENAME, (uintptr_t)snode, 654 (uintptr_t)&lmr); 655 656 break; 657 658 default: 659 break; 660 } 661 } 662 663 /* 664 * Return latency between "from" and "to" lgroups 665 * 666 * This latency number can only be used for relative comparison 667 * between lgroups on the running system, cannot be used across platforms, 668 * and may not reflect the actual latency. It is platform and implementation 669 * specific, so platform gets to decide its value. It would be nice if the 670 * number was at least proportional to make comparisons more meaningful though. 671 * NOTE: The numbers below are supposed to be load latencies for uncached 672 * memory divided by 10. 673 * 674 */ 675 int 676 plat_lgrp_latency(lgrp_handle_t from, lgrp_handle_t to) 677 { 678 /* 679 * Return min remote latency when there are more than two lgroups 680 * (root and child) and getting latency between two different lgroups 681 * or root is involved 682 */ 683 if (lgrp_optimizations() && (from != to || 684 from == LGRP_DEFAULT_HANDLE || to == LGRP_DEFAULT_HANDLE)) 685 return (42); 686 else 687 return (35); 688 } 689 690 /* 691 * Return platform handle for root lgroup 692 */ 693 lgrp_handle_t 694 plat_lgrp_root_hand(void) 695 { 696 if (mpo_disabled) 697 return (lgrp_default_handle); 698 699 return (LGRP_DEFAULT_HANDLE); 700 } 701 702 /*ARGSUSED*/ 703 void 704 plat_freelist_process(int mnode) 705 { 706 } 707 708 void 709 load_platform_drivers(void) 710 { 711 (void) i_ddi_attach_pseudo_node("dr"); 712 } 713 714 /* 715 * No platform drivers on this platform 716 */ 717 char *platform_module_list[] = { 718 (char *)0 719 }; 720 721 /*ARGSUSED*/ 722 void 723 plat_tod_fault(enum tod_fault_type tod_bad) 724 { 725 } 726 727 /*ARGSUSED*/ 728 void 729 cpu_sgn_update(ushort_t sgn, uchar_t state, uchar_t sub_state, int cpuid) 730 { 731 static void (*scf_panic_callback)(int); 732 static void (*scf_shutdown_callback)(int); 733 734 /* 735 * This is for notifing system panic/shutdown to SCF. 736 * In case of shutdown and panic, SCF call back 737 * function should be called. 738 * <SCF call back functions> 739 * scf_panic_callb() : panicsys()->panic_quiesce_hw() 740 * scf_shutdown_callb(): halt() or power_down() or reboot_machine() 741 * cpuid should be -1 and state should be SIGST_EXIT. 742 */ 743 if (state == SIGST_EXIT && cpuid == -1) { 744 745 /* 746 * find the symbol for the SCF panic callback routine in driver 747 */ 748 if (scf_panic_callback == NULL) 749 scf_panic_callback = (void (*)(int)) 750 modgetsymvalue("scf_panic_callb", 0); 751 if (scf_shutdown_callback == NULL) 752 scf_shutdown_callback = (void (*)(int)) 753 modgetsymvalue("scf_shutdown_callb", 0); 754 755 switch (sub_state) { 756 case SIGSUBST_PANIC: 757 if (scf_panic_callback == NULL) { 758 cmn_err(CE_NOTE, "!cpu_sgn_update: " 759 "scf_panic_callb not found\n"); 760 return; 761 } 762 scf_panic_callback(SIGSUBST_PANIC); 763 break; 764 765 case SIGSUBST_HALT: 766 if (scf_shutdown_callback == NULL) { 767 cmn_err(CE_NOTE, "!cpu_sgn_update: " 768 "scf_shutdown_callb not found\n"); 769 return; 770 } 771 scf_shutdown_callback(SIGSUBST_HALT); 772 break; 773 774 case SIGSUBST_ENVIRON: 775 if (scf_shutdown_callback == NULL) { 776 cmn_err(CE_NOTE, "!cpu_sgn_update: " 777 "scf_shutdown_callb not found\n"); 778 return; 779 } 780 scf_shutdown_callback(SIGSUBST_ENVIRON); 781 break; 782 783 case SIGSUBST_REBOOT: 784 if (scf_shutdown_callback == NULL) { 785 cmn_err(CE_NOTE, "!cpu_sgn_update: " 786 "scf_shutdown_callb not found\n"); 787 return; 788 } 789 scf_shutdown_callback(SIGSUBST_REBOOT); 790 break; 791 } 792 } 793 } 794 795 /*ARGSUSED*/ 796 int 797 plat_get_mem_unum(int synd_code, uint64_t flt_addr, int flt_bus_id, 798 int flt_in_memory, ushort_t flt_status, 799 char *buf, int buflen, int *lenp) 800 { 801 /* 802 * check if it's a Memory error. 803 */ 804 if (flt_in_memory) { 805 if (opl_get_mem_unum != NULL) { 806 return (opl_get_mem_unum(synd_code, flt_addr, 807 buf, buflen, lenp)); 808 } else { 809 return (ENOTSUP); 810 } 811 } else { 812 return (ENOTSUP); 813 } 814 } 815 816 /*ARGSUSED*/ 817 int 818 plat_get_cpu_unum(int cpuid, char *buf, int buflen, int *lenp) 819 { 820 int ret = 0; 821 uint_t sb; 822 int plen; 823 824 sb = opl_get_physical_board(LSB_ID(cpuid)); 825 if (sb == -1) { 826 return (ENXIO); 827 } 828 829 ASSERT((opl_cur_model - opl_models) == (opl_cur_model->model_type)); 830 831 switch (opl_cur_model->model_type) { 832 case FF1: 833 plen = snprintf(buf, buflen, "/%s/CPUM%d", "MBU_A", 834 CHIP_ID(cpuid) / 2); 835 break; 836 837 case FF2: 838 plen = snprintf(buf, buflen, "/%s/CPUM%d", "MBU_B", 839 (CHIP_ID(cpuid) / 2) + (sb * 2)); 840 break; 841 842 case DC1: 843 case DC2: 844 case DC3: 845 plen = snprintf(buf, buflen, "/%s%02d/CPUM%d", "CMU", sb, 846 CHIP_ID(cpuid)); 847 break; 848 849 default: 850 /* This should never happen */ 851 return (ENODEV); 852 } 853 854 if (plen >= buflen) { 855 ret = ENOSPC; 856 } else { 857 if (lenp) 858 *lenp = strlen(buf); 859 } 860 return (ret); 861 } 862 863 #define SCF_PUTINFO(f, s, p) \ 864 f(KEY_ESCF, 0x01, 0, s, p) 865 void 866 plat_nodename_set(void) 867 { 868 void *datap; 869 static int (*scf_service_function)(uint32_t, uint8_t, 870 uint32_t, uint32_t, void *); 871 int counter = 5; 872 873 /* 874 * find the symbol for the SCF put routine in driver 875 */ 876 if (scf_service_function == NULL) 877 scf_service_function = 878 (int (*)(uint32_t, uint8_t, uint32_t, uint32_t, void *)) 879 modgetsymvalue("scf_service_putinfo", 0); 880 881 /* 882 * If the symbol was found, call it. Otherwise, log a note (but not to 883 * the console). 884 */ 885 886 if (scf_service_function == NULL) { 887 cmn_err(CE_NOTE, 888 "!plat_nodename_set: scf_service_putinfo not found\n"); 889 return; 890 } 891 892 datap = 893 (struct utsname *)kmem_zalloc(sizeof (struct utsname), KM_SLEEP); 894 895 if (datap == NULL) { 896 return; 897 } 898 899 bcopy((struct utsname *)&utsname, 900 (struct utsname *)datap, sizeof (struct utsname)); 901 902 while ((SCF_PUTINFO(scf_service_function, 903 sizeof (struct utsname), datap) == EBUSY) && (counter-- > 0)) { 904 delay(10 * drv_usectohz(1000000)); 905 } 906 if (counter == 0) 907 cmn_err(CE_NOTE, 908 "!plat_nodename_set: " 909 "scf_service_putinfo not responding\n"); 910 911 kmem_free(datap, sizeof (struct utsname)); 912 } 913 914 caddr_t efcode_vaddr = NULL; 915 916 /* 917 * Preallocate enough memory for fcode claims. 918 */ 919 920 caddr_t 921 efcode_alloc(caddr_t alloc_base) 922 { 923 caddr_t efcode_alloc_base = (caddr_t)roundup((uintptr_t)alloc_base, 924 MMU_PAGESIZE); 925 caddr_t vaddr; 926 927 /* 928 * allocate the physical memory for the Oberon fcode. 929 */ 930 if ((vaddr = (caddr_t)BOP_ALLOC(bootops, efcode_alloc_base, 931 efcode_size, MMU_PAGESIZE)) == NULL) 932 cmn_err(CE_PANIC, "Cannot allocate Efcode Memory"); 933 934 efcode_vaddr = vaddr; 935 936 return (efcode_alloc_base + efcode_size); 937 } 938 939 caddr_t 940 plat_startup_memlist(caddr_t alloc_base) 941 { 942 caddr_t tmp_alloc_base; 943 944 tmp_alloc_base = efcode_alloc(alloc_base); 945 tmp_alloc_base = 946 (caddr_t)roundup((uintptr_t)tmp_alloc_base, ecache_alignsize); 947 return (tmp_alloc_base); 948 } 949 950 void 951 startup_platform(void) 952 { 953 } 954 955 void 956 plat_cpuid_to_mmu_ctx_info(processorid_t cpuid, mmu_ctx_info_t *info) 957 { 958 int impl; 959 960 impl = cpunodes[cpuid].implementation; 961 if (IS_OLYMPUS_C(impl)) { 962 info->mmu_idx = MMU_ID(cpuid); 963 info->mmu_nctxs = 8192; 964 } else { 965 cmn_err(CE_PANIC, "Unknown processor %d", impl); 966 } 967 } 968 969 int 970 plat_get_mem_sid(char *unum, char *buf, int buflen, int *lenp) 971 { 972 if (opl_get_mem_sid == NULL) { 973 return (ENOTSUP); 974 } 975 return (opl_get_mem_sid(unum, buf, buflen, lenp)); 976 } 977 978 int 979 plat_get_mem_offset(uint64_t paddr, uint64_t *offp) 980 { 981 if (opl_get_mem_offset == NULL) { 982 return (ENOTSUP); 983 } 984 return (opl_get_mem_offset(paddr, offp)); 985 } 986 987 int 988 plat_get_mem_addr(char *unum, char *sid, uint64_t offset, uint64_t *addrp) 989 { 990 if (opl_get_mem_addr == NULL) { 991 return (ENOTSUP); 992 } 993 return (opl_get_mem_addr(unum, sid, offset, addrp)); 994 } 995