/*
* 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/processor.h>
#include <unistd.h>
#include <dirent.h>
#include <fcntl.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
#include <errno.h>
#include <syslog.h>
#include <time.h>
#include <ctype.h>
#include <assert.h>
#include <libgen.h>
#include <locale.h>
#include <libintl.h>
static char *cmdname;
static int ucode_debug = 0;
};
static void
{
if (ucode_debug) {
}
}
static void
{
if (verbose) {
gettext("\t\t Shows running microcode version.\n\n"));
}
if (verbose) {
"latest matching version found in\n"
"\t\t microcode-file.\n\n"));
}
if (verbose) {
"used for subsequent boots.\n\n"));
"with vendor name, such as \"intel\" or \"amd\".\n\n"));
}
}
static void
{
errno = 0;
}
/*
* Convert text format microcode release into binary format.
* Return the number of characters read.
*/
static int
{
int fd;
return (0);
return (0);
return (size);
}
static int
{
return (0);
return (0);
/* Check to see if we are processing a binary file */
return (count);
}
firstline = 0;
/* Skip blank lines */
continue;
/* Skip lines with all spaces or tabs */
continue;
/* Text file. Skip comments. */
if (linebuf[0] == '/')
continue;
break;
count += 4;
}
/*
* If we get here, we are processing a text format file
* where "count" is used to count the number of integers
* read. Convert it to number of characters read.
*/
return (count * sizeof (int));
}
/*
* Returns 0 if no need to update the link; -1 otherwise
*/
static int
{
int fd;
/*
* If the file or link already exists, check to see if
* it is necessary to update it.
*/
return (-1);
return (-1);
}
return (0);
}
return (-1);
}
/*
* Generate microcode binary files. Must be called after ucode_validate().
*/
static ucode_errno_t
{
/* LINTED: pointer alignment */
int last_cpu_rev = 0;
/* write container file */
if (fd == -1) {
return (EM_SYS);
}
return (EM_SYS);
}
/* skip over magic number & equivalence table header */
/* equivalence table uses special name */
"equivalence-table");
for (;;) {
if (fd == -1) {
return (EM_SYS);
}
return (EM_SYS);
}
if (!size)
return (EM_OK);
/* construct name from header information */
counter = 0;
}
}
}
static ucode_errno_t
{
int remaining;
return (EM_SYS);
}
int i;
remaining -= total_size;
int fd;
/* Remove the existing one first */
return (EM_SYS);
}
return (EM_SYS);
}
}
/*
* Only 1 byte of the proc_flags field is used, therefore
* we only need to match 8 potential platform ids.
*/
for (i = 0; i < 8; i++) {
continue;
dprintf("proc_flags = %x, platid = %x, name = %s\n",
/* Remove the existing one first */
return (EM_SYS);
}
}
if (uhp->uh_proc_flags == 0)
break;
}
/* Check to see if there is extended signature table */
if (total_size == offset)
continue;
/* There is extended signature table. More processing. */
int j;
for (j = 0; j < 8; j++) {
continue;
id);
!= 0) {
/* Remove the existing one first */
return (EM_SYS);
}
}
if (uesp->ues_proc_flags == 0)
break;
}
}
}
/*
* Remove files with no links to them. These are probably
* obsolete microcode files.
*/
return (EM_SYS);
}
continue;
}
}
return (EM_OK);
}
/*
* Returns 0 on success, 2 on usage error, and 3 on operation error.
*/
int
{
int c;
int action = 0;
int actcount = 0;
int errflg = 0;
int verbose = 0;
#if !defined(TEXT_DOMAIN)
#endif
(void) textdomain(TEXT_DOMAIN);
switch (c) {
case 'i':
actcount++;
break;
case 'u':
actcount++;
break;
case 'v':
actcount++;
break;
case 'd':
ucode_debug = 1;
break;
case 'R':
if (optarg[0] == '-')
errflg++;
gettext("Alternate path too long\n"));
errflg++;
errflg++;
}
break;
case 'V':
verbose = 1;
break;
case 'h':
usage(1);
return (0);
default:
return (2);
}
}
if (actcount != 1) {
"are mutually exclusive.\n"), cmdname);
return (2);
}
else if (!(action & UCODE_OPT_VERSION))
errflg++;
return (2);
}
/*
* Convert from text format to binary format
*/
int i;
dprintf("i = %d, filestr = %s, filename = %s\n",
(void) strncpy(ucode_vendor_str,
sizeof (ucode_vendor_str));
break;
}
}
rc = EM_NOVENDOR;
goto err_out;
}
goto err_out;
}
rc = EM_FILEFORMAT;
goto err_out;
}
goto err_out;
}
if (ucode_size == 0) {
rc = EM_FILEFORMAT;
goto err_out;
}
goto err_out;
}
}
/*
* For the install option, the microcode file must start with
* "intel" for Intel microcode, and "amd" for AMD microcode.
*/
if (action & UCODE_OPT_INSTALL) {
/*
* If no path is provided by the -R option, put the files in
*/
goto err_out;
}
}
goto err_out;
}
goto err_out;
}
goto err_out;
}
if (action & UCODE_OPT_VERSION) {
int tmprc;
int i;
#if defined(_SYSCALL32_IMPL)
#else
#endif
goto err_out;
}
for (i = 0; i < cpuid_max; i++)
#if defined(_SYSCALL32_IMPL)
#else
#endif
}
for (i = 0; i < cpuid_max; i++) {
continue;
}
} else {
}
if (revp)
}
if (action & UCODE_OPT_UPDATE) {
int tmprc;
#if defined(_SYSCALL32_IMPL)
#else
#endif
#if defined(_SYSCALL32_IMPL)
#else
#endif
if (tmprc) {
}
} else {
}
}
if (dev_fd != -1)
if (fd != -1)
return (3);
return (0);
}