/*
* 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 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <sys/ddi_impldefs.h>
#include <sys/sysmacros.h>
#include <sys/machsystm.h>
#include <sys/machparam.h>
#include <sys/cpu_module.h>
#include <vm/seg_kmem.h>
#include <vm/hat_sfmmu.h>
#include <sys/mem_config.h>
#include <sys/mem_cage.h>
extern ac_err_t ac_kpm_err_cvt(int);
int ac_del_clean = 0;
/*
* Default timeout, in seconds, for delete.
* Time is counted when no progress is being made.
*/
struct del_status {
volatile int its_done;
int done_error;
int del_timeout;
int del_noprogress;
};
static struct del_status *
{
ac_del_list = dsp;
return (dsp);
}
static void
{
dspp = &ac_del_list;
break;
}
}
}
static void
{
#ifdef DEBUG
{
break;
}
}
#endif /* DEBUG */
}
/*ARGSUSED*/
static void
{
int do_cancel;
int err;
#ifdef DEBUG
{
break;
}
}
#endif /* DEBUG */
do_cancel = 0;
return;
}
dsp->del_noprogress = 0;
} else {
dsp->del_noprogress++;
if (dsp->cancel_code == 0)
do_cancel = 1;
}
}
if (!do_cancel)
else
if (do_cancel)
}
static void
{
if (dsp->del_timeout != 0)
}
static void
{
}
}
static int
{
int errs;
int ret;
/*
* Cannot delete interleaved banks at the moment.
*/
if (ilv != 1) {
return (EINVAL);
}
/*
* Determine the physical location of the selected bank
*/
/*
* Delete the pages from the cage growth list.
*/
if (ret != 0) {
/* TODO: Should this be a separate error? */
return (EINVAL);
}
/*
* Add to delete memory list.
*/
/*
* Restore the pages to the cage growth list.
* TODO: We should not unconditionally add back
* if we conditionally add at memory add time.
*/
/* TODO: deal with error return. */
if (errs != 0) {
"board %d, bank %d, "
"kcage_range_add() returned %d",
}
return (EINVAL);
}
return (0);
}
static void
enum ac_bank_id bank)
{
int errs;
/*
* Determine the physical location of the selected bank
*/
/*
* Restore the pages to the cage growth list.
* TODO: We should not unconditionally add back
* if we conditionally add at memory add time.
*/
/* TODO: deal with error return. */
if (errs != 0)
"board %d, bank %d, "
"kcage_range_add() returned %d",
}
static int
{
int errs;
KPHYSM_OK) {
return (EINVAL);
}
/* Wait for it to complete. */
if (dsp->cancel_code == 0)
}
break;
}
}
/*
* If the loop exited due to a signal, we must continue to wait
* using cv_wait() as the signal is pending until syscall exit.
*/
}
if (dsp->cancel_code != 0) {
}
} else {
}
} else
errs = 0;
return (errs);
}
/*
* set the memory to known state for debugging
*/
static void
{
int linesize;
/*
* Determine the physical location of the selected bank
*/
/*
* We need a page_va and a fill buffer for this operation
*/
{
patt = 0xbeaddeed;
}
/*
* 'empty' the memory
*/
current_pa += DEL_PAGESIZE) {
/* map current pa */
/* fill the target page */
/* tear down translation */
}
/*
* clean up temporary resources
*/
{
/* Distinguish the fill buf from memory deleted! */
patt = 0xbeadfeed;
}
}
int
{
int busy_set;
int retval;
int r_errs;
if (!kcage_on) {
static int cage_msg_done = 0;
if (!cage_msg_done) {
cage_msg_done = 1;
" refused: cage is off");
}
return (EINVAL);
}
dsp = ac_del_alloc_status();
return (EINVAL);
}
retval = 0;
busy_set = 0;
goto out;
}
/* verify the board is of the correct type */
case CPU_BOARD:
case MEM_BOARD:
break;
default:
goto out;
}
/* verify the memory condition is acceptable */
goto out;
}
/*
* at this point, we have an available bank to del.
* mark it busy and initiate the del function.
*/
busy_set = 1;
out:
if (retval != 0) {
if (busy_set) {
}
return (retval);
}
if (retval == 0) {
if (ac_del_clean) {
/* DEBUG - set memory to known state */
}
} else {
/*
* Restore the pages to the cage growth list.
*/
}
return (retval);
}