/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#include <sys/promif_impl.h>
#include <sys/machsystm.h>
#include <sys/prom_plat.h>
#include <sys/hypervisor_api.h>
#include <sys/mach_descrip.h>
#include <sys/cpu_module.h>
#include <vm/seg_kmem.h>
#ifndef _KMDB
#include <vm/hat_sfmmu.h>
#include <sys/memlist_impl.h>
int cif_cpu_mp_ready;
extern struct memlist *phys_avail;
extern void kdi_tlb_page_unlock(caddr_t, int);
((a) >= OFW_PT_START_ADDR && (a) <= OFW_PT_END_ADDR))
#endif
#ifdef DEBUG
int prom_free_debug;
#else
#endif
extern int (*cif_handler)(void *);
typedef struct {
char *name;
{ "getprop", promif_getprop },
{ "getproplen", promif_getproplen },
{ "nextprop", promif_nextprop },
{ "peer", promif_nextnode },
{ "child", promif_childnode },
{ "parent", promif_parentnode },
{ "enter", promif_enter_mon },
{ "exit", promif_exit_to_mon },
{ "boot", promif_reboot },
{ "write", promif_write },
{ "read", promif_read },
{ "interpret", promif_interpret },
{ "finddevice", promif_finddevice },
{ "instance-to-package", promif_instance_to_package },
#ifndef _KMDB
{ "setprop", promif_setprop },
{ "test", promif_test },
{ "instance-to-path", promif_instance_to_path },
{ "SUNW,power-off", promif_power_off },
{ "SUNW,asr-list-keys-len", promif_asr_list_keys_len },
{ "SUNW,asr-list-keys", promif_asr_list_keys },
{ "SUNW,asr-export-len", promif_asr_export_len },
{ "SUNW,asr-export", promif_asr_export },
{ "SUNW,set-security-key", promif_set_security_key },
{ "SUNW,get-security-key", promif_get_security_key },
{ "SUNW,start-cpu-by-cpuid", promif_start_cpu },
{ "SUNW,set-trap-table", promif_set_mmfsa_traptable },
{ "SUNW,set-sun4v-api-version", promif_set_sun4v_api_version },
{ "SUNW,get-sun4v-api-version", promif_get_sun4v_api_version },
#endif
};
{
return (NULL);
break;
}
}
static int
kern_cif_handler(void *p)
{
char *opname;
int rv;
#ifndef _KMDB
cif_cpu = getprocessorid();
#endif
/* lookup the callback for the desired operation */
#ifdef _KMDB
prom_fatal_error("sun4v unsupported CIFs\n");
#else
return (-1);
#endif
}
/* callback found, execute it */
#ifndef _KMDB
cif_cpu = -1;
#endif
return (rv);
}
#ifdef _KMDB
void
{
/* initialize pointer to a copy of OBP device tree */
/* initialize io parameters */
/*
* Switch CIF handler to the kernel.
*/
else
}
#else
static struct translation *
{
*ntransp = 0;
/*
* the "translations" property is associated with the mmu node
*/
PMFREE_DEBUG("no mmu ihandle");
return (NULL);
}
PMFREE_DEBUG("no mmu node");
return (NULL);
}
PMFREE_DEBUG("no translations property");
return (NULL);
}
PMFREE_DEBUG("translations getprop failed");
return (NULL);
}
return (transroot);
}
static void
{
int i, j, rv;
char *p;
/*
* During startup isa_list is allocated in OBP address space
* so it needs to be re-allocated in kernel address space
* before OBP memory is unmapped.
*
* see cpu_setup_common().
*/
isa_list = p;
nfreed = 0;
nunmapped = 0;
nskipped = 0;
nskipped_io = 0;
nskipped++;
continue;
}
if (npgs > 1) {
PMFREE_DEBUG("large trans vaddr=0x%lx, npgs=%d\n",
}
for (j = 0; j < npgs; j++) {
if (pfn == PFN_INVALID) {
"no mapping for vaddr=0x%lx (opfn=0x%lx)\n",
break;
}
/*
* Unload the current mapping for the pfn and
* if it is the last mapping for a memory page,
* free the page.
*/
if (pf_is_memory(pfn)) {
PMFREE_DEBUG(" skip\n");
} else {
page_destroy(pp, 0);
PAGESIZE, &phys_avail);
PMFREE_DEBUG(" free\n");
nfreed++;
}
} else {
nskipped_io++;
PMFREE_DEBUG(" skip IO\n");
}
nunmapped++;
}
}
if (transroot) {
"nunmapped=%d nfreed=%d nskipped=%d nskipped_io=%d\n",
}
/*
* Unload OBP permanent mappings.
*/
KCONTEXT);
}
static void cache_prom_data(void);
/*
* This function returns 1 if the current thread is executing in
* the CIF and 0 otherwise. This is useful information to know
* since code that implements CIF handlers can assume that it has
* gone through the kern_preprom() entry point, implying it is
* running single threaded, has preemption disabled, etc.
*/
int
promif_in_cif(void)
{
}
/*
* Check that all cpus in the MD are within range (< NCPU). Attempt
* to stop any that aren't.
*/
static void
cif_check_cpus(void)
{
int i;
int num_nodes;
int status;
mdp = md_get_handle();
if (num_nodes <= 0)
goto done;
for (i = 0; i < num_nodes; i++) {
"CPU instance %d has no 'id' property", i);
continue;
}
}
}
done:
(void) md_fini_handle(mdp);
}
void
cif_init(void)
{
void (*kmdb_cb)(void);
/*
* Check if domaining is enabled. If not, do not
* initialize the kernel CIF handler.
*/
if (!domaining_enabled())
return;
/*
* Cache PROM data that is needed later, e.g. a shadow
* copy of the device tree, IO mappings, etc.
*/
/*
*/
/*
* Switch CIF handler to the kernel.
*/
/*
* Take over rtba for the boot CPU. The rtba for
* all other CPUs are set as they enter the system.
*/
/*
* If the system has been booted with kmdb we need kmdb to
* use the kernel cif handler instead of the PROM cif handler.
*/
"kctl_switch_promif");
(*kmdb_cb)();
}
}
static void
cache_prom_data(void)
{
/* initialize copy of OBP device tree */
/* initialize io parameters */
}
#endif /* _KMDB */