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 2006 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 }, 77 { "FF2", OPL_MAX_BOARDS_FF2 }, 78 { "DC1", OPL_MAX_BOARDS_DC1 }, 79 { "DC2", OPL_MAX_BOARDS_DC2 }, 80 { "DC3", OPL_MAX_BOARDS_DC3 }, 81 }; 82 static int opl_num_models = sizeof (opl_models)/sizeof (opl_model_info_t); 83 84 static opl_model_info_t *opl_cur_model = NULL; 85 86 static struct memlist *opl_memlist_per_board(struct memlist *ml); 87 88 static enum { 89 MODEL_FF1 = 0, 90 MODEL_FF2 = 1, 91 MODEL_DC = 2 92 } plat_model = -1; 93 94 int 95 set_platform_max_ncpus(void) 96 { 97 return (OPL_MAX_CPU_PER_BOARD * OPL_MAX_BOARDS); 98 } 99 100 int 101 set_platform_tsb_spares(void) 102 { 103 return (MIN(opl_tsb_spares, MAX_UPA)); 104 } 105 106 static void 107 set_model_info() 108 { 109 char name[MAXSYSNAME]; 110 int i; 111 112 /* 113 * Get model name from the root node. 114 * 115 * We are using the prom device tree since, at this point, 116 * the Solaris device tree is not yet setup. 117 */ 118 (void) prom_getprop(prom_rootnode(), "model", (caddr_t)name); 119 120 for (i = 0; i < opl_num_models; i++) { 121 if (strncmp(name, opl_models[i].model_name, MAXSYSNAME) == 0) { 122 opl_cur_model = &opl_models[i]; 123 break; 124 } 125 } 126 if (i == opl_num_models) 127 cmn_err(CE_WARN, "No valid OPL model is found!" 128 "Set max_mmu_ctxdoms to the default."); 129 } 130 131 static void 132 set_max_mmu_ctxdoms() 133 { 134 extern uint_t max_mmu_ctxdoms; 135 int max_boards; 136 137 /* 138 * From the model, get the maximum number of boards 139 * supported and set the value accordingly. If the model 140 * could not be determined or recognized, we assume the max value. 141 */ 142 if (opl_cur_model == NULL) 143 max_boards = OPL_MAX_BOARDS; 144 else 145 max_boards = opl_cur_model->model_max_boards; 146 147 /* 148 * On OPL, cores and MMUs are one-to-one. 149 */ 150 max_mmu_ctxdoms = OPL_MAX_CORE_UNITS_PER_BOARD * max_boards; 151 } 152 153 #pragma weak mmu_init_large_pages 154 155 void 156 set_platform_defaults(void) 157 { 158 extern char *tod_module_name; 159 extern void cpu_sgn_update(ushort_t, uchar_t, uchar_t, int); 160 extern int ts_dispatch_extended; 161 extern void mmu_init_large_pages(size_t); 162 163 /* Set the CPU signature function pointer */ 164 cpu_sgn_func = cpu_sgn_update; 165 166 /* Set appropriate tod module for OPL platform */ 167 ASSERT(tod_module_name == NULL); 168 tod_module_name = "todopl"; 169 170 /* 171 * Use the alternate TS dispatch table, which is better tuned 172 * for large servers. 173 */ 174 if (ts_dispatch_extended == -1) 175 ts_dispatch_extended = 1; 176 177 if ((mmu_page_sizes == max_mmu_page_sizes) && 178 (mmu_ism_pagesize != MMU_PAGESIZE32M)) { 179 if (&mmu_init_large_pages) 180 mmu_init_large_pages(mmu_ism_pagesize); 181 } 182 183 tsb_lgrp_affinity = 1; 184 185 set_model_info(); 186 set_max_mmu_ctxdoms(); 187 } 188 189 /* 190 * Convert logical a board number to a physical one. 191 */ 192 193 #define LSBPROP "board#" 194 #define PSBPROP "physical-board#" 195 196 int 197 opl_get_physical_board(int id) 198 { 199 dev_info_t *root_dip, *dip = NULL; 200 char *dname = NULL; 201 int circ; 202 203 pnode_t pnode; 204 char pname[MAXSYSNAME] = {0}; 205 206 int lsb_id; /* Logical System Board ID */ 207 int psb_id; /* Physical System Board ID */ 208 209 210 /* 211 * This function is called on early stage of bootup when the 212 * kernel device tree is not initialized yet, and also 213 * later on when the device tree is up. We want to try 214 * the fast track first. 215 */ 216 root_dip = ddi_root_node(); 217 if (root_dip) { 218 /* Get from devinfo node */ 219 ndi_devi_enter(root_dip, &circ); 220 for (dip = ddi_get_child(root_dip); dip; 221 dip = ddi_get_next_sibling(dip)) { 222 223 dname = ddi_node_name(dip); 224 if (strncmp(dname, "pseudo-mc", 9) != 0) 225 continue; 226 227 if ((lsb_id = (int)ddi_getprop(DDI_DEV_T_ANY, dip, 228 DDI_PROP_DONTPASS, LSBPROP, -1)) == -1) 229 continue; 230 231 if (id == lsb_id) { 232 if ((psb_id = (int)ddi_getprop(DDI_DEV_T_ANY, 233 dip, DDI_PROP_DONTPASS, PSBPROP, -1)) 234 == -1) { 235 ndi_devi_exit(root_dip, circ); 236 return (-1); 237 } else { 238 ndi_devi_exit(root_dip, circ); 239 return (psb_id); 240 } 241 } 242 } 243 ndi_devi_exit(root_dip, circ); 244 } 245 246 /* 247 * We do not have the kernel device tree, or we did not 248 * find the node for some reason (let's say the kernel 249 * device tree was modified), let's try the OBP tree. 250 */ 251 pnode = prom_rootnode(); 252 for (pnode = prom_childnode(pnode); pnode; 253 pnode = prom_nextnode(pnode)) { 254 255 if ((prom_getprop(pnode, "name", (caddr_t)pname) == -1) || 256 (strncmp(pname, "pseudo-mc", 9) != 0)) 257 continue; 258 259 if (prom_getprop(pnode, LSBPROP, (caddr_t)&lsb_id) == -1) 260 continue; 261 262 if (id == lsb_id) { 263 if (prom_getprop(pnode, PSBPROP, 264 (caddr_t)&psb_id) == -1) { 265 return (-1); 266 } else { 267 return (psb_id); 268 } 269 } 270 } 271 272 return (-1); 273 } 274 275 /* 276 * For OPL it's possible that memory from two or more successive boards 277 * will be contiguous across the boards, and therefore represented as a 278 * single chunk. 279 * This function splits such chunks down the board boundaries. 280 */ 281 static struct memlist * 282 opl_memlist_per_board(struct memlist *ml) 283 { 284 uint64_t ssize, low, high, boundary; 285 struct memlist *head, *tail, *new; 286 287 ssize = (1ull << OPL_MC_MEMBOARD_SHIFT); 288 289 head = tail = NULL; 290 291 for (; ml; ml = ml->next) { 292 low = (uint64_t)ml->address; 293 high = low+(uint64_t)(ml->size); 294 while (low < high) { 295 boundary = roundup(low+1, ssize); 296 boundary = MIN(high, boundary); 297 new = kmem_zalloc(sizeof (struct memlist), KM_SLEEP); 298 new->address = low; 299 new->size = boundary - low; 300 if (head == NULL) 301 head = new; 302 if (tail) { 303 tail->next = new; 304 new->prev = tail; 305 } 306 tail = new; 307 low = boundary; 308 } 309 } 310 return (head); 311 } 312 313 void 314 set_platform_cage_params(void) 315 { 316 extern pgcnt_t total_pages; 317 extern struct memlist *phys_avail; 318 struct memlist *ml, *tml; 319 int ret; 320 321 if (kernel_cage_enable) { 322 pgcnt_t preferred_cage_size; 323 324 preferred_cage_size = 325 MAX(opl_startup_cage_size, total_pages / 256); 326 327 ml = opl_memlist_per_board(phys_avail); 328 329 kcage_range_lock(); 330 /* 331 * Note: we are assuming that post has load the 332 * whole show in to the high end of memory. Having 333 * taken this leap, we copy the whole of phys_avail 334 * the glist and arrange for the cage to grow 335 * downward (descending pfns). 336 */ 337 ret = kcage_range_init(ml, 1); 338 339 /* free the memlist */ 340 do { 341 tml = ml->next; 342 kmem_free(ml, sizeof (struct memlist)); 343 ml = tml; 344 } while (ml != NULL); 345 346 if (ret == 0) 347 kcage_init(preferred_cage_size); 348 kcage_range_unlock(); 349 } 350 351 if (kcage_on) 352 cmn_err(CE_NOTE, "!DR Kernel Cage is ENABLED"); 353 else 354 cmn_err(CE_NOTE, "!DR Kernel Cage is DISABLED"); 355 } 356 357 /*ARGSUSED*/ 358 int 359 plat_cpu_poweron(struct cpu *cp) 360 { 361 int (*opl_cpu_poweron)(struct cpu *) = NULL; 362 363 opl_cpu_poweron = 364 (int (*)(struct cpu *))kobj_getsymvalue("drmach_cpu_poweron", 0); 365 366 if (opl_cpu_poweron == NULL) 367 return (ENOTSUP); 368 else 369 return ((opl_cpu_poweron)(cp)); 370 371 } 372 373 /*ARGSUSED*/ 374 int 375 plat_cpu_poweroff(struct cpu *cp) 376 { 377 int (*opl_cpu_poweroff)(struct cpu *) = NULL; 378 379 opl_cpu_poweroff = 380 (int (*)(struct cpu *))kobj_getsymvalue("drmach_cpu_poweroff", 0); 381 382 if (opl_cpu_poweroff == NULL) 383 return (ENOTSUP); 384 else 385 return ((opl_cpu_poweroff)(cp)); 386 387 } 388 389 int 390 plat_max_boards(void) 391 { 392 return (OPL_MAX_BOARDS); 393 } 394 395 int 396 plat_max_cpu_units_per_board(void) 397 { 398 return (OPL_MAX_CPU_PER_BOARD); 399 } 400 401 int 402 plat_max_mem_units_per_board(void) 403 { 404 return (OPL_MAX_MEM_UNITS_PER_BOARD); 405 } 406 407 int 408 plat_max_io_units_per_board(void) 409 { 410 return (OPL_MAX_IO_UNITS_PER_BOARD); 411 } 412 413 int 414 plat_max_cmp_units_per_board(void) 415 { 416 return (OPL_MAX_CMP_UNITS_PER_BOARD); 417 } 418 419 int 420 plat_max_core_units_per_board(void) 421 { 422 return (OPL_MAX_CORE_UNITS_PER_BOARD); 423 } 424 425 int 426 plat_pfn_to_mem_node(pfn_t pfn) 427 { 428 return (pfn >> mem_node_pfn_shift); 429 } 430 431 /* ARGSUSED */ 432 void 433 plat_build_mem_nodes(u_longlong_t *list, size_t nelems) 434 { 435 size_t elem; 436 pfn_t basepfn; 437 pgcnt_t npgs; 438 uint64_t boundary, ssize; 439 uint64_t low, high; 440 441 /* 442 * OPL mem slices are always aligned on a 256GB boundary. 443 */ 444 mem_node_pfn_shift = OPL_MC_MEMBOARD_SHIFT - MMU_PAGESHIFT; 445 mem_node_physalign = 0; 446 447 /* 448 * Boot install lists are arranged <addr, len>, <addr, len>, ... 449 */ 450 ssize = (1ull << OPL_MC_MEMBOARD_SHIFT); 451 for (elem = 0; elem < nelems; elem += 2) { 452 low = (uint64_t)list[elem]; 453 high = low+(uint64_t)(list[elem+1]); 454 while (low < high) { 455 boundary = roundup(low+1, ssize); 456 boundary = MIN(high, boundary); 457 basepfn = btop(low); 458 npgs = btop(boundary - low); 459 mem_node_add_slice(basepfn, basepfn + npgs - 1); 460 low = boundary; 461 } 462 } 463 } 464 465 /* 466 * Find the CPU associated with a slice at boot-time. 467 */ 468 void 469 plat_fill_mc(pnode_t nodeid) 470 { 471 int board; 472 int memnode; 473 struct { 474 uint64_t addr; 475 uint64_t size; 476 } mem_range; 477 478 if (prom_getprop(nodeid, "board#", (caddr_t)&board) < 0) { 479 panic("Can not find board# property in mc node %x", nodeid); 480 } 481 if (prom_getprop(nodeid, "sb-mem-ranges", (caddr_t)&mem_range) < 0) { 482 panic("Can not find sb-mem-ranges property in mc node %x", 483 nodeid); 484 } 485 memnode = mem_range.addr >> OPL_MC_MEMBOARD_SHIFT; 486 plat_assign_lgrphand_to_mem_node(board, memnode); 487 } 488 489 /* 490 * Return the platform handle for the lgroup containing the given CPU 491 * 492 * For OPL, lgroup platform handle == board #. 493 */ 494 495 extern int mpo_disabled; 496 extern lgrp_handle_t lgrp_default_handle; 497 498 lgrp_handle_t 499 plat_lgrp_cpu_to_hand(processorid_t id) 500 { 501 lgrp_handle_t plathand; 502 503 /* 504 * Return the real platform handle for the CPU until 505 * such time as we know that MPO should be disabled. 506 * At that point, we set the "mpo_disabled" flag to true, 507 * and from that point on, return the default handle. 508 * 509 * By the time we know that MPO should be disabled, the 510 * first CPU will have already been added to a leaf 511 * lgroup, but that's ok. The common lgroup code will 512 * double check that the boot CPU is in the correct place, 513 * and in the case where mpo should be disabled, will move 514 * it to the root if necessary. 515 */ 516 if (mpo_disabled) { 517 /* If MPO is disabled, return the default (UMA) handle */ 518 plathand = lgrp_default_handle; 519 } else 520 plathand = (lgrp_handle_t)LSB_ID(id); 521 return (plathand); 522 } 523 524 /* 525 * Platform specific lgroup initialization 526 */ 527 void 528 plat_lgrp_init(void) 529 { 530 extern uint32_t lgrp_expand_proc_thresh; 531 extern uint32_t lgrp_expand_proc_diff; 532 533 /* 534 * Set tuneables for the OPL architecture 535 * 536 * lgrp_expand_proc_thresh is the minimum load on the lgroups 537 * this process is currently running on before considering 538 * expanding threads to another lgroup. 539 * 540 * lgrp_expand_proc_diff determines how much less the remote lgroup 541 * must be loaded before expanding to it. 542 * 543 * Since remote latencies can be costly, attempt to keep 3 threads 544 * within the same lgroup before expanding to the next lgroup. 545 */ 546 lgrp_expand_proc_thresh = LGRP_LOADAVG_THREAD_MAX * 3; 547 lgrp_expand_proc_diff = LGRP_LOADAVG_THREAD_MAX; 548 } 549 550 /* 551 * Platform notification of lgroup (re)configuration changes 552 */ 553 /*ARGSUSED*/ 554 void 555 plat_lgrp_config(lgrp_config_flag_t evt, uintptr_t arg) 556 { 557 update_membounds_t *umb; 558 lgrp_config_mem_rename_t lmr; 559 int sbd, tbd; 560 lgrp_handle_t hand, shand, thand; 561 int mnode, snode, tnode; 562 pfn_t start, end; 563 564 if (mpo_disabled) 565 return; 566 567 switch (evt) { 568 569 case LGRP_CONFIG_MEM_ADD: 570 /* 571 * Establish the lgroup handle to memnode translation. 572 */ 573 umb = (update_membounds_t *)arg; 574 575 hand = umb->u_board; 576 mnode = plat_pfn_to_mem_node(umb->u_base >> MMU_PAGESHIFT); 577 plat_assign_lgrphand_to_mem_node(hand, mnode); 578 579 break; 580 581 case LGRP_CONFIG_MEM_DEL: 582 /* 583 * Special handling for possible memory holes. 584 */ 585 umb = (update_membounds_t *)arg; 586 hand = umb->u_board; 587 if ((mnode = plat_lgrphand_to_mem_node(hand)) != -1) { 588 if (mem_node_config[mnode].exists) { 589 start = mem_node_config[mnode].physbase; 590 end = mem_node_config[mnode].physmax; 591 mem_node_pre_del_slice(start, end); 592 mem_node_post_del_slice(start, end, 0); 593 } 594 } 595 596 break; 597 598 case LGRP_CONFIG_MEM_RENAME: 599 /* 600 * During a DR copy-rename operation, all of the memory 601 * on one board is moved to another board -- but the 602 * addresses/pfns and memnodes don't change. This means 603 * the memory has changed locations without changing identity. 604 * 605 * Source is where we are copying from and target is where we 606 * are copying to. After source memnode is copied to target 607 * memnode, the physical addresses of the target memnode are 608 * renamed to match what the source memnode had. Then target 609 * memnode can be removed and source memnode can take its 610 * place. 611 * 612 * To do this, swap the lgroup handle to memnode mappings for 613 * the boards, so target lgroup will have source memnode and 614 * source lgroup will have empty target memnode which is where 615 * its memory will go (if any is added to it later). 616 * 617 * Then source memnode needs to be removed from its lgroup 618 * and added to the target lgroup where the memory was living 619 * but under a different name/memnode. The memory was in the 620 * target memnode and now lives in the source memnode with 621 * different physical addresses even though it is the same 622 * memory. 623 */ 624 sbd = arg & 0xffff; 625 tbd = (arg & 0xffff0000) >> 16; 626 shand = sbd; 627 thand = tbd; 628 snode = plat_lgrphand_to_mem_node(shand); 629 tnode = plat_lgrphand_to_mem_node(thand); 630 631 /* 632 * Special handling for possible memory holes. 633 */ 634 if (tnode != -1 && mem_node_config[tnode].exists) { 635 start = mem_node_config[mnode].physbase; 636 end = mem_node_config[mnode].physmax; 637 mem_node_pre_del_slice(start, end); 638 mem_node_post_del_slice(start, end, 0); 639 } 640 641 plat_assign_lgrphand_to_mem_node(thand, snode); 642 plat_assign_lgrphand_to_mem_node(shand, tnode); 643 644 lmr.lmem_rename_from = shand; 645 lmr.lmem_rename_to = thand; 646 647 /* 648 * Remove source memnode of copy rename from its lgroup 649 * and add it to its new target lgroup 650 */ 651 lgrp_config(LGRP_CONFIG_MEM_RENAME, (uintptr_t)snode, 652 (uintptr_t)&lmr); 653 654 break; 655 656 default: 657 break; 658 } 659 } 660 661 /* 662 * Return latency between "from" and "to" lgroups 663 * 664 * This latency number can only be used for relative comparison 665 * between lgroups on the running system, cannot be used across platforms, 666 * and may not reflect the actual latency. It is platform and implementation 667 * specific, so platform gets to decide its value. It would be nice if the 668 * number was at least proportional to make comparisons more meaningful though. 669 * NOTE: The numbers below are supposed to be load latencies for uncached 670 * memory divided by 10. 671 * 672 * XXX latency values for Columbus, not Columbus2. Should be fixed later when 673 * we know the actual numbers for Columbus2. 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 (27); 686 else 687 return (25); 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 plen; 821 int ret = 0; 822 char model[20]; 823 uint_t sb; 824 pnode_t node; 825 826 /* determine the platform model once */ 827 if (plat_model == -1) { 828 plat_model = MODEL_DC; /* Default model */ 829 node = prom_rootnode(); 830 plen = prom_getproplen(node, "model"); 831 if (plen > 0 && plen < sizeof (model)) { 832 (void) prom_getprop(node, "model", model); 833 model[plen] = '\0'; 834 if (strcmp(model, "FF1") == 0) 835 plat_model = MODEL_FF1; 836 else if (strcmp(model, "FF2") == 0) 837 plat_model = MODEL_FF2; 838 else if (strncmp(model, "DC", 2) == 0) 839 plat_model = MODEL_DC; 840 } 841 } 842 843 sb = opl_get_physical_board(LSB_ID(cpuid)); 844 if (sb == -1) { 845 return (ENXIO); 846 } 847 848 switch (plat_model) { 849 case MODEL_FF1: 850 plen = snprintf(buf, buflen, "/%s/CPUM%d", "MBU_A", 851 CHIP_ID(cpuid) / 2); 852 break; 853 854 case MODEL_FF2: 855 plen = snprintf(buf, buflen, "/%s/CPUM%d", "MBU_B", 856 CHIP_ID(cpuid) / 2); 857 break; 858 859 case MODEL_DC: 860 plen = snprintf(buf, buflen, "/%s%02d/CPUM%d", "CMU", sb, 861 CHIP_ID(cpuid)); 862 break; 863 864 default: 865 /* This should never happen */ 866 return (ENODEV); 867 } 868 869 if (plen >= buflen) { 870 ret = ENOSPC; 871 } else { 872 if (lenp) 873 *lenp = strlen(buf); 874 } 875 return (ret); 876 } 877 878 #define SCF_PUTINFO(f, s, p) \ 879 f(KEY_ESCF, 0x01, 0, s, p) 880 void 881 plat_nodename_set(void) 882 { 883 void *datap; 884 static int (*scf_service_function)(uint32_t, uint8_t, 885 uint32_t, uint32_t, void *); 886 int counter = 5; 887 888 /* 889 * find the symbol for the SCF put routine in driver 890 */ 891 if (scf_service_function == NULL) 892 scf_service_function = 893 (int (*)(uint32_t, uint8_t, uint32_t, uint32_t, void *)) 894 modgetsymvalue("scf_service_putinfo", 0); 895 896 /* 897 * If the symbol was found, call it. Otherwise, log a note (but not to 898 * the console). 899 */ 900 901 if (scf_service_function == NULL) { 902 cmn_err(CE_NOTE, 903 "!plat_nodename_set: scf_service_putinfo not found\n"); 904 return; 905 } 906 907 datap = 908 (struct utsname *)kmem_zalloc(sizeof (struct utsname), KM_SLEEP); 909 910 if (datap == NULL) { 911 return; 912 } 913 914 bcopy((struct utsname *)&utsname, 915 (struct utsname *)datap, sizeof (struct utsname)); 916 917 while ((SCF_PUTINFO(scf_service_function, 918 sizeof (struct utsname), datap) == EBUSY) && (counter-- > 0)) { 919 delay(10 * drv_usectohz(1000000)); 920 } 921 if (counter == 0) 922 cmn_err(CE_NOTE, 923 "!plat_nodename_set: " 924 "scf_service_putinfo not responding\n"); 925 926 kmem_free(datap, sizeof (struct utsname)); 927 } 928 929 caddr_t efcode_vaddr = NULL; 930 931 /* 932 * Preallocate enough memory for fcode claims. 933 */ 934 935 caddr_t 936 efcode_alloc(caddr_t alloc_base) 937 { 938 caddr_t efcode_alloc_base = (caddr_t)roundup((uintptr_t)alloc_base, 939 MMU_PAGESIZE); 940 caddr_t vaddr; 941 942 /* 943 * allocate the physical memory for the Oberon fcode. 944 */ 945 if ((vaddr = (caddr_t)BOP_ALLOC(bootops, efcode_alloc_base, 946 efcode_size, MMU_PAGESIZE)) == NULL) 947 cmn_err(CE_PANIC, "Cannot allocate Efcode Memory"); 948 949 efcode_vaddr = vaddr; 950 951 return (efcode_alloc_base + efcode_size); 952 } 953 954 caddr_t 955 plat_startup_memlist(caddr_t alloc_base) 956 { 957 caddr_t tmp_alloc_base; 958 959 tmp_alloc_base = efcode_alloc(alloc_base); 960 tmp_alloc_base = 961 (caddr_t)roundup((uintptr_t)tmp_alloc_base, ecache_alignsize); 962 return (tmp_alloc_base); 963 } 964 965 void 966 startup_platform(void) 967 { 968 } 969 970 void 971 plat_cpuid_to_mmu_ctx_info(processorid_t cpuid, mmu_ctx_info_t *info) 972 { 973 int impl; 974 975 impl = cpunodes[cpuid].implementation; 976 if (IS_OLYMPUS_C(impl)) { 977 /* 978 * Olympus-C processor supports 2 strands per core. 979 */ 980 info->mmu_idx = cpuid >> 1; 981 info->mmu_nctxs = 8192; 982 } else { 983 cmn_err(CE_PANIC, "Unknown processor %d", impl); 984 } 985 } 986 987 int 988 plat_get_mem_sid(char *unum, char *buf, int buflen, int *lenp) 989 { 990 if (opl_get_mem_sid == NULL) { 991 return (ENOTSUP); 992 } 993 return (opl_get_mem_sid(unum, buf, buflen, lenp)); 994 } 995 996 int 997 plat_get_mem_offset(uint64_t paddr, uint64_t *offp) 998 { 999 if (opl_get_mem_offset == NULL) { 1000 return (ENOTSUP); 1001 } 1002 return (opl_get_mem_offset(paddr, offp)); 1003 } 1004 1005 int 1006 plat_get_mem_addr(char *unum, char *sid, uint64_t offset, uint64_t *addrp) 1007 { 1008 if (opl_get_mem_addr == NULL) { 1009 return (ENOTSUP); 1010 } 1011 return (opl_get_mem_addr(unum, sid, offset, addrp)); 1012 } 1013