10Sstevel@tonic-gate /* 20Sstevel@tonic-gate * CDDL HEADER START 30Sstevel@tonic-gate * 40Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*5565Sab196087 * Common Development and Distribution License (the "License"). 6*5565Sab196087 * You may not use this file except in compliance with the License. 70Sstevel@tonic-gate * 80Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 90Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 100Sstevel@tonic-gate * See the License for the specific language governing permissions 110Sstevel@tonic-gate * and limitations under the License. 120Sstevel@tonic-gate * 130Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 140Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 150Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 160Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 170Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 180Sstevel@tonic-gate * 190Sstevel@tonic-gate * CDDL HEADER END 200Sstevel@tonic-gate */ 210Sstevel@tonic-gate /* 22*5565Sab196087 * Copyright 2007 Sun Microsystems, Inc. All rights reserved. 230Sstevel@tonic-gate * Use is subject to license terms. 240Sstevel@tonic-gate */ 250Sstevel@tonic-gate 260Sstevel@tonic-gate #ifndef _ELFCAP_DOT_H 270Sstevel@tonic-gate #define _ELFCAP_DOT_H 280Sstevel@tonic-gate 290Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 300Sstevel@tonic-gate 310Sstevel@tonic-gate #include <sys/types.h> 320Sstevel@tonic-gate 330Sstevel@tonic-gate #ifdef __cplusplus 340Sstevel@tonic-gate extern "C" { 350Sstevel@tonic-gate #endif 360Sstevel@tonic-gate 370Sstevel@tonic-gate /* 38*5565Sab196087 * The elfcap code handles mappings to and from several string styles. 39*5565Sab196087 * The caller uses elfcap_style_t to specify the style to use. 40*5565Sab196087 */ 41*5565Sab196087 typedef enum { 42*5565Sab196087 ELFCAP_STYLE_FULL = 1, /* Full formal name (e.g. AV_386_SSE) */ 43*5565Sab196087 ELFCAP_STYLE_UC = 2, /* Informal upper case (e.g. SSE) */ 44*5565Sab196087 ELFCAP_STYLE_LC = 3 /* Informal lower case (e.g. sse) */ 45*5565Sab196087 } elfcap_style_t; 46*5565Sab196087 47*5565Sab196087 /* 48*5565Sab196087 * String descriptor: Contains the string and strlen(string). elfcap can 49*5565Sab196087 * be used in contexts (ld.so.1) where we do not want to make calls to 50*5565Sab196087 * string processing functions, so the length is calculated at compile time. 510Sstevel@tonic-gate */ 520Sstevel@tonic-gate typedef struct { 53*5565Sab196087 const char *s_str; 54*5565Sab196087 size_t s_len; 55*5565Sab196087 } elfcap_str_t; 560Sstevel@tonic-gate 570Sstevel@tonic-gate /* 58*5565Sab196087 * Capabilities descriptor: This maps the integer bit value 59*5565Sab196087 * (c_val) to/from the various strings that represent it. 60*5565Sab196087 * 61*5565Sab196087 * c_val is normally expected to be a non-zero power of 2 62*5565Sab196087 * value (i.e. a single set bit). The value 0 is special, and 63*5565Sab196087 * used to represent a "reserved" placeholder in an array of 64*5565Sab196087 * capabilities. These reserved values have NULL string pointers, 65*5565Sab196087 * and are intended to be ignored by the processing code. 660Sstevel@tonic-gate */ 67*5565Sab196087 typedef struct { 68*5565Sab196087 uint64_t c_val; /* Bit value */ 69*5565Sab196087 elfcap_str_t c_full; /* ELFCAP_STYLE_FULL */ 70*5565Sab196087 elfcap_str_t c_uc; /* ELFCAP_STYLE_UC */ 71*5565Sab196087 elfcap_str_t c_lc; /* ELFCAP_STYLE_LC */ 72*5565Sab196087 } elfcap_desc_t; 73*5565Sab196087 74*5565Sab196087 /* 75*5565Sab196087 * Valid format values: The various formats in which a generated 76*5565Sab196087 * string representing bitmap values can be displayed. 77*5565Sab196087 * 78*5565Sab196087 * This must be kept in sync with the format[] array in elfcap.c. 79*5565Sab196087 */ 80*5565Sab196087 typedef enum { 81*5565Sab196087 ELFCAP_FMT_SNGSPACE = 0, 82*5565Sab196087 ELFCAP_FMT_DBLSPACE = 1, 83*5565Sab196087 ELFCAP_FMT_PIPSPACE = 2 84*5565Sab196087 } elfcap_fmt_t; 850Sstevel@tonic-gate 860Sstevel@tonic-gate /* 87*5565Sab196087 * Error codes: 880Sstevel@tonic-gate */ 89*5565Sab196087 typedef enum { 90*5565Sab196087 ELFCAP_ERR_NONE = 0, /* no error */ 91*5565Sab196087 ELFCAP_ERR_BUFOVFL = 1, /* buffer overfow */ 92*5565Sab196087 ELFCAP_ERR_INVFMT = 2, /* invalid format */ 93*5565Sab196087 ELFCAP_ERR_UNKTAG = 3, /* unknown capabilities tag */ 94*5565Sab196087 ELFCAP_ERR_UNKMACH = 4, /* unknown machine type */ 95*5565Sab196087 ELFCAP_ERR_INVSTYLE = 5 /* unknown style */ 96*5565Sab196087 } elfcap_err_t; 97*5565Sab196087 980Sstevel@tonic-gate 99*5565Sab196087 /* 100*5565Sab196087 * # of each type of capability known to the system. These values 101*5565Sab196087 * must be kept in sync with the arrays found in elfcap.c 102*5565Sab196087 */ 103*5565Sab196087 #define ELFCAP_NUM_SF1 2 104*5565Sab196087 #define ELFCAP_NUM_HW1_SPARC 16 105*5565Sab196087 #define ELFCAP_NUM_HW1_386 25 106*5565Sab196087 107*5565Sab196087 108*5565Sab196087 /* 109*5565Sab196087 * Given a capability section tag and value, call the proper underlying 110*5565Sab196087 * "to str" function to generate the string description. 111*5565Sab196087 */ 112*5565Sab196087 extern elfcap_err_t elfcap_tag_to_str(elfcap_style_t, uint64_t, 113*5565Sab196087 uint64_t, char *, size_t, elfcap_fmt_t, ushort_t); 1140Sstevel@tonic-gate 1150Sstevel@tonic-gate /* 116*5565Sab196087 * The functions that convert from a specific capability value to 117*5565Sab196087 * a string representation all use the same common prototype. 1180Sstevel@tonic-gate */ 119*5565Sab196087 typedef elfcap_err_t elfcap_to_str_func_t(elfcap_style_t, uint64_t, char *, 120*5565Sab196087 size_t, elfcap_fmt_t, ushort_t); 121*5565Sab196087 122*5565Sab196087 extern elfcap_to_str_func_t elfcap_hw1_to_str; 123*5565Sab196087 extern elfcap_to_str_func_t elfcap_sf1_to_str; 1240Sstevel@tonic-gate 125*5565Sab196087 /* 126*5565Sab196087 * The reverse mapping: Given a string representation, turn it back into 127*5565Sab196087 * integer form. 128*5565Sab196087 */ 129*5565Sab196087 typedef uint64_t elfcap_from_str_func_t(elfcap_style_t, 130*5565Sab196087 const char *, ushort_t mach); 1310Sstevel@tonic-gate 132*5565Sab196087 extern elfcap_from_str_func_t elfcap_hw1_from_str; 133*5565Sab196087 extern elfcap_from_str_func_t elfcap_sf1_from_str; 134*5565Sab196087 135*5565Sab196087 /* 136*5565Sab196087 * These functions give access to the individual descriptor arrays. 137*5565Sab196087 * The caller is allowed to copy and use the string pointers contained 138*5565Sab196087 * in the descriptors, but must not alter them. Functions are used instead 139*5565Sab196087 * of making the arrays directly visible to preclude copy relocations in 140*5565Sab196087 * non-pic code. 141*5565Sab196087 */ 142*5565Sab196087 extern const elfcap_desc_t *elfcap_getdesc_hw1_sparc(void); 143*5565Sab196087 extern const elfcap_desc_t *elfcap_getdesc_hw1_386(void); 144*5565Sab196087 extern const elfcap_desc_t *elfcap_getdesc_sf1(void); 1450Sstevel@tonic-gate 1460Sstevel@tonic-gate #ifdef __cplusplus 1470Sstevel@tonic-gate } 1480Sstevel@tonic-gate #endif 1490Sstevel@tonic-gate 1500Sstevel@tonic-gate #endif /* _ELFCAP_DOT_H */ 151