cmd_ecache.c revision 822fb41d6f36e90a1ec836b32f869e1235e7da40
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (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 2004 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* E-cache flushing
*
* Prior to clearing the UE cache, the CPU state code needs to ensure that the
* CPU's E-cache has been flushed. The flushing is handled by the routines in
* in this file, which use the memory controller (mc) driver to perform the
* flush.
*
* Matters are complicated by the fact that there isn't a well-known device name
* for driver access - we have to hunt around for one. Furthermore, the minor
* nodes that are created correspond to individual memory controllers, and as
* such can change during a DR. We'll search for a memory controller device
* during initialization just to make sure that we can do E$ flushing on this
* platform, but we're also able to rescan if the device we found suddenly
* disappears.
*/
#include <cmd_ecache.h>
#include <cmd.h>
#include <string.h>
#include <fcntl.h>
#include <unistd.h>
#include <errno.h>
#include <dirent.h>
static int
{
char path[MAXPATHLEN];
return (-1); /* errno is set for us */
struct mc_ctrlconf mcc;
int fd;
continue;
continue;
continue;
}
return (cmd_set_errno(ENOSPC));
return (0);
}
return (cmd_set_errno(ENOENT));
}
static int
{
/*
* Yet more platform-specific hackery. It's possible that the
* able to use any of them. As a fallback, therefore, we're
* going to search a couple of well-known locations in /devices.
*/
dir = "/devices";
}
return (0);
}
int
cmd_ecache_init(void)
{
sizeof (cmd.cmd_ecache_dev)));
}
int
cmd_ecache_flush(int cpuid)
{
int fd;
return (-1); /* errno is set for us */
/*
* A DR may have occurred, thus rendering our path invalid.
* Try once to find another one.
*/
if (cmd_ecache_init() < 0 ||
return (-1); /* errno is set for us */
}
return (cmd_set_errno(oserr));
}
return (0);
}