17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 599f63845Sab * Common Development and Distribution License (the "License"). 699f63845Sab * You may not use this file except in compliance with the License. 77c478bd9Sstevel@tonic-gate * 87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 117c478bd9Sstevel@tonic-gate * and limitations under the License. 127c478bd9Sstevel@tonic-gate * 137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 187c478bd9Sstevel@tonic-gate * 197c478bd9Sstevel@tonic-gate * CDDL HEADER END 207c478bd9Sstevel@tonic-gate */ 21bebb829dSRod Evans 227c478bd9Sstevel@tonic-gate /* 23*7af88ac7SKuriakose Kuruvilla * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved. 247c478bd9Sstevel@tonic-gate */ 257c478bd9Sstevel@tonic-gate 267c478bd9Sstevel@tonic-gate #ifndef _ELFCAP_DOT_H 277c478bd9Sstevel@tonic-gate #define _ELFCAP_DOT_H 287c478bd9Sstevel@tonic-gate 297c478bd9Sstevel@tonic-gate #include <sys/types.h> 307c478bd9Sstevel@tonic-gate 317c478bd9Sstevel@tonic-gate #ifdef __cplusplus 327c478bd9Sstevel@tonic-gate extern "C" { 337c478bd9Sstevel@tonic-gate #endif 347c478bd9Sstevel@tonic-gate 3569112eddSAli Bahrami /* 3669112eddSAli Bahrami * Type used to represent capability bitmasks. This 32-bit type cannot be 3769112eddSAli Bahrami * widened without breaking the ability to use them in ELFCLASS32 objects. 3869112eddSAli Bahrami */ 3969112eddSAli Bahrami typedef uint32_t elfcap_mask_t; 4069112eddSAli Bahrami 417c478bd9Sstevel@tonic-gate /* 4299f63845Sab * The elfcap code handles mappings to and from several string styles. 4399f63845Sab * The caller uses elfcap_style_t to specify the style to use. 4469112eddSAli Bahrami * 4569112eddSAli Bahrami * The bottom 16 bits are used to represent styles, and the upper 16 4669112eddSAli Bahrami * bits are used for flags to modify default behavior. 4799f63845Sab */ 4869112eddSAli Bahrami #define ELFCAP_STYLE_MASK(_style) (_style & 0xff) 4969112eddSAli Bahrami 5099f63845Sab typedef enum { 5199f63845Sab ELFCAP_STYLE_FULL = 1, /* Full formal name (e.g. AV_386_SSE) */ 5299f63845Sab ELFCAP_STYLE_UC = 2, /* Informal upper case (e.g. SSE) */ 5369112eddSAli Bahrami ELFCAP_STYLE_LC = 3, /* Informal lower case (e.g. sse) */ 5469112eddSAli Bahrami 5569112eddSAli Bahrami ELFCAP_STYLE_F_ICMP = 0x0100 /* Use case insensitive strcmp */ 5699f63845Sab } elfcap_style_t; 5799f63845Sab 5899f63845Sab /* 5999f63845Sab * String descriptor: Contains the string and strlen(string). elfcap can 6099f63845Sab * be used in contexts (ld.so.1) where we do not want to make calls to 6199f63845Sab * string processing functions, so the length is calculated at compile time. 627c478bd9Sstevel@tonic-gate */ 637c478bd9Sstevel@tonic-gate typedef struct { 6499f63845Sab const char *s_str; 6599f63845Sab size_t s_len; 6699f63845Sab } elfcap_str_t; 6799f63845Sab 6899f63845Sab /* 6999f63845Sab * Capabilities descriptor: This maps the integer bit value 7099f63845Sab * (c_val) to/from the various strings that represent it. 7199f63845Sab * 7299f63845Sab * c_val is normally expected to be a non-zero power of 2 7399f63845Sab * value (i.e. a single set bit). The value 0 is special, and 7499f63845Sab * used to represent a "reserved" placeholder in an array of 7599f63845Sab * capabilities. These reserved values have NULL string pointers, 7699f63845Sab * and are intended to be ignored by the processing code. 7799f63845Sab */ 7899f63845Sab typedef struct { 7969112eddSAli Bahrami elfcap_mask_t c_val; /* Bit value */ 8099f63845Sab elfcap_str_t c_full; /* ELFCAP_STYLE_FULL */ 8199f63845Sab elfcap_str_t c_uc; /* ELFCAP_STYLE_UC */ 8299f63845Sab elfcap_str_t c_lc; /* ELFCAP_STYLE_LC */ 8399f63845Sab } elfcap_desc_t; 8499f63845Sab 8599f63845Sab /* 8699f63845Sab * Valid format values: The various formats in which a generated 8799f63845Sab * string representing bitmap values can be displayed. 8899f63845Sab * 8999f63845Sab * This must be kept in sync with the format[] array in elfcap.c. 9099f63845Sab */ 9199f63845Sab typedef enum { 9299f63845Sab ELFCAP_FMT_SNGSPACE = 0, 9399f63845Sab ELFCAP_FMT_DBLSPACE = 1, 9499f63845Sab ELFCAP_FMT_PIPSPACE = 2 9599f63845Sab } elfcap_fmt_t; 967c478bd9Sstevel@tonic-gate 977c478bd9Sstevel@tonic-gate /* 9899f63845Sab * Error codes: 997c478bd9Sstevel@tonic-gate */ 10099f63845Sab typedef enum { 10199f63845Sab ELFCAP_ERR_NONE = 0, /* no error */ 10299f63845Sab ELFCAP_ERR_BUFOVFL = 1, /* buffer overfow */ 10399f63845Sab ELFCAP_ERR_INVFMT = 2, /* invalid format */ 10499f63845Sab ELFCAP_ERR_UNKTAG = 3, /* unknown capabilities tag */ 10599f63845Sab ELFCAP_ERR_UNKMACH = 4, /* unknown machine type */ 10699f63845Sab ELFCAP_ERR_INVSTYLE = 5 /* unknown style */ 10799f63845Sab } elfcap_err_t; 10899f63845Sab 1097c478bd9Sstevel@tonic-gate 1107c478bd9Sstevel@tonic-gate /* 11199f63845Sab * # of each type of capability known to the system. These values 1124a8d0ea7SAli Bahrami * must be kept in sync with the arrays found in elfcap.c. 1137c478bd9Sstevel@tonic-gate */ 114bebb829dSRod Evans #define ELFCAP_NUM_SF1 3 115b1593d50SJason Beloro #define ELFCAP_NUM_HW1_SPARC 17 116*7af88ac7SKuriakose Kuruvilla #define ELFCAP_NUM_HW1_386 30 11799f63845Sab 1187c478bd9Sstevel@tonic-gate 11999f63845Sab /* 12099f63845Sab * Given a capability section tag and value, call the proper underlying 12199f63845Sab * "to str" function to generate the string description. 12299f63845Sab */ 12399f63845Sab extern elfcap_err_t elfcap_tag_to_str(elfcap_style_t, uint64_t, 12469112eddSAli Bahrami elfcap_mask_t, char *, size_t, elfcap_fmt_t, ushort_t); 1257c478bd9Sstevel@tonic-gate 1267c478bd9Sstevel@tonic-gate /* 12799f63845Sab * The functions that convert from a specific capability value to 12899f63845Sab * a string representation all use the same common prototype. 1297c478bd9Sstevel@tonic-gate */ 13069112eddSAli Bahrami typedef elfcap_err_t elfcap_to_str_func_t(elfcap_style_t, elfcap_mask_t, char *, 13199f63845Sab size_t, elfcap_fmt_t, ushort_t); 1327c478bd9Sstevel@tonic-gate 13399f63845Sab extern elfcap_to_str_func_t elfcap_hw1_to_str; 13469112eddSAli Bahrami extern elfcap_to_str_func_t elfcap_hw2_to_str; 13599f63845Sab extern elfcap_to_str_func_t elfcap_sf1_to_str; 1367c478bd9Sstevel@tonic-gate 13799f63845Sab /* 13899f63845Sab * The reverse mapping: Given a string representation, turn it back into 13999f63845Sab * integer form. 14099f63845Sab */ 14169112eddSAli Bahrami typedef elfcap_mask_t elfcap_from_str_func_t(elfcap_style_t, 14299f63845Sab const char *, ushort_t mach); 14399f63845Sab 14469112eddSAli Bahrami /* 14569112eddSAli Bahrami * Given a capability section tag and string, call the proper underlying 14669112eddSAli Bahrami * "from str" function to generate the numeric value. 14769112eddSAli Bahrami */ 14869112eddSAli Bahrami extern elfcap_mask_t elfcap_tag_from_str(elfcap_style_t, uint64_t, 14969112eddSAli Bahrami const char *, ushort_t); 15069112eddSAli Bahrami 15199f63845Sab extern elfcap_from_str_func_t elfcap_hw1_from_str; 15269112eddSAli Bahrami extern elfcap_from_str_func_t elfcap_hw2_from_str; 15399f63845Sab extern elfcap_from_str_func_t elfcap_sf1_from_str; 15499f63845Sab 15599f63845Sab /* 15699f63845Sab * These functions give access to the individual descriptor arrays. 15799f63845Sab * The caller is allowed to copy and use the string pointers contained 15899f63845Sab * in the descriptors, but must not alter them. Functions are used instead 15999f63845Sab * of making the arrays directly visible to preclude copy relocations in 16099f63845Sab * non-pic code. 16199f63845Sab */ 16299f63845Sab extern const elfcap_desc_t *elfcap_getdesc_hw1_sparc(void); 16399f63845Sab extern const elfcap_desc_t *elfcap_getdesc_hw1_386(void); 16499f63845Sab extern const elfcap_desc_t *elfcap_getdesc_sf1(void); 1657c478bd9Sstevel@tonic-gate 1667c478bd9Sstevel@tonic-gate #ifdef __cplusplus 1677c478bd9Sstevel@tonic-gate } 1687c478bd9Sstevel@tonic-gate #endif 1697c478bd9Sstevel@tonic-gate 1707c478bd9Sstevel@tonic-gate #endif /* _ELFCAP_DOT_H */ 171