elfcap.c revision ae115bc77f6fcde83175c75b4206dc2e50747966
/*
* 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"
/* LINTLIBRARY */
/*
* String conversion routine for hardware capabilities types.
*/
#include <strings.h>
#include <stdio.h>
#include <ctype.h>
#include <limits.h>
#include <sys/auxv_SPARC.h>
#include <sys/auxv_386.h>
#include <elfcap.h>
/*
* Define separators for val2str processing.
*/
{" ", 1 },
{" ", 2 },
{" | ", 3 }
};
/*
* Define all known capabilities as both lower and upper case strings. This
* duplication is necessary, rather than have one string and use something
* like toupper(), as a client such as ld.so.1 doesn't need the overhead of
* dragging in the internationalization support of toupper(). The Intel 3DNow
* flags are a slightly odd convention too.
*
* Define all known software capabilities.
*/
#ifdef CAP_UPPERCASE
static const char Sf1_fpknwn[] = "FPKNWN";
static const char Sf1_fpused[] = "FPUSED";
static const char Sf1_fpknwn[] = "fpknwn";
static const char Sf1_fpused[] = "fpused";
#else
#error "Software Capabilities - what case do you want?"
#endif
/*
* Order the software capabilities to match their numeric value. See SF1_SUNW_
*/
};
/*
* Define all known SPARC hardware capabilities.
*/
#ifdef CAP_UPPERCASE
static const char Hw1_s_mul32[] = "MUL32";
static const char Hw1_s_div32[] = "DIV32";
static const char Hw1_s_fsmuld[] = "FSMULD";
static const char Hw1_s_v8plus[] = "V8PLUS";
static const char Hw1_s_popc[] = "POPC";
static const char Hw1_s_vis[] = "VIS";
static const char Hw1_s_vis2[] = "VIS2";
static const char Hw1_s_asi_blk_init[] = "ASI_BLK_INIT";
static const char Hw1_s_fmaf[] = "FMAF";
static const char Hw1_s_mul32[] = "mul32";
static const char Hw1_s_div32[] = "div32";
static const char Hw1_s_fsmuld[] = "fsmuld";
static const char Hw1_s_v8plus[] = "v8plus";
static const char Hw1_s_popc[] = "popc";
static const char Hw1_s_vis[] = "vis";
static const char Hw1_s_vis2[] = "vis2";
static const char Hw1_s_asi_blk_init[] = "asi_blk_init";
static const char Hw1_s_fmaf[] = "fmaf";
#else
#error "Hardware Capabilities (sparc) - what case do you want?"
#endif
/*
* Order the SPARC hardware capabilities to match their numeric value. See
* AV_SPARC_ values in sys/auxv_SPARC.h.
*/
sizeof (Hw1_s_asi_blk_init) - 1 },
};
/*
* Define all known Intel hardware capabilities.
*/
#ifdef CAP_UPPERCASE
static const char Hw1_i_fpu[] = "FPU";
static const char Hw1_i_tsc[] = "TSC";
static const char Hw1_i_cx8[] = "CX8";
static const char Hw1_i_sep[] = "SEP";
static const char Hw1_i_amd_sysc[] = "AMD_SYSC";
static const char Hw1_i_cmov[] = "CMOV";
static const char Hw1_i_mmx[] = "MMX";
static const char Hw1_i_amd_mmx[] = "AMD_MMX";
static const char Hw1_i_amd_3dnow[] = "AMD_3DNow";
static const char Hw1_i_amd_3dnowx[] = "AMD_3DNowx";
static const char Hw1_i_fxsr[] = "FXSR";
static const char Hw1_i_sse[] = "SSE";
static const char Hw1_i_sse2[] = "SSE2";
static const char Hw1_i_pause[] = "PAUSE";
static const char Hw1_i_sse3[] = "SSE3";
static const char Hw1_i_mon[] = "MON";
static const char Hw1_i_cx16[] = "CX16";
static const char Hw1_i_ahf[] = "AHF";
static const char Hw1_i_tscp[] = "TSCP";
static const char Hw1_i_fpu[] = "fpu";
static const char Hw1_i_tsc[] = "tsc";
static const char Hw1_i_cx8[] = "cx8";
static const char Hw1_i_sep[] = "sep";
static const char Hw1_i_amd_sysc[] = "amd_sysc";
static const char Hw1_i_cmov[] = "cmov";
static const char Hw1_i_mmx[] = "mmx";
static const char Hw1_i_amd_mmx[] = "amd_mmx";
static const char Hw1_i_amd_3dnow[] = "amd_3dnow";
static const char Hw1_i_amd_3dnowx[] = "amd_3dnowx";
static const char Hw1_i_fxsr[] = "fxsr";
static const char Hw1_i_sse[] = "sse";
static const char Hw1_i_sse2[] = "sse2";
static const char Hw1_i_pause[] = "pause";
static const char Hw1_i_sse3[] = "sse3";
static const char Hw1_i_mon[] = "mon";
static const char Hw1_i_cx16[] = "cx16";
static const char Hw1_i_ahf[] = "ahf";
static const char Hw1_i_tscp[] = "tscp";
#else
#error "Hardware Capabilities (intel) - what case do you want?"
#endif
/*
* Order the Intel hardware capabilities to match their numeric value. See
* AV_386_ values in sys/auxv_386.h.
*/
sizeof (Hw1_i_amd_3dnow) - 1 },
sizeof (Hw1_i_amd_3dnowx) - 1 },
};
/*
* Concatenate a token to the string buffer. This can be a capabilities token
* or a separator token.
*/
static int
{
return (CAP_ERR_BUFOVFL);
return (0);
}
/*
* Expand a capabilities value into the strings defined in the associated
* capabilities descriptor.
*/
static int
int fmt)
{
if (val == 0)
return (0);
return (err);
return (err);
}
}
/*
* If there are any unknown bits remaining display the numeric value.
*/
if (val) {
return (err);
}
return (0);
}
/*
* Expand a CA_SUNW_HW_1 value.
*/
int
{
/*
* Initialize the string buffer, and validate the format request.
*/
*str = '\0';
if (fmt > CAP_MAX_TYPE)
return (CAP_ERR_INVFMT);
(mach == EM_SPARCV9))
return (CAP_ERR_UNKMACH);
}
/*
* Expand a CA_SUNW_SF_1 value. Note, that at present these capabilities are
* common across all platforms. The use of "mach" is therefore redundant, but
* is retained for compatibility with the interface of hwcap_1_val2str(), and
* possible future expansion.
*/
int
/* ARGSUSED4 */
{
/*
* Initialize the string buffer, and validate the format request.
*/
*str = '\0';
if (fmt > CAP_MAX_TYPE)
return (CAP_ERR_INVFMT);
}
/*
* Determine capability type from the capability tag.
*/
int
{
if (tag == CA_SUNW_HW_1)
if (tag == CA_SUNW_SF_1)
return (CAP_ERR_UNKTAG);
}
/*
* Determine a capabilities value from a capabilities string.
*/
static uint64_t
{
}
return (0);
}
{
}
{
(mach == EM_SPARCV9))
return (0);
}