opl.c revision 31f6f5ee98526c6119cd0a39fb1ace69897209fa
25cf1a301a396c38e8adf52c15f537b80d2483f7jl/*
25cf1a301a396c38e8adf52c15f537b80d2483f7jl * CDDL HEADER START
25cf1a301a396c38e8adf52c15f537b80d2483f7jl *
25cf1a301a396c38e8adf52c15f537b80d2483f7jl * The contents of this file are subject to the terms of the
25cf1a301a396c38e8adf52c15f537b80d2483f7jl * Common Development and Distribution License (the "License").
25cf1a301a396c38e8adf52c15f537b80d2483f7jl * You may not use this file except in compliance with the License.
25cf1a301a396c38e8adf52c15f537b80d2483f7jl *
25cf1a301a396c38e8adf52c15f537b80d2483f7jl * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
25cf1a301a396c38e8adf52c15f537b80d2483f7jl * or http://www.opensolaris.org/os/licensing.
25cf1a301a396c38e8adf52c15f537b80d2483f7jl * See the License for the specific language governing permissions
25cf1a301a396c38e8adf52c15f537b80d2483f7jl * and limitations under the License.
25cf1a301a396c38e8adf52c15f537b80d2483f7jl *
25cf1a301a396c38e8adf52c15f537b80d2483f7jl * When distributing Covered Code, include this CDDL HEADER in each
25cf1a301a396c38e8adf52c15f537b80d2483f7jl * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
25cf1a301a396c38e8adf52c15f537b80d2483f7jl * If applicable, add the following below this CDDL HEADER, with the
25cf1a301a396c38e8adf52c15f537b80d2483f7jl * fields enclosed by brackets "[]" replaced with your own identifying
25cf1a301a396c38e8adf52c15f537b80d2483f7jl * information: Portions Copyright [yyyy] [name of copyright owner]
25cf1a301a396c38e8adf52c15f537b80d2483f7jl *
25cf1a301a396c38e8adf52c15f537b80d2483f7jl * CDDL HEADER END
25cf1a301a396c38e8adf52c15f537b80d2483f7jl */
25cf1a301a396c38e8adf52c15f537b80d2483f7jl/*
25cf1a301a396c38e8adf52c15f537b80d2483f7jl * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
25cf1a301a396c38e8adf52c15f537b80d2483f7jl * Use is subject to license terms.
25cf1a301a396c38e8adf52c15f537b80d2483f7jl */
25cf1a301a396c38e8adf52c15f537b80d2483f7jl
25cf1a301a396c38e8adf52c15f537b80d2483f7jl#pragma ident "%Z%%M% %I% %E% SMI"
25cf1a301a396c38e8adf52c15f537b80d2483f7jl
25cf1a301a396c38e8adf52c15f537b80d2483f7jl#include <sys/cpuvar.h>
25cf1a301a396c38e8adf52c15f537b80d2483f7jl#include <sys/systm.h>
25cf1a301a396c38e8adf52c15f537b80d2483f7jl#include <sys/sysmacros.h>
25cf1a301a396c38e8adf52c15f537b80d2483f7jl#include <sys/promif.h>
25cf1a301a396c38e8adf52c15f537b80d2483f7jl#include <sys/platform_module.h>
25cf1a301a396c38e8adf52c15f537b80d2483f7jl#include <sys/cmn_err.h>
25cf1a301a396c38e8adf52c15f537b80d2483f7jl#include <sys/errno.h>
25cf1a301a396c38e8adf52c15f537b80d2483f7jl#include <sys/machsystm.h>
25cf1a301a396c38e8adf52c15f537b80d2483f7jl#include <sys/bootconf.h>
25cf1a301a396c38e8adf52c15f537b80d2483f7jl#include <sys/nvpair.h>
25cf1a301a396c38e8adf52c15f537b80d2483f7jl#include <sys/kobj.h>
25cf1a301a396c38e8adf52c15f537b80d2483f7jl#include <sys/mem_cage.h>
25cf1a301a396c38e8adf52c15f537b80d2483f7jl#include <sys/opl.h>
25cf1a301a396c38e8adf52c15f537b80d2483f7jl#include <sys/scfd/scfostoescf.h>
25cf1a301a396c38e8adf52c15f537b80d2483f7jl#include <sys/cpu_sgnblk_defs.h>
25cf1a301a396c38e8adf52c15f537b80d2483f7jl#include <sys/utsname.h>
25cf1a301a396c38e8adf52c15f537b80d2483f7jl#include <sys/ddi.h>
25cf1a301a396c38e8adf52c15f537b80d2483f7jl#include <sys/sunndi.h>
25cf1a301a396c38e8adf52c15f537b80d2483f7jl#include <sys/lgrp.h>
25cf1a301a396c38e8adf52c15f537b80d2483f7jl#include <sys/memnode.h>
25cf1a301a396c38e8adf52c15f537b80d2483f7jl#include <sys/sysmacros.h>
25cf1a301a396c38e8adf52c15f537b80d2483f7jl#include <vm/vm_dep.h>
25cf1a301a396c38e8adf52c15f537b80d2483f7jl
25cf1a301a396c38e8adf52c15f537b80d2483f7jlint (*opl_get_mem_unum)(int, uint64_t, char *, int, int *);
0cc8ae8667155d352d327b5c92b62899a7e05bcdavint (*opl_get_mem_sid)(char *unum, char *buf, int buflen, int *lenp);
0cc8ae8667155d352d327b5c92b62899a7e05bcdavint (*opl_get_mem_offset)(uint64_t paddr, uint64_t *offp);
0cc8ae8667155d352d327b5c92b62899a7e05bcdavint (*opl_get_mem_addr)(char *unum, char *sid,
0cc8ae8667155d352d327b5c92b62899a7e05bcdav uint64_t offset, uint64_t *paddr);
25cf1a301a396c38e8adf52c15f537b80d2483f7jl
25cf1a301a396c38e8adf52c15f537b80d2483f7jl/* Memory for fcode claims. 16k times # maximum possible IO units */
25cf1a301a396c38e8adf52c15f537b80d2483f7jl#define EFCODE_SIZE (OPL_MAX_BOARDS * OPL_MAX_IO_UNITS_PER_BOARD * 0x4000)
25cf1a301a396c38e8adf52c15f537b80d2483f7jlint efcode_size = EFCODE_SIZE;
25cf1a301a396c38e8adf52c15f537b80d2483f7jl
25cf1a301a396c38e8adf52c15f537b80d2483f7jl#define OPL_MC_MEMBOARD_SHIFT 38 /* Boards on 256BG boundary */
25cf1a301a396c38e8adf52c15f537b80d2483f7jl
25cf1a301a396c38e8adf52c15f537b80d2483f7jl/* Set the maximum number of boards for DR */
25cf1a301a396c38e8adf52c15f537b80d2483f7jlint opl_boards = OPL_MAX_BOARDS;
25cf1a301a396c38e8adf52c15f537b80d2483f7jl
25cf1a301a396c38e8adf52c15f537b80d2483f7jlvoid sgn_update_all_cpus(ushort_t, uchar_t, uchar_t);
25cf1a301a396c38e8adf52c15f537b80d2483f7jl
25cf1a301a396c38e8adf52c15f537b80d2483f7jlextern int tsb_lgrp_affinity;
25cf1a301a396c38e8adf52c15f537b80d2483f7jl
25cf1a301a396c38e8adf52c15f537b80d2483f7jlint opl_tsb_spares = (OPL_MAX_BOARDS) * (OPL_MAX_PCICH_UNITS_PER_BOARD) *
25cf1a301a396c38e8adf52c15f537b80d2483f7jl (OPL_MAX_TSBS_PER_PCICH);
25cf1a301a396c38e8adf52c15f537b80d2483f7jl
25cf1a301a396c38e8adf52c15f537b80d2483f7jlpgcnt_t opl_startup_cage_size = 0;
25cf1a301a396c38e8adf52c15f537b80d2483f7jl
1e2e7a75ddb1eedcefa449ce98fd5862749b72eehuahstatic opl_model_info_t opl_models[] = {
1e2e7a75ddb1eedcefa449ce98fd5862749b72eehuah { "FF1", OPL_MAX_BOARDS_FF1 },
1e2e7a75ddb1eedcefa449ce98fd5862749b72eehuah { "FF2", OPL_MAX_BOARDS_FF2 },
1e2e7a75ddb1eedcefa449ce98fd5862749b72eehuah { "DC1", OPL_MAX_BOARDS_DC1 },
1e2e7a75ddb1eedcefa449ce98fd5862749b72eehuah { "DC2", OPL_MAX_BOARDS_DC2 },
1e2e7a75ddb1eedcefa449ce98fd5862749b72eehuah { "DC3", OPL_MAX_BOARDS_DC3 },
1e2e7a75ddb1eedcefa449ce98fd5862749b72eehuah};
1e2e7a75ddb1eedcefa449ce98fd5862749b72eehuahstatic int opl_num_models = sizeof (opl_models)/sizeof (opl_model_info_t);
1e2e7a75ddb1eedcefa449ce98fd5862749b72eehuah
1e2e7a75ddb1eedcefa449ce98fd5862749b72eehuahstatic opl_model_info_t *opl_cur_model = NULL;
1e2e7a75ddb1eedcefa449ce98fd5862749b72eehuah
25cf1a301a396c38e8adf52c15f537b80d2483f7jlstatic struct memlist *opl_memlist_per_board(struct memlist *ml);
25cf1a301a396c38e8adf52c15f537b80d2483f7jl
0cc8ae8667155d352d327b5c92b62899a7e05bcdavstatic enum {
0cc8ae8667155d352d327b5c92b62899a7e05bcdav MODEL_FF1 = 0,
0cc8ae8667155d352d327b5c92b62899a7e05bcdav MODEL_FF2 = 1,
0cc8ae8667155d352d327b5c92b62899a7e05bcdav MODEL_DC = 2
0cc8ae8667155d352d327b5c92b62899a7e05bcdav} plat_model = -1;
0cc8ae8667155d352d327b5c92b62899a7e05bcdav
25cf1a301a396c38e8adf52c15f537b80d2483f7jlint
25cf1a301a396c38e8adf52c15f537b80d2483f7jlset_platform_max_ncpus(void)
25cf1a301a396c38e8adf52c15f537b80d2483f7jl{
25cf1a301a396c38e8adf52c15f537b80d2483f7jl return (OPL_MAX_CPU_PER_BOARD * OPL_MAX_BOARDS);
25cf1a301a396c38e8adf52c15f537b80d2483f7jl}
25cf1a301a396c38e8adf52c15f537b80d2483f7jl
25cf1a301a396c38e8adf52c15f537b80d2483f7jlint
25cf1a301a396c38e8adf52c15f537b80d2483f7jlset_platform_tsb_spares(void)
25cf1a301a396c38e8adf52c15f537b80d2483f7jl{
25cf1a301a396c38e8adf52c15f537b80d2483f7jl return (MIN(opl_tsb_spares, MAX_UPA));
25cf1a301a396c38e8adf52c15f537b80d2483f7jl}
25cf1a301a396c38e8adf52c15f537b80d2483f7jl
1e2e7a75ddb1eedcefa449ce98fd5862749b72eehuahstatic void
1e2e7a75ddb1eedcefa449ce98fd5862749b72eehuahset_model_info()
1e2e7a75ddb1eedcefa449ce98fd5862749b72eehuah{
1e2e7a75ddb1eedcefa449ce98fd5862749b72eehuah char name[MAXSYSNAME];
1e2e7a75ddb1eedcefa449ce98fd5862749b72eehuah int i;
1e2e7a75ddb1eedcefa449ce98fd5862749b72eehuah
1e2e7a75ddb1eedcefa449ce98fd5862749b72eehuah /*
1e2e7a75ddb1eedcefa449ce98fd5862749b72eehuah * Get model name from the root node.
1e2e7a75ddb1eedcefa449ce98fd5862749b72eehuah *
1e2e7a75ddb1eedcefa449ce98fd5862749b72eehuah * We are using the prom device tree since, at this point,
1e2e7a75ddb1eedcefa449ce98fd5862749b72eehuah * the Solaris device tree is not yet setup.
1e2e7a75ddb1eedcefa449ce98fd5862749b72eehuah */
1e2e7a75ddb1eedcefa449ce98fd5862749b72eehuah (void) prom_getprop(prom_rootnode(), "model", (caddr_t)name);
1e2e7a75ddb1eedcefa449ce98fd5862749b72eehuah
1e2e7a75ddb1eedcefa449ce98fd5862749b72eehuah for (i = 0; i < opl_num_models; i++) {
1e2e7a75ddb1eedcefa449ce98fd5862749b72eehuah if (strncmp(name, opl_models[i].model_name, MAXSYSNAME) == 0) {
1e2e7a75ddb1eedcefa449ce98fd5862749b72eehuah opl_cur_model = &opl_models[i];
1e2e7a75ddb1eedcefa449ce98fd5862749b72eehuah break;
1e2e7a75ddb1eedcefa449ce98fd5862749b72eehuah }
1e2e7a75ddb1eedcefa449ce98fd5862749b72eehuah }
1e2e7a75ddb1eedcefa449ce98fd5862749b72eehuah if (i == opl_num_models)
1e2e7a75ddb1eedcefa449ce98fd5862749b72eehuah cmn_err(CE_WARN, "No valid OPL model is found!"
1e2e7a75ddb1eedcefa449ce98fd5862749b72eehuah "Set max_mmu_ctxdoms to the default.");
1e2e7a75ddb1eedcefa449ce98fd5862749b72eehuah}
1e2e7a75ddb1eedcefa449ce98fd5862749b72eehuah
1e2e7a75ddb1eedcefa449ce98fd5862749b72eehuahstatic void
1e2e7a75ddb1eedcefa449ce98fd5862749b72eehuahset_max_mmu_ctxdoms()
1e2e7a75ddb1eedcefa449ce98fd5862749b72eehuah{
1e2e7a75ddb1eedcefa449ce98fd5862749b72eehuah extern uint_t max_mmu_ctxdoms;
1e2e7a75ddb1eedcefa449ce98fd5862749b72eehuah int max_boards;
1e2e7a75ddb1eedcefa449ce98fd5862749b72eehuah
1e2e7a75ddb1eedcefa449ce98fd5862749b72eehuah /*
1e2e7a75ddb1eedcefa449ce98fd5862749b72eehuah * From the model, get the maximum number of boards
1e2e7a75ddb1eedcefa449ce98fd5862749b72eehuah * supported and set the value accordingly. If the model
1e2e7a75ddb1eedcefa449ce98fd5862749b72eehuah * could not be determined or recognized, we assume the max value.
1e2e7a75ddb1eedcefa449ce98fd5862749b72eehuah */
1e2e7a75ddb1eedcefa449ce98fd5862749b72eehuah if (opl_cur_model == NULL)
1e2e7a75ddb1eedcefa449ce98fd5862749b72eehuah max_boards = OPL_MAX_BOARDS;
1e2e7a75ddb1eedcefa449ce98fd5862749b72eehuah else
1e2e7a75ddb1eedcefa449ce98fd5862749b72eehuah max_boards = opl_cur_model->model_max_boards;
1e2e7a75ddb1eedcefa449ce98fd5862749b72eehuah
1e2e7a75ddb1eedcefa449ce98fd5862749b72eehuah /*
1e2e7a75ddb1eedcefa449ce98fd5862749b72eehuah * On OPL, cores and MMUs are one-to-one.
1e2e7a75ddb1eedcefa449ce98fd5862749b72eehuah */
1e2e7a75ddb1eedcefa449ce98fd5862749b72eehuah max_mmu_ctxdoms = OPL_MAX_CORE_UNITS_PER_BOARD * max_boards;
1e2e7a75ddb1eedcefa449ce98fd5862749b72eehuah}
1e2e7a75ddb1eedcefa449ce98fd5862749b72eehuah
25cf1a301a396c38e8adf52c15f537b80d2483f7jl#pragma weak mmu_init_large_pages
25cf1a301a396c38e8adf52c15f537b80d2483f7jl
25cf1a301a396c38e8adf52c15f537b80d2483f7jlvoid
25cf1a301a396c38e8adf52c15f537b80d2483f7jlset_platform_defaults(void)
25cf1a301a396c38e8adf52c15f537b80d2483f7jl{
25cf1a301a396c38e8adf52c15f537b80d2483f7jl extern char *tod_module_name;
25cf1a301a396c38e8adf52c15f537b80d2483f7jl extern void cpu_sgn_update(ushort_t, uchar_t, uchar_t, int);
25cf1a301a396c38e8adf52c15f537b80d2483f7jl extern int ts_dispatch_extended;
25cf1a301a396c38e8adf52c15f537b80d2483f7jl extern void mmu_init_large_pages(size_t);
25cf1a301a396c38e8adf52c15f537b80d2483f7jl
25cf1a301a396c38e8adf52c15f537b80d2483f7jl /* Set the CPU signature function pointer */
25cf1a301a396c38e8adf52c15f537b80d2483f7jl cpu_sgn_func = cpu_sgn_update;
25cf1a301a396c38e8adf52c15f537b80d2483f7jl
25cf1a301a396c38e8adf52c15f537b80d2483f7jl /* Set appropriate tod module for OPL platform */
25cf1a301a396c38e8adf52c15f537b80d2483f7jl ASSERT(tod_module_name == NULL);
25cf1a301a396c38e8adf52c15f537b80d2483f7jl tod_module_name = "todopl";
25cf1a301a396c38e8adf52c15f537b80d2483f7jl
25cf1a301a396c38e8adf52c15f537b80d2483f7jl /*
25cf1a301a396c38e8adf52c15f537b80d2483f7jl * Use the alternate TS dispatch table, which is better tuned
25cf1a301a396c38e8adf52c15f537b80d2483f7jl * for large servers.
25cf1a301a396c38e8adf52c15f537b80d2483f7jl */
25cf1a301a396c38e8adf52c15f537b80d2483f7jl if (ts_dispatch_extended == -1)
25cf1a301a396c38e8adf52c15f537b80d2483f7jl ts_dispatch_extended = 1;
25cf1a301a396c38e8adf52c15f537b80d2483f7jl
25cf1a301a396c38e8adf52c15f537b80d2483f7jl if ((mmu_page_sizes == max_mmu_page_sizes) &&
25cf1a301a396c38e8adf52c15f537b80d2483f7jl (mmu_ism_pagesize != MMU_PAGESIZE32M)) {
25cf1a301a396c38e8adf52c15f537b80d2483f7jl if (&mmu_init_large_pages)
25cf1a301a396c38e8adf52c15f537b80d2483f7jl mmu_init_large_pages(mmu_ism_pagesize);
25cf1a301a396c38e8adf52c15f537b80d2483f7jl }
25cf1a301a396c38e8adf52c15f537b80d2483f7jl
25cf1a301a396c38e8adf52c15f537b80d2483f7jl tsb_lgrp_affinity = 1;
1e2e7a75ddb1eedcefa449ce98fd5862749b72eehuah
1e2e7a75ddb1eedcefa449ce98fd5862749b72eehuah set_model_info();
1e2e7a75ddb1eedcefa449ce98fd5862749b72eehuah set_max_mmu_ctxdoms();
25cf1a301a396c38e8adf52c15f537b80d2483f7jl}
25cf1a301a396c38e8adf52c15f537b80d2483f7jl
25cf1a301a396c38e8adf52c15f537b80d2483f7jl/*
25cf1a301a396c38e8adf52c15f537b80d2483f7jl * Convert logical a board number to a physical one.
25cf1a301a396c38e8adf52c15f537b80d2483f7jl */
25cf1a301a396c38e8adf52c15f537b80d2483f7jl
25cf1a301a396c38e8adf52c15f537b80d2483f7jl#define LSBPROP "board#"
25cf1a301a396c38e8adf52c15f537b80d2483f7jl#define PSBPROP "physical-board#"
25cf1a301a396c38e8adf52c15f537b80d2483f7jl
25cf1a301a396c38e8adf52c15f537b80d2483f7jlint
25cf1a301a396c38e8adf52c15f537b80d2483f7jlopl_get_physical_board(int id)
25cf1a301a396c38e8adf52c15f537b80d2483f7jl{
25cf1a301a396c38e8adf52c15f537b80d2483f7jl dev_info_t *root_dip, *dip = NULL;
25cf1a301a396c38e8adf52c15f537b80d2483f7jl char *dname = NULL;
25cf1a301a396c38e8adf52c15f537b80d2483f7jl int circ;
25cf1a301a396c38e8adf52c15f537b80d2483f7jl
25cf1a301a396c38e8adf52c15f537b80d2483f7jl pnode_t pnode;
25cf1a301a396c38e8adf52c15f537b80d2483f7jl char pname[MAXSYSNAME] = {0};
25cf1a301a396c38e8adf52c15f537b80d2483f7jl
25cf1a301a396c38e8adf52c15f537b80d2483f7jl int lsb_id; /* Logical System Board ID */
25cf1a301a396c38e8adf52c15f537b80d2483f7jl int psb_id; /* Physical System Board ID */
25cf1a301a396c38e8adf52c15f537b80d2483f7jl
25cf1a301a396c38e8adf52c15f537b80d2483f7jl
25cf1a301a396c38e8adf52c15f537b80d2483f7jl /*
25cf1a301a396c38e8adf52c15f537b80d2483f7jl * This function is called on early stage of bootup when the
25cf1a301a396c38e8adf52c15f537b80d2483f7jl * kernel device tree is not initialized yet, and also
25cf1a301a396c38e8adf52c15f537b80d2483f7jl * later on when the device tree is up. We want to try
25cf1a301a396c38e8adf52c15f537b80d2483f7jl * the fast track first.
25cf1a301a396c38e8adf52c15f537b80d2483f7jl */
25cf1a301a396c38e8adf52c15f537b80d2483f7jl root_dip = ddi_root_node();
25cf1a301a396c38e8adf52c15f537b80d2483f7jl if (root_dip) {
25cf1a301a396c38e8adf52c15f537b80d2483f7jl /* Get from devinfo node */
25cf1a301a396c38e8adf52c15f537b80d2483f7jl ndi_devi_enter(root_dip, &circ);
25cf1a301a396c38e8adf52c15f537b80d2483f7jl for (dip = ddi_get_child(root_dip); dip;
25cf1a301a396c38e8adf52c15f537b80d2483f7jl dip = ddi_get_next_sibling(dip)) {
25cf1a301a396c38e8adf52c15f537b80d2483f7jl
25cf1a301a396c38e8adf52c15f537b80d2483f7jl dname = ddi_node_name(dip);
25cf1a301a396c38e8adf52c15f537b80d2483f7jl if (strncmp(dname, "pseudo-mc", 9) != 0)
25cf1a301a396c38e8adf52c15f537b80d2483f7jl continue;
25cf1a301a396c38e8adf52c15f537b80d2483f7jl
25cf1a301a396c38e8adf52c15f537b80d2483f7jl if ((lsb_id = (int)ddi_getprop(DDI_DEV_T_ANY, dip,
25cf1a301a396c38e8adf52c15f537b80d2483f7jl DDI_PROP_DONTPASS, LSBPROP, -1)) == -1)
25cf1a301a396c38e8adf52c15f537b80d2483f7jl continue;
25cf1a301a396c38e8adf52c15f537b80d2483f7jl
25cf1a301a396c38e8adf52c15f537b80d2483f7jl if (id == lsb_id) {
25cf1a301a396c38e8adf52c15f537b80d2483f7jl if ((psb_id = (int)ddi_getprop(DDI_DEV_T_ANY,
25cf1a301a396c38e8adf52c15f537b80d2483f7jl dip, DDI_PROP_DONTPASS, PSBPROP, -1))
25cf1a301a396c38e8adf52c15f537b80d2483f7jl == -1) {
25cf1a301a396c38e8adf52c15f537b80d2483f7jl ndi_devi_exit(root_dip, circ);
25cf1a301a396c38e8adf52c15f537b80d2483f7jl return (-1);
25cf1a301a396c38e8adf52c15f537b80d2483f7jl } else {
25cf1a301a396c38e8adf52c15f537b80d2483f7jl ndi_devi_exit(root_dip, circ);
25cf1a301a396c38e8adf52c15f537b80d2483f7jl return (psb_id);
25cf1a301a396c38e8adf52c15f537b80d2483f7jl }
25cf1a301a396c38e8adf52c15f537b80d2483f7jl }
25cf1a301a396c38e8adf52c15f537b80d2483f7jl }
25cf1a301a396c38e8adf52c15f537b80d2483f7jl ndi_devi_exit(root_dip, circ);
25cf1a301a396c38e8adf52c15f537b80d2483f7jl }
25cf1a301a396c38e8adf52c15f537b80d2483f7jl
25cf1a301a396c38e8adf52c15f537b80d2483f7jl /*
25cf1a301a396c38e8adf52c15f537b80d2483f7jl * We do not have the kernel device tree, or we did not
25cf1a301a396c38e8adf52c15f537b80d2483f7jl * find the node for some reason (let's say the kernel
25cf1a301a396c38e8adf52c15f537b80d2483f7jl * device tree was modified), let's try the OBP tree.
25cf1a301a396c38e8adf52c15f537b80d2483f7jl */
25cf1a301a396c38e8adf52c15f537b80d2483f7jl pnode = prom_rootnode();
25cf1a301a396c38e8adf52c15f537b80d2483f7jl for (pnode = prom_childnode(pnode); pnode;
25cf1a301a396c38e8adf52c15f537b80d2483f7jl pnode = prom_nextnode(pnode)) {
25cf1a301a396c38e8adf52c15f537b80d2483f7jl
25cf1a301a396c38e8adf52c15f537b80d2483f7jl if ((prom_getprop(pnode, "name", (caddr_t)pname) == -1) ||
25cf1a301a396c38e8adf52c15f537b80d2483f7jl (strncmp(pname, "pseudo-mc", 9) != 0))
25cf1a301a396c38e8adf52c15f537b80d2483f7jl continue;
25cf1a301a396c38e8adf52c15f537b80d2483f7jl
25cf1a301a396c38e8adf52c15f537b80d2483f7jl if (prom_getprop(pnode, LSBPROP, (caddr_t)&lsb_id) == -1)
25cf1a301a396c38e8adf52c15f537b80d2483f7jl continue;
25cf1a301a396c38e8adf52c15f537b80d2483f7jl
25cf1a301a396c38e8adf52c15f537b80d2483f7jl if (id == lsb_id) {
25cf1a301a396c38e8adf52c15f537b80d2483f7jl if (prom_getprop(pnode, PSBPROP,
25cf1a301a396c38e8adf52c15f537b80d2483f7jl (caddr_t)&psb_id) == -1) {
25cf1a301a396c38e8adf52c15f537b80d2483f7jl return (-1);
25cf1a301a396c38e8adf52c15f537b80d2483f7jl } else {
25cf1a301a396c38e8adf52c15f537b80d2483f7jl return (psb_id);
25cf1a301a396c38e8adf52c15f537b80d2483f7jl }
25cf1a301a396c38e8adf52c15f537b80d2483f7jl }
25cf1a301a396c38e8adf52c15f537b80d2483f7jl }
25cf1a301a396c38e8adf52c15f537b80d2483f7jl
25cf1a301a396c38e8adf52c15f537b80d2483f7jl return (-1);
25cf1a301a396c38e8adf52c15f537b80d2483f7jl}
25cf1a301a396c38e8adf52c15f537b80d2483f7jl
25cf1a301a396c38e8adf52c15f537b80d2483f7jl/*
25cf1a301a396c38e8adf52c15f537b80d2483f7jl * For OPL it's possible that memory from two or more successive boards
25cf1a301a396c38e8adf52c15f537b80d2483f7jl * will be contiguous across the boards, and therefore represented as a
25cf1a301a396c38e8adf52c15f537b80d2483f7jl * single chunk.
25cf1a301a396c38e8adf52c15f537b80d2483f7jl * This function splits such chunks down the board boundaries.
25cf1a301a396c38e8adf52c15f537b80d2483f7jl */
25cf1a301a396c38e8adf52c15f537b80d2483f7jlstatic struct memlist *
25cf1a301a396c38e8adf52c15f537b80d2483f7jlopl_memlist_per_board(struct memlist *ml)
25cf1a301a396c38e8adf52c15f537b80d2483f7jl{
25cf1a301a396c38e8adf52c15f537b80d2483f7jl uint64_t ssize, low, high, boundary;
25cf1a301a396c38e8adf52c15f537b80d2483f7jl struct memlist *head, *tail, *new;
25cf1a301a396c38e8adf52c15f537b80d2483f7jl
25cf1a301a396c38e8adf52c15f537b80d2483f7jl ssize = (1ull << OPL_MC_MEMBOARD_SHIFT);
25cf1a301a396c38e8adf52c15f537b80d2483f7jl
25cf1a301a396c38e8adf52c15f537b80d2483f7jl head = tail = NULL;
25cf1a301a396c38e8adf52c15f537b80d2483f7jl
25cf1a301a396c38e8adf52c15f537b80d2483f7jl for (; ml; ml = ml->next) {
25cf1a301a396c38e8adf52c15f537b80d2483f7jl low = (uint64_t)ml->address;
25cf1a301a396c38e8adf52c15f537b80d2483f7jl high = low+(uint64_t)(ml->size);
25cf1a301a396c38e8adf52c15f537b80d2483f7jl while (low < high) {
25cf1a301a396c38e8adf52c15f537b80d2483f7jl boundary = roundup(low+1, ssize);
25cf1a301a396c38e8adf52c15f537b80d2483f7jl boundary = MIN(high, boundary);
25cf1a301a396c38e8adf52c15f537b80d2483f7jl new = kmem_zalloc(sizeof (struct memlist), KM_SLEEP);
25cf1a301a396c38e8adf52c15f537b80d2483f7jl new->address = low;
25cf1a301a396c38e8adf52c15f537b80d2483f7jl new->size = boundary - low;
25cf1a301a396c38e8adf52c15f537b80d2483f7jl if (head == NULL)
25cf1a301a396c38e8adf52c15f537b80d2483f7jl head = new;
25cf1a301a396c38e8adf52c15f537b80d2483f7jl if (tail) {
25cf1a301a396c38e8adf52c15f537b80d2483f7jl tail->next = new;
25cf1a301a396c38e8adf52c15f537b80d2483f7jl new->prev = tail;
25cf1a301a396c38e8adf52c15f537b80d2483f7jl }
25cf1a301a396c38e8adf52c15f537b80d2483f7jl tail = new;
25cf1a301a396c38e8adf52c15f537b80d2483f7jl low = boundary;
25cf1a301a396c38e8adf52c15f537b80d2483f7jl }
25cf1a301a396c38e8adf52c15f537b80d2483f7jl }
25cf1a301a396c38e8adf52c15f537b80d2483f7jl return (head);
25cf1a301a396c38e8adf52c15f537b80d2483f7jl}
25cf1a301a396c38e8adf52c15f537b80d2483f7jl
25cf1a301a396c38e8adf52c15f537b80d2483f7jlvoid
25cf1a301a396c38e8adf52c15f537b80d2483f7jlset_platform_cage_params(void)
25cf1a301a396c38e8adf52c15f537b80d2483f7jl{
25cf1a301a396c38e8adf52c15f537b80d2483f7jl extern pgcnt_t total_pages;
25cf1a301a396c38e8adf52c15f537b80d2483f7jl extern struct memlist *phys_avail;
25cf1a301a396c38e8adf52c15f537b80d2483f7jl struct memlist *ml, *tml;
25cf1a301a396c38e8adf52c15f537b80d2483f7jl int ret;
25cf1a301a396c38e8adf52c15f537b80d2483f7jl
25cf1a301a396c38e8adf52c15f537b80d2483f7jl if (kernel_cage_enable) {
25cf1a301a396c38e8adf52c15f537b80d2483f7jl pgcnt_t preferred_cage_size;
25cf1a301a396c38e8adf52c15f537b80d2483f7jl
25cf1a301a396c38e8adf52c15f537b80d2483f7jl preferred_cage_size =
25cf1a301a396c38e8adf52c15f537b80d2483f7jl MAX(opl_startup_cage_size, total_pages / 256);
25cf1a301a396c38e8adf52c15f537b80d2483f7jl
25cf1a301a396c38e8adf52c15f537b80d2483f7jl ml = opl_memlist_per_board(phys_avail);
25cf1a301a396c38e8adf52c15f537b80d2483f7jl
25cf1a301a396c38e8adf52c15f537b80d2483f7jl kcage_range_lock();
25cf1a301a396c38e8adf52c15f537b80d2483f7jl /*
25cf1a301a396c38e8adf52c15f537b80d2483f7jl * Note: we are assuming that post has load the
25cf1a301a396c38e8adf52c15f537b80d2483f7jl * whole show in to the high end of memory. Having
25cf1a301a396c38e8adf52c15f537b80d2483f7jl * taken this leap, we copy the whole of phys_avail
25cf1a301a396c38e8adf52c15f537b80d2483f7jl * the glist and arrange for the cage to grow
25cf1a301a396c38e8adf52c15f537b80d2483f7jl * downward (descending pfns).
25cf1a301a396c38e8adf52c15f537b80d2483f7jl */
25cf1a301a396c38e8adf52c15f537b80d2483f7jl ret = kcage_range_init(ml, 1);
25cf1a301a396c38e8adf52c15f537b80d2483f7jl
25cf1a301a396c38e8adf52c15f537b80d2483f7jl /* free the memlist */
25cf1a301a396c38e8adf52c15f537b80d2483f7jl do {
25cf1a301a396c38e8adf52c15f537b80d2483f7jl tml = ml->next;
25cf1a301a396c38e8adf52c15f537b80d2483f7jl kmem_free(ml, sizeof (struct memlist));
25cf1a301a396c38e8adf52c15f537b80d2483f7jl ml = tml;
25cf1a301a396c38e8adf52c15f537b80d2483f7jl } while (ml != NULL);
25cf1a301a396c38e8adf52c15f537b80d2483f7jl
25cf1a301a396c38e8adf52c15f537b80d2483f7jl if (ret == 0)
25cf1a301a396c38e8adf52c15f537b80d2483f7jl kcage_init(preferred_cage_size);
25cf1a301a396c38e8adf52c15f537b80d2483f7jl kcage_range_unlock();
25cf1a301a396c38e8adf52c15f537b80d2483f7jl }
25cf1a301a396c38e8adf52c15f537b80d2483f7jl
25cf1a301a396c38e8adf52c15f537b80d2483f7jl if (kcage_on)
25cf1a301a396c38e8adf52c15f537b80d2483f7jl cmn_err(CE_NOTE, "!DR Kernel Cage is ENABLED");
25cf1a301a396c38e8adf52c15f537b80d2483f7jl else
25cf1a301a396c38e8adf52c15f537b80d2483f7jl cmn_err(CE_NOTE, "!DR Kernel Cage is DISABLED");
25cf1a301a396c38e8adf52c15f537b80d2483f7jl}
25cf1a301a396c38e8adf52c15f537b80d2483f7jl
25cf1a301a396c38e8adf52c15f537b80d2483f7jl/*ARGSUSED*/
25cf1a301a396c38e8adf52c15f537b80d2483f7jlint
25cf1a301a396c38e8adf52c15f537b80d2483f7jlplat_cpu_poweron(struct cpu *cp)
25cf1a301a396c38e8adf52c15f537b80d2483f7jl{
25cf1a301a396c38e8adf52c15f537b80d2483f7jl int (*opl_cpu_poweron)(struct cpu *) = NULL;
25cf1a301a396c38e8adf52c15f537b80d2483f7jl
25cf1a301a396c38e8adf52c15f537b80d2483f7jl opl_cpu_poweron =
25cf1a301a396c38e8adf52c15f537b80d2483f7jl (int (*)(struct cpu *))kobj_getsymvalue("drmach_cpu_poweron", 0);
25cf1a301a396c38e8adf52c15f537b80d2483f7jl
25cf1a301a396c38e8adf52c15f537b80d2483f7jl if (opl_cpu_poweron == NULL)
25cf1a301a396c38e8adf52c15f537b80d2483f7jl return (ENOTSUP);
25cf1a301a396c38e8adf52c15f537b80d2483f7jl else
25cf1a301a396c38e8adf52c15f537b80d2483f7jl return ((opl_cpu_poweron)(cp));
25cf1a301a396c38e8adf52c15f537b80d2483f7jl
25cf1a301a396c38e8adf52c15f537b80d2483f7jl}
25cf1a301a396c38e8adf52c15f537b80d2483f7jl
25cf1a301a396c38e8adf52c15f537b80d2483f7jl/*ARGSUSED*/
25cf1a301a396c38e8adf52c15f537b80d2483f7jlint
25cf1a301a396c38e8adf52c15f537b80d2483f7jlplat_cpu_poweroff(struct cpu *cp)
25cf1a301a396c38e8adf52c15f537b80d2483f7jl{
25cf1a301a396c38e8adf52c15f537b80d2483f7jl int (*opl_cpu_poweroff)(struct cpu *) = NULL;
25cf1a301a396c38e8adf52c15f537b80d2483f7jl
25cf1a301a396c38e8adf52c15f537b80d2483f7jl opl_cpu_poweroff =
25cf1a301a396c38e8adf52c15f537b80d2483f7jl (int (*)(struct cpu *))kobj_getsymvalue("drmach_cpu_poweroff", 0);
25cf1a301a396c38e8adf52c15f537b80d2483f7jl
25cf1a301a396c38e8adf52c15f537b80d2483f7jl if (opl_cpu_poweroff == NULL)
25cf1a301a396c38e8adf52c15f537b80d2483f7jl return (ENOTSUP);
25cf1a301a396c38e8adf52c15f537b80d2483f7jl else
25cf1a301a396c38e8adf52c15f537b80d2483f7jl return ((opl_cpu_poweroff)(cp));
25cf1a301a396c38e8adf52c15f537b80d2483f7jl
25cf1a301a396c38e8adf52c15f537b80d2483f7jl}
25cf1a301a396c38e8adf52c15f537b80d2483f7jl
25cf1a301a396c38e8adf52c15f537b80d2483f7jlint
25cf1a301a396c38e8adf52c15f537b80d2483f7jlplat_max_boards(void)
25cf1a301a396c38e8adf52c15f537b80d2483f7jl{
25cf1a301a396c38e8adf52c15f537b80d2483f7jl return (OPL_MAX_BOARDS);
25cf1a301a396c38e8adf52c15f537b80d2483f7jl}
25cf1a301a396c38e8adf52c15f537b80d2483f7jl
25cf1a301a396c38e8adf52c15f537b80d2483f7jlint
25cf1a301a396c38e8adf52c15f537b80d2483f7jlplat_max_cpu_units_per_board(void)
25cf1a301a396c38e8adf52c15f537b80d2483f7jl{
25cf1a301a396c38e8adf52c15f537b80d2483f7jl return (OPL_MAX_CPU_PER_BOARD);
25cf1a301a396c38e8adf52c15f537b80d2483f7jl}
25cf1a301a396c38e8adf52c15f537b80d2483f7jl
25cf1a301a396c38e8adf52c15f537b80d2483f7jlint
25cf1a301a396c38e8adf52c15f537b80d2483f7jlplat_max_mem_units_per_board(void)
25cf1a301a396c38e8adf52c15f537b80d2483f7jl{
25cf1a301a396c38e8adf52c15f537b80d2483f7jl return (OPL_MAX_MEM_UNITS_PER_BOARD);
25cf1a301a396c38e8adf52c15f537b80d2483f7jl}
25cf1a301a396c38e8adf52c15f537b80d2483f7jl
25cf1a301a396c38e8adf52c15f537b80d2483f7jlint
25cf1a301a396c38e8adf52c15f537b80d2483f7jlplat_max_io_units_per_board(void)
25cf1a301a396c38e8adf52c15f537b80d2483f7jl{
25cf1a301a396c38e8adf52c15f537b80d2483f7jl return (OPL_MAX_IO_UNITS_PER_BOARD);
25cf1a301a396c38e8adf52c15f537b80d2483f7jl}
25cf1a301a396c38e8adf52c15f537b80d2483f7jl
25cf1a301a396c38e8adf52c15f537b80d2483f7jlint
25cf1a301a396c38e8adf52c15f537b80d2483f7jlplat_max_cmp_units_per_board(void)
25cf1a301a396c38e8adf52c15f537b80d2483f7jl{
25cf1a301a396c38e8adf52c15f537b80d2483f7jl return (OPL_MAX_CMP_UNITS_PER_BOARD);
25cf1a301a396c38e8adf52c15f537b80d2483f7jl}
25cf1a301a396c38e8adf52c15f537b80d2483f7jl
25cf1a301a396c38e8adf52c15f537b80d2483f7jlint
25cf1a301a396c38e8adf52c15f537b80d2483f7jlplat_max_core_units_per_board(void)
25cf1a301a396c38e8adf52c15f537b80d2483f7jl{
25cf1a301a396c38e8adf52c15f537b80d2483f7jl return (OPL_MAX_CORE_UNITS_PER_BOARD);
25cf1a301a396c38e8adf52c15f537b80d2483f7jl}
25cf1a301a396c38e8adf52c15f537b80d2483f7jl
25cf1a301a396c38e8adf52c15f537b80d2483f7jlint
25cf1a301a396c38e8adf52c15f537b80d2483f7jlplat_pfn_to_mem_node(pfn_t pfn)
25cf1a301a396c38e8adf52c15f537b80d2483f7jl{
25cf1a301a396c38e8adf52c15f537b80d2483f7jl return (pfn >> mem_node_pfn_shift);
25cf1a301a396c38e8adf52c15f537b80d2483f7jl}
25cf1a301a396c38e8adf52c15f537b80d2483f7jl
25cf1a301a396c38e8adf52c15f537b80d2483f7jl/* ARGSUSED */
25cf1a301a396c38e8adf52c15f537b80d2483f7jlvoid
25cf1a301a396c38e8adf52c15f537b80d2483f7jlplat_build_mem_nodes(u_longlong_t *list, size_t nelems)
25cf1a301a396c38e8adf52c15f537b80d2483f7jl{
25cf1a301a396c38e8adf52c15f537b80d2483f7jl size_t elem;
25cf1a301a396c38e8adf52c15f537b80d2483f7jl pfn_t basepfn;
25cf1a301a396c38e8adf52c15f537b80d2483f7jl pgcnt_t npgs;
25cf1a301a396c38e8adf52c15f537b80d2483f7jl uint64_t boundary, ssize;
25cf1a301a396c38e8adf52c15f537b80d2483f7jl uint64_t low, high;
25cf1a301a396c38e8adf52c15f537b80d2483f7jl
25cf1a301a396c38e8adf52c15f537b80d2483f7jl /*
25cf1a301a396c38e8adf52c15f537b80d2483f7jl * OPL mem slices are always aligned on a 256GB boundary.
25cf1a301a396c38e8adf52c15f537b80d2483f7jl */
25cf1a301a396c38e8adf52c15f537b80d2483f7jl mem_node_pfn_shift = OPL_MC_MEMBOARD_SHIFT - MMU_PAGESHIFT;
25cf1a301a396c38e8adf52c15f537b80d2483f7jl mem_node_physalign = 0;
25cf1a301a396c38e8adf52c15f537b80d2483f7jl
25cf1a301a396c38e8adf52c15f537b80d2483f7jl /*
25cf1a301a396c38e8adf52c15f537b80d2483f7jl * Boot install lists are arranged <addr, len>, <addr, len>, ...
25cf1a301a396c38e8adf52c15f537b80d2483f7jl */
25cf1a301a396c38e8adf52c15f537b80d2483f7jl ssize = (1ull << OPL_MC_MEMBOARD_SHIFT);
25cf1a301a396c38e8adf52c15f537b80d2483f7jl for (elem = 0; elem < nelems; elem += 2) {
25cf1a301a396c38e8adf52c15f537b80d2483f7jl low = (uint64_t)list[elem];
25cf1a301a396c38e8adf52c15f537b80d2483f7jl high = low+(uint64_t)(list[elem+1]);
25cf1a301a396c38e8adf52c15f537b80d2483f7jl while (low < high) {
25cf1a301a396c38e8adf52c15f537b80d2483f7jl boundary = roundup(low+1, ssize);
25cf1a301a396c38e8adf52c15f537b80d2483f7jl boundary = MIN(high, boundary);
25cf1a301a396c38e8adf52c15f537b80d2483f7jl basepfn = btop(low);
25cf1a301a396c38e8adf52c15f537b80d2483f7jl npgs = btop(boundary - low);
25cf1a301a396c38e8adf52c15f537b80d2483f7jl mem_node_add_slice(basepfn, basepfn + npgs - 1);
25cf1a301a396c38e8adf52c15f537b80d2483f7jl low = boundary;
25cf1a301a396c38e8adf52c15f537b80d2483f7jl }
25cf1a301a396c38e8adf52c15f537b80d2483f7jl }
25cf1a301a396c38e8adf52c15f537b80d2483f7jl}
25cf1a301a396c38e8adf52c15f537b80d2483f7jl
25cf1a301a396c38e8adf52c15f537b80d2483f7jl/*
25cf1a301a396c38e8adf52c15f537b80d2483f7jl * Find the CPU associated with a slice at boot-time.
25cf1a301a396c38e8adf52c15f537b80d2483f7jl */
25cf1a301a396c38e8adf52c15f537b80d2483f7jlvoid
25cf1a301a396c38e8adf52c15f537b80d2483f7jlplat_fill_mc(pnode_t nodeid)
25cf1a301a396c38e8adf52c15f537b80d2483f7jl{
25cf1a301a396c38e8adf52c15f537b80d2483f7jl int board;
25cf1a301a396c38e8adf52c15f537b80d2483f7jl int memnode;
25cf1a301a396c38e8adf52c15f537b80d2483f7jl struct {
25cf1a301a396c38e8adf52c15f537b80d2483f7jl uint64_t addr;
25cf1a301a396c38e8adf52c15f537b80d2483f7jl uint64_t size;
25cf1a301a396c38e8adf52c15f537b80d2483f7jl } mem_range;
25cf1a301a396c38e8adf52c15f537b80d2483f7jl
25cf1a301a396c38e8adf52c15f537b80d2483f7jl if (prom_getprop(nodeid, "board#", (caddr_t)&board) < 0) {
25cf1a301a396c38e8adf52c15f537b80d2483f7jl panic("Can not find board# property in mc node %x", nodeid);
25cf1a301a396c38e8adf52c15f537b80d2483f7jl }
25cf1a301a396c38e8adf52c15f537b80d2483f7jl if (prom_getprop(nodeid, "sb-mem-ranges", (caddr_t)&mem_range) < 0) {
25cf1a301a396c38e8adf52c15f537b80d2483f7jl panic("Can not find sb-mem-ranges property in mc node %x",
25cf1a301a396c38e8adf52c15f537b80d2483f7jl nodeid);
25cf1a301a396c38e8adf52c15f537b80d2483f7jl }
25cf1a301a396c38e8adf52c15f537b80d2483f7jl memnode = mem_range.addr >> OPL_MC_MEMBOARD_SHIFT;
25cf1a301a396c38e8adf52c15f537b80d2483f7jl plat_assign_lgrphand_to_mem_node(board, memnode);
25cf1a301a396c38e8adf52c15f537b80d2483f7jl}
25cf1a301a396c38e8adf52c15f537b80d2483f7jl
25cf1a301a396c38e8adf52c15f537b80d2483f7jl/*
25cf1a301a396c38e8adf52c15f537b80d2483f7jl * Return the platform handle for the lgroup containing the given CPU
25cf1a301a396c38e8adf52c15f537b80d2483f7jl *
25cf1a301a396c38e8adf52c15f537b80d2483f7jl * For OPL, lgroup platform handle == board #.
25cf1a301a396c38e8adf52c15f537b80d2483f7jl */
25cf1a301a396c38e8adf52c15f537b80d2483f7jl
25cf1a301a396c38e8adf52c15f537b80d2483f7jlextern int mpo_disabled;
25cf1a301a396c38e8adf52c15f537b80d2483f7jlextern lgrp_handle_t lgrp_default_handle;
25cf1a301a396c38e8adf52c15f537b80d2483f7jl
25cf1a301a396c38e8adf52c15f537b80d2483f7jllgrp_handle_t
25cf1a301a396c38e8adf52c15f537b80d2483f7jlplat_lgrp_cpu_to_hand(processorid_t id)
25cf1a301a396c38e8adf52c15f537b80d2483f7jl{
25cf1a301a396c38e8adf52c15f537b80d2483f7jl lgrp_handle_t plathand;
25cf1a301a396c38e8adf52c15f537b80d2483f7jl
25cf1a301a396c38e8adf52c15f537b80d2483f7jl /*
25cf1a301a396c38e8adf52c15f537b80d2483f7jl * Return the real platform handle for the CPU until
25cf1a301a396c38e8adf52c15f537b80d2483f7jl * such time as we know that MPO should be disabled.
25cf1a301a396c38e8adf52c15f537b80d2483f7jl * At that point, we set the "mpo_disabled" flag to true,
25cf1a301a396c38e8adf52c15f537b80d2483f7jl * and from that point on, return the default handle.
25cf1a301a396c38e8adf52c15f537b80d2483f7jl *
25cf1a301a396c38e8adf52c15f537b80d2483f7jl * By the time we know that MPO should be disabled, the
25cf1a301a396c38e8adf52c15f537b80d2483f7jl * first CPU will have already been added to a leaf
25cf1a301a396c38e8adf52c15f537b80d2483f7jl * lgroup, but that's ok. The common lgroup code will
25cf1a301a396c38e8adf52c15f537b80d2483f7jl * double check that the boot CPU is in the correct place,
25cf1a301a396c38e8adf52c15f537b80d2483f7jl * and in the case where mpo should be disabled, will move
25cf1a301a396c38e8adf52c15f537b80d2483f7jl * it to the root if necessary.
25cf1a301a396c38e8adf52c15f537b80d2483f7jl */
25cf1a301a396c38e8adf52c15f537b80d2483f7jl if (mpo_disabled) {
25cf1a301a396c38e8adf52c15f537b80d2483f7jl /* If MPO is disabled, return the default (UMA) handle */
25cf1a301a396c38e8adf52c15f537b80d2483f7jl plathand = lgrp_default_handle;
25cf1a301a396c38e8adf52c15f537b80d2483f7jl } else
25cf1a301a396c38e8adf52c15f537b80d2483f7jl plathand = (lgrp_handle_t)LSB_ID(id);
25cf1a301a396c38e8adf52c15f537b80d2483f7jl return (plathand);
25cf1a301a396c38e8adf52c15f537b80d2483f7jl}
25cf1a301a396c38e8adf52c15f537b80d2483f7jl
25cf1a301a396c38e8adf52c15f537b80d2483f7jl/*
25cf1a301a396c38e8adf52c15f537b80d2483f7jl * Platform specific lgroup initialization
25cf1a301a396c38e8adf52c15f537b80d2483f7jl */
25cf1a301a396c38e8adf52c15f537b80d2483f7jlvoid
25cf1a301a396c38e8adf52c15f537b80d2483f7jlplat_lgrp_init(void)
25cf1a301a396c38e8adf52c15f537b80d2483f7jl{
25cf1a301a396c38e8adf52c15f537b80d2483f7jl extern uint32_t lgrp_expand_proc_thresh;
25cf1a301a396c38e8adf52c15f537b80d2483f7jl extern uint32_t lgrp_expand_proc_diff;
25cf1a301a396c38e8adf52c15f537b80d2483f7jl
25cf1a301a396c38e8adf52c15f537b80d2483f7jl /*
25cf1a301a396c38e8adf52c15f537b80d2483f7jl * Set tuneables for the OPL architecture
25cf1a301a396c38e8adf52c15f537b80d2483f7jl *
25cf1a301a396c38e8adf52c15f537b80d2483f7jl * lgrp_expand_proc_thresh is the minimum load on the lgroups
25cf1a301a396c38e8adf52c15f537b80d2483f7jl * this process is currently running on before considering
25cf1a301a396c38e8adf52c15f537b80d2483f7jl * expanding threads to another lgroup.
25cf1a301a396c38e8adf52c15f537b80d2483f7jl *
25cf1a301a396c38e8adf52c15f537b80d2483f7jl * lgrp_expand_proc_diff determines how much less the remote lgroup
25cf1a301a396c38e8adf52c15f537b80d2483f7jl * must be loaded before expanding to it.
25cf1a301a396c38e8adf52c15f537b80d2483f7jl *
25cf1a301a396c38e8adf52c15f537b80d2483f7jl * Since remote latencies can be costly, attempt to keep 3 threads
25cf1a301a396c38e8adf52c15f537b80d2483f7jl * within the same lgroup before expanding to the next lgroup.
25cf1a301a396c38e8adf52c15f537b80d2483f7jl */
25cf1a301a396c38e8adf52c15f537b80d2483f7jl lgrp_expand_proc_thresh = LGRP_LOADAVG_THREAD_MAX * 3;
25cf1a301a396c38e8adf52c15f537b80d2483f7jl lgrp_expand_proc_diff = LGRP_LOADAVG_THREAD_MAX;
25cf1a301a396c38e8adf52c15f537b80d2483f7jl}
25cf1a301a396c38e8adf52c15f537b80d2483f7jl
25cf1a301a396c38e8adf52c15f537b80d2483f7jl/*
25cf1a301a396c38e8adf52c15f537b80d2483f7jl * Platform notification of lgroup (re)configuration changes
25cf1a301a396c38e8adf52c15f537b80d2483f7jl */
25cf1a301a396c38e8adf52c15f537b80d2483f7jl/*ARGSUSED*/
25cf1a301a396c38e8adf52c15f537b80d2483f7jlvoid
25cf1a301a396c38e8adf52c15f537b80d2483f7jlplat_lgrp_config(lgrp_config_flag_t evt, uintptr_t arg)
25cf1a301a396c38e8adf52c15f537b80d2483f7jl{
25cf1a301a396c38e8adf52c15f537b80d2483f7jl update_membounds_t *umb;
25cf1a301a396c38e8adf52c15f537b80d2483f7jl lgrp_config_mem_rename_t lmr;
25cf1a301a396c38e8adf52c15f537b80d2483f7jl int sbd, tbd;
25cf1a301a396c38e8adf52c15f537b80d2483f7jl lgrp_handle_t hand, shand, thand;
25cf1a301a396c38e8adf52c15f537b80d2483f7jl int mnode, snode, tnode;
25cf1a301a396c38e8adf52c15f537b80d2483f7jl pfn_t start, end;
25cf1a301a396c38e8adf52c15f537b80d2483f7jl
25cf1a301a396c38e8adf52c15f537b80d2483f7jl if (mpo_disabled)
25cf1a301a396c38e8adf52c15f537b80d2483f7jl return;
25cf1a301a396c38e8adf52c15f537b80d2483f7jl
25cf1a301a396c38e8adf52c15f537b80d2483f7jl switch (evt) {
25cf1a301a396c38e8adf52c15f537b80d2483f7jl
25cf1a301a396c38e8adf52c15f537b80d2483f7jl case LGRP_CONFIG_MEM_ADD:
25cf1a301a396c38e8adf52c15f537b80d2483f7jl /*
25cf1a301a396c38e8adf52c15f537b80d2483f7jl * Establish the lgroup handle to memnode translation.
25cf1a301a396c38e8adf52c15f537b80d2483f7jl */
25cf1a301a396c38e8adf52c15f537b80d2483f7jl umb = (update_membounds_t *)arg;
25cf1a301a396c38e8adf52c15f537b80d2483f7jl
25cf1a301a396c38e8adf52c15f537b80d2483f7jl hand = umb->u_board;
25cf1a301a396c38e8adf52c15f537b80d2483f7jl mnode = plat_pfn_to_mem_node(umb->u_base >> MMU_PAGESHIFT);
25cf1a301a396c38e8adf52c15f537b80d2483f7jl plat_assign_lgrphand_to_mem_node(hand, mnode);
25cf1a301a396c38e8adf52c15f537b80d2483f7jl
25cf1a301a396c38e8adf52c15f537b80d2483f7jl break;
25cf1a301a396c38e8adf52c15f537b80d2483f7jl
25cf1a301a396c38e8adf52c15f537b80d2483f7jl case LGRP_CONFIG_MEM_DEL:
25cf1a301a396c38e8adf52c15f537b80d2483f7jl /*
25cf1a301a396c38e8adf52c15f537b80d2483f7jl * Special handling for possible memory holes.
25cf1a301a396c38e8adf52c15f537b80d2483f7jl */
25cf1a301a396c38e8adf52c15f537b80d2483f7jl umb = (update_membounds_t *)arg;
25cf1a301a396c38e8adf52c15f537b80d2483f7jl hand = umb->u_board;
25cf1a301a396c38e8adf52c15f537b80d2483f7jl if ((mnode = plat_lgrphand_to_mem_node(hand)) != -1) {
25cf1a301a396c38e8adf52c15f537b80d2483f7jl if (mem_node_config[mnode].exists) {
25cf1a301a396c38e8adf52c15f537b80d2483f7jl start = mem_node_config[mnode].physbase;
25cf1a301a396c38e8adf52c15f537b80d2483f7jl end = mem_node_config[mnode].physmax;
25cf1a301a396c38e8adf52c15f537b80d2483f7jl mem_node_pre_del_slice(start, end);
25cf1a301a396c38e8adf52c15f537b80d2483f7jl mem_node_post_del_slice(start, end, 0);
25cf1a301a396c38e8adf52c15f537b80d2483f7jl }
25cf1a301a396c38e8adf52c15f537b80d2483f7jl }
25cf1a301a396c38e8adf52c15f537b80d2483f7jl
25cf1a301a396c38e8adf52c15f537b80d2483f7jl break;
25cf1a301a396c38e8adf52c15f537b80d2483f7jl
25cf1a301a396c38e8adf52c15f537b80d2483f7jl case LGRP_CONFIG_MEM_RENAME:
25cf1a301a396c38e8adf52c15f537b80d2483f7jl /*
25cf1a301a396c38e8adf52c15f537b80d2483f7jl * During a DR copy-rename operation, all of the memory
25cf1a301a396c38e8adf52c15f537b80d2483f7jl * on one board is moved to another board -- but the
25cf1a301a396c38e8adf52c15f537b80d2483f7jl * addresses/pfns and memnodes don't change. This means
25cf1a301a396c38e8adf52c15f537b80d2483f7jl * the memory has changed locations without changing identity.
25cf1a301a396c38e8adf52c15f537b80d2483f7jl *
25cf1a301a396c38e8adf52c15f537b80d2483f7jl * Source is where we are copying from and target is where we
25cf1a301a396c38e8adf52c15f537b80d2483f7jl * are copying to. After source memnode is copied to target
25cf1a301a396c38e8adf52c15f537b80d2483f7jl * memnode, the physical addresses of the target memnode are
25cf1a301a396c38e8adf52c15f537b80d2483f7jl * renamed to match what the source memnode had. Then target
25cf1a301a396c38e8adf52c15f537b80d2483f7jl * memnode can be removed and source memnode can take its
25cf1a301a396c38e8adf52c15f537b80d2483f7jl * place.
25cf1a301a396c38e8adf52c15f537b80d2483f7jl *
25cf1a301a396c38e8adf52c15f537b80d2483f7jl * To do this, swap the lgroup handle to memnode mappings for
25cf1a301a396c38e8adf52c15f537b80d2483f7jl * the boards, so target lgroup will have source memnode and
25cf1a301a396c38e8adf52c15f537b80d2483f7jl * source lgroup will have empty target memnode which is where
25cf1a301a396c38e8adf52c15f537b80d2483f7jl * its memory will go (if any is added to it later).
25cf1a301a396c38e8adf52c15f537b80d2483f7jl *
25cf1a301a396c38e8adf52c15f537b80d2483f7jl * Then source memnode needs to be removed from its lgroup
25cf1a301a396c38e8adf52c15f537b80d2483f7jl * and added to the target lgroup where the memory was living
25cf1a301a396c38e8adf52c15f537b80d2483f7jl * but under a different name/memnode. The memory was in the
25cf1a301a396c38e8adf52c15f537b80d2483f7jl * target memnode and now lives in the source memnode with
25cf1a301a396c38e8adf52c15f537b80d2483f7jl * different physical addresses even though it is the same
25cf1a301a396c38e8adf52c15f537b80d2483f7jl * memory.
25cf1a301a396c38e8adf52c15f537b80d2483f7jl */
25cf1a301a396c38e8adf52c15f537b80d2483f7jl sbd = arg & 0xffff;
25cf1a301a396c38e8adf52c15f537b80d2483f7jl tbd = (arg & 0xffff0000) >> 16;
25cf1a301a396c38e8adf52c15f537b80d2483f7jl shand = sbd;
25cf1a301a396c38e8adf52c15f537b80d2483f7jl thand = tbd;
25cf1a301a396c38e8adf52c15f537b80d2483f7jl snode = plat_lgrphand_to_mem_node(shand);
25cf1a301a396c38e8adf52c15f537b80d2483f7jl tnode = plat_lgrphand_to_mem_node(thand);
25cf1a301a396c38e8adf52c15f537b80d2483f7jl
25cf1a301a396c38e8adf52c15f537b80d2483f7jl /*
25cf1a301a396c38e8adf52c15f537b80d2483f7jl * Special handling for possible memory holes.
25cf1a301a396c38e8adf52c15f537b80d2483f7jl */
25cf1a301a396c38e8adf52c15f537b80d2483f7jl if (tnode != -1 && mem_node_config[tnode].exists) {
25cf1a301a396c38e8adf52c15f537b80d2483f7jl start = mem_node_config[mnode].physbase;
25cf1a301a396c38e8adf52c15f537b80d2483f7jl end = mem_node_config[mnode].physmax;
25cf1a301a396c38e8adf52c15f537b80d2483f7jl mem_node_pre_del_slice(start, end);
25cf1a301a396c38e8adf52c15f537b80d2483f7jl mem_node_post_del_slice(start, end, 0);
25cf1a301a396c38e8adf52c15f537b80d2483f7jl }
25cf1a301a396c38e8adf52c15f537b80d2483f7jl
25cf1a301a396c38e8adf52c15f537b80d2483f7jl plat_assign_lgrphand_to_mem_node(thand, snode);
25cf1a301a396c38e8adf52c15f537b80d2483f7jl plat_assign_lgrphand_to_mem_node(shand, tnode);
25cf1a301a396c38e8adf52c15f537b80d2483f7jl
25cf1a301a396c38e8adf52c15f537b80d2483f7jl lmr.lmem_rename_from = shand;
25cf1a301a396c38e8adf52c15f537b80d2483f7jl lmr.lmem_rename_to = thand;
25cf1a301a396c38e8adf52c15f537b80d2483f7jl
25cf1a301a396c38e8adf52c15f537b80d2483f7jl /*
25cf1a301a396c38e8adf52c15f537b80d2483f7jl * Remove source memnode of copy rename from its lgroup
25cf1a301a396c38e8adf52c15f537b80d2483f7jl * and add it to its new target lgroup
25cf1a301a396c38e8adf52c15f537b80d2483f7jl */
25cf1a301a396c38e8adf52c15f537b80d2483f7jl lgrp_config(LGRP_CONFIG_MEM_RENAME, (uintptr_t)snode,
25cf1a301a396c38e8adf52c15f537b80d2483f7jl (uintptr_t)&lmr);
25cf1a301a396c38e8adf52c15f537b80d2483f7jl
25cf1a301a396c38e8adf52c15f537b80d2483f7jl break;
25cf1a301a396c38e8adf52c15f537b80d2483f7jl
25cf1a301a396c38e8adf52c15f537b80d2483f7jl default:
25cf1a301a396c38e8adf52c15f537b80d2483f7jl break;
25cf1a301a396c38e8adf52c15f537b80d2483f7jl }
25cf1a301a396c38e8adf52c15f537b80d2483f7jl}
25cf1a301a396c38e8adf52c15f537b80d2483f7jl
25cf1a301a396c38e8adf52c15f537b80d2483f7jl/*
25cf1a301a396c38e8adf52c15f537b80d2483f7jl * Return latency between "from" and "to" lgroups
25cf1a301a396c38e8adf52c15f537b80d2483f7jl *
25cf1a301a396c38e8adf52c15f537b80d2483f7jl * This latency number can only be used for relative comparison
25cf1a301a396c38e8adf52c15f537b80d2483f7jl * between lgroups on the running system, cannot be used across platforms,
25cf1a301a396c38e8adf52c15f537b80d2483f7jl * and may not reflect the actual latency. It is platform and implementation
25cf1a301a396c38e8adf52c15f537b80d2483f7jl * specific, so platform gets to decide its value. It would be nice if the
25cf1a301a396c38e8adf52c15f537b80d2483f7jl * number was at least proportional to make comparisons more meaningful though.
25cf1a301a396c38e8adf52c15f537b80d2483f7jl * NOTE: The numbers below are supposed to be load latencies for uncached
25cf1a301a396c38e8adf52c15f537b80d2483f7jl * memory divided by 10.
25cf1a301a396c38e8adf52c15f537b80d2483f7jl *
25cf1a301a396c38e8adf52c15f537b80d2483f7jl * XXX latency values for Columbus, not Columbus2. Should be fixed later when
25cf1a301a396c38e8adf52c15f537b80d2483f7jl * we know the actual numbers for Columbus2.
25cf1a301a396c38e8adf52c15f537b80d2483f7jl */
25cf1a301a396c38e8adf52c15f537b80d2483f7jlint
25cf1a301a396c38e8adf52c15f537b80d2483f7jlplat_lgrp_latency(lgrp_handle_t from, lgrp_handle_t to)
25cf1a301a396c38e8adf52c15f537b80d2483f7jl{
25cf1a301a396c38e8adf52c15f537b80d2483f7jl /*
25cf1a301a396c38e8adf52c15f537b80d2483f7jl * Return min remote latency when there are more than two lgroups
25cf1a301a396c38e8adf52c15f537b80d2483f7jl * (root and child) and getting latency between two different lgroups
25cf1a301a396c38e8adf52c15f537b80d2483f7jl * or root is involved
25cf1a301a396c38e8adf52c15f537b80d2483f7jl */
25cf1a301a396c38e8adf52c15f537b80d2483f7jl if (lgrp_optimizations() && (from != to ||
25cf1a301a396c38e8adf52c15f537b80d2483f7jl from == LGRP_DEFAULT_HANDLE || to == LGRP_DEFAULT_HANDLE))
25cf1a301a396c38e8adf52c15f537b80d2483f7jl return (27);
25cf1a301a396c38e8adf52c15f537b80d2483f7jl else
25cf1a301a396c38e8adf52c15f537b80d2483f7jl return (25);
25cf1a301a396c38e8adf52c15f537b80d2483f7jl}
25cf1a301a396c38e8adf52c15f537b80d2483f7jl
25cf1a301a396c38e8adf52c15f537b80d2483f7jl/*
25cf1a301a396c38e8adf52c15f537b80d2483f7jl * Return platform handle for root lgroup
25cf1a301a396c38e8adf52c15f537b80d2483f7jl */
25cf1a301a396c38e8adf52c15f537b80d2483f7jllgrp_handle_t
25cf1a301a396c38e8adf52c15f537b80d2483f7jlplat_lgrp_root_hand(void)
25cf1a301a396c38e8adf52c15f537b80d2483f7jl{
25cf1a301a396c38e8adf52c15f537b80d2483f7jl if (mpo_disabled)
25cf1a301a396c38e8adf52c15f537b80d2483f7jl return (lgrp_default_handle);
25cf1a301a396c38e8adf52c15f537b80d2483f7jl
25cf1a301a396c38e8adf52c15f537b80d2483f7jl return (LGRP_DEFAULT_HANDLE);
25cf1a301a396c38e8adf52c15f537b80d2483f7jl}
25cf1a301a396c38e8adf52c15f537b80d2483f7jl
25cf1a301a396c38e8adf52c15f537b80d2483f7jl/*ARGSUSED*/
25cf1a301a396c38e8adf52c15f537b80d2483f7jlvoid
25cf1a301a396c38e8adf52c15f537b80d2483f7jlplat_freelist_process(int mnode)
25cf1a301a396c38e8adf52c15f537b80d2483f7jl{
25cf1a301a396c38e8adf52c15f537b80d2483f7jl}
25cf1a301a396c38e8adf52c15f537b80d2483f7jl
25cf1a301a396c38e8adf52c15f537b80d2483f7jlvoid
25cf1a301a396c38e8adf52c15f537b80d2483f7jlload_platform_drivers(void)
25cf1a301a396c38e8adf52c15f537b80d2483f7jl{
25cf1a301a396c38e8adf52c15f537b80d2483f7jl (void) i_ddi_attach_pseudo_node("dr");
25cf1a301a396c38e8adf52c15f537b80d2483f7jl}
25cf1a301a396c38e8adf52c15f537b80d2483f7jl
25cf1a301a396c38e8adf52c15f537b80d2483f7jl/*
25cf1a301a396c38e8adf52c15f537b80d2483f7jl * No platform drivers on this platform
25cf1a301a396c38e8adf52c15f537b80d2483f7jl */
25cf1a301a396c38e8adf52c15f537b80d2483f7jlchar *platform_module_list[] = {
25cf1a301a396c38e8adf52c15f537b80d2483f7jl (char *)0
25cf1a301a396c38e8adf52c15f537b80d2483f7jl};
25cf1a301a396c38e8adf52c15f537b80d2483f7jl
25cf1a301a396c38e8adf52c15f537b80d2483f7jl/*ARGSUSED*/
25cf1a301a396c38e8adf52c15f537b80d2483f7jlvoid
25cf1a301a396c38e8adf52c15f537b80d2483f7jlplat_tod_fault(enum tod_fault_type tod_bad)
25cf1a301a396c38e8adf52c15f537b80d2483f7jl{
25cf1a301a396c38e8adf52c15f537b80d2483f7jl}
25cf1a301a396c38e8adf52c15f537b80d2483f7jl
25cf1a301a396c38e8adf52c15f537b80d2483f7jl/*ARGSUSED*/
25cf1a301a396c38e8adf52c15f537b80d2483f7jlvoid
25cf1a301a396c38e8adf52c15f537b80d2483f7jlcpu_sgn_update(ushort_t sgn, uchar_t state, uchar_t sub_state, int cpuid)
25cf1a301a396c38e8adf52c15f537b80d2483f7jl{
25cf1a301a396c38e8adf52c15f537b80d2483f7jl static void (*scf_panic_callback)(int);
25cf1a301a396c38e8adf52c15f537b80d2483f7jl static void (*scf_shutdown_callback)(int);
25cf1a301a396c38e8adf52c15f537b80d2483f7jl
25cf1a301a396c38e8adf52c15f537b80d2483f7jl /*
25cf1a301a396c38e8adf52c15f537b80d2483f7jl * This is for notifing system panic/shutdown to SCF.
25cf1a301a396c38e8adf52c15f537b80d2483f7jl * In case of shutdown and panic, SCF call back
25cf1a301a396c38e8adf52c15f537b80d2483f7jl * function should be called.
25cf1a301a396c38e8adf52c15f537b80d2483f7jl * <SCF call back functions>
25cf1a301a396c38e8adf52c15f537b80d2483f7jl * scf_panic_callb() : panicsys()->panic_quiesce_hw()
25cf1a301a396c38e8adf52c15f537b80d2483f7jl * scf_shutdown_callb(): halt() or power_down() or reboot_machine()
25cf1a301a396c38e8adf52c15f537b80d2483f7jl * cpuid should be -1 and state should be SIGST_EXIT.
25cf1a301a396c38e8adf52c15f537b80d2483f7jl */
25cf1a301a396c38e8adf52c15f537b80d2483f7jl if (state == SIGST_EXIT && cpuid == -1) {
25cf1a301a396c38e8adf52c15f537b80d2483f7jl
25cf1a301a396c38e8adf52c15f537b80d2483f7jl /*
25cf1a301a396c38e8adf52c15f537b80d2483f7jl * find the symbol for the SCF panic callback routine in driver
25cf1a301a396c38e8adf52c15f537b80d2483f7jl */
25cf1a301a396c38e8adf52c15f537b80d2483f7jl if (scf_panic_callback == NULL)
25cf1a301a396c38e8adf52c15f537b80d2483f7jl scf_panic_callback = (void (*)(int))
25cf1a301a396c38e8adf52c15f537b80d2483f7jl modgetsymvalue("scf_panic_callb", 0);
25cf1a301a396c38e8adf52c15f537b80d2483f7jl if (scf_shutdown_callback == NULL)
25cf1a301a396c38e8adf52c15f537b80d2483f7jl scf_shutdown_callback = (void (*)(int))
25cf1a301a396c38e8adf52c15f537b80d2483f7jl modgetsymvalue("scf_shutdown_callb", 0);
25cf1a301a396c38e8adf52c15f537b80d2483f7jl
25cf1a301a396c38e8adf52c15f537b80d2483f7jl switch (sub_state) {
25cf1a301a396c38e8adf52c15f537b80d2483f7jl case SIGSUBST_PANIC:
25cf1a301a396c38e8adf52c15f537b80d2483f7jl if (scf_panic_callback == NULL) {
25cf1a301a396c38e8adf52c15f537b80d2483f7jl cmn_err(CE_NOTE, "!cpu_sgn_update: "
25cf1a301a396c38e8adf52c15f537b80d2483f7jl "scf_panic_callb not found\n");
25cf1a301a396c38e8adf52c15f537b80d2483f7jl return;
25cf1a301a396c38e8adf52c15f537b80d2483f7jl }
25cf1a301a396c38e8adf52c15f537b80d2483f7jl scf_panic_callback(SIGSUBST_PANIC);
25cf1a301a396c38e8adf52c15f537b80d2483f7jl break;
25cf1a301a396c38e8adf52c15f537b80d2483f7jl
25cf1a301a396c38e8adf52c15f537b80d2483f7jl case SIGSUBST_HALT:
25cf1a301a396c38e8adf52c15f537b80d2483f7jl if (scf_shutdown_callback == NULL) {
25cf1a301a396c38e8adf52c15f537b80d2483f7jl cmn_err(CE_NOTE, "!cpu_sgn_update: "
25cf1a301a396c38e8adf52c15f537b80d2483f7jl "scf_shutdown_callb not found\n");
25cf1a301a396c38e8adf52c15f537b80d2483f7jl return;
25cf1a301a396c38e8adf52c15f537b80d2483f7jl }
25cf1a301a396c38e8adf52c15f537b80d2483f7jl scf_shutdown_callback(SIGSUBST_HALT);
25cf1a301a396c38e8adf52c15f537b80d2483f7jl break;
25cf1a301a396c38e8adf52c15f537b80d2483f7jl
25cf1a301a396c38e8adf52c15f537b80d2483f7jl case SIGSUBST_ENVIRON:
25cf1a301a396c38e8adf52c15f537b80d2483f7jl if (scf_shutdown_callback == NULL) {
25cf1a301a396c38e8adf52c15f537b80d2483f7jl cmn_err(CE_NOTE, "!cpu_sgn_update: "
25cf1a301a396c38e8adf52c15f537b80d2483f7jl "scf_shutdown_callb not found\n");
25cf1a301a396c38e8adf52c15f537b80d2483f7jl return;
25cf1a301a396c38e8adf52c15f537b80d2483f7jl }
25cf1a301a396c38e8adf52c15f537b80d2483f7jl scf_shutdown_callback(SIGSUBST_ENVIRON);
25cf1a301a396c38e8adf52c15f537b80d2483f7jl break;
25cf1a301a396c38e8adf52c15f537b80d2483f7jl
25cf1a301a396c38e8adf52c15f537b80d2483f7jl case SIGSUBST_REBOOT:
25cf1a301a396c38e8adf52c15f537b80d2483f7jl if (scf_shutdown_callback == NULL) {
25cf1a301a396c38e8adf52c15f537b80d2483f7jl cmn_err(CE_NOTE, "!cpu_sgn_update: "
25cf1a301a396c38e8adf52c15f537b80d2483f7jl "scf_shutdown_callb not found\n");
25cf1a301a396c38e8adf52c15f537b80d2483f7jl return;
25cf1a301a396c38e8adf52c15f537b80d2483f7jl }
25cf1a301a396c38e8adf52c15f537b80d2483f7jl scf_shutdown_callback(SIGSUBST_REBOOT);
25cf1a301a396c38e8adf52c15f537b80d2483f7jl break;
25cf1a301a396c38e8adf52c15f537b80d2483f7jl }
25cf1a301a396c38e8adf52c15f537b80d2483f7jl }
25cf1a301a396c38e8adf52c15f537b80d2483f7jl}
25cf1a301a396c38e8adf52c15f537b80d2483f7jl
25cf1a301a396c38e8adf52c15f537b80d2483f7jl/*ARGSUSED*/
25cf1a301a396c38e8adf52c15f537b80d2483f7jlint
25cf1a301a396c38e8adf52c15f537b80d2483f7jlplat_get_mem_unum(int synd_code, uint64_t flt_addr, int flt_bus_id,
25cf1a301a396c38e8adf52c15f537b80d2483f7jl int flt_in_memory, ushort_t flt_status,
25cf1a301a396c38e8adf52c15f537b80d2483f7jl char *buf, int buflen, int *lenp)
25cf1a301a396c38e8adf52c15f537b80d2483f7jl{
25cf1a301a396c38e8adf52c15f537b80d2483f7jl /*
25cf1a301a396c38e8adf52c15f537b80d2483f7jl * check if it's a Memory error.
25cf1a301a396c38e8adf52c15f537b80d2483f7jl */
25cf1a301a396c38e8adf52c15f537b80d2483f7jl if (flt_in_memory) {
25cf1a301a396c38e8adf52c15f537b80d2483f7jl if (opl_get_mem_unum != NULL) {
25cf1a301a396c38e8adf52c15f537b80d2483f7jl return (opl_get_mem_unum(synd_code, flt_addr,
25cf1a301a396c38e8adf52c15f537b80d2483f7jl buf, buflen, lenp));
25cf1a301a396c38e8adf52c15f537b80d2483f7jl } else {
25cf1a301a396c38e8adf52c15f537b80d2483f7jl return (ENOTSUP);
25cf1a301a396c38e8adf52c15f537b80d2483f7jl }
25cf1a301a396c38e8adf52c15f537b80d2483f7jl } else {
25cf1a301a396c38e8adf52c15f537b80d2483f7jl return (ENOTSUP);
25cf1a301a396c38e8adf52c15f537b80d2483f7jl }
25cf1a301a396c38e8adf52c15f537b80d2483f7jl}
25cf1a301a396c38e8adf52c15f537b80d2483f7jl
25cf1a301a396c38e8adf52c15f537b80d2483f7jl/*ARGSUSED*/
25cf1a301a396c38e8adf52c15f537b80d2483f7jlint
25cf1a301a396c38e8adf52c15f537b80d2483f7jlplat_get_cpu_unum(int cpuid, char *buf, int buflen, int *lenp)
25cf1a301a396c38e8adf52c15f537b80d2483f7jl{
0cc8ae8667155d352d327b5c92b62899a7e05bcdav int plen;
0cc8ae8667155d352d327b5c92b62899a7e05bcdav int ret = 0;
0cc8ae8667155d352d327b5c92b62899a7e05bcdav char model[20];
0cc8ae8667155d352d327b5c92b62899a7e05bcdav uint_t sb;
0cc8ae8667155d352d327b5c92b62899a7e05bcdav pnode_t node;
0cc8ae8667155d352d327b5c92b62899a7e05bcdav
0cc8ae8667155d352d327b5c92b62899a7e05bcdav /* determine the platform model once */
0cc8ae8667155d352d327b5c92b62899a7e05bcdav if (plat_model == -1) {
0cc8ae8667155d352d327b5c92b62899a7e05bcdav plat_model = MODEL_DC; /* Default model */
0cc8ae8667155d352d327b5c92b62899a7e05bcdav node = prom_rootnode();
0cc8ae8667155d352d327b5c92b62899a7e05bcdav plen = prom_getproplen(node, "model");
0cc8ae8667155d352d327b5c92b62899a7e05bcdav if (plen > 0 && plen < sizeof (model)) {
0cc8ae8667155d352d327b5c92b62899a7e05bcdav (void) prom_getprop(node, "model", model);
0cc8ae8667155d352d327b5c92b62899a7e05bcdav model[plen] = '\0';
0cc8ae8667155d352d327b5c92b62899a7e05bcdav if (strcmp(model, "FF1") == 0)
0cc8ae8667155d352d327b5c92b62899a7e05bcdav plat_model = MODEL_FF1;
0cc8ae8667155d352d327b5c92b62899a7e05bcdav else if (strcmp(model, "FF2") == 0)
0cc8ae8667155d352d327b5c92b62899a7e05bcdav plat_model = MODEL_FF2;
0cc8ae8667155d352d327b5c92b62899a7e05bcdav else if (strncmp(model, "DC", 2) == 0)
0cc8ae8667155d352d327b5c92b62899a7e05bcdav plat_model = MODEL_DC;
0cc8ae8667155d352d327b5c92b62899a7e05bcdav }
0cc8ae8667155d352d327b5c92b62899a7e05bcdav }
25cf1a301a396c38e8adf52c15f537b80d2483f7jl
25cf1a301a396c38e8adf52c15f537b80d2483f7jl sb = opl_get_physical_board(LSB_ID(cpuid));
25cf1a301a396c38e8adf52c15f537b80d2483f7jl if (sb == -1) {
25cf1a301a396c38e8adf52c15f537b80d2483f7jl return (ENXIO);
25cf1a301a396c38e8adf52c15f537b80d2483f7jl }
25cf1a301a396c38e8adf52c15f537b80d2483f7jl
0cc8ae8667155d352d327b5c92b62899a7e05bcdav switch (plat_model) {
0cc8ae8667155d352d327b5c92b62899a7e05bcdav case MODEL_FF1:
0cc8ae8667155d352d327b5c92b62899a7e05bcdav plen = snprintf(buf, buflen, "/%s/CPUM%d", "MBU_A",
0cc8ae8667155d352d327b5c92b62899a7e05bcdav CHIP_ID(cpuid) / 2);
0cc8ae8667155d352d327b5c92b62899a7e05bcdav break;
0cc8ae8667155d352d327b5c92b62899a7e05bcdav
0cc8ae8667155d352d327b5c92b62899a7e05bcdav case MODEL_FF2:
0cc8ae8667155d352d327b5c92b62899a7e05bcdav plen = snprintf(buf, buflen, "/%s/CPUM%d", "MBU_B",
0cc8ae8667155d352d327b5c92b62899a7e05bcdav CHIP_ID(cpuid) / 2);
0cc8ae8667155d352d327b5c92b62899a7e05bcdav break;
0cc8ae8667155d352d327b5c92b62899a7e05bcdav
0cc8ae8667155d352d327b5c92b62899a7e05bcdav case MODEL_DC:
0cc8ae8667155d352d327b5c92b62899a7e05bcdav plen = snprintf(buf, buflen, "/%s%02d/CPUM%d", "CMU", sb,
0cc8ae8667155d352d327b5c92b62899a7e05bcdav CHIP_ID(cpuid));
0cc8ae8667155d352d327b5c92b62899a7e05bcdav break;
0cc8ae8667155d352d327b5c92b62899a7e05bcdav
0cc8ae8667155d352d327b5c92b62899a7e05bcdav default:
0cc8ae8667155d352d327b5c92b62899a7e05bcdav /* This should never happen */
0cc8ae8667155d352d327b5c92b62899a7e05bcdav return (ENODEV);
0cc8ae8667155d352d327b5c92b62899a7e05bcdav }
0cc8ae8667155d352d327b5c92b62899a7e05bcdav
0cc8ae8667155d352d327b5c92b62899a7e05bcdav if (plen >= buflen) {
0cc8ae8667155d352d327b5c92b62899a7e05bcdav ret = ENOSPC;
25cf1a301a396c38e8adf52c15f537b80d2483f7jl } else {
25cf1a301a396c38e8adf52c15f537b80d2483f7jl if (lenp)
25cf1a301a396c38e8adf52c15f537b80d2483f7jl *lenp = strlen(buf);
25cf1a301a396c38e8adf52c15f537b80d2483f7jl }
0cc8ae8667155d352d327b5c92b62899a7e05bcdav return (ret);
25cf1a301a396c38e8adf52c15f537b80d2483f7jl}
25cf1a301a396c38e8adf52c15f537b80d2483f7jl
25cf1a301a396c38e8adf52c15f537b80d2483f7jl#define SCF_PUTINFO(f, s, p) \
25cf1a301a396c38e8adf52c15f537b80d2483f7jl f(KEY_ESCF, 0x01, 0, s, p)
25cf1a301a396c38e8adf52c15f537b80d2483f7jlvoid
25cf1a301a396c38e8adf52c15f537b80d2483f7jlplat_nodename_set(void)
25cf1a301a396c38e8adf52c15f537b80d2483f7jl{
25cf1a301a396c38e8adf52c15f537b80d2483f7jl void *datap;
25cf1a301a396c38e8adf52c15f537b80d2483f7jl static int (*scf_service_function)(uint32_t, uint8_t,
25cf1a301a396c38e8adf52c15f537b80d2483f7jl uint32_t, uint32_t, void *);
25cf1a301a396c38e8adf52c15f537b80d2483f7jl int counter = 5;
25cf1a301a396c38e8adf52c15f537b80d2483f7jl
25cf1a301a396c38e8adf52c15f537b80d2483f7jl /*
25cf1a301a396c38e8adf52c15f537b80d2483f7jl * find the symbol for the SCF put routine in driver
25cf1a301a396c38e8adf52c15f537b80d2483f7jl */
25cf1a301a396c38e8adf52c15f537b80d2483f7jl if (scf_service_function == NULL)
25cf1a301a396c38e8adf52c15f537b80d2483f7jl scf_service_function =
25cf1a301a396c38e8adf52c15f537b80d2483f7jl (int (*)(uint32_t, uint8_t, uint32_t, uint32_t, void *))
25cf1a301a396c38e8adf52c15f537b80d2483f7jl modgetsymvalue("scf_service_putinfo", 0);
25cf1a301a396c38e8adf52c15f537b80d2483f7jl
25cf1a301a396c38e8adf52c15f537b80d2483f7jl /*
25cf1a301a396c38e8adf52c15f537b80d2483f7jl * If the symbol was found, call it. Otherwise, log a note (but not to
25cf1a301a396c38e8adf52c15f537b80d2483f7jl * the console).
25cf1a301a396c38e8adf52c15f537b80d2483f7jl */
25cf1a301a396c38e8adf52c15f537b80d2483f7jl
25cf1a301a396c38e8adf52c15f537b80d2483f7jl if (scf_service_function == NULL) {
25cf1a301a396c38e8adf52c15f537b80d2483f7jl cmn_err(CE_NOTE,
25cf1a301a396c38e8adf52c15f537b80d2483f7jl "!plat_nodename_set: scf_service_putinfo not found\n");
25cf1a301a396c38e8adf52c15f537b80d2483f7jl return;
25cf1a301a396c38e8adf52c15f537b80d2483f7jl }
25cf1a301a396c38e8adf52c15f537b80d2483f7jl
25cf1a301a396c38e8adf52c15f537b80d2483f7jl datap =
25cf1a301a396c38e8adf52c15f537b80d2483f7jl (struct utsname *)kmem_zalloc(sizeof (struct utsname), KM_SLEEP);
25cf1a301a396c38e8adf52c15f537b80d2483f7jl
25cf1a301a396c38e8adf52c15f537b80d2483f7jl if (datap == NULL) {
25cf1a301a396c38e8adf52c15f537b80d2483f7jl return;
25cf1a301a396c38e8adf52c15f537b80d2483f7jl }
25cf1a301a396c38e8adf52c15f537b80d2483f7jl
25cf1a301a396c38e8adf52c15f537b80d2483f7jl bcopy((struct utsname *)&utsname,
25cf1a301a396c38e8adf52c15f537b80d2483f7jl (struct utsname *)datap, sizeof (struct utsname));
25cf1a301a396c38e8adf52c15f537b80d2483f7jl
25cf1a301a396c38e8adf52c15f537b80d2483f7jl while ((SCF_PUTINFO(scf_service_function,
25cf1a301a396c38e8adf52c15f537b80d2483f7jl sizeof (struct utsname), datap) == EBUSY) && (counter-- > 0)) {
25cf1a301a396c38e8adf52c15f537b80d2483f7jl delay(10 * drv_usectohz(1000000));
25cf1a301a396c38e8adf52c15f537b80d2483f7jl }
25cf1a301a396c38e8adf52c15f537b80d2483f7jl if (counter == 0)
25cf1a301a396c38e8adf52c15f537b80d2483f7jl cmn_err(CE_NOTE,
25cf1a301a396c38e8adf52c15f537b80d2483f7jl "!plat_nodename_set: "
25cf1a301a396c38e8adf52c15f537b80d2483f7jl "scf_service_putinfo not responding\n");
25cf1a301a396c38e8adf52c15f537b80d2483f7jl
25cf1a301a396c38e8adf52c15f537b80d2483f7jl kmem_free(datap, sizeof (struct utsname));
25cf1a301a396c38e8adf52c15f537b80d2483f7jl}
25cf1a301a396c38e8adf52c15f537b80d2483f7jl
25cf1a301a396c38e8adf52c15f537b80d2483f7jlcaddr_t efcode_vaddr = NULL;
25cf1a301a396c38e8adf52c15f537b80d2483f7jl
25cf1a301a396c38e8adf52c15f537b80d2483f7jl/*
25cf1a301a396c38e8adf52c15f537b80d2483f7jl * Preallocate enough memory for fcode claims.
25cf1a301a396c38e8adf52c15f537b80d2483f7jl */
25cf1a301a396c38e8adf52c15f537b80d2483f7jl
25cf1a301a396c38e8adf52c15f537b80d2483f7jlcaddr_t
25cf1a301a396c38e8adf52c15f537b80d2483f7jlefcode_alloc(caddr_t alloc_base)
25cf1a301a396c38e8adf52c15f537b80d2483f7jl{
25cf1a301a396c38e8adf52c15f537b80d2483f7jl caddr_t efcode_alloc_base = (caddr_t)roundup((uintptr_t)alloc_base,
25cf1a301a396c38e8adf52c15f537b80d2483f7jl MMU_PAGESIZE);
25cf1a301a396c38e8adf52c15f537b80d2483f7jl caddr_t vaddr;
25cf1a301a396c38e8adf52c15f537b80d2483f7jl
25cf1a301a396c38e8adf52c15f537b80d2483f7jl /*
25cf1a301a396c38e8adf52c15f537b80d2483f7jl * allocate the physical memory for the Oberon fcode.
25cf1a301a396c38e8adf52c15f537b80d2483f7jl */
25cf1a301a396c38e8adf52c15f537b80d2483f7jl if ((vaddr = (caddr_t)BOP_ALLOC(bootops, efcode_alloc_base,
25cf1a301a396c38e8adf52c15f537b80d2483f7jl efcode_size, MMU_PAGESIZE)) == NULL)
25cf1a301a396c38e8adf52c15f537b80d2483f7jl cmn_err(CE_PANIC, "Cannot allocate Efcode Memory");
25cf1a301a396c38e8adf52c15f537b80d2483f7jl
25cf1a301a396c38e8adf52c15f537b80d2483f7jl efcode_vaddr = vaddr;
25cf1a301a396c38e8adf52c15f537b80d2483f7jl
25cf1a301a396c38e8adf52c15f537b80d2483f7jl return (efcode_alloc_base + efcode_size);
25cf1a301a396c38e8adf52c15f537b80d2483f7jl}
25cf1a301a396c38e8adf52c15f537b80d2483f7jl
25cf1a301a396c38e8adf52c15f537b80d2483f7jlcaddr_t
25cf1a301a396c38e8adf52c15f537b80d2483f7jlplat_startup_memlist(caddr_t alloc_base)
25cf1a301a396c38e8adf52c15f537b80d2483f7jl{
25cf1a301a396c38e8adf52c15f537b80d2483f7jl caddr_t tmp_alloc_base;
25cf1a301a396c38e8adf52c15f537b80d2483f7jl
25cf1a301a396c38e8adf52c15f537b80d2483f7jl tmp_alloc_base = efcode_alloc(alloc_base);
25cf1a301a396c38e8adf52c15f537b80d2483f7jl tmp_alloc_base =
25cf1a301a396c38e8adf52c15f537b80d2483f7jl (caddr_t)roundup((uintptr_t)tmp_alloc_base, ecache_alignsize);
25cf1a301a396c38e8adf52c15f537b80d2483f7jl return (tmp_alloc_base);
25cf1a301a396c38e8adf52c15f537b80d2483f7jl}
25cf1a301a396c38e8adf52c15f537b80d2483f7jl
25cf1a301a396c38e8adf52c15f537b80d2483f7jlvoid
25cf1a301a396c38e8adf52c15f537b80d2483f7jlstartup_platform(void)
25cf1a301a396c38e8adf52c15f537b80d2483f7jl{
25cf1a301a396c38e8adf52c15f537b80d2483f7jl}
0cc8ae8667155d352d327b5c92b62899a7e05bcdav
1e2e7a75ddb1eedcefa449ce98fd5862749b72eehuahvoid
1e2e7a75ddb1eedcefa449ce98fd5862749b72eehuahplat_cpuid_to_mmu_ctx_info(processorid_t cpuid, mmu_ctx_info_t *info)
1e2e7a75ddb1eedcefa449ce98fd5862749b72eehuah{
1e2e7a75ddb1eedcefa449ce98fd5862749b72eehuah int impl;
1e2e7a75ddb1eedcefa449ce98fd5862749b72eehuah
1e2e7a75ddb1eedcefa449ce98fd5862749b72eehuah impl = cpunodes[cpuid].implementation;
1e2e7a75ddb1eedcefa449ce98fd5862749b72eehuah if (IS_OLYMPUS_C(impl)) {
31f6f5ee98526c6119cd0a39fb1ace69897209famv info->mmu_idx = MMU_ID(cpuid);
1e2e7a75ddb1eedcefa449ce98fd5862749b72eehuah info->mmu_nctxs = 8192;
1e2e7a75ddb1eedcefa449ce98fd5862749b72eehuah } else {
1e2e7a75ddb1eedcefa449ce98fd5862749b72eehuah cmn_err(CE_PANIC, "Unknown processor %d", impl);
1e2e7a75ddb1eedcefa449ce98fd5862749b72eehuah }
1e2e7a75ddb1eedcefa449ce98fd5862749b72eehuah}
1e2e7a75ddb1eedcefa449ce98fd5862749b72eehuah
0cc8ae8667155d352d327b5c92b62899a7e05bcdavint
0cc8ae8667155d352d327b5c92b62899a7e05bcdavplat_get_mem_sid(char *unum, char *buf, int buflen, int *lenp)
0cc8ae8667155d352d327b5c92b62899a7e05bcdav{
0cc8ae8667155d352d327b5c92b62899a7e05bcdav if (opl_get_mem_sid == NULL) {
0cc8ae8667155d352d327b5c92b62899a7e05bcdav return (ENOTSUP);
0cc8ae8667155d352d327b5c92b62899a7e05bcdav }
0cc8ae8667155d352d327b5c92b62899a7e05bcdav return (opl_get_mem_sid(unum, buf, buflen, lenp));
0cc8ae8667155d352d327b5c92b62899a7e05bcdav}
0cc8ae8667155d352d327b5c92b62899a7e05bcdav
0cc8ae8667155d352d327b5c92b62899a7e05bcdavint
0cc8ae8667155d352d327b5c92b62899a7e05bcdavplat_get_mem_offset(uint64_t paddr, uint64_t *offp)
0cc8ae8667155d352d327b5c92b62899a7e05bcdav{
0cc8ae8667155d352d327b5c92b62899a7e05bcdav if (opl_get_mem_offset == NULL) {
0cc8ae8667155d352d327b5c92b62899a7e05bcdav return (ENOTSUP);
0cc8ae8667155d352d327b5c92b62899a7e05bcdav }
0cc8ae8667155d352d327b5c92b62899a7e05bcdav return (opl_get_mem_offset(paddr, offp));
0cc8ae8667155d352d327b5c92b62899a7e05bcdav}
0cc8ae8667155d352d327b5c92b62899a7e05bcdav
0cc8ae8667155d352d327b5c92b62899a7e05bcdavint
0cc8ae8667155d352d327b5c92b62899a7e05bcdavplat_get_mem_addr(char *unum, char *sid, uint64_t offset, uint64_t *addrp)
0cc8ae8667155d352d327b5c92b62899a7e05bcdav{
0cc8ae8667155d352d327b5c92b62899a7e05bcdav if (opl_get_mem_addr == NULL) {
0cc8ae8667155d352d327b5c92b62899a7e05bcdav return (ENOTSUP);
0cc8ae8667155d352d327b5c92b62899a7e05bcdav }
0cc8ae8667155d352d327b5c92b62899a7e05bcdav return (opl_get_mem_addr(unum, sid, offset, addrp));
0cc8ae8667155d352d327b5c92b62899a7e05bcdav}